internal void PacketizeEmitterState(IMyCubeBlock block, ProtoEmitterState state) { var data = new DataEmitterState(MyAPIGateway.Multiplayer.MyId, block.EntityId, state); var bytes = MyAPIGateway.Utilities.SerializeToBinary(data); EmitterStateToClients(block.CubeGrid.GetPosition(), bytes, data.Sender); }
public DataEmitterState(ulong sender, long entityId, PacketType action) { Type = action; Sender = sender; EntityId = entityId; State = null; }
public bool LoadState() { if (Emitter.Storage == null) { return(false); } string rawData; bool loadedSomething = false; if (Emitter.Storage.TryGetValue(Session.Instance.EmitterStateGuid, out rawData)) { ProtoEmitterState loadedState = null; var base64 = Convert.FromBase64String(rawData); loadedState = MyAPIGateway.Utilities.SerializeFromBinary <ProtoEmitterState>(base64); if (loadedState != null) { State = loadedState; loadedSomething = true; } if (Session.Enforced.Debug == 3) { Log.Line($"Loaded - EmitterId [{Emitter.EntityId}]:"); } } return(loadedSomething); }
} // empty ctor is required for deserialization public DataEmitterState(ulong sender, long entityId, ProtoEmitterState state) { Type = PacketType.Emitterstate; Sender = sender; EntityId = entityId; State = state; }
internal void UpdateState(ProtoEmitterState newState) { EmiState.State = newState; if (Session.Enforced.Debug <= 3) { Log.Line($"UpdateState - EmitterId [{Emitter.EntityId}]:\n{EmiState.State}"); } }