示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        }                               // empty ctor is required for deserialization

        public DataModulatorState(ulong sender, long entityId, ProtoModulatorState state)
        {
            Type     = PacketType.Modulatorstate;
            Sender   = sender;
            EntityId = entityId;
            State    = state;
        }
示例#4
0
 public DataModulatorState(ulong sender, long entityId, PacketType action)
 {
     Type     = action;
     Sender   = sender;
     EntityId = entityId;
     State    = null;
 }
示例#5
0
 internal void UpdateState(ProtoModulatorState newState)
 {
     ModState.State = newState;
     if (Session.Enforced.Debug == 3)
     {
         Log.Line($"UpdateState - ModulatorId [{Modulator.EntityId}]:\n{ModState.State}");
     }
 }