diff --git a/Torch.Mod/Messages/MessageBase.cs b/Torch.Mod/Messages/MessageBase.cs index ce8f1a5..3a00738 100644 --- a/Torch.Mod/Messages/MessageBase.cs +++ b/Torch.Mod/Messages/MessageBase.cs @@ -10,6 +10,7 @@ namespace Torch.Mod.Messages #region Includes [ProtoInclude(1, typeof(DialogMessage))] [ProtoInclude(2, typeof(NotificationMessage))] + [ProtoInclude(3, typeof(VoxelResetMessage))] #endregion [ProtoContract] diff --git a/Torch.Mod/Messages/VoxelResetMessage.cs b/Torch.Mod/Messages/VoxelResetMessage.cs new file mode 100644 index 0000000..e5cd66b --- /dev/null +++ b/Torch.Mod/Messages/VoxelResetMessage.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ProtoBuf; +using Sandbox.ModAPI; +using VRage.ModAPI; +using VRage.Voxels; + +namespace Torch.Mod.Messages +{ + [ProtoContract] + public class VoxelResetMessage : MessageBase + { + [ProtoMember(201)] + public long[] EntityId; + + public VoxelResetMessage() + { } + + public VoxelResetMessage(long[] entityId) + { + EntityId = entityId; + } + + public override void ProcessClient() + { + MyAPIGateway.Parallel.ForEach(EntityId, id => + { + IMyEntity e; + if (!MyAPIGateway.Entities.TryGetEntityById(id, out e)) + return; + + var v = e as IMyVoxelBase; + if (v == null) + return; + + v.Storage.Reset(MyStorageDataTypeFlags.All); + }); + } + + public override void ProcessServer() + { + throw new Exception(); + } + } +} diff --git a/Torch.Mod/Torch.Mod.projitems b/Torch.Mod/Torch.Mod.projitems index a6b330f..f05b7b6 100644 --- a/Torch.Mod/Torch.Mod.projitems +++ b/Torch.Mod/Torch.Mod.projitems @@ -12,6 +12,7 @@ + diff --git a/Torch/Commands/TorchCommands.cs b/Torch/Commands/TorchCommands.cs index 1879bae..d8144ff 100644 --- a/Torch/Commands/TorchCommands.cs +++ b/Torch/Commands/TorchCommands.cs @@ -19,6 +19,7 @@ using Torch.Commands.Permissions; using Torch.Managers; using Torch.Mod; using Torch.Mod.Messages; +using VRage.Game; using VRage.Game.ModAPI; namespace Torch.Commands