Add voxel reset message

This commit is contained in:
Brant Martin
2018-06-11 07:57:12 -04:00
parent 045a572058
commit 4db83e6f65
4 changed files with 49 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ namespace Torch.Mod.Messages
#region Includes
[ProtoInclude(1, typeof(DialogMessage))]
[ProtoInclude(2, typeof(NotificationMessage))]
[ProtoInclude(3, typeof(VoxelResetMessage))]
#endregion
[ProtoContract]

View File

@@ -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();
}
}
}