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.
Deploy foldable (space-wizards#30000)
* Deploy foldable * Add NetworkedComponent and access to the component * Add handled to afterinteract * Use drop target location instead of setcoordinates * Put back in hand after failed deploy This prevents dropping the bed when clicking while inside a locker. * Created BaseDeployFoldable for folding chairs, body bags, and rollerbeds
- Loading branch information
1 parent
6afa6b9
commit 050da69
Showing
6 changed files
with
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Foldable; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
[Access(typeof(DeployFoldableSystem))] | ||
public sealed partial class DeployFoldableComponent : Component; |
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,39 @@ | ||
using Content.Shared.Hands.Components; | ||
using Content.Shared.Hands.EntitySystems; | ||
using Content.Shared.Interaction; | ||
|
||
namespace Content.Shared.Foldable; | ||
|
||
public sealed class DeployFoldableSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedHandsSystem _hands = default!; | ||
[Dependency] private readonly FoldableSystem _foldable = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DeployFoldableComponent, AfterInteractEvent>(OnAfterInteract); | ||
} | ||
|
||
private void OnAfterInteract(Entity<DeployFoldableComponent> ent, ref AfterInteractEvent args) | ||
{ | ||
if (args.Handled || !args.CanReach) | ||
return; | ||
|
||
if (!TryComp<FoldableComponent>(ent, out var foldable)) | ||
return; | ||
|
||
if (!TryComp(args.User, out HandsComponent? hands) | ||
|| !_hands.TryDrop(args.User, args.Used, targetDropLocation: args.ClickLocation, handsComp: hands)) | ||
return; | ||
|
||
if (!_foldable.TrySetFolded(ent, foldable, false)) | ||
{ | ||
_hands.TryPickup(args.User, args.Used, handsComp: hands); | ||
return; | ||
} | ||
|
||
args.Handled = true; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml
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
2 changes: 1 addition & 1 deletion
2
Resources/Prototypes/Entities/Structures/Furniture/rollerbeds.yml
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