forked from new-frontiers-14/frontier-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.
Allow for selective tool disabling (new-frontiers-14#1936)
* Allow for selective tool disabling * OnToolsUseComponent: restore VVAccess to fields * Fixup * DisableAnchoring use * Update base_structure.yml * a million booleans * missed base_structure entities * OnToolsUse to DisableToolUse * always anchored * Missed an indent level * remove unnecessary anchor parents * NonLethalVend: POI version is anchored * PTech: movable, not screwable * no screwing * comment ptech --------- Co-authored-by: Dvir <[email protected]>
- Loading branch information
Showing
14 changed files
with
169 additions
and
89 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Content.Server/_NF/Tools/Component/DisableToolUseComponent.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.Tools; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Server._NF.Tools.Components | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class DisableToolUseComponent : Component | ||
{ | ||
// A field for each tool use type to allow for inheritance | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Anchoring; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Prying; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Screwing; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Cutting; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Welding; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Pulsing; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Slicing; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Sawing; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Honking; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Rolling; | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public bool Digging; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
using Content.Server._NF.Tools.Components; | ||
using Content.Shared.Tools; | ||
using Content.Shared.Tools.Components; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Toolshed.TypeParsers; | ||
|
||
namespace Content.Server._NF.Tools; | ||
|
||
public sealed class DisableToolUseSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<DisableToolUseComponent, ToolUseAttemptEvent>(OnToolUseAttempt); | ||
} | ||
|
||
private void OnToolUseAttempt(EntityUid uid, DisableToolUseComponent component, ToolUseAttemptEvent args) | ||
{ | ||
// Check each tool quality being cancelled. | ||
foreach (var quality in args.Qualities) | ||
{ | ||
if (Disabled(component, quality)) | ||
args.Cancel(); | ||
} | ||
} | ||
|
||
private bool Disabled(DisableToolUseComponent component, ProtoId<ToolQualityPrototype> quality) | ||
{ | ||
switch (quality) | ||
{ | ||
case "Anchoring": | ||
return component.Anchoring; | ||
case "Prying": | ||
return component.Prying; | ||
case "Screwing": | ||
return component.Screwing; | ||
case "Cutting": | ||
return component.Cutting; | ||
case "Welding": | ||
return component.Welding; | ||
case "Pulsing": | ||
return component.Pulsing; | ||
case "Slicing": | ||
return component.Slicing; | ||
case "Sawing": | ||
return component.Sawing; | ||
case "Honking": | ||
return component.Honking; | ||
case "Rolling": | ||
return component.Rolling; | ||
case "Digging": | ||
return component.Digging; | ||
default: | ||
return false; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.