コード例 #1
0
        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);
        }
コード例 #2
0
 public DataPlanetShieldState(ulong sender, long entityId, PacketType action)
 {
     Type     = action;
     Sender   = sender;
     EntityId = entityId;
     State    = null;
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        }                                  // empty ctor is required for deserialization

        public DataPlanetShieldState(ulong sender, long entityId, ProtoPlanetShieldState state)
        {
            Type     = PacketType.PlanetShieldstate;
            Sender   = sender;
            EntityId = entityId;
            State    = state;
        }