Move board spawning out of DoorSystem (#11772)

This commit is contained in:
Leon Friedrich
2022-10-17 05:43:33 +13:00
committed by GitHub
parent ad3615dcc6
commit bb61eb7f54
13 changed files with 235 additions and 56 deletions

View File

@@ -18,7 +18,6 @@ using Content.Shared.Tools.Components;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using System.Linq;
using Robust.Shared.Physics.Components;
@@ -38,7 +37,6 @@ public sealed class DoorSystem : SharedDoorSystem
{
base.Initialize();
SubscribeLocalEvent<DoorComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<DoorComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ConstructionSystem) });
// Mob prying doors
@@ -274,30 +272,6 @@ public sealed class DoorSystem : SharedDoorSystem
TryOpen(uid, door, otherUid);
}
private void OnMapInit(EntityUid uid, DoorComponent door, MapInitEvent args)
{
// Ensure that the construction component is aware of the board container.
if (TryComp(uid, out ConstructionComponent? construction))
_constructionSystem.AddContainer(uid, "board", construction);
// We don't do anything if this is null or empty.
if (string.IsNullOrEmpty(door.BoardPrototype))
return;
var container = _containerSystem.EnsureContainer<Container>(uid, "board", out var existed);
if (existed && container.ContainedEntities.Count != 0)
{
// We already contain a board. Note: We don't check if it's the right one!
return;
}
var board = EntityManager.SpawnEntity(door.BoardPrototype, Transform(uid).Coordinates);
if(!container.Insert(board))
Logger.Warning($"Couldn't insert board {ToPrettyString(board)} into door {ToPrettyString(uid)}!");
}
private void OnEmagged(EntityUid uid, DoorComponent door, GotEmaggedEvent args)
{
if(TryComp<AirlockComponent>(uid, out var airlockComponent))