Hotfix door bumps (#8665)

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2022-06-12 11:15:53 +10:00
committed by GitHub
parent 2b51906740
commit 093d65e92a
2 changed files with 36 additions and 10 deletions

View File

@@ -25,11 +25,10 @@ namespace Content.Server.Doors.Systems;
public sealed class DoorSystem : SharedDoorSystem public sealed class DoorSystem : SharedDoorSystem
{ {
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
[Dependency] private readonly AirtightSystem _airtightSystem = default!;
[Dependency] private readonly ConstructionSystem _constructionSystem = default!; [Dependency] private readonly ConstructionSystem _constructionSystem = default!;
[Dependency] private readonly ToolSystem _toolSystem = default!; [Dependency] private readonly ToolSystem _toolSystem = default!;
[Dependency] private readonly AirtightSystem _airtightSystem = default!;
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -239,7 +238,7 @@ public sealed class DoorSystem : SharedDoorSystem
var otherUid = args.OtherFixture.Body.Owner; var otherUid = args.OtherFixture.Body.Owner;
if (_tagSystem.HasTag(otherUid, "DoorBumpOpener")) if (Tags.HasTag(otherUid, "DoorBumpOpener"))
TryOpen(uid, door, otherUid); TryOpen(uid, door, otherUid);
} }
@@ -298,6 +297,18 @@ public sealed class DoorSystem : SharedDoorSystem
if(lastState == DoorState.Emagging && TryComp<AirlockComponent>(door.Owner, out var airlockComponent)) if(lastState == DoorState.Emagging && TryComp<AirlockComponent>(door.Owner, out var airlockComponent))
airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted()); airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted());
} }
protected override void CheckDoorBump(DoorComponent component, PhysicsComponent body)
{
if (component.BumpOpen)
{
foreach (var other in PhysicsSystem.GetCollidingEntities(body))
{
if (Tags.HasTag(other.Owner, "DoorBumpOpener") &&
TryOpen(component.Owner, component, other.Owner)) break;
}
}
}
} }
public sealed class PryFinishedEvent : EntityEventArgs { } public sealed class PryFinishedEvent : EntityEventArgs { }

View File

@@ -10,14 +10,16 @@ using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics; using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using System.Linq; using System.Linq;
using Content.Shared.Tag;
namespace Content.Shared.Doors.Systems; namespace Content.Shared.Doors.Systems;
public abstract class SharedDoorSystem : EntitySystem public abstract class SharedDoorSystem : EntitySystem
{ {
[Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; [Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedStunSystem _stunSystem = default!; [Dependency] private readonly SharedStunSystem _stunSystem = default!;
[Dependency] protected readonly TagSystem Tags = default!;
[Dependency] protected readonly IGameTiming GameTiming = default!; [Dependency] protected readonly IGameTiming GameTiming = default!;
/// <summary> /// <summary>
@@ -139,15 +141,18 @@ public abstract class SharedDoorSystem : EntitySystem
break; break;
case DoorState.Open: case DoorState.Open:
case DoorState.Closed:
door.Partial = false; door.Partial = false;
if (door.NextStateChange == null) if (door.NextStateChange == null)
_activeDoors.Remove(door); _activeDoors.Remove(door);
break; break;
case DoorState.Closed:
// May want to keep the door around to re-check for opening if we got a contact during closing.
door.Partial = false;
break;
} }
door.State = state; door.State = state;
door.Dirty(); Dirty(door);
RaiseLocalEvent(uid, new DoorStateChangedEvent(state), false); RaiseLocalEvent(uid, new DoorStateChangedEvent(state), false);
UpdateAppearance(uid, door); UpdateAppearance(uid, door);
} }
@@ -280,7 +285,7 @@ public abstract class SharedDoorSystem : EntitySystem
door.Partial = true; door.Partial = true;
door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo; door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
_activeDoors.Add(door); _activeDoors.Add(door);
door.Dirty(); Dirty(door);
} }
#endregion #endregion
@@ -335,7 +340,7 @@ public abstract class SharedDoorSystem : EntitySystem
return false; return false;
door.Partial = true; door.Partial = true;
door.Dirty(); Dirty(door);
// Make sure no entity waled into the airlock when it started closing. // Make sure no entity waled into the airlock when it started closing.
if (!CanClose(uid, door)) if (!CanClose(uid, door))
@@ -417,7 +422,7 @@ 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 otherPhysics in _physicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) foreach (var otherPhysics in PhysicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB))
{ {
if (otherPhysics == physics) if (otherPhysics == physics)
continue; continue;
@@ -536,9 +541,19 @@ public abstract class SharedDoorSystem : EntitySystem
if (door.NextStateChange.Value < time) if (door.NextStateChange.Value < time)
NextState(door, time); NextState(door, time);
if (door.State == DoorState.Closed &&
TryComp<PhysicsComponent>(door.Owner, out var doorBody))
{
// If something bumped into us during closing then start to re-open, otherwise, remove it from active.
_activeDoors.Remove(door);
CheckDoorBump(door, doorBody);
}
} }
} }
protected virtual void CheckDoorBump(DoorComponent component, PhysicsComponent body) {}
/// <summary> /// <summary>
/// Makes a door proceed to the next state (if applicable). /// Makes a door proceed to the next state (if applicable).
/// </summary> /// </summary>