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 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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 @@ -82,6 +86,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 @@ -1217,4 +1222,14 @@ public FixedPoint2 ClampReagentAmountByConcentration(
dissolvedReagentAmount += overflow;
return dissolvedReagentAmount;
}

// SS220 Refactor nuzzle begin
private void OnGetSolution(Entity<SolutionProviderComponent> entity, ref TakeSolutionEvent takeSolutionEvent)
{
if (!TryGetSolution(entity, ClothingSlotSolutionProviderComponent.ContainmentSolutionName, out var entsoln, out var solution))
return;

var splitSolution = SplitSolution(entsoln, new FixedPoint2(10f));
}
// 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 @@ -15170,7 +15170,7 @@ entities:
parent: 104
- type: BallisticAmmoProvider
unspawnedCount: 2
- proto: WeaponSprayNozzle
- proto: SprayNozzle
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 @@ -6583,7 +6583,7 @@ entities:
- type: Transform
pos: -1.5,6.5
parent: 1
- proto: WeaponSprayNozzle
- 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 @@ -73,6 +73,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 @@ -81,3 +85,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
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,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 @@ -191,7 +191,7 @@
tier: 2
cost: 10000
recipeUnlocks:
- WeaponSprayNozzle
- SprayNozzle
- ClothingBackpackWaterTank

- type: technology
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down