|
|
@@ -32,18 +32,23 @@ namespace BuildingTools |
|
|
|
GameClient.SetDebugInfo("BlockModInfo", GetBlockInfo); |
|
|
|
_commandUtils.RegisterBlockCommand("scaleBlocks", |
|
|
|
"Scales the selected blocks, relative to current size (current scale * new scale)." + |
|
|
|
" The block you're looking at (when selected based on that) stays where it is, everything else is moved next to it.", |
|
|
|
(scaleX, scaleY, scaleZ, blocks, refBlock) => |
|
|
|
" The block you're looking at stays where it is, everything else is moved next to it.", |
|
|
|
(scaleX, scaleY, scaleZ, blocks, refBlock) => //TODO: Either remove refBlock or add commands for changing it |
|
|
|
{ |
|
|
|
if (!GameState.IsBuildMode()) return; //Scaling & positioning is weird in simulation |
|
|
|
if (_blockSelections.CheckNoBlocks(blocks)) return; |
|
|
|
// ReSharper disable once PossibleNullReferenceException |
|
|
|
float3 reference = refBlock.Position; |
|
|
|
float3? reference = Player.LocalPlayer.GetBlockLookedAt()?.Position; |
|
|
|
if (!reference.HasValue) |
|
|
|
{ |
|
|
|
Logging.CommandLogError("Look at a block (not too far away) to be used as reference."); |
|
|
|
return; |
|
|
|
} |
|
|
|
float3 scale = new float3(scaleX, scaleY, scaleZ); |
|
|
|
foreach (var block in blocks) |
|
|
|
{ |
|
|
|
block.Scale *= scale; |
|
|
|
block.Position = reference + (block.Position - reference) * scale; |
|
|
|
block.Position = (float3) (reference + (block.Position - reference) * scale); |
|
|
|
} |
|
|
|
|
|
|
|
Logging.CommandLog("Blocks scaled."); |
|
|
@@ -57,7 +62,7 @@ namespace BuildingTools |
|
|
|
foreach (var block in blocks) |
|
|
|
block.Scale *= scale; |
|
|
|
}); |
|
|
|
_commandUtils.RegisterBlockCommand("moveBlocks", "Moves the blocks around.", (x, y, z, blocks, refBlock) => |
|
|
|
_commandUtils.RegisterBlockCommand("moveBlocks", "Moves (teleports) the selected blocks around both in time stopped and running. The latter will be reset as expected.", (x, y, z, blocks, refBlock) => |
|
|
|
{ |
|
|
|
if (GameState.IsBuildMode()) |
|
|
|
foreach (var block in blocks) |
|
|
@@ -66,7 +71,7 @@ namespace BuildingTools |
|
|
|
foreach (var body in GetSimBodies(blocks)) |
|
|
|
body.Position += new float3(x, y, z); |
|
|
|
}); |
|
|
|
_commandUtils.RegisterBlockCommand("colorBlocks", "Colors the blocks you're looking at", |
|
|
|
_commandUtils.RegisterBlockCommand("colorBlocks", "Colors the selected blocks permanently both in time stopped and running. It won't be reset when stopping time.", |
|
|
|
(color, darkness, blocks, refBlock) => |
|
|
|
{ |
|
|
|
|
|
|
@@ -80,33 +85,53 @@ namespace BuildingTools |
|
|
|
}); |
|
|
|
|
|
|
|
CommandBuilder.Builder("selectBlocksLookedAt", |
|
|
|
"Selects blocks (1 or more) to change. Only works in build mode, however the blocks can be changed afterwards." + |
|
|
|
"Selects blocks (1 or more) to change. Only works in time stopped mode, however the blocks can be changed afterwards in both modes." + |
|
|
|
" Parameter: whether one (true) or all connected (false) blocks should be selected.") |
|
|
|
.Action<bool>(single => |
|
|
|
{ |
|
|
|
_blockSelections.refBlock = new Player(PlayerType.Local).GetBlockLookedAt(); |
|
|
|
var refBlock = _blockSelections.refBlock; |
|
|
|
_blockSelections.blocks = single ? new[] {refBlock} : refBlock?.GetConnectedCubes() ?? new Block[0]; |
|
|
|
if (!GameState.IsBuildMode()) |
|
|
|
{ |
|
|
|
Logging.CommandLogError("This command can only be used in time stopped mode."); |
|
|
|
return; |
|
|
|
} |
|
|
|
var refBlock = Player.LocalPlayer.GetBlockLookedAt(); |
|
|
|
if (refBlock == null) |
|
|
|
{ |
|
|
|
Logging.CommandLogError("Block not found. Make sure to be close enough to the block."); |
|
|
|
return; |
|
|
|
} |
|
|
|
_blockSelections.refBlock = refBlock; |
|
|
|
_blockSelections.blocks = single ? new[] {refBlock} : refBlock.GetConnectedCubes() ?? new Block[0]; |
|
|
|
var blocks = _blockSelections.blocks; |
|
|
|
Logging.CommandLog(blocks == null ? "Selection cleared." : blocks.Length + " blocks selected."); |
|
|
|
Logging.CommandLog(blocks.Length + " blocks selected."); |
|
|
|
}).Build(); |
|
|
|
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]).Build(); |
|
|
|
{ |
|
|
|
_blockSelections.blocks = |
|
|
|
(_blockSelections.refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault()) |
|
|
|
?.GetConnectedCubes() ?? new Block[0]; |
|
|
|
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected."); |
|
|
|
}).Build(); |
|
|
|
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.") |
|
|
|
.Action(() => |
|
|
|
{ |
|
|
|
_blockSelections.blocks = new Player(PlayerType.Local).GetSelectedBlocks(); |
|
|
|
_blockSelections.blocks = Player.LocalPlayer.GetSelectedBlocks(); |
|
|
|
_blockSelections.refBlock = _blockSelections.blocks.Length > 0 ? _blockSelections.blocks[0] : null; |
|
|
|
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected."); |
|
|
|
}).Build(); |
|
|
|
|
|
|
|
ConsoleCommands.RegisterWithChannel("selectSendSignal", ch => { }, ChannelType.Object, |
|
|
|
"Sends a signal for selecting a given object ID for a command block."); |
|
|
|
/*ConsoleCommands.RegisterWithChannel("selectSendSignal", ch => { }, ChannelType.Object, |
|
|
|
"Sends a signal for selecting a given object ID for a command block.");*/ |
|
|
|
|
|
|
|
_commandUtils.RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in simulation.", |
|
|
|
_commandUtils.RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in time running mode.", |
|
|
|
(x, y, z, blocks, refBlock) => |
|
|
|
{ |
|
|
|
if (!GameState.IsSimulationMode()) |
|
|
|
{ |
|
|
|
Logging.CommandLogError("This command can only be used in time running mode."); |
|
|
|
return; |
|
|
|
} |
|
|
|
foreach (var block in GetSimBodies(blocks)) |
|
|
|
block.Velocity += new float3(x, y, z); |
|
|
|
}); |
|
|
@@ -114,18 +139,23 @@ namespace BuildingTools |
|
|
|
"Adds angular velocity to the selected blocks. Only works in simulation.", |
|
|
|
(x, y, z, blocks, refBlock) => |
|
|
|
{ |
|
|
|
if (!GameState.IsSimulationMode()) |
|
|
|
{ |
|
|
|
Logging.CommandLogError("This command can only be used in time running mode."); |
|
|
|
return; |
|
|
|
} |
|
|
|
foreach (var block in GetSimBodies(blocks)) |
|
|
|
block.AngularVelocity += new float3(x, y, z); |
|
|
|
}); |
|
|
|
CommandBuilder.Builder("pushPlayer", "Adds velocity to the player.") |
|
|
|
.Action<float, float, float>((x, y, z) => |
|
|
|
{ |
|
|
|
new Player(PlayerType.Local).Velocity += new float3(x, y, z); |
|
|
|
Player.LocalPlayer.Velocity += new float3(x, y, z); |
|
|
|
}).Build(); |
|
|
|
CommandBuilder.Builder("pushRotatePlayer", "Adds angular velocity to the player.") |
|
|
|
.Action<float, float, float>((x, y, z) => |
|
|
|
{ |
|
|
|
new Player(PlayerType.Local).AngularVelocity += new float3(x, y, z); |
|
|
|
Player.LocalPlayer.AngularVelocity += new float3(x, y, z); |
|
|
|
}).Build(); |
|
|
|
var noClip = new NoClipCommand(); |
|
|
|
GameEngineManager.AddGameEngine(noClip); |
|
|
|