Misc audio and related changes for replays (#12578)

This commit is contained in:
Leon Friedrich
2022-11-22 13:49:48 +13:00
committed by GitHub
parent d6be5d2df3
commit 6917b0fe17
30 changed files with 64 additions and 50 deletions

View File

@@ -199,7 +199,7 @@ public sealed class BackgroundAudioSystem : EntitySystem
return;
_playingCollection = _currentCollection;
var file = _robustRandom.Pick(_currentCollection.PickFiles).ToString();
_ambientStream = _audio.PlayGlobal(file, Filter.Local(),
_ambientStream = _audio.PlayGlobal(file, Filter.Local(), false,
_ambientParams.WithVolume(_ambientParams.Volume + _configManager.GetCVar(CCVars.AmbienceVolume)));
}
@@ -304,7 +304,7 @@ public sealed class BackgroundAudioSystem : EntitySystem
return;
}
_lobbyStream = _audio.PlayGlobal(file, Filter.Local(),
_lobbyStream = _audio.PlayGlobal(file, Filter.Local(), false,
_lobbyParams.WithVolume(_lobbyParams.Volume + _configManager.GetCVar(CCVars.LobbyMusicVolume)));
}

View File

@@ -65,7 +65,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
{
if(!_adminAudioEnabled) return;
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_adminAudio.Add(stream);
}
@@ -74,13 +74,13 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
// Either the cvar is disabled or it's already playing
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_eventAudio.Add(soundEvent.Type, stream);
}
private void PlayGameSound(GameGlobalSoundEvent soundEvent)
{
_audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
_audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
}
private void StopStationEventMusic(StopStationEventMusic soundEvent)

View File

@@ -30,6 +30,6 @@ public sealed class DoorSystem : SharedDoorSystem
protected override void PlaySound(EntityUid uid, SoundSpecifier soundSpecifier, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted)
{
if (GameTiming.InPrediction && GameTiming.IsFirstTimePredicted)
Audio.Play(soundSpecifier, Filter.Local(), uid, audioParams);
Audio.Play(soundSpecifier, Filter.Local(), uid, false, audioParams);
}
}

View File

@@ -119,7 +119,7 @@ namespace Content.Client.Voting
@new = true;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>()
.PlayGlobal("/Audio/Effects/voteding.ogg", Filter.Local());
.PlayGlobal("/Audio/Effects/voteding.ogg", Filter.Local(), false);
// New vote from the server.
var vote = new ActiveVote(voteId)

View File

@@ -42,6 +42,6 @@ public sealed class FlyBySoundSystem : SharedFlyBySoundSystem
}
// Play attached to our entity because the projectile may immediately delete or the likes.
_audio.Play(component.Sound, Filter.Local(), attachedEnt.Value);
_audio.Play(component.Sound, Filter.Local(), attachedEnt.Value, false);
}
}

View File

@@ -94,7 +94,7 @@ public sealed partial class QuickDialogSystem : EntitySystem
entries,
did,
buttons),
Filter.SinglePlayer(session)
session
);
_openDialogs.Add(did, (okAction, cancelAction));

View File

@@ -203,7 +203,7 @@ namespace Content.Server.Atmos.EntitySystems
component.ConnectStream?.Stop();
if (component.ConnectSound != null)
component.ConnectStream = _audioSys.Play(component.ConnectSound, Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, component.ConnectSound.Params);
component.ConnectStream = _audioSys.PlayPvs(component.ConnectSound, component.Owner);
UpdateUserInterface(component);
}
@@ -222,7 +222,7 @@ namespace Content.Server.Atmos.EntitySystems
component.DisconnectStream?.Stop();
if (component.DisconnectSound != null)
component.DisconnectStream = _audioSys.Play(component.DisconnectSound, Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, component.DisconnectSound.Params);
component.DisconnectStream = _audioSys.PlayPvs(component.DisconnectSound, component.Owner);
UpdateUserInterface(component);
}
@@ -281,7 +281,7 @@ namespace Content.Server.Atmos.EntitySystems
if(environment != null)
_atmosphereSystem.Merge(environment, component.Air);
_audioSys.Play(component.RuptureSound, Filter.Pvs(component.Owner), Transform(component.Owner).Coordinates, AudioParams.Default.WithVariation(0.125f));
_audioSys.Play(component.RuptureSound, Filter.Pvs(component.Owner), Transform(component.Owner).Coordinates, true, AudioParams.Default.WithVariation(0.125f));
QueueDel(component.Owner);
return;

