From c8a318e728f66e7fd5f3a904761aabc1ddb49599 Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 08:31:48 +0300 Subject: [PATCH 1/6] First time fix nozzle --- .../ClothingSlotSprayProviderComponent.cs | 26 +++++++++ .../Components/SprayProviderComponent.cs | 6 ++ .../Systems/SharedSpraySystem.Clothing.cs | 55 +++++++++++++++++++ .../weapons/guns/basic/spraynozzle.ftl | 4 +- Resources/Maps/Nonstations/nukieplanet.yml | 2 +- Resources/Maps/Shuttles/dart.yml | 2 +- .../Weapons/Guns/Basic/spraynozzle.yml | 35 +++++++++--- .../Entities/Structures/Machines/lathe.yml | 2 +- .../Prototypes/Recipes/Lathes/janitorial.yml | 4 +- .../Prototypes/Research/civilianservices.yml | 2 +- 10 files changed, 121 insertions(+), 17 deletions(-) create mode 100644 Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs create mode 100644 Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs create mode 100644 Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs diff --git a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs new file mode 100644 index 00000000000000..b6201780906e90 --- /dev/null +++ b/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs @@ -0,0 +1,26 @@ +using Content.Shared.Inventory; +using Content.Shared.Whitelist; +using Robust.Shared.GameStates; +using Content.Shared.SS220.SpraySystem; + +namespace Content.Shared.SS220.SpraySystem.Components; + +/// +/// This is used for relaying solition events +/// to an entity in the user's clothing slot. +/// +[RegisterComponent, NetworkedComponent, Access(typeof(SharedSpraySystem))] +public sealed partial class ClothingSlotSprayProviderComponent : SprayProviderComponent +{ + /// + /// The slot that the ammo provider should be located in. + /// + [DataField("requiredSlot", required: true)] + public SlotFlags RequiredSlot; + + /// + /// A whitelist for determining whether or not an solution provider is valid. + /// + [DataField("providerWhitelist")] + public EntityWhitelist? ProviderWhitelist; +} diff --git a/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs new file mode 100644 index 00000000000000..0c3cb54066794b --- /dev/null +++ b/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs @@ -0,0 +1,6 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.SS220.SpraySystem.Components; + +[NetworkedComponent] +public abstract partial class SprayProviderComponent : Component {} diff --git a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs new file mode 100644 index 00000000000000..79016e979bbade --- /dev/null +++ b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs @@ -0,0 +1,55 @@ +using System.Diagnostics.CodeAnalysis; +using Content.Shared.Inventory; +using Content.Shared.SS220.Spray; +using Content.Shared.Weapons.Ranged.Events; + +namespace Content.Shared.SS220.Spray.System; + +public partial class SharedSpraySystem +{ + [Dependency] private readonly InventorySystem _inventory = default!; + + private void InitializeClothing() + { + SubscribeLocalEvent(OnClothingTakeAmmo); + SubscribeLocalEvent(OnClothingAmmoCount); + } + + private void OnClothingTakeAmmo(EntityUid uid, ClothingSlotAmmoProviderComponent component, TakeAmmoEvent args) + { + if (!TryGetClothingSlotEntity(uid, component, out var entity)) + return; + RaiseLocalEvent(entity.Value, args); + } + + private void OnClothingAmmoCount(EntityUid uid, ClothingSlotAmmoProviderComponent component, ref GetAmmoCountEvent args) + { + if (!TryGetClothingSlotEntity(uid, component, out var entity)) + return; + RaiseLocalEvent(entity.Value, ref args); + } + + private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotAmmoProviderComponent component, [NotNullWhen(true)] out EntityUid? slotEntity) + { + slotEntity = null; + + if (!Containers.TryGetContainingContainer(uid, out var container)) + return false; + var user = container.Owner; + + if (!_inventory.TryGetContainerSlotEnumerator(user, out var enumerator, component.TargetSlot)) + return false; + + while (enumerator.NextItem(out var item)) + { + if (component.ProviderWhitelist == null || !component.ProviderWhitelist.IsValid(item, EntityManager)) + continue; + + slotEntity = item; + return true; + } + + return false; + } +} + diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/weapons/guns/basic/spraynozzle.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/weapons/guns/basic/spraynozzle.ftl index a5ce8719a29b5b..43fee543420e35 100644 --- a/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/weapons/guns/basic/spraynozzle.ftl +++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/weapons/guns/basic/spraynozzle.ftl @@ -1,2 +1,2 @@ -ent-WeaponSprayNozzle = форсунка-распылитель - .desc = Мощное разбрызгивающее устройство, используемое в связке с ранцевым резервуаром с водой. +ent-SprayNozzle = пневматический распылитель высокого давления + .desc = Мощное разбрызгивающее устройство, используемое в связке с ранцевым резервуаром с космическим очистителем. diff --git a/Resources/Maps/Nonstations/nukieplanet.yml b/Resources/Maps/Nonstations/nukieplanet.yml index 4d1172198cabae..d23936053ecbcb 100644 --- a/Resources/Maps/Nonstations/nukieplanet.yml +++ b/Resources/Maps/Nonstations/nukieplanet.yml @@ -15167,7 +15167,7 @@ entities: parent: 104 - type: BallisticAmmoProvider unspawnedCount: 2 -- proto: WeaponSprayNozzle +- proto: SprayNozzle entities: - uid: 152 components: diff --git a/Resources/Maps/Shuttles/dart.yml b/Resources/Maps/Shuttles/dart.yml index c44dfe890dfbeb..53afef308d8fd1 100644 --- a/Resources/Maps/Shuttles/dart.yml +++ b/Resources/Maps/Shuttles/dart.yml @@ -6687,7 +6687,7 @@ entities: - type: Transform pos: -1.5,6.5 parent: 1 -- proto: WeaponSprayNozzle +- proto: SprayNozzle entities: - uid: 337 components: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/spraynozzle.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/spraynozzle.yml index f2e93a607ece05..b8eeb42ca5ca12 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/spraynozzle.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/spraynozzle.yml @@ -1,5 +1,5 @@ - type: entity - id: WeaponSprayNozzle + id: SprayNozzle parent: BaseItem name: spray nozzle description: A high-powered spray nozzle used in conjunction with a backpack-mounted water tank. @@ -10,14 +10,31 @@ - type: Item sprite: Objects/Weapons/Guns/Basic/spraynozzle.rsi size: Normal - - type: Gun - cameraRecoilScalar: 0 #no recoil - fireRate: 4 - selectedMode: FullAuto - availableModes: - - FullAuto - soundGunshot: - path: /Audio/Weapons/Guns/Gunshots/water_spray.ogg + # SS220 Nozzle fix begin + #- type: Gun + # cameraRecoilScalar: 0 #no recoil + # fireRate: 4 + # selectedMode: FullAuto + # availableModes: + # - FullAuto + # soundGunshot: + # path: /Audio/Weapons/Guns/Gunshots/water_spray.ogg + - type: UseDelay + - type: Spray + transferAmount: 15 + sprayedPrototype: BigVapor + sprayVelocity: 4 + sprayDistance: 6 + spraySound: + path: /Audio/Effects/spray2.ogg + - type: Drink + solution: spray + ignoreEmpty: true + useSound: + path: /Audio/Effects/spray3.ogg + transferAmount: 10 + - type: SolutionItemStatus + solution: spray - type: Appearance - type: ClothingSlotAmmoProvider targetSlot: BACK diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 4a9dc3eafc678c..5c24cae6a203a6 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -291,7 +291,7 @@ - ChemistryEmptyBottle01 - AdvMopItem - TrashBagAdvanced #SS220 Borg Modules - - WeaponSprayNozzle + - SprayNozzle - ClothingBackpackWaterTank - MegaSprayBottle - TimerTrigger diff --git a/Resources/Prototypes/Recipes/Lathes/janitorial.yml b/Resources/Prototypes/Recipes/Lathes/janitorial.yml index 9ba7dfa1889e94..e6aa0a353f6523 100644 --- a/Resources/Prototypes/Recipes/Lathes/janitorial.yml +++ b/Resources/Prototypes/Recipes/Lathes/janitorial.yml @@ -90,8 +90,8 @@ Wood: 200 - type: latheRecipe - id: WeaponSprayNozzle - result: WeaponSprayNozzle + id: SprayNozzle + result: SprayNozzle completetime: 5 materials: Steel: 1500 diff --git a/Resources/Prototypes/Research/civilianservices.yml b/Resources/Prototypes/Research/civilianservices.yml index 74737936cd9689..fb94f038a93303 100644 --- a/Resources/Prototypes/Research/civilianservices.yml +++ b/Resources/Prototypes/Research/civilianservices.yml @@ -189,7 +189,7 @@ tier: 2 cost: 10000 recipeUnlocks: - - WeaponSprayNozzle + - SprayNozzle - ClothingBackpackWaterTank - type: technology From 6252d6eaaffeae16f4a4d6ea698f63003f71ba53 Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 14:21:05 +0300 Subject: [PATCH 2/6] Some changes for SharedSpaySystem.Clothings --- .../ClothingSlotSprayProviderComponent.cs | 5 +-- .../Components/SprayProviderComponent.cs | 2 +- .../Spray/Events/GetSolutionCountEvent.cs | 11 +++++++ .../SS220/Spray/Events/TakeSolutionEvent.cs | 31 +++++++++++++++++++ .../Systems/SharedSpraySystem.Clothing.cs | 22 +++++++------ 5 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 Content.Shared/SS220/Spray/Events/GetSolutionCountEvent.cs create mode 100644 Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs diff --git a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs index b6201780906e90..3adda1c569e858 100644 --- a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs @@ -1,9 +1,10 @@ using Content.Shared.Inventory; using Content.Shared.Whitelist; using Robust.Shared.GameStates; -using Content.Shared.SS220.SpraySystem; +using Content.Shared.SS220.Spray.System; +using Content.Shared.SS220.Spray.Components; -namespace Content.Shared.SS220.SpraySystem.Components; +namespace Content.Shared.SS220.Spray.Components; /// /// This is used for relaying solition events diff --git a/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs index 0c3cb54066794b..2040a094ad8a33 100644 --- a/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs @@ -1,6 +1,6 @@ using Robust.Shared.GameStates; -namespace Content.Shared.SS220.SpraySystem.Components; +namespace Content.Shared.SS220.Spray.Components; [NetworkedComponent] public abstract partial class SprayProviderComponent : Component {} diff --git a/Content.Shared/SS220/Spray/Events/GetSolutionCountEvent.cs b/Content.Shared/SS220/Spray/Events/GetSolutionCountEvent.cs new file mode 100644 index 00000000000000..0082283f95faaf --- /dev/null +++ b/Content.Shared/SS220/Spray/Events/GetSolutionCountEvent.cs @@ -0,0 +1,11 @@ +namespace Content.Shared.SS220.Spray.Events; + +/// +/// Raised on an AmmoProvider to request deets. +/// +[ByRefEvent] +public struct GetSolutionCountEvent +{ + public int Count; + public int Capacity; +} diff --git a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs new file mode 100644 index 00000000000000..773c2cccf97ad2 --- /dev/null +++ b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs @@ -0,0 +1,31 @@ +using Robust.Shared.Map; + +namespace Content.Shared.SS220.Spray.Events; + +/// +/// Raised on a gun when it would like to take the specified amount of ammo. +/// +public sealed class TakeSolutionEvent : EntityEventArgs +{ + public readonly EntityUid? User; + public readonly int Shots; + public List<(EntityUid? Entity, IShootable Shootable)> Ammo; + + /// + /// If no ammo returned what is the reason for it? + /// + public string? Reason; + + /// + /// Coordinates to spawn the ammo at. + /// + public EntityCoordinates Coordinates; + + public TakeAmmoEvent(int shots, List<(EntityUid? Entity, IShootable Shootable)> ammo, EntityCoordinates coordinates, EntityUid? user) + { + Shots = shots; + Ammo = ammo; + Coordinates = coordinates; + User = user; + } +} diff --git a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs index 79016e979bbade..9722a9f542df32 100644 --- a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs +++ b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs @@ -1,43 +1,45 @@ using System.Diagnostics.CodeAnalysis; using Content.Shared.Inventory; -using Content.Shared.SS220.Spray; -using Content.Shared.Weapons.Ranged.Events; +using Content.Shared.SS220.Spray.Components; +using Content.Shared.SS220.Spray.Events; +using Robust.Shared.Containers; namespace Content.Shared.SS220.Spray.System; -public partial class SharedSpraySystem +public partial class SharedSpraySystem : EntitySystem { [Dependency] private readonly InventorySystem _inventory = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; private void InitializeClothing() { - SubscribeLocalEvent(OnClothingTakeAmmo); - SubscribeLocalEvent(OnClothingAmmoCount); + SubscribeLocalEvent(OnClothingTakeSolution); + SubscribeLocalEvent(OnClothingSolutionCount); } - private void OnClothingTakeAmmo(EntityUid uid, ClothingSlotAmmoProviderComponent component, TakeAmmoEvent args) + private void OnClothingTakeSolution(EntityUid uid, ClothingSlotSprayProviderComponent component, TakeSolutionEvent args) { if (!TryGetClothingSlotEntity(uid, component, out var entity)) return; RaiseLocalEvent(entity.Value, args); } - private void OnClothingAmmoCount(EntityUid uid, ClothingSlotAmmoProviderComponent component, ref GetAmmoCountEvent args) + private void OnClothingSolutionCount(EntityUid uid, ClothingSlotSprayProviderComponent component, ref GetSolutionCountEvent args) { if (!TryGetClothingSlotEntity(uid, component, out var entity)) return; RaiseLocalEvent(entity.Value, ref args); } - private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotAmmoProviderComponent component, [NotNullWhen(true)] out EntityUid? slotEntity) + private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSprayProviderComponent component, [NotNullWhen(true)] out EntityUid? slotEntity) { slotEntity = null; - if (!Containers.TryGetContainingContainer(uid, out var container)) + if (!_container.TryGetContainingContainer(uid, out var container)) return false; var user = container.Owner; - if (!_inventory.TryGetContainerSlotEnumerator(user, out var enumerator, component.TargetSlot)) + if (!_inventory.TryGetContainerSlotEnumerator(user, out var enumerator, component.RequiredSlot)) return false; while (enumerator.NextItem(out var item)) From e6f2c92ca3d67d8a8d4137f9f5792d707b77c7e4 Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 14:23:33 +0300 Subject: [PATCH 3/6] Move spraynozzle from weapons to tools --- .../Objects/{Weapons/Guns/Basic => Tools}/spraynozzle.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Resources/Prototypes/Entities/Objects/{Weapons/Guns/Basic => Tools}/spraynozzle.yml (100%) diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/spraynozzle.yml b/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml similarity index 100% rename from Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/spraynozzle.yml rename to Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml From f531849111fce7304d8bcc5581a00c9c9c42174c Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 14:36:36 +0300 Subject: [PATCH 4/6] Refactor whitelist check --- .../Spray/Components/ClothingSlotSprayProviderComponent.cs | 6 +++--- Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs | 2 +- .../SS220/Spray/Systems/SharedSpraySystem.Clothing.cs | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs index 3adda1c569e858..92b6a358634ed4 100644 --- a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs @@ -17,11 +17,11 @@ public sealed partial class ClothingSlotSprayProviderComponent : SprayProviderCo /// The slot that the ammo provider should be located in. /// [DataField("requiredSlot", required: true)] - public SlotFlags RequiredSlot; + public SlotFlags SolutionRequiredSlot; /// /// A whitelist for determining whether or not an solution provider is valid. /// - [DataField("providerWhitelist")] - public EntityWhitelist? ProviderWhitelist; + [DataField("solutionProviderWhitelist")] + public EntityWhitelist? solutionProviderWhitelist; } diff --git a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs index 773c2cccf97ad2..3a2a499fb0edbd 100644 --- a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs +++ b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs @@ -21,7 +21,7 @@ public sealed class TakeSolutionEvent : EntityEventArgs /// public EntityCoordinates Coordinates; - public TakeAmmoEvent(int shots, List<(EntityUid? Entity, IShootable Shootable)> ammo, EntityCoordinates coordinates, EntityUid? user) + public TakeSolutionEvent(int shots, List<(EntityUid? Entity, IShootable Shootable)> ammo, EntityCoordinates coordinates, EntityUid? user) { Shots = shots; Ammo = ammo; diff --git a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs index 9722a9f542df32..7d5b39b0505e47 100644 --- a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs +++ b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs @@ -2,6 +2,7 @@ using Content.Shared.Inventory; using Content.Shared.SS220.Spray.Components; using Content.Shared.SS220.Spray.Events; +using Content.Shared.Whitelist; using Robust.Shared.Containers; namespace Content.Shared.SS220.Spray.System; @@ -10,6 +11,7 @@ public partial class SharedSpraySystem : EntitySystem { [Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; private void InitializeClothing() { @@ -39,12 +41,12 @@ private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSprayProviderCo return false; var user = container.Owner; - if (!_inventory.TryGetContainerSlotEnumerator(user, out var enumerator, component.RequiredSlot)) + if (!_inventory.TryGetContainerSlotEnumerator(user, out var enumerator, component.SolutionRequiredSlot)) return false; while (enumerator.NextItem(out var item)) { - if (component.ProviderWhitelist == null || !component.ProviderWhitelist.IsValid(item, EntityManager)) + if (component.solutionProviderWhitelist == null || !_whitelistSystem.IsValid(component.solutionProviderWhitelist, uid)) continue; slotEntity = item; From 7f81a61a72302329732952420788b943cb98e468 Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 15:06:51 +0300 Subject: [PATCH 5/6] Rename spaces and methods in SharedSpraySystem --- ...t.cs => ClothingSlotSolutionProviderComponent.cs} | 5 ++--- ...iderComponent.cs => SolutionProviderComponent.cs} | 2 +- .../SS220/Spray/Events/TakeSolutionEvent.cs | 1 + .../Spray/Systems/SharedSpraySystem.Clothing.cs | 12 ++++++------ .../Entities/Objects/Tools/spraynozzle.yml | 8 +++++--- 5 files changed, 15 insertions(+), 13 deletions(-) rename Content.Shared/SS220/Spray/Components/{ClothingSlotSprayProviderComponent.cs => ClothingSlotSolutionProviderComponent.cs} (79%) rename Content.Shared/SS220/Spray/Components/{SprayProviderComponent.cs => SolutionProviderComponent.cs} (59%) diff --git a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs similarity index 79% rename from Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs rename to Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs index 92b6a358634ed4..517f9db6cada00 100644 --- a/Content.Shared/SS220/Spray/Components/ClothingSlotSprayProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs @@ -2,7 +2,6 @@ using Content.Shared.Whitelist; using Robust.Shared.GameStates; using Content.Shared.SS220.Spray.System; -using Content.Shared.SS220.Spray.Components; namespace Content.Shared.SS220.Spray.Components; @@ -11,7 +10,7 @@ namespace Content.Shared.SS220.Spray.Components; /// to an entity in the user's clothing slot. /// [RegisterComponent, NetworkedComponent, Access(typeof(SharedSpraySystem))] -public sealed partial class ClothingSlotSprayProviderComponent : SprayProviderComponent +public sealed partial class ClothingSlotSolutionProviderComponent : SolutionProviderComponent { /// /// The slot that the ammo provider should be located in. @@ -23,5 +22,5 @@ public sealed partial class ClothingSlotSprayProviderComponent : SprayProviderCo /// A whitelist for determining whether or not an solution provider is valid. /// [DataField("solutionProviderWhitelist")] - public EntityWhitelist? solutionProviderWhitelist; + public EntityWhitelist? SolutionProviderWhitelist; } diff --git a/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs b/Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs similarity index 59% rename from Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs rename to Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs index 2040a094ad8a33..5662e0cb0adc3b 100644 --- a/Content.Shared/SS220/Spray/Components/SprayProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs @@ -3,4 +3,4 @@ namespace Content.Shared.SS220.Spray.Components; [NetworkedComponent] -public abstract partial class SprayProviderComponent : Component {} +public abstract partial class SolutionProviderComponent : Component {} diff --git a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs index 3a2a499fb0edbd..b82752bbd23b18 100644 --- a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs +++ b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs @@ -1,4 +1,5 @@ using Robust.Shared.Map; +using Content.Shared.Weapons.Ranged; namespace Content.Shared.SS220.Spray.Events; diff --git a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs index 7d5b39b0505e47..75d416d3557ff6 100644 --- a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs +++ b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs @@ -15,25 +15,25 @@ public partial class SharedSpraySystem : EntitySystem private void InitializeClothing() { - SubscribeLocalEvent(OnClothingTakeSolution); - SubscribeLocalEvent(OnClothingSolutionCount); + SubscribeLocalEvent(OnClothingTakeSolution); + SubscribeLocalEvent(OnClothingSolutionCount); } - private void OnClothingTakeSolution(EntityUid uid, ClothingSlotSprayProviderComponent component, TakeSolutionEvent args) + private void OnClothingTakeSolution(EntityUid uid, ClothingSlotSolutionProviderComponent component, TakeSolutionEvent args) { if (!TryGetClothingSlotEntity(uid, component, out var entity)) return; RaiseLocalEvent(entity.Value, args); } - private void OnClothingSolutionCount(EntityUid uid, ClothingSlotSprayProviderComponent component, ref GetSolutionCountEvent args) + private void OnClothingSolutionCount(EntityUid uid, ClothingSlotSolutionProviderComponent component, ref GetSolutionCountEvent args) { if (!TryGetClothingSlotEntity(uid, component, out var entity)) return; RaiseLocalEvent(entity.Value, ref args); } - private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSprayProviderComponent component, [NotNullWhen(true)] out EntityUid? slotEntity) + private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSolutionProviderComponent component, [NotNullWhen(true)] out EntityUid? slotEntity) { slotEntity = null; @@ -46,7 +46,7 @@ private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSprayProviderCo while (enumerator.NextItem(out var item)) { - if (component.solutionProviderWhitelist == null || !_whitelistSystem.IsValid(component.solutionProviderWhitelist, uid)) + if (component.SolutionProviderWhitelist == null || !_whitelistSystem.IsValid(component.SolutionProviderWhitelist, uid)) continue; slotEntity = item; diff --git a/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml b/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml index b8eeb42ca5ca12..34cb503f9b5018 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml @@ -36,8 +36,10 @@ - type: SolutionItemStatus solution: spray - type: Appearance - - type: ClothingSlotAmmoProvider - targetSlot: BACK - providerWhitelist: + - type: SolutionAmmoProvider + solutionId: SpaceCleaner + - type: ClothingSlotSolutionProvider + solutionRequiredSlot: BACK + solutionProviderWhitelist: tags: - NozzleBackTank From 101d51e32d918f571d16f87e8dd56241d82d71ce Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 22:04:53 +0300 Subject: [PATCH 6/6] Add OnGetSolution but in not work --- .../SharedSolutionContainerSystem.cs | 15 +++++++++++++++ .../ClothingSlotSolutionProviderComponent.cs | 3 ++- .../SS220/Spray/Events/TakeSolutionEvent.cs | 15 +++------------ .../Spray/Systems/SharedSpraySystem.Clothing.cs | 8 +++++--- .../Entities/Clothing/Back/specific.yml | 14 +++++++++++++- .../Entities/Objects/Tools/spraynozzle.yml | 2 -- 6 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs index 5e58a0944a496e..02ddb9e27f311f 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs @@ -19,6 +19,10 @@ using Robust.Shared.Map; using Robust.Shared.Network; using Dependency = Robust.Shared.IoC.DependencyAttribute; +using Content.Shared.SS220.Spray.Components; +using Content.Shared.SS220.Spray.Events; +using Content.Shared.SS220.Spray.System; +using YamlDotNet.Core.Tokens; namespace Content.Shared.Chemistry.EntitySystems; @@ -76,6 +80,7 @@ public override void Initialize() SubscribeLocalEvent(OnExamineSolution); SubscribeLocalEvent>(OnSolutionExaminableVerb); SubscribeLocalEvent(OnMapInit); + //SubscribeLocalEvent(OnGetSolution); if (NetManager.IsServer) { @@ -1203,4 +1208,14 @@ public FixedPoint2 ClampReagentAmountByConcentration( dissolvedReagentAmount += overflow; return dissolvedReagentAmount; } + + // SS220 Refactor nuzzle begin + private void OnGetSolution(EntityUid uid, TakeSolutionEvent takeSolutionEvent) + { + if (!TryGetSolution(uid, ClothingSlotSolutionProviderComponent.ContainmentSolutionName, out var soln, out var solution)) + return; + + SplitSolution(uid, FixedPoint2.Value, FixedPoint2.New(takeSolutionEvent.SolutionAmount)); + } + // SS220 Refactor nuzzle end } diff --git a/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs b/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs index 517f9db6cada00..0bced4cb58b034 100644 --- a/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs @@ -12,10 +12,11 @@ namespace Content.Shared.SS220.Spray.Components; [RegisterComponent, NetworkedComponent, Access(typeof(SharedSpraySystem))] public sealed partial class ClothingSlotSolutionProviderComponent : SolutionProviderComponent { + public const string ContainmentSolutionName = "containmentsolution"; /// /// The slot that the ammo provider should be located in. /// - [DataField("requiredSlot", required: true)] + [DataField("solutionRequiredSlot", required: true)] public SlotFlags SolutionRequiredSlot; /// diff --git a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs index b82752bbd23b18..13476d1a929b31 100644 --- a/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs +++ b/Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs @@ -9,24 +9,15 @@ namespace Content.Shared.SS220.Spray.Events; public sealed class TakeSolutionEvent : EntityEventArgs { public readonly EntityUid? User; - public readonly int Shots; - public List<(EntityUid? Entity, IShootable Shootable)> Ammo; + public byte SolutionAmount { get; } /// /// If no ammo returned what is the reason for it? /// public string? Reason; - /// - /// Coordinates to spawn the ammo at. - /// - public EntityCoordinates Coordinates; - - public TakeSolutionEvent(int shots, List<(EntityUid? Entity, IShootable Shootable)> ammo, EntityCoordinates coordinates, EntityUid? user) + public TakeSolutionEvent(EntityUid? user, byte solutionAmount) { - Shots = shots; - Ammo = ammo; - Coordinates = coordinates; - User = user; } + } diff --git a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs index 75d416d3557ff6..3748e2577e6b08 100644 --- a/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs +++ b/Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs @@ -3,17 +3,18 @@ using Content.Shared.SS220.Spray.Components; using Content.Shared.SS220.Spray.Events; using Content.Shared.Whitelist; +using Linguini.Bundle.Errors; using Robust.Shared.Containers; namespace Content.Shared.SS220.Spray.System; -public partial class SharedSpraySystem : EntitySystem +public sealed partial class SharedSpraySystem : EntitySystem { [Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; - private void InitializeClothing() + public override void Initialize() { SubscribeLocalEvent(OnClothingTakeSolution); SubscribeLocalEvent(OnClothingSolutionCount); @@ -46,7 +47,8 @@ private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSolutionProvide while (enumerator.NextItem(out var item)) { - if (component.SolutionProviderWhitelist == null || !_whitelistSystem.IsValid(component.SolutionProviderWhitelist, uid)) + if (component.SolutionProviderWhitelist == null || + !_whitelistSystem.IsValid(component.SolutionProviderWhitelist, uid)) continue; slotEntity = item; diff --git a/Resources/Prototypes/Entities/Clothing/Back/specific.yml b/Resources/Prototypes/Entities/Clothing/Back/specific.yml index 9a116500c02151..4498acf0f0c615 100644 --- a/Resources/Prototypes/Entities/Clothing/Back/specific.yml +++ b/Resources/Prototypes/Entities/Clothing/Back/specific.yml @@ -19,7 +19,7 @@ enum.ChameleonUiKey.Key: type: ChameleonBoundUserInterface # Corvax-HiddenDesc-Start - - type: HiddenDescription + - type: HiddenDescription entries: - label: corvax-hidden-desc-Chameleon-syndicate whitelistMind: @@ -68,6 +68,10 @@ interfaces: enum.TransferAmountUiKey.Key: type: TransferAmountBoundUserInterface + # SS220 Nuzzle refactor begin + enum.StorageUiKey.Key: + type: StorageBoundUserInterface + # SS220 Nuzzle refactor end - type: DrawableSolution solution: tank - type: RefillableSolution @@ -76,3 +80,11 @@ solution: tank - type: ExaminableSolution solution: tank + # SS220 Nuzzle refactor begin + - type: Storage + grid: + - 0,0,1,1 + whitelist: + components: + - ClothingSlotSolutionProvider + # SS220 Nuzzle refactor begin diff --git a/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml b/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml index 34cb503f9b5018..66b03f5acc07c1 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml @@ -36,8 +36,6 @@ - type: SolutionItemStatus solution: spray - type: Appearance - - type: SolutionAmmoProvider - solutionId: SpaceCleaner - type: ClothingSlotSolutionProvider solutionRequiredSlot: BACK solutionProviderWhitelist: