Skip to content

Commit

Permalink
Allow for selective tool disabling (new-frontiers-14#1936)
Browse files Browse the repository at this point in the history
* 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
whatston3 and dvir001 authored Sep 3, 2024
1 parent 079ca02 commit 060b491
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 89 deletions.
34 changes: 34 additions & 0 deletions Content.Server/_NF/Tools/Component/DisableToolUseComponent.cs
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;
}
}
19 changes: 0 additions & 19 deletions Content.Server/_NF/Tools/Component/OnToolsUseComponent.cs

This file was deleted.

57 changes: 57 additions & 0 deletions Content.Server/_NF/Tools/DisableToolUseSystem.cs
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;
}
}
}
20 changes: 0 additions & 20 deletions Content.Server/_NF/Tools/OnToolsUseSystem.cs

This file was deleted.

4 changes: 3 additions & 1 deletion Content.Shared/Tools/Components/ToolComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public sealed partial class ToolComponent : Component
/// Attempt event called *before* any do afters to see if the tool usage should succeed or not.
/// Raised on both the tool and then target.
/// </summary>
public sealed class ToolUseAttemptEvent(EntityUid user, float fuel) : CancellableEntityEventArgs
public sealed class ToolUseAttemptEvent(EntityUid user, float fuel, EntityUid tool, IEnumerable<string> qualities) : CancellableEntityEventArgs // Frontier: added tool, qualities
{
public EntityUid User { get; } = user;
public float Fuel = fuel;
public EntityUid Tool { get; } = tool; // Frontier: the tool being used
public IEnumerable<string> Qualities { get; } = qualities; // Frontier: the tool qualities being used here
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Tools/Systems/SharedToolSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private bool CanStartToolUse(EntityUid tool, EntityUid user, EntityUid? target,
return false;

// check if the tool allows being used
var beforeAttempt = new ToolUseAttemptEvent(user, fuel);
var beforeAttempt = new ToolUseAttemptEvent(user, fuel, tool, toolQualitiesNeeded); // Frontier: added tool, toolQualitiesNeeded
RaiseLocalEvent(tool, beforeAttempt);
if (beforeAttempt.Cancelled)
return false;
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/Catalog/Fills/Lockers/suit_storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
#HOS's hardsuit
- type: entity
id: SuitStorageHOS
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, BaseStructureUnanchorable, SuitStorageBase] # Frontier
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, SuitStorageBase] # Frontier: added BaseStructureDisableToolUse
suffix: Head of Security
components:
- type: StorageFill
Expand All @@ -268,7 +268,7 @@
#Warden's hardsuit
- type: entity
id: SuitStorageWarden
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, BaseStructureUnanchorable, SuitStorageBase] # Frontier
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, SuitStorageBase] # Frontier: added BaseStructureDisableToolUse
suffix: Warden
components:
- type: StorageFill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
noRot: false

- type: entity
parent: [BaseStructureUnanchorable, VendingMachine] # Frontier
parent: [BaseStructureDisableAnchoring, VendingMachine] # Frontier
id: VendingMachineAmmo
name: liberation station
description: An overwhelming amount of ancient patriotism washes over you just by looking at the machine.
Expand Down Expand Up @@ -204,7 +204,7 @@
- Bartender

- type: entity
parent: [BaseStructureIndestructible, BaseStructureAccessReaderImmuneToEmag, VendingMachine] # Frontier
parent: [BaseStructureDisableScrewing, BaseStructureIndestructible, BaseStructureAccessReaderImmuneToEmag, VendingMachine] # Frontier: add BaseStructureDisableScrewing, BaseStructureIndestructible, BaseStructureAccessReaderImmuneToEmag
id: VendingMachineCart
name: PTech
description: PTech vending! Providing a ROBUST selection of PDAs, cartridges, and anything else a dull paper pusher needs!
Expand Down Expand Up @@ -1883,7 +1883,7 @@
map: ["enum.WiresVisualLayers.MaintenancePanel"]

- type: entity
parent: [BaseStructureUnanchorable, VendingMachine] # Frontier
parent: [BaseStructureDisableAnchoring, VendingMachine] # Frontier
id: VendingMachineSyndieDrobe
name: SyndieDrobe
description: Wardrobe machine encoded by the syndicate, contains elite outfits for various operations.
Expand Down Expand Up @@ -1993,7 +1993,7 @@
map: ["enum.WiresVisualLayers.MaintenancePanel"]