View File

@@ -28,10 +28,10 @@ public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
_conHost.UnregisterCommand("playglobalsound");
}
private void PlayAdminGlobal(Filter playerFilter, string filename, AudioParams? audioParams = null)
private void PlayAdminGlobal(Filter playerFilter, string filename, AudioParams? audioParams = null, bool replay = true)
{
var msg = new AdminSoundEvent(filename, audioParams);
RaiseNetworkEvent(msg, playerFilter);
RaiseNetworkEvent(msg, playerFilter, recordReplay: replay);
}
private Filter GetStationAndPvs(EntityUid source)
@@ -50,6 +50,10 @@ public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
public void StopStationEventMusic(EntityUid source, StationEventMusicType type)
{
// TODO REPLAYS
// these start & stop events are gonna be a PITA
// theres probably some nice way of handling them. Maybe it just needs dedicated replay data (in which case these events should NOT get recorded).
var msg = new StopStationEventMusic(type);
var filter = GetStationAndPvs(source);
RaiseNetworkEvent(msg, filter);
@@ -74,6 +78,8 @@ public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
Filter filter;
var audio = AudioParams.Default.WithVolume(-8);
bool replay = true;
switch (args.Length)
{
// No arguments, show command help.
@@ -110,6 +116,9 @@ public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
}
else
{
// TODO REPLAYS uhhh.. what to do with this?
replay = false;
filter = Filter.Empty();
// Skip the first argument, which is the sound path.
@@ -130,6 +139,6 @@ public sealed class ServerGlobalSoundSystem : SharedGlobalSoundSystem
break;
}
PlayAdminGlobal(filter, args[0], audio);
PlayAdminGlobal(filter, args[0], audio, replay);
}
}

View File

@@ -142,7 +142,7 @@ public sealed class BodySystem : SharedBodySystem
var filter = Filter.Pvs(bodyId.Value, entityManager: EntityManager);
var audio = AudioParams.Default.WithVariation(0.025f);
_audio.Play(body.GibSound, filter, coordinates, audio);
_audio.Play(body.GibSound, filter, coordinates, true, audio);
if (TryComp(bodyId, out ContainerManagerComponent? container))
{

View File

@@ -239,7 +239,7 @@ public sealed partial class BuckleSystem
if (!CanBuckle(buckleId, user, to, out var strap, buckle))
return false;
_audio.Play(strap.BuckleSound, Filter.Pvs(buckleId), buckleId);
_audio.PlayPvs(strap.BuckleSound, buckleId);
if (!StrapTryAdd(to, buckle, strap: strap))
{
@@ -356,7 +356,7 @@ public sealed partial class BuckleSystem
Dirty(oldBuckledTo);
}
_audio.Play(oldBuckledTo.UnbuckleSound, Filter.Pvs(buckleId), buckleId);
_audio.PlayPvs(oldBuckledTo.UnbuckleSound, buckleId);
var ev = new BuckleChangeEvent { Buckling = false, Strap = oldBuckledTo.Owner, BuckledEntity = buckleId };
RaiseLocalEvent(buckleId, ev);

View File

@@ -9,6 +9,6 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
{
if (!Resolve(euid, ref component, false)) return;
RaiseNetworkEvent(new CameraKickEvent(euid, kickback), Filter.Entities(euid));
RaiseNetworkEvent(new CameraKickEvent(euid, kickback), euid);
}
}

View File

@@ -50,7 +50,7 @@ public sealed class NetProbeCartridgeSystem : EntitySystem
//Play scanning sound with slightly randomized pitch
//Why is there no NextFloat(float min, float max)???
var audioParams = AudioParams.Default.WithVolume(-2f).WithPitchScale((float)_random.Next(12, 21) / 10);
_audioSystem.Play(component.SoundScan, Filter.Pvs(args.InteractEvent.User), target, audioParams);
_audioSystem.PlayEntity(component.SoundScan, args.InteractEvent.User, target, audioParams);
_popupSystem.PopupCursor(Loc.GetString("net-probe-scan", ("device", target)), Filter.Entities(args.InteractEvent.User));

