Browse Source

Add command for setting tweak limits

tags/v1.2.0
NorbiPeti 2 years ago
parent
commit
1f94cf1608
1 changed files with 44 additions and 2 deletions
  1. +44
    -2
      BuildingTools/BuildingTools.cs

+ 44
- 2
BuildingTools/BuildingTools.cs 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();


Loading…
Cancel
Save