internal void PacketizeControllerState(IMyCubeBlock block, ProtoControllerState state) { var data = new DataControllerState(MyAPIGateway.Multiplayer.MyId, block.EntityId, state); var bytes = MyAPIGateway.Utilities.SerializeToBinary(data); ControllerStateToClients(block.CubeGrid.GetPosition(), bytes, data.Sender); }
internal bool LoadState() { if (Shield.Storage == null) { return(false); } string rawData; bool loadedSomething = false; if (Shield.Storage.TryGetValue(Session.Instance.ControllerStateGuid, out rawData)) { var base64 = Convert.FromBase64String(rawData); var loadedState = MyAPIGateway.Utilities.SerializeFromBinary <ProtoControllerState>(base64); if (loadedState != null) { State = loadedState; loadedSomething = true; } if (Session.Enforced.Debug == 3) { Log.Line($"Loaded - ShieldId [{Shield.EntityId}]"); } } return(loadedSomething); }
} // empty ctor is required for deserialization public DataControllerState(ulong sender, long entityId, ProtoControllerState state) { Type = PacketType.Controllerstate; Sender = sender; EntityId = entityId; State = state; }
public DataControllerState(ulong sender, long entityId, PacketType action) { Type = action; Sender = sender; EntityId = entityId; State = null; }
internal void UpdateState(ProtoControllerState newState) { DsState.State = newState; if (!_isServer && Session.Enforced.Debug == 3 && (_clientNotReady || DsState.State.Mode < 0)) { Log.Line($"UpdateState - ClientAndReady:{!_clientNotReady} - Mode:{DsState.State.Mode} - server:{Session.Instance.IsServer} - ShieldId [{Shield.EntityId}]:\n{newState}"); } _clientNotReady = false; }