예제 #1
0
        public bool LoadState()
        {
            if (O2Generator.Storage == null)
            {
                return(false);
            }

            string rawData;
            bool   loadedSomething = false;

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

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

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

            return(loadedSomething);
        }
예제 #2
0
 internal void UpdateState(O2GeneratorStateValues newState)
 {
     if (newState.MId > O2State.State.MId)
     {
         O2State.State = newState;
         if (!_isDedicated)
         {
             UpdateVisuals();
         }
         if (Session.Enforced.Debug == 3)
         {
             Log.Line($"UpdateState - O2GenId [{O2Generator.EntityId}]:\n{newState}");
         }
     }
 }
 public DataO2GeneratorState(long entityId, O2GeneratorStateValues state) : base(entityId)
 {
     State = state;
 }