[DataField("rotateAirBlocked")]
public bool RotateAirBlocked { get; set; } = true;
- /// <summary>
- /// Whether to fix the <see cref="CurrentAirBlockedDirection"/> on initialization
- /// to the entity's current rotation.
- /// </summary>
- /// <remarks>This is an optimization routine for initializing airtight components.
- /// If this entity doesn't have unique airtight directions
- /// (ex. not all directions are blocked but some are), we can skip
- /// a lot of event/transform business during initialization.
- /// This field marks whether this is skipped or not.</remarks>
- /// <example>If your entity only blocks air in one direction,
- /// and that can depend on rotation, this needs to be set to true.</example>
- [DataField]
- public bool FixAirBlockedDirectionInitialize = true;
-
/// <summary>
/// If true, then the tile that this entity is on will have no air at all if all directions are blocked.
/// </summary>
private void OnAirtightInit(Entity<AirtightComponent> airtight, ref ComponentInit args)
{
- // If this entity has unique airtight directions that are affected by rotation,
- // we need to fix up the current airtight directions based on its rotation.
- // Otherwise, we can skip all of that logic (stuff adds up when you're initing
- // a morbillion walls).
- if (!airtight.Comp.FixAirBlockedDirectionInitialize)
+ // If this entity blocks air in all directions (e.g. full tile walls, doors, and windows)
+ // we can skip some expensive logic.
+ if (airtight.Comp.InitialAirBlockedDirection == (int)AtmosDirection.All)
{
+ airtight.Comp.CurrentAirBlockedDirection = airtight.Comp.InitialAirBlockedDirection;
UpdatePosition(airtight);
return;
}
+ // Otherwise we need to determine its current blocked air directions based on rotation
+ // and check if it's still airtight.
var xform = Transform(airtight);
airtight.Comp.CurrentAirBlockedDirection =
(int) Rotate((AtmosDirection) airtight.Comp.InitialAirBlockedDirection, xform.LocalRotation);