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