|
|
|
|
@@ -46,8 +46,9 @@ public sealed class EntityStorageSystem : EntitySystem
|
|
|
|
|
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
|
|
|
|
|
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
|
|
|
|
|
SubscribeLocalEvent<EntityStorageComponent, LockToggleAttemptEvent>(OnLockToggleAttempt);
|
|
|
|
|
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestroy);
|
|
|
|
|
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestruction);
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<InsideEntityStorageComponent, EntGotRemovedFromContainerMessage>(OnRemoved);
|
|
|
|
|
SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale);
|
|
|
|
|
SubscribeLocalEvent<InsideEntityStorageComponent, ExhaleLocationEvent>(OnInsideExhale);
|
|
|
|
|
SubscribeLocalEvent<InsideEntityStorageComponent, AtmosExposedGetAirEvent>(OnInsideExposed);
|
|
|
|
|
@@ -115,11 +116,19 @@ public sealed class EntityStorageSystem : EntitySystem
|
|
|
|
|
args.Cancelled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
|
|
|
|
|
private void OnDestruction(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
component.Open = true;
|
|
|
|
|
if (!component.DeleteContentsOnDestruction)
|
|
|
|
|
{
|
|
|
|
|
EmptyContents(uid, component);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var ent in new List<EntityUid>(component.Contents.ContainedEntities))
|
|
|
|
|
{
|
|
|
|
|
EntityManager.DeleteEntity(ent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ToggleOpen(EntityUid user, EntityUid target, EntityStorageComponent? component = null)
|
|
|
|
|
@@ -146,12 +155,7 @@ public sealed class EntityStorageSystem : EntitySystem
|
|
|
|
|
var containedArr = component.Contents.ContainedEntities.ToArray();
|
|
|
|
|
foreach (var contained in containedArr)
|
|
|
|
|
{
|
|
|
|
|
if (!component.Contents.Remove(contained))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
RemComp<InsideEntityStorageComponent>(contained);
|
|
|
|
|
Transform(contained).WorldPosition =
|
|
|
|
|
uidXform.WorldPosition + uidXform.WorldRotation.RotateVec(component.EnteringOffset);
|
|
|
|
|
Remove(contained, uid, component, uidXform);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -192,9 +196,6 @@ public sealed class EntityStorageSystem : EntitySystem
|
|
|
|
|
if (!AddToContents(entity, uid, component))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
var inside = EnsureComp<InsideEntityStorageComponent>(entity);
|
|
|
|
|
inside.Storage = uid;
|
|
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
if (count >= component.Capacity)
|
|
|
|
|
break;
|
|
|
|
|
@@ -218,15 +219,20 @@ public sealed class EntityStorageSystem : EntitySystem
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var inside = EnsureComp<InsideEntityStorageComponent>(toInsert);
|
|
|
|
|
inside.Storage = container;
|
|
|
|
|
return component.Contents.Insert(toInsert, EntityManager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Remove(EntityUid toRemove, EntityUid container, EntityStorageComponent? component = null)
|
|
|
|
|
public bool Remove(EntityUid toRemove, EntityUid container, EntityStorageComponent? component = null, TransformComponent? xform = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(container, ref component))
|
|
|
|
|
if (!Resolve(container, ref component, ref xform, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return component.Contents.Remove(toRemove, EntityManager);
|
|
|
|
|
RemComp<InsideEntityStorageComponent>(toRemove);
|
|
|
|
|
component.Contents.Remove(toRemove, EntityManager);
|
|
|
|
|
Transform(toRemove).WorldPosition = xform.WorldPosition + xform.WorldRotation.RotateVec(component.EnteringOffset);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanInsert(EntityUid container, EntityStorageComponent? component = null)
|
|
|
|
|
@@ -434,6 +440,13 @@ public sealed class EntityStorageSystem : EntitySystem
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRemoved(EntityUid uid, InsideEntityStorageComponent component, EntGotRemovedFromContainerMessage args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Container.Owner != component.Storage)
|
|
|
|
|
return;
|
|
|
|
|
RemComp(uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Gas mix event handlers
|
|
|
|
|
|
|
|
|
|
private void OnInsideInhale(EntityUid uid, InsideEntityStorageComponent component, InhaleLocationEvent args)
|
|
|
|
|
|