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