Puddles & spreader refactor (#15191)

This commit is contained in:
metalgearsloth
2023-04-10 15:37:03 +10:00
committed by GitHub
parent 3178ab83f6
commit 317a4013eb
141 changed files with 3046 additions and 3201 deletions

View File

@@ -0,0 +1,17 @@
using Robust.Shared.Audio;
namespace Content.Shared.Movement.Events;
/// <summary>
/// Raised directed on an entity when trying to get a relevant footstep sound
/// </summary>
[ByRefEvent]
public record struct GetFootstepSoundEvent(EntityUid User)
{
public readonly EntityUid User = User;
/// <summary>
/// Set the sound to specify a footstep sound and mark as handled.
/// </summary>
public SoundSpecifier? Sound;
}

View File

@@ -466,10 +466,9 @@ namespace Content.Shared.Movement.Systems
private bool TryGetFootstepSound(TransformComponent xform, bool haveShoes, [NotNullWhen(true)] out SoundSpecifier? sound)
{
sound = null;
MapGridComponent? grid;
// Fallback to the map?
if (xform.GridUid == null)
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
{
if (TryComp<FootstepModifierComponent>(xform.MapUid, out var modifier))
{
@@ -480,8 +479,8 @@ namespace Content.Shared.Movement.Systems
return false;
}
grid = _mapManager.GetGrid(xform.GridUid.Value);
var position = grid.LocalToTile(xform.Coordinates);
var soundEv = new GetFootstepSoundEvent(xform.Owner);
// If the coordinates have a FootstepModifier component
// i.e. component that emit sound on footsteps emit that sound
@@ -489,6 +488,14 @@ namespace Content.Shared.Movement.Systems
while (anchored.MoveNext(out var maybeFootstep))
{
RaiseLocalEvent(maybeFootstep.Value, ref soundEv);
if (soundEv.Sound != null)
{
sound = soundEv.Sound;
return true;
}
if (TryComp<FootstepModifierComponent>(maybeFootstep, out var footstep))
{
sound = footstep.Sound;