View File

@@ -55,7 +55,6 @@ public sealed class CharacterInfoSystem : EntitySystem
briefing = mind.Briefing;
}
RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing),
Filter.SinglePlayer(args.SenderSession));
RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing), args.SenderSession);
}
}

View File

@@ -279,7 +279,7 @@ namespace Content.Server.Chemistry.EntitySystems
private void ClickSound(ChemMasterComponent chemMaster)
{
_audioSystem.Play(chemMaster.ClickSound, Filter.Pvs(chemMaster.Owner), chemMaster.Owner, AudioParams.Default.WithVolume(-2f));
_audioSystem.PlayPvs(chemMaster.ClickSound, chemMaster.Owner, AudioParams.Default.WithVolume(-2f));
}
private ContainerInfo? BuildInputContainerInfo(EntityUid? container)

View File

@@ -522,7 +522,7 @@ namespace Content.Server.Decals
}
if (updatedDecals.Count != 0 || staleChunks.Count != 0)
RaiseNetworkEvent(new DecalChunkUpdateEvent{Data = updatedDecals, RemovedChunks = staleChunks}, Filter.SinglePlayer(session));
RaiseNetworkEvent(new DecalChunkUpdateEvent{Data = updatedDecals, RemovedChunks = staleChunks}, session);
ReturnToPool(updatedChunks);
ReturnToPool(staleChunks);

View File

@@ -105,16 +105,10 @@ public sealed class DoorSystem : SharedDoorSystem
if (predicted && predictingPlayer == null)
return;
var filter = Filter.Pvs(uid);
if (predicted)
{
// This interaction is predicted, but only by the instigating user, who will have played their own sounds.
filter.RemoveWhereAttachedEntity(e => e == predictingPlayer);
}
// send the sound to players.
Audio.Play(soundSpecifier, filter, uid, audioParams);
Audio.PlayPredicted(soundSpecifier, uid, predictingPlayer, audioParams);
else
Audio.PlayPvs(soundSpecifier, uid, audioParams);
}
#region DoAfters

View File

@@ -147,7 +147,7 @@ namespace Content.Server.Dragon
var location = Transform(comp.Owner).LocalPosition;
_chat.DispatchGlobalAnnouncement(Loc.GetString("carp-rift-warning", ("location", location)), playSound: false, colorOverride: Color.Red);
_audioSystem.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast());
_audioSystem.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true);
}
if (comp.SpawnAccumulator > comp.SpawnCooldown)
@@ -258,7 +258,7 @@ namespace Content.Server.Dragon
var carpUid = Spawn(component.RiftPrototype, xform.MapPosition);
component.Rifts.Add(carpUid);
Comp<DragonRiftComponent>(carpUid).Dragon = uid;
_audioSystem.Play("/Audio/Weapons/Guns/Gunshots/rocket_launcher.ogg", Filter.Pvs(carpUid, entityManager: EntityManager), carpUid);
_audioSystem.PlayPvs("/Audio/Weapons/Guns/Gunshots/rocket_launcher.ogg", carpUid);
}
#endregion
@@ -327,7 +327,7 @@ namespace Content.Server.Dragon
private void Roar(DragonComponent component)
{
if (component.SoundRoar != null)
_audioSystem.Play(component.SoundRoar, Filter.Pvs(component.Owner, 4f, EntityManager), component.Owner, component.SoundRoar.Params);
_audioSystem.Play(component.SoundRoar, Filter.Pvs(component.Owner, 4f, EntityManager), component.Owner, true, component.SoundRoar.Params);
}
private void OnStartup(EntityUid uid, DragonComponent component, ComponentStartup args)

View File

