Ejemplo n.º 1
0
        public bool LoadState()
        {
            if (Modulator.Storage == null)
            {
                return(false);
            }

            string rawData;
            bool   loadedSomething = false;

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

                if (loadedState != null)
                {
                    State           = loadedState;
                    loadedSomething = true;
                }
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Loaded - ModulatorId [{Modulator.EntityId}]:\n{State.ToString()}");
                }
            }
            return(loadedSomething);
        }
Ejemplo n.º 2
0
 internal void UpdateState(ModulatorStateValues newState)
 {
     if (newState.MId > ModState.State.MId)
     {
         ModState.State = newState;
         if (Session.Enforced.Debug == 3)
         {
             Log.Line($"UpdateState - ModulatorId [{Modulator.EntityId}]:\n{ModState.State}");
         }
     }
 }
 public DataModulatorState(long entityId, ModulatorStateValues state) : base(entityId)
 {
     State = state;
 }