- type: entity
parent: [BaseStructureUnanchorable, VendingMachine] # Frontier
parent: [BaseStructureDisableAnchoring, VendingMachine] # Frontier
id: VendingMachineCentDrobe
name: CentDrobe
description: A one-of-a-kind vending machine for all your centcom aesthetic needs!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
# HoS
- type: entity
id: LockerHeadOfSecurity
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, BaseStructureUnanchorable, LockerBaseSecure] # Frontier
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, BaseStructureDisableAnchoring, LockerBaseSecure] # Frontier
name: head of security's locker
components:
- type: Appearance
Expand All @@ -309,7 +309,7 @@
# Warden
- type: entity
id: LockerWarden
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, BaseStructureUnanchorable, LockerBaseSecure] # Frontier
parent: [BaseStructureIndestructible, BaseStructureLockImmuneToEmag, BaseStructureAccessReaderImmuneToEmag, BaseStructureDisableToolUse, BaseStructureDisableAnchoring, LockerBaseSecure] # Frontier
name: warden's locker
components:
- type: Appearance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Outpost
- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFOutpostSTC
suffix: Outpost, STC
noSpawn: true
Expand All @@ -28,7 +28,7 @@
name: "Frontier Outpost STC"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFOutpostSR
suffix: Outpost, SR
noSpawn: true
Expand All @@ -37,7 +37,7 @@
name: "Frontier Outpost SR"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFOutpostGuard
suffix: Outpost, Guard
noSpawn: true
Expand All @@ -46,7 +46,7 @@
name: "Frontier Outpost Guard"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFOutpostReception
suffix: Outpost, Reception
noSpawn: true
Expand All @@ -55,7 +55,7 @@
name: "Frontier Outpost Reception"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineCaptain]
parent: [BaseStructureDisableToolUse, FaxMachineCaptain]
id: FaxMachineNFOutpostAdministration
suffix: Outpost, Administration
noSpawn: true
Expand All @@ -65,7 +65,7 @@

# POI
- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFBeacon
suffix: POI, Omnichurch Beacon
noSpawn: true
Expand All @@ -74,7 +74,7 @@
name: "Omnichurch Beacon"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineSyndie, FaxMachineShipAntag]
parent: [BaseStructureDisableToolUse, FaxMachineSyndie, FaxMachineShipAntag]
id: FaxMachineNFLPBravo
suffix: POI, LP Bravo
noSpawn: true
Expand All @@ -85,7 +85,7 @@
powerDisabled: true #starts off

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFLodge
suffix: POI, Lodge
noSpawn: true
Expand All @@ -94,7 +94,7 @@
name: "The Lodge"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFPole
suffix: POI, Pole
noSpawn: true
Expand All @@ -103,7 +103,7 @@
name: "The North Pole"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFTinnia
suffix: POI, Tinnia
noSpawn: true
Expand All @@ -112,7 +112,7 @@
name: "Tinnia's Rest"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFTrade
suffix: POI, Trade
noSpawn: true
Expand All @@ -121,7 +121,7 @@
name: "Trade Outpost"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFLab
suffix: POI, Lab
noSpawn: true
Expand All @@ -130,7 +130,7 @@
name: "Anomalous Lab"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFArena
suffix: POI, Arena
noSpawn: true
Expand All @@ -139,7 +139,7 @@
name: "The Pit"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFCasino
suffix: POI, Casino
noSpawn: true
Expand All @@ -148,7 +148,7 @@
name: "Casey's Casino"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFCourthouse
suffix: POI, Courthouse
noSpawn: true
Expand All @@ -157,7 +157,7 @@
name: "Courthouse"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineShipAntag]
parent: [BaseStructureDisableToolUse, FaxMachineShipAntag]
id: FaxMachineNFCove
suffix: POI, Cove
noSpawn: true
Expand All @@ -166,7 +166,7 @@
name: "Pirate's Cove"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFNfsd
suffix: POI, NFSD
noSpawn: true
Expand All @@ -175,7 +175,7 @@
name: "NFSD Outpost Sheriff"

- type: entity
parent: [BaseStructureDisableToolUse, BaseStructureUnanchorable, FaxMachineBase]
parent: [BaseStructureDisableToolUse, FaxMachineBase]
id: FaxMachineNFNfsdLawyer
suffix: POI, NFSD Lawyer
noSpawn: true
Expand Down
Loading

0 comments on commit 060b491

Please sign in to comment.