@@ -263,7 +263,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
filter.AddPlayer(actor.PlayerSession);
}
_audioSystem.PlayGlobal(_nukeopsRuleConfig.GreetSound, filter);
_audioSystem.PlayGlobal(_nukeopsRuleConfig.GreetSound, filter, recordReplay: false);
}
private void OnRoundEnd()
@@ -592,7 +592,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
return;
if (_nukeopsRuleConfig.GreetSound != null)
_audioSystem.PlayGlobal(_nukeopsRuleConfig.GreetSound, Filter.Empty().AddPlayer(playerSession));
_audioSystem.PlayGlobal(_nukeopsRuleConfig.GreetSound, playerSession);
if (_targetStation != null && !string.IsNullOrEmpty(Name(_targetStation.Value)))
_chatManager.DispatchServerMessage(playerSession, Loc.GetString("nukeops-welcome", ("station", _targetStation.Value)));

View File

@@ -72,7 +72,7 @@ namespace Content.Server.Kitchen.EntitySystems
SetAppearance(microwaveComponent, MicrowaveVisualState.Cooking);
microwaveComponent.PlayingStream =
_audio.Play(microwaveComponent.LoopingSound, Filter.Pvs(uid), uid, AudioParams.Default.WithLoop(true).WithMaxDistance(5));
_audio.PlayPvs(microwaveComponent.LoopingSound, uid, AudioParams.Default.WithLoop(true).WithMaxDistance(5));
}
private void OnCookStop(EntityUid uid, ActiveMicrowaveComponent component, ComponentShutdown args)

View File

@@ -120,7 +120,7 @@ namespace Content.Server.Medical.BiomassReclaimer
private void OnInit(EntityUid uid, ActiveBiomassReclaimerComponent component, ComponentInit args)
{
_jitteringSystem.AddJitter(uid, -10, 100);
_sharedAudioSystem.Play("/Audio/Machines/reclaimer_startup.ogg", Filter.Pvs(uid), uid);
_sharedAudioSystem.PlayPvs("/Audio/Machines/reclaimer_startup.ogg", uid);
_ambientSoundSystem.SetAmbience(uid, true);
}

View File

@@ -1,3 +1,4 @@
using System;
using System.Linq;
using Content.Server.Ghost.Components;
using Content.Server.Players;
@@ -19,6 +20,7 @@ using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Replays;
using Robust.Shared.Timing;
namespace Content.Server.Pointing.EntitySystems
@@ -26,6 +28,7 @@ namespace Content.Server.Pointing.EntitySystems
[UsedImplicitly]
internal sealed class PointingSystem : SharedPointingSystem
{
[Dependency] private readonly IReplayRecordingManager _replay = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
@@ -72,8 +75,10 @@ namespace Content.Server.Pointing.EntitySystems
? viewerPointedAtMessage
: viewerMessage;
_popup.PopupEntity(message, source, Filter.Entities(viewerEntity));
RaiseNetworkEvent(new PopupEntityEvent(message, PopupType.Small, source), viewerEntity);
}
_replay.QueueReplayMessage(new PopupEntityEvent(viewerMessage, PopupType.Small, source));
}
public bool InRange(EntityUid pointer, EntityCoordinates coordinates)

View File

@@ -8,16 +8,23 @@ namespace Content.Server.Popups
{
public override void PopupCursor(string message, Filter filter, PopupType type=PopupType.Small)
{
// TODO REPLAYS
// add variants that take in a EntityUid or ICommonSession
// then remove any that send Filter.SinglePlayer() or single entity.
// then default to recording replays
// and manually remove any that shouldn't be replayed.
RaiseNetworkEvent(new PopupCursorEvent(message, type), filter);
}
public override void PopupCoordinates(string message, EntityCoordinates coordinates, Filter filter, PopupType type=PopupType.Small)
{
// TODO REPLAYS See above
RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), filter);
}
public override void PopupEntity(string message, EntityUid uid, Filter filter, PopupType type=PopupType.Small)
{
// TODO REPLAYS See above
RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), filter);
}
}

View File

@@ -90,6 +90,6 @@ public sealed class PrayerSystem : SharedPrayerSystem
var networkMessage = new PrayerTextMessage(Loc.GetString("prayer-chat-notify", ("message", message)));
RaiseNetworkEvent(networkMessage, Filter.Empty().AddPlayer(sender));
RaiseNetworkEvent(networkMessage, sender);
}
}

