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; }
private void ReadThrusterState(MyThrust thruster, out ThrusterMode mode) { ThrusterBoostInfo boostInfo; if (!_boostInfo.TryGetValue(thruster.EntityId, out boostInfo)) { boostInfo = new ThrusterBoostInfo(); } mode = boostInfo.Mode; }
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); } }
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(); }
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(); }
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; } }
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); }
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; } } }
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; } }