Skip to content
Open
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
60 changes: 59 additions & 1 deletion Content.Server/Fluids/EntitySystems/SpraySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
using Content.Shared.Fluids.Components;
using Robust.Server.Containers;
using Robust.Shared.Map;
using Content.Shared.Inventory; // Funky atmos - firefighter backpack
using Content.Shared.Whitelist;
using Content.Shared.Hands.EntitySystems; // Funky atmos - firefighter backpack

namespace Content.Server.Fluids.EntitySystems;

Expand All @@ -59,6 +62,10 @@ public sealed class SpraySystem : SharedSpraySystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ContainerSystem _container = default!;
[Dependency] private readonly InventorySystem _inventory = default!; // Funky atmos - firefighter backpack
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; // Funky atmos - firefighter backpack
[Dependency] private readonly SharedHandsSystem _handsSystem = default!; // Funky atmos - firefighter backpack


private float _gridImpulseMultiplier;

Expand Down Expand Up @@ -111,8 +118,22 @@ public override void Spray(Entity<SprayComponent> entity, EntityUid? user = null

public override void Spray(Entity<SprayComponent> entity, MapCoordinates mapcoord, EntityUid? user = null)
{
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out var soln, out var solution))
// Funky atmos - firefighter backpack
var sprayOwner = entity.Owner;
var solutionName = entity.Comp.Solution;

if (entity.Comp.ExternalContainer)
{
TryFindExternalProvider(entity, user, ref sprayOwner, ref solutionName);
}

if (!_solutionContainer.TryGetSolution(sprayOwner, solutionName, out var soln, out var solution))
return;
// Funky atmos - end of changes

// Funky - Uncomment and delete above block to revert
// if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out var soln, out var solution))
// return;

var ev = new SprayAttemptEvent(user);
RaiseLocalEvent(entity, ref ev);
Expand Down Expand Up @@ -232,4 +253,41 @@ public override void Spray(Entity<SprayComponent> entity, MapCoordinates mapcoor

_useDelay.TryResetDelay(entity);
}

