Exemplo n.º 1
0
        internal void UpdateState(ControllerStateValues newState)
        {
            if (newState.MId > DsState.State.MId)
            {
                if (!_isServer)
                {
                    ClientInitPacket = true;
                    if (Session.Enforced.Debug == 3)
                    {
                        Log.Line($"[Shield Update]: On:{newState.Online} - Suspend:{newState.Suspended} - Sleep:{newState.Sleeping} - ClientOn:{_clientOn} - SId:{MyCube.EntityId} - Name:{MyGrid.DebugName}");
                    }
                    if (!newState.EllipsoidAdjust.Equals(DsState.State.EllipsoidAdjust) || !newState.ShieldFudge.Equals(DsState.State.ShieldFudge) || !newState.GridHalfExtents.Equals(DsState.State.GridHalfExtents))
                    {
                        _updateMobileShape = true;
                    }
                }
                DsState.State = newState;

                if (!_isDedicated && _clientMessageCount < DsState.State.MessageCount)
                {
                    BroadcastMessage();
                }

                _clientNotReady = false;
            }
        }
Exemplo n.º 2
0
        internal bool LoadState()
        {
            if (Shield.Storage == null)
            {
                return(false);
            }

            string rawData;
            bool   loadedSomething = false;

            if (Shield.Storage.TryGetValue(Session.Instance.ControllerStateGuid, out rawData))
            {
                var base64      = Convert.FromBase64String(rawData);
                var loadedState = MyAPIGateway.Utilities.SerializeFromBinary <ControllerStateValues>(base64);

                if (loadedState != null)
                {
                    State           = loadedState;
                    loadedSomething = true;
                }
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"Loaded - ShieldId [{Shield.EntityId}]");
                }
            }
            return(loadedSomething);
        }
 public DataControllerState(long entityId, ControllerStateValues state) : base(entityId)
 {
     State = state;
 }