コード例 #1
0
 public ControllableThruster(IMyThrust thisThruster, ThrustDirection thisDirection)
 {
     _thisIThruster         = thisThruster;
     ThrustDirection        = thisDirection;
     _thisThruster          = (MyThrust)thisThruster;
     _thisDefinition        = _thisThruster.BlockDefinition;
     _thisThruster.OnClose += Close;
 }
コード例 #2
0
 private void SetBalancedThrust(ThrustDirection direction, float value)
 {
     if (IsClosed)
     {
         return;
     }
     if (_maxEffectiveThrust[direction] - _currentlyUtilizedThrust[direction] > value)
     {
         InsufficientThrustAvailable?.Invoke(direction);
     }
     foreach (ControllableThruster thruster in _thrusters[direction])
     {
         thruster.SetThrust(value / _thrusters[direction].Count);
     }
     _currentlyUtilizedThrust[direction] = value;
 }
コード例 #3
0
        private void SetRollingThrust(ThrustDirection direction, float value)
        {
            if (IsClosed)
            {
                return;
            }
            float tmpValue = value;

            _currentlyUtilizedThrust[direction] = 0;
            foreach (ControllableThruster thruster in _thrusters[direction])
            {
                if (Math.Abs(value) <= 0)
                {
                    thruster.SetThrust(0);
                    continue;
                }

                float availableThrust = thruster.MaxThrust() - thruster.CurrentThrust();
                if (availableThrust <= 0)
                {
                    continue;
                }

                if (availableThrust > tmpValue)
                {
                    thruster.SetThrust(thruster.CurrentThrust() + tmpValue);
                    tmpValue = 0;
                }
                else
                {
                    thruster.SetThrust(thruster.MaxThrust());
                    tmpValue -= thruster.MaxThrust();
                }
                if (tmpValue > 0)
                {
                    continue;
                }
                thruster.SetThrust(0);
            }
            if (tmpValue > 0)
            {
                InsufficientThrustAvailable?.Invoke(direction);
                _currentlyUtilizedThrust[direction] = value - tmpValue;
                return;
            }
            _currentlyUtilizedThrust[direction] = value;
        }
コード例 #4
0
        public void SetThrust(ThrustDirection direction, float value)
        {
            if (Math.Sign(value) < 0)
            {
                value = Math.Abs(value);
                // If we're requesting negative thrust on this axis, then any
                //	thrust on this axis in the requested direction needs to be nullified
                // Remember, this is a set, not an accumulated value
                SetThrust(direction, 0);
                switch (direction)
                {
                case ThrustDirection.Up:
                    direction = ThrustDirection.Down;
                    break;

                case ThrustDirection.Down:
                    direction = ThrustDirection.Up;
                    break;

                case ThrustDirection.Left:
                    direction = ThrustDirection.Right;
                    break;

                case ThrustDirection.Right:
                    direction = ThrustDirection.Left;
                    break;

                case ThrustDirection.Forward:
                    direction = ThrustDirection.Back;
                    break;

                case ThrustDirection.Back:
                    direction = ThrustDirection.Forward;
                    break;

                default:
                    return;                             // something is broken if this ever happens, so... ignore it.
                }
            }
            SetRollingThrust(direction, value);
        }
コード例 #5
0
ファイル: Craft.cs プロジェクト: jbrowneuk/stormrunner
 public void SetThrustDirection(ThrustDirection direction)
 {
     isReversing = direction == ThrustDirection.Backwards;
 }
コード例 #6
0
ファイル: Ship.cs プロジェクト: Killili/Dreadnought
 private bool thrusterBurning(ThrustDirection dir)
 {
     return thrusterLastActive[dir]+thrusterBurnTime >= gameTime;
 }
コード例 #7
0
ファイル: Ship.cs プロジェクト: Killili/Dreadnought
 private bool thrusterActive(ThrustDirection dir)
 {
     return thrusterLastActive[dir] == gameTime;
 }
コード例 #8
0
ファイル: Ship.cs プロジェクト: Killili/Dreadnought
 private void fireThruster(ThrustDirection dir)
 {
     thrusterLastActive[dir] = gameTime;
     if(Thrust != null) Thrust(this, new EventArgs());
 }
コード例 #9
0
 public float GetMaxEffectiveThrustInDirection(ThrustDirection direction)
 {
     return(_maxEffectiveThrust[direction]);
 }