private void TryFindExternalProvider(Entity<SprayComponent> entity, EntityUid? user, ref EntityUid sprayOwner, ref string solutionName)
{
if (!entity.Comp.ExternalContainer)
return;

if (user == null)
return;

foreach (var item in _handsSystem.EnumerateHeld(user.Value))
{
if (item == entity.Owner)
continue;

if (!_whitelistSystem.IsWhitelistFailOrNull(entity.Comp.ProviderWhitelist, item) &&
_solutionContainer.TryGetSolution(item, entity.Comp.TankSolutionName, out _, out _))
{
sprayOwner = item;
solutionName = entity.Comp.TankSolutionName;
return;
}
}

if (_inventory.TryGetContainerSlotEnumerator(user.Value, out var enumerator, entity.Comp.TargetSlot))
{
while (enumerator.NextItem(out var item))
{
if (!_whitelistSystem.IsWhitelistFailOrNull(entity.Comp.ProviderWhitelist, item) &&
_solutionContainer.TryGetSolution(item, entity.Comp.TankSolutionName, out _, out _))
{
sprayOwner = item;
solutionName = entity.Comp.TankSolutionName;
return;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Content.Server._Funkystation.Atmos.EntitySystems;

namespace Content.Server._Funkystation.Atmos.Components;

/// <summary>
/// When a TimedDespawnComponent despawns, another one will be spawned in its place.
/// Funky atmos - firefighter backpack
/// </summary>
[RegisterComponent, Access(typeof(AtmosResinDespawnSystem))]
public sealed partial class AtmosResinDespawnComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Content.Server._Funkystation.Atmos.Components;
using Robust.Shared.Spawners;
using Content.Shared.Atmos;
using Content.Server.Atmos.EntitySystems;

namespace Content.Server._Funkystation.Atmos.EntitySystems;


/// <summary>
/// Sets atmospheric temperature to 20C and removes all toxins.
/// Funky atmos - firefighter backpack
/// </summary>
public sealed class AtmosResinDespawnSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmo = default!;
[Dependency] private readonly GasTileOverlaySystem _gasOverlaySystem = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AtmosResinDespawnComponent, TimedDespawnEvent>(OnDespawn);
}

private void OnDespawn(EntityUid uid, AtmosResinDespawnComponent comp, ref TimedDespawnEvent args)
{
if (!TryComp(uid, out TransformComponent? xform))
return;

var mix = _atmo.GetContainingMixture(uid, true);
GasMixture tempMix = new();
if (mix is null) return;

var gasesToRemove = new[]
{
Gas.WaterVapor,
Gas.CarbonDioxide,
Gas.Plasma,
Gas.Tritium,
Gas.Ammonia,
Gas.NitrousOxide,
Gas.Frezon,
Gas.BZ,
Gas.Healium,
Gas.Nitrium,
Gas.Hydrogen,
Gas.HyperNoblium,
Gas.ProtoNitrate,
Gas.Zauker,
Gas.Halon,
Gas.Helium,
Gas.AntiNoblium
};

float totalMolesRemoved = 0f;

foreach (var gas in gasesToRemove)
{
float moles = mix.GetMoles(gas);
if (moles > 0)
{
totalMolesRemoved += moles;
mix.AdjustMoles(gas, -moles);
}
}

if (totalMolesRemoved > 0)
{
tempMix.AdjustMoles(Gas.WaterVapor, totalMolesRemoved);
}

_atmo.Merge(mix, tempMix);
mix.Temperature = Atmospherics.T20C;
_gasOverlaySystem.UpdateSessions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ public sealed partial class SlotBasedConnectedContainerComponent : Component
/// </summary>
[DataField]
public EntityWhitelist? ContainerWhitelist;

/// <summary>
/// If true, also check the user's active hands for a valid provider.
/// Funky atmos - firefighter backpack
/// </summary>
[DataField]
public bool CheckHands = false;
}
21 changes: 21 additions & 0 deletions Content.Shared/Containers/SlotBasedConnectedContainerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics.CodeAnalysis;
using Content.Shared.Chemistry.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Inventory;
using Content.Shared.Whitelist;
using Robust.Shared.Containers;
Expand All @@ -18,6 +19,7 @@ public sealed class SlotBasedConnectedContainerSystem : EntitySystem
[Dependency] private readonly SharedContainerSystem _containers = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!; // Funky atmos - firefighter backpack

/// <inheritdoc />
public override void Initialize()
Expand Down Expand Up @@ -59,6 +61,25 @@ private bool TryGetConnectedContainer(EntityUid uid, SlotFlags slotFlag, EntityW
return false;

var user = container.Owner;

// Funky atmos - firefighter backpack
// Check hands for connected container
if (TryComp<SlotBasedConnectedContainerComponent>(uid, out var comp) && comp.CheckHands)
{
foreach (var held in _hands.EnumerateHeld(user))
{
if (held == uid) // don't pick active hand
continue;

if (!_whitelistSystem.IsWhitelistFailOrNull(providerWhitelist, held))
{
slotEntity = held;
return true;
}
}
}
// Funky atmos - end of changes

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

Expand Down
14 changes: 14 additions & 0 deletions Content.Shared/Fluids/Components/SprayComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
using Content.Shared.Fluids.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Content.Shared.Inventory; // Funky atmos - firefighter backpack
using Content.Shared.Whitelist; // Funky atmos - firefighter backpack

namespace Content.Shared.Fluids.Components;

Expand All @@ -38,6 +40,9 @@ public sealed partial class SprayComponent : Component
[DataField]
public string Solution = "spray";

[DataField]
public string TankSolutionName = "tank"; // Funky atmos - firefighter backpack

[DataField]
public FixedPoint2 TransferAmount = 10;

Expand Down Expand Up @@ -68,4 +73,13 @@ public sealed partial class SprayComponent : Component

[DataField]
public LocId SprayEmptyPopupMessage = "spray-component-is-empty-message";

[ViewVariables(VVAccess.ReadWrite), DataField]
public SlotFlags TargetSlot; // Funky atmos - firefighter backpack

[ViewVariables(VVAccess.ReadWrite), DataField]
public EntityWhitelist? ProviderWhitelist; // Funky atmos - firefighter backpack

[ViewVariables(VVAccess.ReadWrite), DataField]
public bool ExternalContainer = false; // Funky atmos - firefighter backpack
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.Whitelist;

namespace Content.Shared._Funkystation.Atmos.Components;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
public sealed partial class FirefighterTankRefillableComponent : Component
{
[DataField, AutoNetworkedField]
public bool Enabled;

/// <summary>
/// Name of solution/>.
/// </summary>
public const string SolutionName = "tank";

/// <summary>
/// Reagent that will be used in backpack.
/// </summary>
[DataField]
public ProtoId<ReagentPrototype> TankReagent = "Water";

[ViewVariables(VVAccess.ReadWrite), DataField]
public SlotFlags TargetSlot;

[ViewVariables(VVAccess.ReadWrite), DataField]
public EntityWhitelist? ProviderWhitelist;

[ViewVariables(VVAccess.ReadWrite), DataField]
public bool ExternalContainer = false;

/// <summary>
/// Sound played when refilling the backpack.
/// </summary>
[DataField]
public SoundSpecifier FirefightingNozzleRefill = new SoundPathSpecifier("/Audio/Effects/refill.ogg");
}
Loading
Loading