diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj
index 1ace32f240..2aa95b10b7 100644
--- a/Content.Server/Content.Server.csproj
+++ b/Content.Server/Content.Server.csproj
@@ -66,6 +66,7 @@
+
diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs
index 3024e3ce61..500ca70c25 100644
--- a/Content.Server/EntryPoint.cs
+++ b/Content.Server/EntryPoint.cs
@@ -150,6 +150,8 @@ namespace Content.Server
factory.Register();
+ factory.Register();
+
IoCManager.Register();
IoCManager.Register();
IoCManager.Register();
diff --git a/Content.Server/GameObjects/Components/CatwalkComponent.cs b/Content.Server/GameObjects/Components/CatwalkComponent.cs
new file mode 100644
index 0000000000..ea1a0123f1
--- /dev/null
+++ b/Content.Server/GameObjects/Components/CatwalkComponent.cs
@@ -0,0 +1,12 @@
+using SS14.Shared.GameObjects;
+
+namespace Content.Server.GameObjects.Components
+{
+ ///
+ /// Literally just a marker component for footsteps for now.
+ ///
+ public sealed class CatwalkComponent : Component
+ {
+ public override string Name => "Catwalk";
+ }
+}
diff --git a/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs b/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs
index 968dde62e4..9d89028ef8 100644
--- a/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs
+++ b/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs
@@ -2,6 +2,7 @@
using SS14.Server.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Log;
+using SS14.Shared.Map;
using SS14.Shared.Maths;
using SS14.Shared.Serialization;
using SS14.Shared.ViewVariables;
@@ -45,6 +46,10 @@ namespace Content.Server.GameObjects.Components.Movement
[ViewVariables]
public Vector2 VelocityDir { get; private set; }
+ public GridCoordinates LastPosition { get; set; }
+
+ public float StepSoundDistance { get; set; }
+
///
public override void OnAdd()
{
diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs
index 02557bbdc6..60e5558fe7 100644
--- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs
+++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs
@@ -1,17 +1,25 @@
-using Content.Server.GameObjects.Components.Movement;
+using System;
+using Content.Server.GameObjects.Components;
+using Content.Server.GameObjects.Components.Movement;
using Content.Server.Interfaces.GameObjects.Components.Movement;
+using Content.Shared.Audio;
+using Content.Shared.Maps;
using JetBrains.Annotations;
using SS14.Server.GameObjects;
using SS14.Server.GameObjects.EntitySystems;
using SS14.Server.Interfaces.Player;
using SS14.Server.Interfaces.Timing;
+using SS14.Shared.Audio;
using SS14.Shared.GameObjects;
+using SS14.Shared.GameObjects.Components.Transform;
using SS14.Shared.GameObjects.Systems;
using SS14.Shared.Input;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.IoC;
+using SS14.Shared.Map;
using SS14.Shared.Maths;
using SS14.Shared.Players;
+using SS14.Shared.Prototypes;
namespace Content.Server.GameObjects.EntitySystems
{
@@ -21,8 +29,16 @@ namespace Content.Server.GameObjects.EntitySystems
#pragma warning disable 649
[Dependency]
private IPauseManager _pauseManager;
+ [Dependency]
+ private IPrototypeManager _prototypeManager;
#pragma warning restore 649
+ private AudioSystem _audioSystem;
+ private Random _footstepRandom;
+
+ private const float StepSoundMoveDistanceRunning = 2;
+ private const float StepSoundMoveDistanceWalking = 1.5f;
+
///
public override void Initialize()
{
@@ -56,6 +72,9 @@ namespace Content.Server.GameObjects.EntitySystems
SubscribeEvent(PlayerAttached);
SubscribeEvent(PlayerDetached);
+
+ _footstepRandom = new Random();
+ _audioSystem = EntitySystemManager.GetEntitySystem();
}
private static void PlayerAttached(object sender, PlayerAttachSystemMessage ev)
@@ -103,7 +122,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
- private static void UpdateKinematics(ITransformComponent transform, PlayerInputMoverComponent mover, PhysicsComponent physics)
+ private void UpdateKinematics(ITransformComponent transform, PlayerInputMoverComponent mover, PhysicsComponent physics)
{
if (mover.VelocityDir.LengthSquared < 0.001 || !ActionBlockerSystem.CanMove(mover.Owner))
{
@@ -114,6 +133,25 @@ namespace Content.Server.GameObjects.EntitySystems
{
physics.LinearVelocity = mover.VelocityDir * (mover.Sprinting ? mover.SprintMoveSpeed : mover.WalkMoveSpeed);
transform.LocalRotation = mover.VelocityDir.GetDir().ToAngle();
+
+ // Handle footsteps.
+ var distance = transform.GridPosition.Distance(mover.LastPosition);
+ mover.StepSoundDistance += distance;
+ mover.LastPosition = transform.GridPosition;
+ float distanceNeeded;
+ if (mover.Sprinting)
+ {
+ distanceNeeded = StepSoundMoveDistanceRunning;
+ }
+ else
+ {
+ distanceNeeded = StepSoundMoveDistanceWalking;
+ }
+ if (mover.StepSoundDistance > distanceNeeded)
+ {
+ mover.StepSoundDistance = 0;
+ PlayFootstepSound(transform.GridPosition);
+ }
}
}
@@ -149,5 +187,46 @@ namespace Content.Server.GameObjects.EntitySystems
component = comp;
return true;
}
+
+ private void PlayFootstepSound(GridCoordinates coordinates)
+ {
+ // Step one: figure out sound collection prototype.
+ var grid = coordinates.Grid;
+ var tile = grid.GetTile(coordinates);
+
+ // If the coordinates have a catwalk, it's always catwalk.
+ string soundCollectionName;
+ var catwalk = false;
+ foreach (var maybeCatwalk in grid.GetSnapGridCell(tile.GridTile, SnapGridOffset.Center))
+ {
+ if (maybeCatwalk.Owner.HasComponent())
+ {
+ catwalk = true;
+ break;
+ }
+ }
+
+ if (catwalk)
+ {
+ // Catwalk overrides tile sound.s
+ soundCollectionName = "footstep_catwalk";
+ }
+ else
+ {
+ // Walking on a tile.
+ var def = (ContentTileDefinition)tile.TileDef;
+ if (def.FootstepSounds == null)
+ {
+ // Nothing to play, oh well.
+ return;
+ }
+ soundCollectionName = def.FootstepSounds;
+ }
+
+ // Ok well we know the position of the
+ var soundCollection = _prototypeManager.Index(soundCollectionName);
+ var file = _footstepRandom.Pick(soundCollection.PickFiles);
+ _audioSystem.Play(file, coordinates);
+ }
}
}
diff --git a/Content.Shared/Audio/SoundCollectionPrototype.cs b/Content.Shared/Audio/SoundCollectionPrototype.cs
new file mode 100644
index 0000000000..8a787821ce
--- /dev/null
+++ b/Content.Shared/Audio/SoundCollectionPrototype.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using SS14.Shared.Prototypes;
+using SS14.Shared.Utility;
+using YamlDotNet.RepresentationModel;
+
+namespace Content.Shared.Audio
+{
+ [Prototype("sound_collection")]
+ public sealed class SoundCollectionPrototype : IPrototype, IIndexedPrototype
+ {
+ public string ID { get; private set; }
+ public IReadOnlyList PickFiles { get; private set; }
+
+ public void LoadFrom(YamlMappingNode mapping)
+ {
+ ID = mapping.GetNode("id").AsString();
+
+ var pickFiles = new List();
+
+ foreach (var file in mapping.GetNode("files"))
+ {
+ pickFiles.Add(file.AsString());
+ }
+
+ PickFiles = pickFiles;
+ }
+ }
+}
diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj
index 7160372905..9b6c55ce85 100644
--- a/Content.Shared/Content.Shared.csproj
+++ b/Content.Shared/Content.Shared.csproj
@@ -62,6 +62,7 @@
+
diff --git a/Content.Shared/Maps/ContentTileDefinition.cs b/Content.Shared/Maps/ContentTileDefinition.cs
index 17a42e6a0b..a539da4f4a 100644
--- a/Content.Shared/Maps/ContentTileDefinition.cs
+++ b/Content.Shared/Maps/ContentTileDefinition.cs
@@ -18,6 +18,7 @@ namespace Content.Shared.Maps
public string SpriteName { get; private set; }
public bool IsSubFloor { get; private set; }
public bool CanCrowbar { get; private set; }
+ public string FootstepSounds { get; private set; }
public void AssignTileId(ushort id)
{
@@ -39,6 +40,11 @@ namespace Content.Shared.Maps
{
CanCrowbar = node.AsBool();
}
+
+ if (mapping.TryGetNode("footstep_sounds", out node))
+ {
+ FootstepSounds = node.AsString();
+ }
}
}
}
diff --git a/Resources/Audio/effects/footsteps/catwalk1.ogg b/Resources/Audio/effects/footsteps/catwalk1.ogg
new file mode 100644
index 0000000000..5d6ad7b4a0
Binary files /dev/null and b/Resources/Audio/effects/footsteps/catwalk1.ogg differ
diff --git a/Resources/Audio/effects/footsteps/catwalk2.ogg b/Resources/Audio/effects/footsteps/catwalk2.ogg
new file mode 100644
index 0000000000..07a624dbe4
Binary files /dev/null and b/Resources/Audio/effects/footsteps/catwalk2.ogg differ
diff --git a/Resources/Audio/effects/footsteps/catwalk3.ogg b/Resources/Audio/effects/footsteps/catwalk3.ogg
new file mode 100644
index 0000000000..acff22e386
Binary files /dev/null and b/Resources/Audio/effects/footsteps/catwalk3.ogg differ
diff --git a/Resources/Audio/effects/footsteps/catwalk4.ogg b/Resources/Audio/effects/footsteps/catwalk4.ogg
new file mode 100644
index 0000000000..7235a6b9fe
Binary files /dev/null and b/Resources/Audio/effects/footsteps/catwalk4.ogg differ
diff --git a/Resources/Audio/effects/footsteps/catwalk5.ogg b/Resources/Audio/effects/footsteps/catwalk5.ogg
new file mode 100644
index 0000000000..c33f248acd
Binary files /dev/null and b/Resources/Audio/effects/footsteps/catwalk5.ogg differ
diff --git a/Resources/Audio/effects/footsteps/floor1.ogg b/Resources/Audio/effects/footsteps/floor1.ogg
new file mode 100644
index 0000000000..1e3e155839
Binary files /dev/null and b/Resources/Audio/effects/footsteps/floor1.ogg differ
diff --git a/Resources/Audio/effects/footsteps/floor2.ogg b/Resources/Audio/effects/footsteps/floor2.ogg
new file mode 100644
index 0000000000..cce5a25d82
Binary files /dev/null and b/Resources/Audio/effects/footsteps/floor2.ogg differ
diff --git a/Resources/Audio/effects/footsteps/floor3.ogg b/Resources/Audio/effects/footsteps/floor3.ogg
new file mode 100644
index 0000000000..16ab67f729
Binary files /dev/null and b/Resources/Audio/effects/footsteps/floor3.ogg differ
diff --git a/Resources/Audio/effects/footsteps/floor4.ogg b/Resources/Audio/effects/footsteps/floor4.ogg
new file mode 100644
index 0000000000..9ef15430ff
Binary files /dev/null and b/Resources/Audio/effects/footsteps/floor4.ogg differ
diff --git a/Resources/Audio/effects/footsteps/floor5.ogg b/Resources/Audio/effects/footsteps/floor5.ogg
new file mode 100644
index 0000000000..0f6a66057d
Binary files /dev/null and b/Resources/Audio/effects/footsteps/floor5.ogg differ
diff --git a/Resources/Audio/effects/footsteps/plating1.ogg b/Resources/Audio/effects/footsteps/plating1.ogg
new file mode 100644
index 0000000000..0df770e663
Binary files /dev/null and b/Resources/Audio/effects/footsteps/plating1.ogg differ
diff --git a/Resources/Audio/effects/footsteps/plating2.ogg b/Resources/Audio/effects/footsteps/plating2.ogg
new file mode 100644
index 0000000000..314b9133d2
Binary files /dev/null and b/Resources/Audio/effects/footsteps/plating2.ogg differ
diff --git a/Resources/Audio/effects/footsteps/plating3.ogg b/Resources/Audio/effects/footsteps/plating3.ogg
new file mode 100644
index 0000000000..5c571d77eb
Binary files /dev/null and b/Resources/Audio/effects/footsteps/plating3.ogg differ
diff --git a/Resources/Audio/effects/footsteps/plating4.ogg b/Resources/Audio/effects/footsteps/plating4.ogg
new file mode 100644
index 0000000000..5953262764
Binary files /dev/null and b/Resources/Audio/effects/footsteps/plating4.ogg differ
diff --git a/Resources/Audio/effects/footsteps/plating5.ogg b/Resources/Audio/effects/footsteps/plating5.ogg
new file mode 100644
index 0000000000..4676a637a6
Binary files /dev/null and b/Resources/Audio/effects/footsteps/plating5.ogg differ
diff --git a/Resources/Audio/effects/footsteps/sources.txt b/Resources/Audio/effects/footsteps/sources.txt
new file mode 100644
index 0000000000..ca35309007
--- /dev/null
+++ b/Resources/Audio/effects/footsteps/sources.txt
@@ -0,0 +1 @@
+Sounds in this folder taken from here: https://github.com/discordia-space/CEV-Eris/tree/04f9e57ecf8a1c89ae2cba0f6803b6c5e9887c15/sound/effects/footstep
diff --git a/Resources/Prototypes/Entities/catwalk.yml b/Resources/Prototypes/Entities/catwalk.yml
index de416ed8ce..1763009a78 100644
--- a/Resources/Prototypes/Entities/catwalk.yml
+++ b/Resources/Prototypes/Entities/catwalk.yml
@@ -18,3 +18,5 @@
- type: IconSmooth
key: catwalk
base: catwalk_
+
+ - type: Catwalk
diff --git a/Resources/Prototypes/SoundCollections/footsteps.yml b/Resources/Prototypes/SoundCollections/footsteps.yml
new file mode 100644
index 0000000000..7b8f14121d
--- /dev/null
+++ b/Resources/Prototypes/SoundCollections/footsteps.yml
@@ -0,0 +1,27 @@
+- type: sound_collection
+ id: footstep_catwalk
+ files:
+ - /Audio/effects/footsteps/catwalk1.ogg
+ - /Audio/effects/footsteps/catwalk2.ogg
+ - /Audio/effects/footsteps/catwalk3.ogg
+ - /Audio/effects/footsteps/catwalk4.ogg
+ - /Audio/effects/footsteps/catwalk5.ogg
+
+- type: sound_collection
+ id: footstep_floor
+ files:
+ - /Audio/effects/footsteps/floor1.ogg
+ - /Audio/effects/footsteps/floor2.ogg
+ - /Audio/effects/footsteps/floor3.ogg
+ - /Audio/effects/footsteps/floor4.ogg
+ - /Audio/effects/footsteps/floor5.ogg
+
+- type: sound_collection
+ id: footstep_plating
+ files:
+ - /Audio/effects/footsteps/plating1.ogg
+ - /Audio/effects/footsteps/plating2.ogg
+ - /Audio/effects/footsteps/plating3.ogg
+ - /Audio/effects/footsteps/plating4.ogg
+ - /Audio/effects/footsteps/plating5.ogg
+
diff --git a/Resources/Prototypes/Tiles/floors.yml b/Resources/Prototypes/Tiles/floors.yml
index 3e835548ad..cb875d980b 100644
--- a/Resources/Prototypes/Tiles/floors.yml
+++ b/Resources/Prototypes/Tiles/floors.yml
@@ -4,6 +4,7 @@
texture: "floor_steel"
is_subfloor: false
can_crowbar: true
+ footstep_sounds: footstep_floor
- type: tile
name: floor_white
@@ -11,6 +12,7 @@
texture: "floor_white"
is_subfloor: false
can_crowbar: true
+ footstep_sounds: footstep_floor
- type: tile
name: floor_techmaint
@@ -18,3 +20,4 @@
texture: "floor_techmaint"
is_subfloor: false
can_crowbar: true
+ footstep_sounds: footstep_floor
diff --git a/Resources/Prototypes/Tiles/plating.yml b/Resources/Prototypes/Tiles/plating.yml
index 38256a223d..77b960b118 100644
--- a/Resources/Prototypes/Tiles/plating.yml
+++ b/Resources/Prototypes/Tiles/plating.yml
@@ -3,9 +3,11 @@
display_name: Plating
texture: plating
is_subfloor: true
+ footstep_sounds: footstep_plating
- type: tile
name: underplating
display_name: Underplating
texture: underplating
is_subfloor: true
+ footstep_sounds: footstep_plating