From c8a318e728f66e7fd5f3a904761aabc1ddb49599 Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Thu, 20 Jun 2024 08:31:48 +0300 Subject: [PATCH 1/8] 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 000000000000..b6201780906e --- /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 000000000000..0c3cb5406679 --- /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 000000000000..79016e979bba --- /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 a5ce8719a29b..43fee543420e 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 4d1172198cab..d23936053ecb 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 c44dfe890dfb..53afef308d8f 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 f2e93a607ece..b8eeb42ca5ca 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 4a9dc3eafc67..5c24cae6a203 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 9ba7dfa1889e..e6aa0a353f65 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 74737936cd96..fb94f038a933 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/8] 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 b6201780906e..3adda1c569e8 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 0c3cb5406679..2040a094ad8a 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 000000000000..0082283f95fa --- /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 000000000000..773c2cccf97a --- /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 79016e979bba..9722a9f542df 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/8] 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/8] 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 3adda1c569e8..92b6a358634e 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 773c2cccf97a..3a2a499fb0ed 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 9722a9f542df..7d5b39b0505e 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/8] 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 92b6a358634e..517f9db6cada 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 2040a094ad8a..5662e0cb0adc 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 3a2a499fb0ed..b82752bbd23b 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 7d5b39b0505e..75d416d3557f 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 b8eeb42ca5ca..34cb503f9b50 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/8] 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 5e58a0944a49..02ddb9e27f31 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 517f9db6cada..0bced4cb58b0 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 b82752bbd23b..13476d1a929b 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 75d416d3557f..3748e2577e6b 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 9a116500c021..4498acf0f0c6 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 34cb503f9b50..66b03f5acc07 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: From b684517f25a5e9192ce8e1eb08988bbbf84e16ee Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Sun, 1 Sep 2024 22:42:56 +0300 Subject: [PATCH 7/8] Add more love to Dexler --- .../SharedSolutionContainerSystem.cs | 8 ++-- .../Entities/Objects/Tools/spraynozzle.yml | 43 ------------------- .../Prototypes/SS220/Tools/spraynozzle.yml | 31 +++++++++++++ 3 files changed, 35 insertions(+), 47 deletions(-) delete mode 100644 Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml create mode 100644 Resources/Prototypes/SS220/Tools/spraynozzle.yml diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs index 311df5f5ad5f..513f2e16ffda 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs @@ -86,7 +86,7 @@ public override void Initialize() SubscribeLocalEvent(OnExamineSolution); SubscribeLocalEvent>(OnSolutionExaminableVerb); SubscribeLocalEvent(OnMapInit); - //SubscribeLocalEvent(OnGetSolution); + SubscribeLocalEvent(OnGetSolution); if (NetManager.IsServer) { @@ -1224,12 +1224,12 @@ public FixedPoint2 ClampReagentAmountByConcentration( } // SS220 Refactor nuzzle begin - private void OnGetSolution(EntityUid uid, TakeSolutionEvent takeSolutionEvent) + private void OnGetSolution(Entity entity, ref TakeSolutionEvent takeSolutionEvent) { - if (!TryGetSolution(uid, ClothingSlotSolutionProviderComponent.ContainmentSolutionName, out var soln, out var solution)) + if (!TryGetSolution(entity, ClothingSlotSolutionProviderComponent.ContainmentSolutionName, out var entsoln, out var solution)) return; - SplitSolution(uid, FixedPoint2.Value, FixedPoint2.New(takeSolutionEvent.SolutionAmount)); + var splitSolution = SplitSolution(entsoln, new FixedPoint2(10f)); } // SS220 Refactor nuzzle end } diff --git a/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml b/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml deleted file mode 100644 index 66b03f5acc07..000000000000 --- a/Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml +++ /dev/null @@ -1,43 +0,0 @@ -- type: entity - id: SprayNozzle - parent: BaseItem - name: spray nozzle - description: A high-powered spray nozzle used in conjunction with a backpack-mounted water tank. - components: - - type: Sprite - sprite: Objects/Weapons/Guns/Basic/spraynozzle.rsi - state: icon - - type: Item - sprite: Objects/Weapons/Guns/Basic/spraynozzle.rsi - size: Normal - # 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: ClothingSlotSolutionProvider - solutionRequiredSlot: BACK - solutionProviderWhitelist: - tags: - - NozzleBackTank diff --git a/Resources/Prototypes/SS220/Tools/spraynozzle.yml b/Resources/Prototypes/SS220/Tools/spraynozzle.yml new file mode 100644 index 000000000000..94a5da06f3c5 --- /dev/null +++ b/Resources/Prototypes/SS220/Tools/spraynozzle.yml @@ -0,0 +1,31 @@ +- type: entity + id: SprayNozzle + parent: BaseItem + name: spray nozzle + description: A high-powered spray nozzle used in conjunction with a backpack-mounted water tank. + components: + - type: EmitSoundOnLand + sound: + path: /Audio/SS220/Effects/Drop/pistol.ogg ##new sound_drop effect, add MIXnikita + params: + volume: 2 + - type: Sprite + sprite: Objects/Weapons/Guns/Basic/spraynozzle.rsi + state: icon + - 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 + - type: Appearance + - type: ClothingSlotAmmoProvider + targetSlot: BACK + providerWhitelist: + tags: + - NozzleBackTank From 52083122faad56b66e1a7232a0f07cbcffbeafb5 Mon Sep 17 00:00:00 2001 From: Ady4ik Date: Mon, 14 Oct 2024 22:26:58 +0300 Subject: [PATCH 8/8] Fix mistakes --- .../EntitySystems/SharedSolutionContainerSystem.cs | 9 ++++++--- .../Components/ClothingSlotSolutionProviderComponent.cs | 2 +- .../SS220/Spray/Components/SolutionProviderComponent.cs | 6 ------ Resources/Prototypes/SS220/Tools/spraynozzle.yml | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) delete mode 100644 Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs index 513f2e16ffda..3f7484865772 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs @@ -1224,12 +1224,15 @@ public FixedPoint2 ClampReagentAmountByConcentration( } // SS220 Refactor nuzzle begin - private void OnGetSolution(Entity entity, ref TakeSolutionEvent takeSolutionEvent) + private void OnGetSolution(Entity entity, ref TakeSolutionEvent takeSolutionEvent) { - if (!TryGetSolution(entity, ClothingSlotSolutionProviderComponent.ContainmentSolutionName, out var entsoln, out var solution)) + if (!TryGetSolution(entity.Owner, ClothingSlotSolutionProviderComponent.ContainmentSolutionName, out var entsoln, out var solution)) return; - var splitSolution = SplitSolution(entsoln, new FixedPoint2(10f)); + if(entsoln != null) + { + var splitSolution = SplitSolution(entsoln.Value, 10f); + } } // SS220 Refactor nuzzle end } diff --git a/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs b/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs index 0bced4cb58b0..336a6e045d5a 100644 --- a/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs +++ b/Content.Shared/SS220/Spray/Components/ClothingSlotSolutionProviderComponent.cs @@ -10,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 ClothingSlotSolutionProviderComponent : SolutionProviderComponent +public sealed partial class ClothingSlotSolutionProviderComponent : Component { public const string ContainmentSolutionName = "containmentsolution"; /// diff --git a/Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs b/Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs deleted file mode 100644 index 5662e0cb0adc..000000000000 --- a/Content.Shared/SS220/Spray/Components/SolutionProviderComponent.cs +++ /dev/null @@ -1,6 +0,0 @@ -using Robust.Shared.GameStates; - -namespace Content.Shared.SS220.Spray.Components; - -[NetworkedComponent] -public abstract partial class SolutionProviderComponent : Component {} diff --git a/Resources/Prototypes/SS220/Tools/spraynozzle.yml b/Resources/Prototypes/SS220/Tools/spraynozzle.yml index 94a5da06f3c5..8d4717c6afea 100644 --- a/Resources/Prototypes/SS220/Tools/spraynozzle.yml +++ b/Resources/Prototypes/SS220/Tools/spraynozzle.yml @@ -24,7 +24,7 @@ soundGunshot: path: /Audio/Weapons/Guns/Gunshots/water_spray.ogg - type: Appearance - - type: ClothingSlotAmmoProvider + - type: ClothingSlotSolutionProvider targetSlot: BACK providerWhitelist: tags: