|
|
@@ -9,6 +9,10 @@ using TechbloxModdingAPI.Blocks; |
|
|
|
using TechbloxModdingAPI.Commands; |
|
|
|
using TechbloxModdingAPI.Utility; |
|
|
|
using IllusionPlugin; |
|
|
|
using RobocraftX.Schedulers; |
|
|
|
using Svelto.Tasks; |
|
|
|
using Svelto.Tasks.Enumerators; |
|
|
|
using Svelto.Tasks.Lean; |
|
|
|
using TechbloxModdingAPI.App; |
|
|
|
using Unity.Mathematics; |
|
|
|
using Main = TechbloxModdingAPI.Main; |
|
|
@@ -40,7 +44,6 @@ namespace BuildingTools |
|
|
|
{ |
|
|
|
if (!GameState.IsBuildMode()) return; //Scaling & positioning is weird in simulation |
|
|
|
if (_blockSelections.CheckNoBlocks(blocks)) return; |
|
|
|
// ReSharper disable once PossibleNullReferenceException |
|
|
|
float3? reference = Player.LocalPlayer.GetBlockLookedAt()?.Position; |
|
|
|
if (!reference.HasValue) |
|
|
|
{ |
|
|
@@ -89,6 +92,26 @@ namespace BuildingTools |
|
|
|
block.Color = new BlockColor(clr, darkness); |
|
|
|
Logging.CommandLog("Blocks colored."); |
|
|
|
}); |
|
|
|
_commandUtils.RegisterBlockCommand("materialBlocks", "Sets the material of the selected blocks permanently both in time stopped and running. It won't be reset when stopping time.", |
|
|
|
(material, darkness, blocks, refBlock) => |
|
|
|
{ |
|
|
|
if (!Enum.TryParse(material, true, out BlockMaterial mat)) |
|
|
|
{ |
|
|
|
Logging.CommandLogWarning("Material " + material + " not found"); |
|
|
|
} |
|
|
|
|
|
|
|
IEnumerator<TaskContract> SetMaterial() |
|
|
|
{ |
|
|
|
foreach (var block in blocks) |
|
|
|
{ |
|
|
|
block.Material = mat; |
|
|
|
yield return new WaitForSecondsEnumerator(0.2f).Continue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SetMaterial().RunOn(ClientLean.UIScheduler); |
|
|
|
Logging.CommandLog("Block materials set."); |
|
|
|
}); |
|
|
|
|
|
|
|
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." + |
|
|
@@ -111,14 +134,14 @@ namespace BuildingTools |
|
|
|
var blocks = _blockSelections.blocks; |
|
|
|
Logging.CommandLog(blocks.Length + " blocks selected."); |
|
|
|
}).Build(); |
|
|
|
/*CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.") |
|
|
|
CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.") |
|
|
|
.Action<char>(id => |
|
|
|
{ |
|
|
|
_blockSelections.blocks = |
|
|
|
(_blockSelections.refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault()) |
|
|
|
?.GetConnectedCubes() ?? new Block[0]; |
|
|
|
(_blockSelections.refBlock = ObjectID.GetByID(id).FirstOrDefault()) |
|
|
|
?.GetConnectedCubes() ?? Array.Empty<Block>(); |
|
|
|
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected."); |
|
|
|
}).Build();*/ |
|
|
|
}).Build(); |
|
|
|
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.") |
|
|
|
.Action(() => |
|
|
|
{ |
|
|
@@ -256,10 +279,9 @@ namespace BuildingTools |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (!data.StatsByName.TryGetValue(stat, out var statInfo)) |
|
|
|
if (!data.statsByName.TryGetValue(stat, out var statInfo)) |
|
|
|
{ |
|
|
|
Logging.CommandLogError( |
|
|
|
$"Tweakable stat {stat} not found. Stats: {data.StatsNames.Aggregate((a, b) => a + ", " + b)}"); |
|
|
|
Logging.CommandLogError($"Tweakable stat {stat} not found. Stats: {data.statsByName.Keys.Aggregate((a, b) => a + ", " + b)}"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@@ -269,6 +291,7 @@ namespace BuildingTools |
|
|
|
foreach (var statInfo in stats) |
|
|
|
{ |
|
|
|
statInfo.max = value == 0 ? 1000 : value; |
|
|
|
statInfo.min = -1000; |
|
|
|
} |
|
|
|
|
|
|
|
Logging.CommandLog($"{(stat is null || stat.Length == 0 ? "All stats" : $"Stat {stat}")} max changed to {(value == 0 ? 1000 : value)} on {bl}"); |
|
|
@@ -361,7 +384,7 @@ namespace BuildingTools |
|
|
|
} |
|
|
|
|
|
|
|
private IEnumerable<SimBody> GetSimBodies(Block[] blocks) |
|
|
|
=> blocks.Select(block => block.GetSimBody()).Distinct(); |
|
|
|
=> blocks.Select(block => block.GetSimBody()).Where(block => !(block is null)).Distinct(); |
|
|
|
|
|
|
|
public override void OnApplicationQuit() => Main.Shutdown(); |
|
|
|
|
|
|
|