Add support for box select

This commit is contained in:
Norbi Peti 2020-06-08 00:18:05 +02:00
parent 0b42884f3a
commit 47d1f43495

View file

@ -5,16 +5,10 @@ using Gamecraft.Wires.ChannelsCommon;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Commands;
using GamecraftModdingAPI.Engines;
using GamecraftModdingAPI.Players;
using GamecraftModdingAPI.Utility;
using HarmonyLib;
using IllusionPlugin;
using RobocraftX.Character.Weapons;
using RobocraftX.CommandLine.Custom;
using RobocraftX.Common.Players;
using Svelto.ECS;
using Svelto.ECS.Internal;
using Unity.Mathematics;
using uREPL;
using Main = GamecraftModdingAPI.Main;
@ -89,6 +83,12 @@ namespace BlockMod
.Action<char>(id =>
blocks = (refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault())?.GetConnectedCubes() ??
new Block[0]).Build();
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.")
.Action(() =>
{
blocks = new Player(PlayerType.Local).GetSelectedBlocks();
refBlock = blocks.Length > 0 ? blocks[0] : null;
}).Build();
RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in simulation.",
(x, y, z, blocks, refBlock) =>
@ -167,19 +167,8 @@ namespace BlockMod
return blocks;
}
//private void RegisterBlockCommand<T>(string name, string desc, T action) where T : Delegate
private void RegisterBlockCommand(string name, string desc, Action<string, byte, Block[], Block> action)
{
/*switch (action)
{
case Action<Block[], Block> act
break;
case Action<float, float, float, Block[], Block> act:
break;
default:
Logging.LogWarning("Unexpected parameters for command: " + name);
break;
}*/
RuntimeCommands.Register<string, byte>(name, (a1, a2) =>
{
if (CheckNoBlocks(blocks)) return;