forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Store on Collide and Wand of the Locker (space-wizards#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
- Loading branch information
Showing
17 changed files
with
284 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Content.Shared/Storage/Components/StoreOnCollideComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Content.Shared.Storage.EntitySystems; | ||
using Content.Shared.Whitelist; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Storage.Components; | ||
|
||
// Use where you want an entity to store other entities on collide | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(StoreOnCollideSystem))] | ||
public sealed partial class StoreOnCollideComponent : Component | ||
{ | ||
/// <summary> | ||
/// Entities that are allowed in the storage on collide | ||
/// </summary> | ||
[DataField] | ||
public EntityWhitelist? Whitelist; | ||
|
||
/// <summary> | ||
/// Should this storage lock on collide, provided they have a lock component? | ||
/// </summary> | ||
[DataField] | ||
public bool LockOnCollide; | ||
|
||
/// <summary> | ||
/// Should the behavior be disabled when the storage is first opened? | ||
/// </summary> | ||
[DataField] | ||
public bool DisableWhenFirstOpened; | ||
|
||
/// <summary> | ||
/// If the behavior is disabled or not | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public bool Disabled; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Content.Shared/Storage/EntitySystems/StoreOnCollideSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- type: accessLevel | ||
id: Wizard | ||
name: id-card-access-level-wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -810,3 +810,4 @@ | |
- CentralCommand | ||
- NuclearOperative | ||
- SyndicateAgent | ||
- Wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+260 Bytes
Resources/Textures/Objects/Weapons/Guns/Basic/wands.rsi/locker-effect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+794 Bytes
Resources/Textures/Objects/Weapons/Guns/Basic/wands.rsi/locker-inhand-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+803 Bytes
Resources/Textures/Objects/Weapons/Guns/Basic/wands.rsi/locker-inhand-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters