move lockcomponent to shared (#13722)

* move lockcomponent to shared

* ajcm review
This commit is contained in:
Nemanja
2023-02-11 20:12:29 -05:00
committed by GitHub
parent 301956ef15
commit c6c319f7e4
23 changed files with 381 additions and 332 deletions

View File

@@ -10,8 +10,10 @@ using Content.Shared.Destructible;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Lock;
using Content.Shared.Placeable;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Content.Shared.Wall;
using Content.Shared.Whitelist;
using Robust.Server.Containers;
@@ -20,7 +22,6 @@ using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
namespace Content.Server.Storage.EntitySystems;
@@ -167,13 +168,15 @@ public sealed class EntityStorageSystem : EntitySystem
if (!Resolve(uid, ref component))
return;
RaiseLocalEvent(uid, new StorageBeforeOpenEvent());
var beforeev = new StorageBeforeOpenEvent();
RaiseLocalEvent(uid, ref beforeev);
component.Open = true;
EmptyContents(uid, component);
ModifyComponents(uid, component);
_audio.PlayPvs(component.OpenSound, component.Owner);
_audio.PlayPvs(component.OpenSound, uid);
ReleaseGas(uid, component);
RaiseLocalEvent(uid, new StorageAfterOpenEvent());
var afterev = new StorageAfterOpenEvent();
RaiseLocalEvent(uid, ref afterev);
}
public void CloseStorage(EntityUid uid, EntityStorageComponent? component = null)
@@ -186,8 +189,8 @@ public sealed class EntityStorageSystem : EntitySystem
var entities = _lookup.GetEntitiesInRange(targetCoordinates, component.EnteringRange, LookupFlags.Approximate | LookupFlags.Dynamic | LookupFlags.Sundries);
var ev = new StorageBeforeCloseEvent(entities);
RaiseLocalEvent(uid, ev);
var ev = new StorageBeforeCloseEvent(entities, new());
RaiseLocalEvent(uid, ref ev);
var count = 0;
foreach (var entity in ev.Contents)
{
@@ -207,9 +210,10 @@ public sealed class EntityStorageSystem : EntitySystem
TakeGas(uid, component);
ModifyComponents(uid, component);
_audio.PlayPvs(component.CloseSound, component.Owner);
_audio.PlayPvs(component.CloseSound, uid);
component.LastInternalOpenAttempt = default;
RaiseLocalEvent(uid, new StorageAfterCloseEvent());
var afterev = new StorageAfterCloseEvent();
RaiseLocalEvent(uid, ref afterev);
}
public bool Insert(EntityUid toInsert, EntityUid container, EntityStorageComponent? component = null)
@@ -302,7 +306,7 @@ public sealed class EntityStorageSystem : EntitySystem
}
var ev = new StorageOpenAttemptEvent(silent);
RaiseLocalEvent(target, ev, true);
RaiseLocalEvent(target, ref ev, true);
return !ev.Cancelled;
}
@@ -310,7 +314,7 @@ public sealed class EntityStorageSystem : EntitySystem
public bool CanClose(EntityUid target, bool silent = false)
{
var ev = new StorageCloseAttemptEvent();
RaiseLocalEvent(target, ev, silent);
RaiseLocalEvent(target, ref ev, silent);
return !ev.Cancelled;
}
@@ -347,7 +351,7 @@ public sealed class EntityStorageSystem : EntitySystem
// 6. if this is an item, then mobs must only be eaten if some other component prevents
// pick-up interactions while a mob is inside (e.g. foldable)
var attemptEvent = new InsertIntoEntityStorageAttemptEvent();
RaiseLocalEvent(toInsert, attemptEvent);
RaiseLocalEvent(toInsert, ref attemptEvent);
if (attemptEvent.Cancelled)
return false;
@@ -367,7 +371,7 @@ public sealed class EntityStorageSystem : EntitySystem
else
{
var storeEv = new StoreMobInItemContainerAttemptEvent();
RaiseLocalEvent(container, storeEv);
RaiseLocalEvent(container, ref storeEv);
allowedToEat = storeEv.Handled && !storeEv.Cancelled;
}
}