Skip to content

Commit

Permalink
Add OnGetSolution but in not work
Browse files Browse the repository at this point in the history
  • Loading branch information
Ady4ik committed Jun 20, 2024
1 parent 7f81a61 commit 101d51e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
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
Expand Up @@ -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";
/// <summary>
/// The slot that the ammo provider should be located in.
/// </summary>
[DataField("requiredSlot", required: true)]
[DataField("solutionRequiredSlot", required: true)]
public SlotFlags SolutionRequiredSlot;

/// <summary>
Expand Down
15 changes: 3 additions & 12 deletions Content.Shared/SS220/Spray/Events/TakeSolutionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

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

/// <summary>
/// Coordinates to spawn the ammo at.
/// </summary>
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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClothingSlotSolutionProviderComponent, TakeSolutionEvent>(OnClothingTakeSolution);
SubscribeLocalEvent<ClothingSlotSolutionProviderComponent, GetSolutionCountEvent>(OnClothingSolutionCount);
Expand Down Expand Up @@ -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;
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
2 changes: 0 additions & 2 deletions Resources/Prototypes/Entities/Objects/Tools/spraynozzle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
- type: SolutionItemStatus
solution: spray
- type: Appearance
- type: SolutionAmmoProvider
solutionId: SpaceCleaner
- type: ClothingSlotSolutionProvider
solutionRequiredSlot: BACK
solutionProviderWhitelist:
Expand Down

0 comments on commit 101d51e

Please sign in to comment.