Exemplo n.º 1
0
        internal void PacketizeO2GeneratorState(IMyCubeBlock block, ProtoO2GeneratorState state)
        {
            var data  = new DataO2GeneratorState(MyAPIGateway.Multiplayer.MyId, block.EntityId, state);
            var bytes = MyAPIGateway.Utilities.SerializeToBinary(data);

            O2GeneratorStateToClients(block.CubeGrid.GetPosition(), bytes, data.Sender);
        }
Exemplo n.º 2
0
        }                                 // empty ctor is required for deserialization

        public DataO2GeneratorState(ulong sender, long entityId, ProtoO2GeneratorState state)
        {
            Type     = PacketType.O2Generatorstate;
            Sender   = sender;
            EntityId = entityId;
            State    = state;
        }
Exemplo n.º 3
0
 public DataO2GeneratorState(ulong sender, long entityId, PacketType action)
 {
     Type     = action;
     Sender   = sender;
     EntityId = entityId;
     State    = null;
 }
Exemplo n.º 4
0
        public bool LoadState()
        {
            if (O2Generator.Storage == null)
            {
                return(false);
            }

            string rawData;
            bool   loadedSomething = false;

            if (O2Generator.Storage.TryGetValue(Session.Instance.O2GeneratorStateGuid, out rawData))
            {
                ProtoO2GeneratorState loadedState = null;
                var base64 = Convert.FromBase64String(rawData);
                loadedState = MyAPIGateway.Utilities.SerializeFromBinary <ProtoO2GeneratorState>(base64);

                if (loadedState != null)
                {
                    State           = loadedState;
                    loadedSomething = true;
                }

                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Loaded - O2GeneratorId [{O2Generator.EntityId}]:\n{State.ToString()}");
                }
            }

            return(loadedSomething);
        }
Exemplo n.º 5
0
 internal void UpdateState(ProtoO2GeneratorState newState)
 {
     O2State.State = newState;
     if (!_isDedicated)
     {
         UpdateVisuals();
     }
     if (Session.Enforced.Debug == 3)
     {
         Log.Line($"UpdateState - O2GenId [{O2Generator.EntityId}]:\n{newState}");
     }
 }