Cleanup atmos air grenade code (#37568)

cleanup
This commit is contained in:
slarticodefast
2025-05-18 14:18:31 +02:00
committed by GitHub
parent f7fdef6eca
commit 643bdf547e
2 changed files with 12 additions and 38 deletions

View File

@@ -66,27 +66,14 @@ public sealed partial class ReleaseGasOnTriggerSystem : SharedReleaseGasOnTrigge
RemCompDeferred<ReleaseGasOnTriggerComponent>(uid); RemCompDeferred<ReleaseGasOnTriggerComponent>(uid);
continue; continue;
} }
if (comp.ExponentialRise)
UpdateExponentialRise(comp, comp.RemoveFraction);
} }
} }
/// <summary>
/// Updates the RemoveFraction for exponential rise.
/// </summary>
/// <remarks>See https://www.desmos.com/calculator/fx9gfrhoim</remarks>
private static void UpdateExponentialRise(ReleaseGasOnTriggerComponent comp, float baseFraction)
{
comp.TimesReleased++;
comp.RemoveFraction = 1f - MathF.Pow(1f - baseFraction, comp.TimesReleased);
}
private void UpdateAppearance(Entity<AppearanceComponent?> entity, bool state) private void UpdateAppearance(Entity<AppearanceComponent?> entity, bool state)
{ {
if (!Resolve(entity, ref entity.Comp, false)) if (!Resolve(entity, ref entity.Comp, false))
return; return;
_appearance.SetData(entity, ReleaseGasOnTriggerComponent.ReleaseGasOnTriggerVisuals.Key, state); _appearance.SetData(entity, ReleaseGasOnTriggerVisuals.Key, state);
} }
} }

View File

@@ -14,16 +14,6 @@ namespace Content.Shared.Explosion.Components.OnTrigger;
[Access(typeof(SharedReleaseGasOnTriggerSystem))] [Access(typeof(SharedReleaseGasOnTriggerSystem))]
public sealed partial class ReleaseGasOnTriggerComponent : Component public sealed partial class ReleaseGasOnTriggerComponent : Component
{ {
/// <summary>
/// Represents visual states for whatever visuals that need to be applied
/// on state changes.
/// </summary>
[Serializable] [NetSerializable]
public enum ReleaseGasOnTriggerVisuals : byte
{
Key,
}
/// <summary> /// <summary>
/// Whether this grenade is active and releasing gas. /// Whether this grenade is active and releasing gas.
/// Set to true when triggered, which starts gas release. /// Set to true when triggered, which starts gas release.
@@ -37,12 +27,6 @@ public sealed partial class ReleaseGasOnTriggerComponent : Component
[DataField] [DataField]
public GasMixture Air; public GasMixture Air;
/// <summary>
/// If true, the gas will be released in an exponential manner.
/// </summary>
[DataField]
public bool ExponentialRise;
/// <summary> /// <summary>
/// Time at which the next release will occur. /// Time at which the next release will occur.
/// This is automatically set when the grenade activates. /// This is automatically set when the grenade activates.
@@ -53,7 +37,7 @@ public sealed partial class ReleaseGasOnTriggerComponent : Component
/// <summary> /// <summary>
/// The cap at which this grenade can fill the exposed atmosphere to. /// The cap at which this grenade can fill the exposed atmosphere to.
/// The grenade automatically deletes itself when the pressure is reached. /// This component automatically removes itself when the pressure limit is reached.
/// </summary> /// </summary>
/// <example>If set to 101.325, the grenade will only fill the exposed /// <example>If set to 101.325, the grenade will only fill the exposed
/// atmosphere up to 101.325 kPa.</example> /// atmosphere up to 101.325 kPa.</example>
@@ -83,11 +67,14 @@ public sealed partial class ReleaseGasOnTriggerComponent : Component
/// <remarks>Set when the grenade is activated.</remarks> /// <remarks>Set when the grenade is activated.</remarks>
[DataField(readOnly: true)] [DataField(readOnly: true)]
public float StartingTotalMoles; public float StartingTotalMoles;
}
/// <summary>
/// Stores the number of times the grenade has been released, /// <summary>
/// for exponential rise calculations. /// Represents visual states for whatever visuals that need to be applied
/// </summary> /// on state changes.
[DataField] /// </summary>
public int TimesReleased; [Serializable, NetSerializable]
public enum ReleaseGasOnTriggerVisuals : byte
{
Key,
} }