Add reagent specific footstep sounds (#24406)

* Add sticky footsteps

* Update Resources/Audio/Effects/Footsteps/attributions.yml

Co-authored-by: ike709 <ike709@users.noreply.github.com>

---------

Co-authored-by: ike709 <ike709@users.noreply.github.com>
This commit is contained in:
themias
2024-01-22 23:18:33 -05:00
committed by GitHub
parent 8921ae7cd0
commit 557e5eb476
12 changed files with 96 additions and 20 deletions

View File

@@ -1,10 +1,18 @@
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.DragDrop;
using Content.Shared.Fluids.Components;
using Content.Shared.Movement.Events;
using Robust.Shared.Prototypes;
namespace Content.Shared.Fluids;
public abstract class SharedPuddleSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
/// <summary>
/// The lowest threshold to be considered for puddle sprite states as well as slipperiness of a puddle.
/// </summary>
@@ -19,6 +27,7 @@ public abstract class SharedPuddleSystem : EntitySystem
SubscribeLocalEvent<DumpableSolutionComponent, CanDropTargetEvent>(OnDumpCanDropTarget);
SubscribeLocalEvent<DrainableSolutionComponent, CanDropTargetEvent>(OnDrainCanDropTarget);
SubscribeLocalEvent<RefillableSolutionComponent, CanDropDraggedEvent>(OnRefillableCanDropDragged);
SubscribeLocalEvent<PuddleComponent, GetFootstepSoundEvent>(OnGetFootstepSound);
}
private void OnRefillableCanDrag(Entity<RefillableSolutionComponent> entity, ref CanDragEvent args)
@@ -52,4 +61,18 @@ public abstract class SharedPuddleSystem : EntitySystem
args.CanDrop = true;
args.Handled = true;
}
private void OnGetFootstepSound(Entity<PuddleComponent> entity, ref GetFootstepSoundEvent args)
{
if (!_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName, ref entity.Comp.Solution,
out var solution))
return;
var reagentId = solution.GetPrimaryReagentId();
if (!string.IsNullOrWhiteSpace(reagentId?.Prototype)
&& _prototypeManager.TryIndex(reagentId.Value.Prototype, out ReagentPrototype? proto))
{
args.Sound = proto.FootstepSound;
}
}
}