View File

@@ -53,6 +53,6 @@ public sealed partial class ShuttleSystem
var volume = MathF.Min(10f, 1f * MathF.Pow(jungleDiff, 0.5f) - 5f);
var audioParams = AudioParams.Default.WithVariation(0.05f).WithVolume(volume);
_audio.Play(_shuttleImpactSound, Filter.Pvs(coordinates, rangeMultiplier: 4f, entityMan: EntityManager), coordinates, audioParams);
_audio.Play(_shuttleImpactSound, Filter.Pvs(coordinates, rangeMultiplier: 4f, entityMan: EntityManager), coordinates, true, audioParams);
}
}

View File

@@ -100,7 +100,7 @@ public sealed class StationSystem : EntitySystem
{
if (e.NewStatus == SessionStatus.Connected)
{
RaiseNetworkEvent(new StationsUpdatedEvent(_stations), Filter.SinglePlayer(e.Session));
RaiseNetworkEvent(new StationsUpdatedEvent(_stations), e.Session);
}
}

View File

@@ -105,7 +105,7 @@ namespace Content.Server.StationEvents.Events
_announceCancelToken = new CancellationTokenSource();
Timer.Spawn(3000, () =>
{
_audioSystem.PlayGlobal("/Audio/Announcements/power_on.ogg", Filter.Broadcast(), AudioParams.Default.WithVolume(-4f));
_audioSystem.PlayGlobal("/Audio/Announcements/power_on.ogg", Filter.Broadcast(), true, AudioParams.Default.WithVolume(-4f));
}, _announceCancelToken.Token);
_unpowered.Clear();

View File

@@ -163,7 +163,7 @@ public sealed partial class StoreSystem : EntitySystem
}
listing.PurchaseAmount++; //track how many times something has been purchased
_audio.Play(component.BuySuccessSound, Filter.SinglePlayer(msg.Session), uid); //cha-ching!
_audio.PlayEntity(component.BuySuccessSound, msg.Session, uid); //cha-ching!
UpdateUserInterface(buyer, component);
}

View File

@@ -98,7 +98,7 @@ namespace Content.Server.Tiles
{
var variant = _random.Pick(((ContentTileDefinition) _tileDefinitionManager[tileId]).PlacementVariants);
mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId, 0, variant));
_audio.Play(placeSound, Filter.Pvs(location), location, AudioHelpers.WithVariation(0.125f, _random));
_audio.Play(placeSound, Filter.Pvs(location), location, true, AudioHelpers.WithVariation(0.125f, _random));
}
}
}

View File

@@ -183,7 +183,7 @@ namespace Content.Server.VendingMachines
return;
vendComponent.Denying = true;
_audioSystem.Play(vendComponent.SoundDeny, Filter.Pvs(vendComponent.Owner), vendComponent.Owner, AudioParams.Default.WithVolume(-2f));
_audioSystem.PlayPvs(vendComponent.SoundDeny, vendComponent.Owner, AudioParams.Default.WithVolume(-2f));
TryUpdateVisualState(uid, vendComponent);
}
@@ -254,7 +254,7 @@ namespace Content.Server.VendingMachines
entry.Amount--;
UpdateVendingMachineInterfaceState(vendComponent);
TryUpdateVisualState(uid, vendComponent);
_audioSystem.Play(vendComponent.SoundVend, Filter.Pvs(vendComponent.Owner), vendComponent.Owner, AudioParams.Default.WithVolume(-2f));
_audioSystem.PlayPvs(vendComponent.SoundVend, vendComponent.Owner, AudioParams.Default.WithVolume(-2f));
}
/// <summary>

View File

@@ -326,7 +326,7 @@ public abstract class SharedActionsSystem : EntitySystem
var filter = Filter.Pvs(performer).RemoveWhereAttachedEntity(e => e == performer);
_audio.Play(action.Sound, filter, performer, action.AudioParams);
_audio.Play(action.Sound, filter, performer, true, action.AudioParams);
if (string.IsNullOrWhiteSpace(action.Popup))
return true;