Add support for object IDs again, some material stuff
This commit is contained in:
parent
8223447319
commit
8877f96ec9
3 changed files with 38 additions and 23 deletions
|
@ -21,17 +21,9 @@ namespace BuildingTools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public Block[] SelectBlocks(byte id)
|
|
||||||
{
|
|
||||||
var blocks = ObjectIdentifier.GetBySimID(id).SelectMany(block => block.GetConnectedCubes()).ToArray();
|
|
||||||
return blocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block[] SelectBlocks(char id)
|
public Block[] SelectBlocks(char id)
|
||||||
{
|
{
|
||||||
var blocks = ObjectIdentifier.GetByID(id).SelectMany(oid => oid.GetConnectedCubes())
|
return ObjectID.GetByID(id).SelectMany(oid => oid.GetConnectedCubes()).ToArray();
|
||||||
.ToArray();
|
}
|
||||||
return blocks;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,10 @@ using TechbloxModdingAPI.Blocks;
|
||||||
using TechbloxModdingAPI.Commands;
|
using TechbloxModdingAPI.Commands;
|
||||||
using TechbloxModdingAPI.Utility;
|
using TechbloxModdingAPI.Utility;
|
||||||
using IllusionPlugin;
|
using IllusionPlugin;
|
||||||
|
using RobocraftX.Schedulers;
|
||||||
|
using Svelto.Tasks;
|
||||||
|
using Svelto.Tasks.Enumerators;
|
||||||
|
using Svelto.Tasks.Lean;
|
||||||
using TechbloxModdingAPI.App;
|
using TechbloxModdingAPI.App;
|
||||||
using Unity.Mathematics;
|
using Unity.Mathematics;
|
||||||
using Main = TechbloxModdingAPI.Main;
|
using Main = TechbloxModdingAPI.Main;
|
||||||
|
@ -40,7 +44,6 @@ namespace BuildingTools
|
||||||
{
|
{
|
||||||
if (!GameState.IsBuildMode()) return; //Scaling & positioning is weird in simulation
|
if (!GameState.IsBuildMode()) return; //Scaling & positioning is weird in simulation
|
||||||
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
||||||
// ReSharper disable once PossibleNullReferenceException
|
|
||||||
float3? reference = Player.LocalPlayer.GetBlockLookedAt()?.Position;
|
float3? reference = Player.LocalPlayer.GetBlockLookedAt()?.Position;
|
||||||
if (!reference.HasValue)
|
if (!reference.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -89,6 +92,26 @@ namespace BuildingTools
|
||||||
block.Color = new BlockColor(clr, darkness);
|
block.Color = new BlockColor(clr, darkness);
|
||||||
Logging.CommandLog("Blocks colored.");
|
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",
|
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, however the blocks can be changed afterwards in both modes." +
|
||||||
|
@ -111,14 +134,14 @@ namespace BuildingTools
|
||||||
var blocks = _blockSelections.blocks;
|
var blocks = _blockSelections.blocks;
|
||||||
Logging.CommandLog(blocks.Length + " blocks selected.");
|
Logging.CommandLog(blocks.Length + " blocks selected.");
|
||||||
}).Build();
|
}).Build();
|
||||||
/*CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.")
|
CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.")
|
||||||
.Action<char>(id =>
|
.Action<char>(id =>
|
||||||
{
|
{
|
||||||
_blockSelections.blocks =
|
_blockSelections.blocks =
|
||||||
(_blockSelections.refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault())
|
(_blockSelections.refBlock = ObjectID.GetByID(id).FirstOrDefault())
|
||||||
?.GetConnectedCubes() ?? new Block[0];
|
?.GetConnectedCubes() ?? Array.Empty<Block>();
|
||||||
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected.");
|
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected.");
|
||||||
}).Build();*/
|
}).Build();
|
||||||
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.")
|
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.")
|
||||||
.Action(() =>
|
.Action(() =>
|
||||||
{
|
{
|
||||||
|
@ -256,10 +279,9 @@ namespace BuildingTools
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!data.StatsByName.TryGetValue(stat, out var statInfo))
|
if (!data.statsByName.TryGetValue(stat, out var statInfo))
|
||||||
{
|
{
|
||||||
Logging.CommandLogError(
|
Logging.CommandLogError($"Tweakable stat {stat} not found. Stats: {data.statsByName.Keys.Aggregate((a, b) => a + ", " + b)}");
|
||||||
$"Tweakable stat {stat} not found. Stats: {data.StatsNames.Aggregate((a, b) => a + ", " + b)}");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +291,7 @@ namespace BuildingTools
|
||||||
foreach (var statInfo in stats)
|
foreach (var statInfo in stats)
|
||||||
{
|
{
|
||||||
statInfo.max = value == 0 ? 1000 : value;
|
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}");
|
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)
|
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();
|
public override void OnApplicationQuit() => Main.Shutdown();
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ namespace BuildingTools
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*var blocks = _blockSelections.SelectBlocks(argsa[3][0]);
|
var blocks = _blockSelections.SelectBlocks(argsa[3][0]);
|
||||||
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
||||||
action(x, y, z, blocks, blocks[0]);*/
|
action(x, y, z, blocks, blocks[0]);
|
||||||
}
|
}
|
||||||
else if (!_blockSelections.CheckNoBlocks(bs))
|
else if (!_blockSelections.CheckNoBlocks(bs))
|
||||||
action(x, y, z, bs, b);
|
action(x, y, z, bs, b);
|
||||||
|
@ -83,9 +83,9 @@ namespace BuildingTools
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*var blocks = _blockSelections.SelectBlocks(argsa[2][0]);
|
var blocks = _blockSelections.SelectBlocks(argsa[2][0]);
|
||||||
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
if (_blockSelections.CheckNoBlocks(blocks)) return;
|
||||||
action(argsa[0], darkness, blocks, blocks[0]);*/
|
action(argsa[0], darkness, blocks, blocks[0]);
|
||||||
}
|
}
|
||||||
else if(!_blockSelections.CheckNoBlocks(bs))
|
else if(!_blockSelections.CheckNoBlocks(bs))
|
||||||
action(argsa[0], darkness, bs, b);
|
action(argsa[0], darkness, bs, b);
|
||||||
|
|
Loading…
Reference in a new issue