From 08a0badd37a56ef90077144fcfbc46c999885089 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 12 Apr 2022 03:33:45 +0200 Subject: [PATCH] Add support for setting cluster limit and remove the volume limit --- BuildingTools/BuildingTools.cs | 4 ++-- BuildingTools/BuildingTools.csproj | 2 +- BuildingTools/SetLimitsCommandEngine.cs | 22 +++++++++++++++++++--- README.md | 7 ------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/BuildingTools/BuildingTools.cs b/BuildingTools/BuildingTools.cs index 0d920c6..67782bc 100644 --- a/BuildingTools/BuildingTools.cs +++ b/BuildingTools/BuildingTools.cs @@ -114,7 +114,7 @@ namespace BuildingTools }); CommandBuilder.Builder("selectBlocksLookedAt", - "Selects blocks (1 or more) to change. Only works in time stopped mode, however the blocks can be changed afterwards in both modes." + + "Selects blocks (1 or more) to change. Only works in time stopped mode." + " Parameter: whether one (true) or all connected (false) blocks should be selected.") .Action(single => { @@ -238,7 +238,7 @@ namespace BuildingTools }).ToArray(); }).Build(); var setLimits = new SetLimitsCommandEngine(); - CommandBuilder.Builder("setBuildLimits", "Set build limits").Action((Action)setLimits.SetLimits).Build(); + CommandBuilder.Builder("setBuildLimits", "Set build limits").Action((Action)setLimits.SetLimits).Build(); GameEngineManager.AddGameEngine(setLimits); CommandBuilder.Builder("freeScaling", "This command removes scaling restrictions on the selected block. Reselect block to apply.") diff --git a/BuildingTools/BuildingTools.csproj b/BuildingTools/BuildingTools.csproj index ee935ed..1addaa0 100644 --- a/BuildingTools/BuildingTools.csproj +++ b/BuildingTools/BuildingTools.csproj @@ -11,7 +11,7 @@ net48 512 true - 1.1.0 + 1.2.0 AnyCPU diff --git a/BuildingTools/SetLimitsCommandEngine.cs b/BuildingTools/SetLimitsCommandEngine.cs index bb12ec4..f4e01d8 100644 --- a/BuildingTools/SetLimitsCommandEngine.cs +++ b/BuildingTools/SetLimitsCommandEngine.cs @@ -1,8 +1,10 @@ +using System; using Svelto.ECS; using Techblox.Building.Rules; using Techblox.Building.Rules.Entities; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; +using Unity.Mathematics; namespace BuildingTools { @@ -17,13 +19,27 @@ namespace BuildingTools { } - public void SetLimits(int cpu, int power) + public void SetLimits(int cpu, int power, int clusters) { + if (entitiesDB is null) + { + Logging.CommandLog("This command only works in build mode. If you're in build mode, well, report pls."); + return; + } + ref var rules = ref entitiesDB.QueryUniqueEntity(GroupCompound.BuildGroup); - Logging.CommandLog($"Old CPU limit: {rules.cpu.max}, power limit: {rules.power.max}"); + Logging.CommandLog($"Old CPU limit: {rules.cpu.max}, power limit: {rules.power.max}, cluster limit: {rules.clusters.max}"); rules.cpu.max = cpu; rules.power.max = power; - Logging.CommandLog($"New CPU limit: {rules.cpu.max}, power limit: {rules.power.max}"); + rules.clusters.max = clusters; + if (BuildRulesUtils.GetLocalMachine(entitiesDB, out var egid)) + { + entitiesDB.QueryEntity(egid).aabb = + new AABB { Center = 0, Extents = float.MaxValue }; + Logging.CommandLog("Removed volume limits"); + } + + Logging.CommandLog($"New CPU limit: {rules.cpu.max}, power limit: {rules.power.max}, cluster limit: {rules.clusters.max}"); } public string Name => "SetLimitsEngine"; diff --git a/README.md b/README.md index 518b2d7..e93ba73 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # BuildingTools Tools for building games, mainly focused on changing and displaying (F3) block properties. -And no clip. ## Commands ### Selection commands @@ -59,12 +58,6 @@ Only works in time running mode. ### Push player The `pushPlayer` and `pushRotatePlayer` commands will apply a specified (regular or angular) force to the player in any mode. -### No clip -The `noClip` command allows you to go through blocks. Run to toggle. -It works in both time stopped and running modes. - -**Always exit noClip before leaving a game save or it will crash the game at the moment.** - ### Examples * Select and move box selected blocks by 5 blocks in the +X direction: ```