Door collision fixes (#6836)
This commit is contained in:
@@ -140,7 +140,7 @@ public sealed class DoorComponent : Component, ISerializationHooks
|
|||||||
/// List of EntityUids of entities we're currently crushing. Cleared in OnPartialOpen().
|
/// List of EntityUids of entities we're currently crushing. Cleared in OnPartialOpen().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("currentlyCrushing")]
|
[DataField("currentlyCrushing")]
|
||||||
public List<EntityUid> CurrentlyCrushing = new();
|
public HashSet<EntityUid> CurrentlyCrushing = new();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Serialization
|
#region Serialization
|
||||||
@@ -238,7 +238,7 @@ public enum DoorVisuals
|
|||||||
public sealed class DoorComponentState : ComponentState
|
public sealed class DoorComponentState : ComponentState
|
||||||
{
|
{
|
||||||
public readonly DoorState DoorState;
|
public readonly DoorState DoorState;
|
||||||
public readonly List<EntityUid> CurrentlyCrushing;
|
public readonly HashSet<EntityUid> CurrentlyCrushing;
|
||||||
public readonly TimeSpan? NextStateChange;
|
public readonly TimeSpan? NextStateChange;
|
||||||
public readonly bool Partial;
|
public readonly bool Partial;
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
if (args.Current is not DoorComponentState state)
|
if (args.Current is not DoorComponentState state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
door.CurrentlyCrushing = state.CurrentlyCrushing;
|
door.CurrentlyCrushing = new(state.CurrentlyCrushing);
|
||||||
door.State = state.DoorState;
|
door.State = state.DoorState;
|
||||||
door.NextStateChange = state.NextStateChange;
|
door.NextStateChange = state.NextStateChange;
|
||||||
door.Partial = state.Partial;
|
door.Partial = state.Partial;
|
||||||
@@ -337,7 +337,6 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
if (!Resolve(uid, ref door, ref physics))
|
if (!Resolve(uid, ref door, ref physics))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetCollidable(uid, true, door, physics);
|
|
||||||
door.Partial = true;
|
door.Partial = true;
|
||||||
door.Dirty();
|
door.Dirty();
|
||||||
|
|
||||||
@@ -350,6 +349,7 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCollidable(uid, true, door, physics);
|
||||||
door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
|
door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
|
||||||
_activeDoors.Add(door);
|
_activeDoors.Add(door);
|
||||||
|
|
||||||
@@ -421,16 +421,22 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
// TODO SLOTH fix electro's code.
|
// TODO SLOTH fix electro's code.
|
||||||
var doorAABB = physics.GetWorldAABB();
|
var doorAABB = physics.GetWorldAABB();
|
||||||
|
|
||||||
foreach (var body in _physicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB))
|
foreach (var otherPhysics in _physicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB))
|
||||||
{
|
{
|
||||||
// static bodies (e.g., furniture) shouldn't stop airlocks/windoors from closing.
|
if (otherPhysics == physics)
|
||||||
if (body.BodyType == BodyType.Static)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (body.GetWorldAABB().IntersectPercentage(doorAABB) < IntersectPercentage)
|
if (!otherPhysics.CanCollide)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
yield return body.Owner;
|
if ((physics.CollisionMask & otherPhysics.CollisionLayer) == 0
|
||||||
|
&& (otherPhysics.CollisionMask & physics.CollisionLayer) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (otherPhysics.GetWorldAABB().IntersectPercentage(doorAABB) < IntersectPercentage)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
yield return otherPhysics.Owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user