Exemplo n.º 1
0
        private void StorageSetup()
        {
            try
            {
                var isServer = MyAPIGateway.Multiplayer.IsServer;

                if (DsSet == null)
                {
                    DsSet = new ControllerSettings(Shield);
                }
                if (DsState == null)
                {
                    DsState = new ControllerState(Shield);
                }
                if (Shield.Storage == null)
                {
                    DsState.StorageInit();
                }
                if (!isServer)
                {
                    var enforcement = Enforcements.LoadEnforcement(Shield);
                    if (enforcement != null)
                    {
                        Session.Enforced = enforcement;
                    }
                }
                DsSet.LoadSettings();
                if (!DsState.LoadState() && !isServer)
                {
                    _clientNotReady = true;
                }
                UpdateSettings(DsSet.Settings);
                if (isServer)
                {
                    if (DsSet.Settings.Fit > 22)
                    {
                        DsSet.Settings.Fit = 22;
                    }

                    DsState.State.Overload   = false;
                    DsState.State.NoPower    = false;
                    DsState.State.Remodulate = false;
                    if (DsState.State.Suspended)
                    {
                        DsState.State.Suspended = false;
                        DsState.State.Online    = false;
                    }
                    DsState.State.Sleeping        = false;
                    DsState.State.Waking          = false;
                    DsState.State.FieldBlocked    = false;
                    DsState.State.GridHalfExtents = Vector3D.Zero;
                    DsState.State.Heat            = 0;
                }
            }
            catch (Exception ex) { Log.Line($"Exception in StorageSetup: {ex}"); }
        }
Exemplo n.º 2
0
 private bool RequestEnforcement()
 {
     if (Session.Enforced.Version <= 0)
     {
         if (!_isServer)
         {
             var enforcement = Enforcements.LoadEnforcement(Shield);
             if (enforcement != null)
             {
                 Session.Enforced = enforcement;
             }
             else if (!_requestedEnforcement)
             {
                 Enforcements.EnforcementRequest(Shield.EntityId);
                 _requestedEnforcement = true;
             }
         }
     }
     return(Session.Enforced.Version <= 0);
 }