Exemplo n.º 1
0
        private void UpdateThruster(MyThrust thruster, bool enableBoost, out float heatLevel, out ThrusterMode mode)
        {
            ThrusterBoostInfo boostInfo;

            if (!_boostInfo.TryGetValue(thruster.EntityId, out boostInfo))
            {
                boostInfo = new ThrusterBoostInfo();
            }

            switch (boostInfo.Mode)
            {
            case ThrusterMode.Boost:
                UpdateThrusterBoostMode(thruster, enableBoost, ref boostInfo);
                break;

            case ThrusterMode.Overheat:
                UpdateThrusterOverheatMode(thruster, enableBoost, ref boostInfo);
                break;

            default:
                UpdateThrusterNormalMode(thruster, enableBoost, ref boostInfo);
                break;
            }

            _boostInfo[thruster.EntityId] = boostInfo;
            heatLevel = boostInfo.CurrentHeatLevel;
            mode      = boostInfo.Mode;
        }
Exemplo n.º 2
0
        private void ReadThrusterState(MyThrust thruster, out ThrusterMode mode)
        {
            ThrusterBoostInfo boostInfo;

            if (!_boostInfo.TryGetValue(thruster.EntityId, out boostInfo))
            {
                boostInfo = new ThrusterBoostInfo();
            }

            mode = boostInfo.Mode;
        }
Exemplo n.º 3
0
 private void UpdateThrusterNormalMode(MyThrust thruster, bool enableBoost, ref ThrusterBoostInfo boostInfo)
 {
     if (enableBoost)
     {
         EnableBooster(thruster, ref boostInfo);
         boostInfo.Mode = ThrusterMode.Boost;
     }
     else
     {
         ApplyCooldown(thruster, ref boostInfo);
     }
 }
Exemplo n.º 4
0
        private void DisableBooster(MyThrust thruster, ref ThrusterBoostInfo boostInfo)
        {
            var t = (IMyThrust)thruster;

            t.ThrustMultiplier           = 1f;
            t.PowerConsumptionMultiplier = 1f;

            thruster.Light.Color = boostInfo.OriginalColor;
            thruster.UpdateLight();

            thruster.CurrentStrength = 1f;
            thruster.UpdateThrustFlame();
        }
Exemplo n.º 5
0
        private void EnableBooster(MyThrust thruster, ref ThrusterBoostInfo boostInfo)
        {
            var t = (IMyThrust)thruster;

            t.ThrustMultiplier           = BOOST_THRUST;
            t.PowerConsumptionMultiplier = BOOST_POWER;

            boostInfo.OriginalColor = thruster.ThrustColor;
            thruster.Light.Color    = BoosterFlameColor;
            thruster.UpdateLight();

            thruster.CurrentStrength = BOOST_STRENGTH;
            thruster.UpdateThrustFlame();
        }
Exemplo n.º 6
0
        private void ApplyCooldown(MyThrust thruster, ref ThrusterBoostInfo boostInfo)
        {
            var t = (IMyThrust)thruster;

            var thrustLevel   = t.CurrentThrust / t.MaxThrust;
            var cooldownQuant = (1f - thrustLevel * 0.75f) * HEAT_QUANT;

            boostInfo.CurrentHeatLevel -= cooldownQuant;

            if (boostInfo.CurrentHeatLevel < 0)
            {
                boostInfo.CurrentHeatLevel = 0f;
            }
        }
Exemplo n.º 7
0
        private bool ApplyHeatup(MyThrust thruster, ref ThrusterBoostInfo boostInfo)
        {
            var t = (IMyThrust)thruster;

            var thrustLevel = t.CurrentThrust / t.MaxThrust;
            var heatQuant   = thrustLevel * HEAT_QUANT;

            boostInfo.CurrentHeatLevel += heatQuant;

            if (boostInfo.CurrentHeatLevel >= MAX_HEAT)
            {
                boostInfo.CurrentHeatLevel = MAX_HEAT;
                DisableBooster(thruster, ref boostInfo);
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        private void UpdateThrusterOverheatMode(MyThrust thruster, bool enableBoost, ref ThrusterBoostInfo boostInfo)
        {
            ApplyCooldown(thruster, ref boostInfo);

            if (boostInfo.CurrentHeatLevel <= 0f)
            {
                thruster.RemoveEffect("Damage");

                if (enableBoost)
                {
                    EnableBooster(thruster, ref boostInfo);
                    boostInfo.Mode = ThrusterMode.Boost;
                }
                else
                {
                    boostInfo.Mode = ThrusterMode.Normal;
                }
            }
        }
Exemplo n.º 9
0
        private void UpdateThrusterBoostMode(MyThrust thruster, bool enableBoost, ref ThrusterBoostInfo boostInfo)
        {
            if (enableBoost)
            {
                var overheat = ApplyHeatup(thruster, ref boostInfo);
                if (overheat)
                {
                    DisableBooster(thruster, ref boostInfo);
                    boostInfo.Mode = ThrusterMode.Overheat;

                    thruster.SetEffect("Damage", true);
                }
            }
            else
            {
                DisableBooster(thruster, ref boostInfo);
                boostInfo.Mode = ThrusterMode.Normal;
            }
        }