Example #1
0
 private void InvalidateSystem(GridSystem system)
 {
     SetStatic(false);
     UpdateEffect(WarpDriveSession.WarpEffectUpdate.State.Destroy);
     OnSystemInvalidated?.Invoke(this);
     OnSystemInvalidated = null;
 }
Example #2
0
        public WarpSystem(WarpDrive block, WarpSystem oldSystem)
        {
            Id = WarpDriveSession.Instance.Rand.Next(int.MinValue, int.MaxValue);

            grid = new GridSystem((MyCubeGrid)block.Block.CubeGrid);

            GridSystem.BlockCounter warpDriveCounter = new GridSystem.BlockCounter((b) => b?.GameLogic.GetAs <WarpDrive>() != null);
            warpDriveCounter.OnBlockAdded   += OnDriveAdded;
            warpDriveCounter.OnBlockRemoved += OnDriveRemoved;
            grid.AddCounter("WarpDrives", warpDriveCounter);

            grid.OnSystemInvalidated += InvalidateSystem;

            if (oldSystem != null)
            {
                totalHeat       = oldSystem.totalHeat;
                startWarpSource = oldSystem.startWarpSource;
                if (startWarpSource?.MarkedForClose == true)
                {
                    startWarpSource = null;
                }
                WarpState = oldSystem.WarpState;
                if (WarpState == State.Charging)
                {
                    UpdateEffect(WarpDriveSession.WarpEffectUpdate.State.Charging);
                    startChargeRuntime = oldSystem.startChargeRuntime;
                    WarpState          = State.Charging;
                }
                else if (WarpState == State.Active)
                {
                    //UpdateEffect(WarpDriveSession.WarpEffectUpdate.State.InWarp);
                    currentSpeedPt = oldSystem.currentSpeedPt;
                    WarpState      = State.Active;
                }
            }
            block.SetWarpSystem(this);
        }