Add command for setting tweak limits

This commit is contained in:
Norbi Peti 2022-02-20 02:58:16 +01:00
parent 94e8a0dc5a
commit 1f94cf1608

View file

@ -215,7 +215,7 @@ namespace BuildingTools
}).ToArray();
}).Build();
var setLimits = new SetLimitsCommandEngine();
CommandBuilder.Builder("setLimits", "Set build limits").Action((Action<int, int>)setLimits.SetLimits).Build();
CommandBuilder.Builder("setBuildLimits", "Set build limits").Action((Action<int, int>)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<CubeListData>((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<TweakableStatsData>((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();