Adds Store on Collide and Wand of the Locker (#33710)
* Adds wand of locker and locker projectile * Adds IsOpen method to check if storage is open * Adds store on collide * Adds Store On Collide to Wizard Locker * Adds Lock API * Adds locking support * Adds resist override and custom visual layers * Fixes decursed states, adds comment for a future visualizer * adds locker wand visuals and descriptions * shrinks locker radius, moves TODO for throw support * Adds whitelist and moves storage and lock logic into their own methods * Adds support to disable store on collide after the first open. Fixes prediction issues with disabling. * Adds wand of locker to the grimoire * Adds wizard access prototype * Adds Wizard to universal access * Moves Lock on collide to on collide method * Comments * Changes layer order * Fixes prediction issues when locking. * Adds Wiz access to universal ID
This commit is contained in:
71
Content.Shared/Storage/EntitySystems/StoreOnCollideSystem.cs
Normal file
71
Content.Shared/Storage/EntitySystems/StoreOnCollideSystem.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Content.Shared.Lock;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Storage.EntitySystems;
|
||||
|
||||
internal sealed class StoreOnCollideSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedEntityStorageSystem _storage = default!;
|
||||
[Dependency] private readonly LockSystem _lock = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
||||
[Dependency] private readonly INetManager _netMan = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<StoreOnCollideComponent, StartCollideEvent>(OnCollide);
|
||||
SubscribeLocalEvent<StoreOnCollideComponent, StorageAfterOpenEvent>(AfterOpen);
|
||||
// TODO: Add support to stop colliding after throw, wands will need a WandComp
|
||||
}
|
||||
|
||||
// We use Collide instead of Projectile to support different types of interactions
|
||||
private void OnCollide(Entity<StoreOnCollideComponent> ent, ref StartCollideEvent args)
|
||||
{
|
||||
TryStoreTarget(ent, args.OtherEntity);
|
||||
|
||||
TryLockStorage(ent);
|
||||
}
|
||||
|
||||
private void AfterOpen(Entity<StoreOnCollideComponent> ent, ref StorageAfterOpenEvent args)
|
||||
{
|
||||
var comp = ent.Comp;
|
||||
|
||||
if (comp is { DisableWhenFirstOpened: true, Disabled: false })
|
||||
comp.Disabled = true;
|
||||
}
|
||||
|
||||
private void TryStoreTarget(Entity<StoreOnCollideComponent> ent, EntityUid target)
|
||||
{
|
||||
var storageEnt = ent.Owner;
|
||||
var comp = ent.Comp;
|
||||
|
||||
if (_netMan.IsClient || _gameTiming.ApplyingState)
|
||||
return;
|
||||
|
||||
if (ent.Comp.Disabled || storageEnt == target || Transform(target).Anchored || _storage.IsOpen(storageEnt) || _whitelist.IsWhitelistFail(comp.Whitelist, target))
|
||||
return;
|
||||
|
||||
_storage.Insert(target, storageEnt);
|
||||
|
||||
}
|
||||
|
||||
private void TryLockStorage(Entity<StoreOnCollideComponent> ent)
|
||||
{
|
||||
var storageEnt = ent.Owner;
|
||||
var comp = ent.Comp;
|
||||
|
||||
if (_netMan.IsClient || _gameTiming.ApplyingState)
|
||||
return;
|
||||
|
||||
if (ent.Comp.Disabled)
|
||||
return;
|
||||
|
||||
if (comp.LockOnCollide && !_lock.IsLocked(storageEnt))
|
||||
_lock.Lock(storageEnt, storageEnt);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user