Minor entitystorage air fixes (#14842)

This commit is contained in:
Kara
2023-03-24 21:30:19 -07:00
committed by GitHub
parent bda78dab60
commit 4ba9e8090d

View File

@@ -20,6 +20,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<EntityStorageComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt); SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded); SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
@@ -30,19 +31,22 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
SubscribeLocalEvent<InsideEntityStorageComponent, EntGotRemovedFromContainerMessage>(OnRemoved); SubscribeLocalEvent<InsideEntityStorageComponent, EntGotRemovedFromContainerMessage>(OnRemoved);
} }
private void OnMapInit(EntityUid uid, EntityStorageComponent component, MapInitEvent args)
{
if (!component.Open && component.Air.TotalMoles == 0)
{
// If we're closed on spawn and have no air already saved, we need to pull some air into our environment from where we spawned,
// so that we have -something-. For example, if you bought an animal crate or something.
TakeGas(uid, component);
}
}
protected override void OnInit(EntityUid uid, SharedEntityStorageComponent component, ComponentInit args) protected override void OnInit(EntityUid uid, SharedEntityStorageComponent component, ComponentInit args)
{ {
base.OnInit(uid, component, args); base.OnInit(uid, component, args);
if (TryComp<ConstructionComponent>(uid, out var construction)) if (TryComp<ConstructionComponent>(uid, out var construction))
_construction.AddContainer(uid, ContainerName, construction); _construction.AddContainer(uid, ContainerName, construction);
if (!component.Open)
{
// If we're closed on spawn, we need to pull some air into our environment from where we spawned,
// so that we have -something-. For example, if you bought an animal crate or something.
TakeGas(uid, (EntityStorageComponent) component);
}
} }
private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component, WeldableAttemptEvent args) private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component, WeldableAttemptEvent args)