using Content.Server.Explosion.EntitySystems; using Content.Shared.Atmos; using Content.Shared.FixedPoint; using Robust.Shared.Map.Components; using Robust.Shared.Utility; namespace Content.Server.Explosion.Components; /// /// Stores data for airtight explosion traversal on a entity. /// /// [RegisterComponent] [Access(typeof(ExplosionSystem), Other = AccessPermissions.None)] public sealed partial class ExplosionAirtightGridComponent : Component { /// /// Data for every tile on the current grid. /// /// /// Intentionally not saved. /// [ViewVariables] public readonly Dictionary Tiles = new(); /// /// Data struct that describes the explosion-blocking airtight entities on a tile. /// public struct TileData { /// /// Which index into the tolerance cache of this tile is using. /// public required int ToleranceCacheIndex; /// /// Which directions this tile is blocking explosions in. Bitflag field. /// public required AtmosDirection BlockedDirections; } /// /// A set of tolerance values /// public struct ToleranceValues : IEquatable { /// /// Special value that indicates the entity is "invulnerable" against a specific explosion type. /// /// /// Here to deal with the limited range of over typical floats. /// public static readonly FixedPoint2 Invulnerable = FixedPoint2.MaxValue; /// /// The intensities at which explosions of each type can instantly break through an entity. /// /// /// /// This is an array, with the index of each value corresponding to the "explosion type ID" cached by /// . /// /// /// Values are stored as to avoid possible precision issues resulting in /// different-but-almost-identical tolerance values wasting memory. /// /// /// If a value is , that indicates the tile is invulnerable. /// /// public required FixedPoint2[] Values; public bool Equals(ToleranceValues other) { return Values.AsSpan().SequenceEqual(other.Values); } public override bool Equals(object? obj) { return obj is ToleranceValues other && Equals(other); } public override int GetHashCode() { var hc = new HashCode(); hc.AddArray(Values); return hc.ToHashCode(); } public static bool operator ==(ToleranceValues left, ToleranceValues right) { return left.Equals(right); } public static bool operator !=(ToleranceValues left, ToleranceValues right) { return !left.Equals(right); } } }