diff --git a/BuildingTools/BuildingTools.cs b/BuildingTools/BuildingTools.cs index bcd3d8a..c787d25 100644 --- a/BuildingTools/BuildingTools.cs +++ b/BuildingTools/BuildingTools.cs @@ -215,7 +215,7 @@ namespace BuildingTools }).ToArray(); }).Build(); var setLimits = new SetLimitsCommandEngine(); - CommandBuilder.Builder("setLimits", "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.") @@ -229,7 +229,49 @@ namespace BuildingTools } FullGameFields._dataDb.GetValue((int) blockID).scalingPermission = ScalingPermission.NonUniform; - Logging.CommandLog("Free scaling enabled for " + blockID + " until the game is restarted."); + Logging.CommandLog("Free scaling enabled for " + blockID + " until the game is restarted. Reselect block to apply."); + }).Build(); + + CommandBuilder.Builder("setTweakLimit", + "Sets the limit on the tweakable stat on selected block. Usage: setTweakLimit [stat] [value]. Sets all stats to 1000 by default.") + .Action((string stat, int value) => + { + var bl = Player.LocalPlayer.SelectedBlock; + if (bl == BlockIDs.Invalid) + { + Logging.CommandLogError("Select the block in the inventory first."); + return; + } + + if (!FullGameFields._dataDb.TryGetValue((int)bl, out var data)) + { + Logging.CommandLogError($"No tweakable stats found on {bl} (selected)"); + return; + } + + TweakPropertyInfo[] stats; + if (stat is null) + { + stats = data.Stats; + } + else + { + if (!data.StatsByName.TryGetValue(stat, out var statInfo)) + { + Logging.CommandLogError( + $"Tweakable stat {stat} not found. Stats: {data.StatsNames.Aggregate((a, b) => a + ", " + b)}"); + return; + } + + stats = new[] { statInfo }; + } + + foreach (var statInfo in stats) + { + statInfo.max = value == 0 ? 1000 : value; + } + + Logging.CommandLog($"{(stat is null ? "All stats" : $"Stat {stat}")} max changed to {(value == 0 ? 1000 : value)}"); }).Build(); _mirrorModeEngine.Init();