Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nozzle refactor #1206

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -76,6 +80,7 @@ public override void Initialize()
SubscribeLocalEvent<ExaminableSolutionComponent, ExaminedEvent>(OnExamineSolution);
SubscribeLocalEvent<ExaminableSolutionComponent, GetVerbsEvent<ExamineVerb>>(OnSolutionExaminableVerb);
SubscribeLocalEvent<SolutionContainerManagerComponent, MapInitEvent>(OnMapInit);
//SubscribeLocalEvent<ClothingSlotSolutionProviderComponent, TakeSolutionEvent>(OnGetSolution);

if (NetManager.IsServer)
{
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Shared.Inventory;
using Content.Shared.Whitelist;
using Robust.Shared.GameStates;
using Content.Shared.SS220.Spray.System;

namespace Content.Shared.SS220.Spray.Components;

/// <summary>
/// This is used for relaying solition events
/// to an entity in the user's clothing slot.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedSpraySystem))]
public sealed partial class ClothingSlotSolutionProviderComponent : SolutionProviderComponent
{
public const string ContainmentSolutionName = "containmentsolution";
/// <summary>
/// The slot that the ammo provider should be located in.
/// </summary>
[DataField("solutionRequiredSlot", required: true)]
public SlotFlags SolutionRequiredSlot;

/// <summary>
/// A whitelist for determining whether or not an solution provider is valid.
/// </summary>
[DataField("solutionProviderWhitelist")]
public EntityWhitelist? SolutionProviderWhitelist;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Robust.Shared.GameStates;

namespace Content.Shared.SS220.Spray.Components;

[NetworkedComponent]
public abstract partial class SolutionProviderComponent : Component {}
11 changes: 11 additions & 0 deletions Content.Shared/SS220/Spray/Events/GetSolutionCountEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Shared.SS220.Spray.Events;

/// <summary>
/// Raised on an AmmoProvider to request deets.
/// </summary>
[ByRefEvent]
public struct GetSolutionCountEvent
{
public int Count;
public int Capacity;
}
23 changes: 23 additions & 0 deletions Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Robust.Shared.Map;
using Content.Shared.Weapons.Ranged;

namespace Content.Shared.SS220.Spray.Events;

/// <summary>
/// Raised on a gun when it would like to take the specified amount of ammo.
/// </summary>
public sealed class TakeSolutionEvent : EntityEventArgs
{
public readonly EntityUid? User;
public byte SolutionAmount { get; }

/// <summary>
/// If no ammo returned what is the reason for it?
/// </summary>
public string? Reason;

public TakeSolutionEvent(EntityUid? user, byte solutionAmount)
{
}

}
61 changes: 61 additions & 0 deletions Content.Shared/SS220/Spray/Systems/SharedSpraySystem.Clothing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Inventory;
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 sealed partial class SharedSpraySystem : EntitySystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;

public override void Initialize()
{
SubscribeLocalEvent<ClothingSlotSolutionProviderComponent, TakeSolutionEvent>(OnClothingTakeSolution);
SubscribeLocalEvent<ClothingSlotSolutionProviderComponent, GetSolutionCountEvent>(OnClothingSolutionCount);
}

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, ClothingSlotSolutionProviderComponent component, ref GetSolutionCountEvent args)
{
if (!TryGetClothingSlotEntity(uid, component, out var entity))
return;
RaiseLocalEvent(entity.Value, ref args);
}

private bool TryGetClothingSlotEntity(EntityUid uid, ClothingSlotSolutionProviderComponent component, [NotNullWhen(true)] out EntityUid? slotEntity)
{
slotEntity = null;

if (!_container.TryGetContainingContainer(uid, out var container))
return false;
var user = container.Owner;

if (!_inventory.TryGetContainerSlotEnumerator(user, out var enumerator, component.SolutionRequiredSlot))
return false;

while (enumerator.NextItem(out var item))
{
if (component.SolutionProviderWhitelist == null ||
!_whitelistSystem.IsValid(component.SolutionProviderWhitelist, uid))
continue;

slotEntity = item;
return true;
}

return false;
}
}

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ent-WeaponSprayNozzle = форсунка-распылитель
.desc = Мощное разбрызгивающее устройство, используемое в связке с ранцевым резервуаром с водой.
ent-SprayNozzle = пневматический распылитель высокого давления
.desc = Мощное разбрызгивающее устройство, используемое в связке с ранцевым резервуаром с космическим очистителем.
2 changes: 1 addition & 1 deletion Resources/Maps/Nonstations/nukieplanet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15167,7 +15167,7 @@ entities:
parent: 104
- type: BallisticAmmoProvider
unspawnedCount: 2
- proto: WeaponSprayNozzle
- proto: SprayNozzle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здравствуйте, пожалуйста, не трогайте, мне страшно

entities:
- uid: 152
components:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Maps/Shuttles/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6687,7 +6687,7 @@ entities:
- type: Transform
pos: -1.5,6.5
parent: 1
- proto: WeaponSprayNozzle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И это тоже

- proto: SprayNozzle
entities:
- uid: 337
components:
Expand Down
14 changes: 13 additions & 1 deletion Resources/Prototypes/Entities/Clothing/Back/specific.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
enum.ChameleonUiKey.Key:
type: ChameleonBoundUserInterface
# Corvax-HiddenDesc-Start
- type: HiddenDescription
- type: HiddenDescription
entries:
- label: corvax-hidden-desc-Chameleon-syndicate
whitelistMind:
Expand Down Expand Up @@ -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
Expand All @@ -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
43 changes: 43 additions & 0 deletions Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
- 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
- ChemistryEmptyBottle01
- AdvMopItem
- TrashBagAdvanced #SS220 Borg Modules
- WeaponSprayNozzle
- SprayNozzle
- ClothingBackpackWaterTank
- MegaSprayBottle
- TimerTrigger
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/Recipes/Lathes/janitorial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
Wood: 200

- type: latheRecipe
id: WeaponSprayNozzle
result: WeaponSprayNozzle
id: SprayNozzle
result: SprayNozzle
completetime: 5
materials:
Steel: 1500
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Research/civilianservices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
tier: 2
cost: 10000
recipeUnlocks:
- WeaponSprayNozzle
- SprayNozzle
- ClothingBackpackWaterTank

- type: technology
Expand Down
Loading