Block TickerJoinGameEvent in replays (#17649)
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
using Content.Client.Administration.Managers;
|
using Content.Client.Administration.Managers;
|
||||||
using Content.Client.Launcher;
|
using Content.Client.Launcher;
|
||||||
using Content.Client.MainMenu;
|
using Content.Client.MainMenu;
|
||||||
|
using Content.Client.Replay.Spectator;
|
||||||
using Content.Client.Replay.UI.Loading;
|
using Content.Client.Replay.UI.Loading;
|
||||||
using Content.Client.UserInterface.Systems.Chat;
|
using Content.Client.UserInterface.Systems.Chat;
|
||||||
using Content.Shared.Chat;
|
using Content.Shared.Chat;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
|
using Content.Shared.GameWindow;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Instruments;
|
using Content.Shared.Instruments;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
@@ -16,6 +18,7 @@ using Content.Shared.Weapons.Ranged.Systems;
|
|||||||
using Robust.Client;
|
using Robust.Client;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.Player;
|
||||||
using Robust.Client.Replays.Loading;
|
using Robust.Client.Replays.Loading;
|
||||||
using Robust.Client.Replays.Playback;
|
using Robust.Client.Replays.Playback;
|
||||||
using Robust.Client.State;
|
using Robust.Client.State;
|
||||||
@@ -38,6 +41,7 @@ public sealed class ContentReplayPlaybackManager
|
|||||||
[Dependency] private readonly IReplayPlaybackManager _playback = default!;
|
[Dependency] private readonly IReplayPlaybackManager _playback = default!;
|
||||||
[Dependency] private readonly IClientConGroupController _conGrp = default!;
|
[Dependency] private readonly IClientConGroupController _conGrp = default!;
|
||||||
[Dependency] private readonly IClientAdminManager _adminMan = default!;
|
[Dependency] private readonly IClientAdminManager _adminMan = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _player = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UI state to return to when stopping a replay or loading fails.
|
/// UI state to return to when stopping a replay or loading fails.
|
||||||
@@ -98,36 +102,53 @@ public sealed class ContentReplayPlaybackManager
|
|||||||
|
|
||||||
private bool OnHandleReplayMessage(object message, bool skipEffects)
|
private bool OnHandleReplayMessage(object message, bool skipEffects)
|
||||||
{
|
{
|
||||||
|
// TODO REPLAYS figure out a cleaner way of doing this. This sucks.
|
||||||
|
// Maybe wrap the event in another cancellable event and raise that?
|
||||||
|
|
||||||
|
// This is where replays filter through networked messages and can choose to ignore or give them special treatment.
|
||||||
|
// In particular, we want to avoid spamming pop-ups, sounds, and visual effect entities while fast forwarding.
|
||||||
|
// E.g., when rewinding 1 tick, we really rewind back to the last checkpoint and then fast forward. Currently, this is
|
||||||
|
// effectively an EntityEvent blacklist.
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case BoundUserInterfaceMessage:
|
case BoundUserInterfaceMessage: // TODO REPLAYS refactor BUIs
|
||||||
break; // TODO REPLAYS refactor BUIs
|
case RequestWindowAttentionEvent:
|
||||||
case ChatMessage chat:
|
// Mark as handled -- the event won't get raised.
|
||||||
// Just pass on the chat message to the UI controller, but skip speech-bubbles if we are fast-forwarding.
|
return true;
|
||||||
_uiMan.GetUIController<ChatUIController>().ProcessChatMessage(chat, speechBubble: !skipEffects);
|
case TickerJoinGameEvent:
|
||||||
return true;
|
if (!_entMan.EntityExists(_player.LocalPlayer?.ControlledEntity))
|
||||||
// TODO REPLAYS figure out a cleaner way of doing this. This sucks.
|
_entMan.System<ReplaySpectatorSystem>().SetSpectatorPosition(default);
|
||||||
// Next: we want to avoid spamming animations, sounds, and pop-ups while scrubbing or rewinding time
|
return true;
|
||||||
// (e.g., to rewind 1 tick, we really rewind ~60 and then fast forward 59). Currently, this is
|
}
|
||||||
// effectively an EntityEvent blacklist. But this is kinda shit and should be done differently somehow.
|
|
||||||
// The unifying aspect of these events is that they trigger pop-ups, UI changes, spawn client-side
|
if (!skipEffects)
|
||||||
// entities or start animations.
|
{
|
||||||
case RoundEndMessageEvent:
|
// Don't mark as handled -- the event get raised as a normal networked event.
|
||||||
case PopupEvent:
|
return false;
|
||||||
case AudioMessage:
|
}
|
||||||
case PickupAnimationEvent:
|
|
||||||
case MeleeLungeEvent:
|
switch (message)
|
||||||
case SharedGunSystem.HitscanEvent:
|
{
|
||||||
case ImpactEffectEvent:
|
case ChatMessage chat:
|
||||||
case MuzzleFlashEvent:
|
// Pass the chat message to the UI controller, skip the speech-bubble / pop-up.
|
||||||
case DamageEffectEvent:
|
_uiMan.GetUIController<ChatUIController>().ProcessChatMessage(chat, speechBubble: false);
|
||||||
case InstrumentStartMidiEvent:
|
return true;
|
||||||
case InstrumentMidiEventEvent:
|
case RoundEndMessageEvent:
|
||||||
case InstrumentStopMidiEvent:
|
case PopupEvent:
|
||||||
if (!skipEffects)
|
case AudioMessage:
|
||||||
_entMan.DispatchReceivedNetworkMsg((EntityEventArgs)message);
|
case PickupAnimationEvent:
|
||||||
return true;
|
case MeleeLungeEvent:
|
||||||
}
|
case SharedGunSystem.HitscanEvent:
|
||||||
|
case ImpactEffectEvent:
|
||||||
|
case MuzzleFlashEvent:
|
||||||
|
case DamageEffectEvent:
|
||||||
|
case InstrumentStartMidiEvent:
|
||||||
|
case InstrumentMidiEventEvent:
|
||||||
|
case InstrumentStopMidiEvent:
|
||||||
|
// Block visual effects, pop-ups, and sounds
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user