Misc replay related changes (#17102)

This commit is contained in:
Leon Friedrich
2023-06-05 16:33:49 +12:00
committed by GitHub
parent 7d178555e1
commit a8eee5878a
14 changed files with 132 additions and 75 deletions

View File

@@ -173,7 +173,7 @@ namespace Content.Client.Actions
public void LinkAllActions(ActionsComponent? actions = null)
{
var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || !Resolve(player.Value, ref actions))
if (player == null || !Resolve(player.Value, ref actions, false))
{
return;
}

View File

@@ -16,6 +16,7 @@ using Robust.Shared.Utility;
using System.Linq;
using System.Threading;
using Content.Shared.Eye.Blinding.Components;
using Robust.Client;
using static Content.Shared.Interaction.SharedInteractionSystem;
using static Robust.Client.UserInterface.Controls.BoxContainer;
@@ -28,6 +29,7 @@ namespace Content.Client.Examine
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly VerbSystem _verbSystem = default!;
[Dependency] private readonly IBaseClient _client = default!;
public const string StyleClassEntityTooltip = "entity-tooltip";
@@ -341,10 +343,10 @@ namespace Content.Client.Examine
canSeeClearly = false;
OpenTooltip(playerEnt.Value, entity, centeredOnCursor, false, knowTarget: canSeeClearly);
if (entity.IsClientSide())
if (entity.IsClientSide()
|| _client.RunLevel == ClientRunLevel.SinglePlayerGame) // i.e. a replay
{
message = GetExamineText(entity, playerEnt);
UpdateTooltipInfo(playerEnt.Value, entity, message);
}
else

View File

@@ -21,11 +21,18 @@ namespace Content.Client.GameTicking.Managers
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly BackgroundAudioSystem _backgroundAudio = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[ViewVariables] private bool _initialized;
private Dictionary<EntityUid, Dictionary<string, uint?>> _jobsAvailable = new();
private Dictionary<EntityUid, string> _stationNames = new();
/// <summary>
/// The current round-end window. Could be used to support re-opening the window after closing it.
/// </summary>
private RoundEndSummaryWindow? _window;
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? LobbySong { get; private set; }
@@ -127,13 +134,17 @@ namespace Content.Client.GameTicking.Managers
if (message.LobbySong != null)
{
LobbySong = message.LobbySong;
Get<BackgroundAudioSystem>().StartLobbyMusic();
_backgroundAudio.StartLobbyMusic();
}
RestartSound = message.RestartSound;
// Don't open duplicate windows (mainly for replays).
if (_window?.RoundId == message.RoundId)
return;
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, _entityManager);
_window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, _entityManager);
}
private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
@@ -147,7 +158,7 @@ namespace Content.Client.GameTicking.Managers
return;
}
SoundSystem.Play(RestartSound, Filter.Empty());
_audio.PlayGlobal(RestartSound, Filter.Local(), false);
// Cleanup the sound, we only want it to play when the round restarts after it ends normally.
RestartSound = null;

View File

@@ -13,7 +13,8 @@ using Robust.Shared.Timing;
namespace Content.Client.Gameplay
{
public sealed class GameplayState : GameplayStateBase, IMainViewportState
[Virtual]
public class GameplayState : GameplayStateBase, IMainViewportState
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;

View File

@@ -1,13 +1,10 @@
using Content.Client.Changelog;
using Content.Client.Parallax;
using Robust.Client.AutoGenerated;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Localization;
namespace Content.Client.MainMenu.UI
{

View File

@@ -12,6 +12,7 @@ namespace Content.Client.RoundEnd
public sealed class RoundEndSummaryWindow : DefaultWindow
{
private readonly IEntityManager _entityManager;
public int RoundId;
public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, int roundId,
RoundEndMessageEvent.RoundEndPlayerInfo[] info, IEntityManager entityManager)
@@ -28,6 +29,7 @@ namespace Content.Client.RoundEnd
// "clown slipped the crew x times.", "x shots were fired this round.", etc.
// Also good for serious info.
RoundId = roundId;
var roundEndTabs = new TabContainer();
roundEndTabs.AddChild(MakeRoundEndSummaryTab(gm, roundEnd, roundTimeSpan, roundId));
roundEndTabs.AddChild(MakePlayerManifestoTab(info));

View File

@@ -108,18 +108,6 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
public void OnStateEntered(GameplayState state)
{
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<ActionsWindow>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
_window.OnOpen += OnWindowOpened;
_window.OnClose += OnWindowClosed;
_window.ClearButton.OnPressed += OnClearPressed;
_window.SearchBar.OnTextChanged += OnSearchChanged;
_window.FilterButton.OnItemSelected += OnFilterSelected;
if (_actionsSystem != null)
{
_actionsSystem.ActionAdded += OnActionAdded;
@@ -328,18 +316,6 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
_actionsSystem.ActionsUpdated -= OnActionsUpdated;
}
if (_window != null)
{
_window.OnOpen -= OnWindowOpened;
_window.OnClose -= OnWindowClosed;
_window.ClearButton.OnPressed -= OnClearPressed;
_window.SearchBar.OnTextChanged -= OnSearchChanged;
_window.FilterButton.OnItemSelected -= OnFilterSelected;
_window.Dispose();
_window = null;
}
CommandBinds.Unregister<ActionUIController>();
}
@@ -779,10 +755,32 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
ActionsBar.PageButtons.LeftArrow.OnPressed -= OnLeftArrowPressed;
ActionsBar.PageButtons.RightArrow.OnPressed -= OnRightArrowPressed;
if (_window != null)
{
_window.OnOpen -= OnWindowOpened;
_window.OnClose -= OnWindowClosed;
_window.ClearButton.OnPressed -= OnClearPressed;
_window.SearchBar.OnTextChanged -= OnSearchChanged;
_window.FilterButton.OnItemSelected -= OnFilterSelected;
_window.Dispose();
_window = null;
}
}
private void LoadGui()
{
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<ActionsWindow>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
_window.OnOpen += OnWindowOpened;
_window.OnClose += OnWindowClosed;
_window.ClearButton.OnPressed += OnClearPressed;
_window.SearchBar.OnTextChanged += OnSearchChanged;
_window.FilterButton.OnItemSelected += OnFilterSelected;
if (ActionsBar == null)
{
return;
@@ -791,7 +789,6 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
ActionsBar.PageButtons.LeftArrow.OnPressed += OnLeftArrowPressed;
ActionsBar.PageButtons.RightArrow.OnPressed += OnRightArrowPressed;
RegisterActionContainer(ActionsBar.ActionsContainer);
_actionsSystem?.LinkAllActions();

View File

@@ -247,9 +247,15 @@ namespace Content.Server.Chat.Managers
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
_netManager.ServerSendMessage(new MsgChatMessage() { Message = msg }, client);
if (recordReplay)
if (!recordReplay)
return;
if ((channel & ChatChannel.AdminRelated) == 0 ||
_configurationManager.GetCVar(CCVars.ReplayRecordAdminChat))
{
_replay.QueueReplayMessage(msg);
}
}
public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, IEnumerable<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
=> ChatMessageToMany(channel, message, wrappedMessage, source, hideChat, recordReplay, clients.ToList(), colorOverride, audioPath, audioVolume);
@@ -259,9 +265,15 @@ namespace Content.Server.Chat.Managers
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
_netManager.ServerSendToMany(new MsgChatMessage() { Message = msg }, clients);
if (recordReplay)
if (!recordReplay)
return;
if ((channel & ChatChannel.AdminRelated) == 0 ||
_configurationManager.GetCVar(CCVars.ReplayRecordAdminChat))
{
_replay.QueueReplayMessage(msg);
}
}
public void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string wrappedMessage, EntityUid source,
bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0)
@@ -283,9 +295,15 @@ namespace Content.Server.Chat.Managers
var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume);
_netManager.ServerSendToAll(new MsgChatMessage() { Message = msg });
if (recordReplay)
if (!recordReplay)
return;
if ((channel & ChatChannel.AdminRelated) == 0 ||
_configurationManager.GetCVar(CCVars.ReplayRecordAdminChat))
{
_replay.QueueReplayMessage(msg);
}
}
public bool MessageCharacterLimit(IPlayerSession? player, string message)
{

View File

@@ -28,6 +28,9 @@ using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Replays;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Value;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -65,7 +68,7 @@ namespace Content.Server.GameTicking
DebugTools.Assert(_prototypeManager.Index<JobPrototype>(FallbackOverflowJob).Name == FallbackOverflowJobName,
"Overflow role does not have the correct name!");
InitializeGameRules();
_replay.OnRecordingStarted += OnRecordingStart;
_initialized = true;
}
@@ -85,6 +88,12 @@ namespace Content.Server.GameTicking
base.Shutdown();
ShutdownGameRules();
_replay.OnRecordingStarted -= OnRecordingStart;
}
private void OnRecordingStart((MappingDataNode, List<object>) data)
{
data.Item1["roundId"] = new ValueDataNode(RoundId.ToString());
}
private void SendServerMessage(string message)
@@ -124,5 +133,6 @@ namespace Content.Server.GameTicking
[Dependency] private readonly ServerUpdateManager _serverUpdates = default!;
[Dependency] private readonly PlayTimeTrackingSystem _playTimeTrackings = default!;
[Dependency] private readonly UserDbDataManager _userDb = default!;
[Dependency] private readonly IReplayRecordingManager _replay = default!;
}
}

View File

@@ -25,12 +25,6 @@ namespace Content.Server.Stunnable
if (EntityManager.TryGetComponent<StatusEffectsComponent>(target, out var status))
{
StandingStateComponent? standingState = null;
AppearanceComponent? appearance = null;
// Let the actual methods log errors for these.
Resolve(target, ref standingState, ref appearance, false);
_stunSystem.TryStun(target, TimeSpan.FromSeconds(component.StunAmount), true, status);
_stunSystem.TryKnockdown(target, TimeSpan.FromSeconds(component.KnockdownAmount), true,

View File

@@ -1581,5 +1581,16 @@ namespace Content.Shared.CCVar
/// </summary>
public static readonly CVarDef<int> GCMaximumTimeMs =
CVarDef.Create("entgc.maximum_time_ms", 5, CVar.SERVERONLY);
/*
* Replays
*/
/// <summary>
/// Whether or not to record admin chat. If replays are being publicly distributes, this should probably be
/// false.
/// </summary>
public static readonly CVarDef<bool> ReplayRecordAdminChat =
CVarDef.Create("replay.record_admin_chat", false, CVar.SERVERONLY);
}
}

View File

@@ -83,5 +83,7 @@ namespace Content.Shared.Chat
/// Channels considered to be IC.
/// </summary>
IC = Local | Whisper | Radio | Dead | Emotes | Damage | Visual,
AdminRelated = Admin | AdminAlert | AdminChat,
}
}

View File

@@ -37,6 +37,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
.Register<SharedContentEyeSystem>();
Sawmill.Level = LogLevel.Info;
UpdatesOutsidePrediction = true;
}
private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args)
@@ -112,6 +113,12 @@ public abstract class SharedContentEyeSystem : EntitySystem
Dirty(component);
}
public void SetMaxZoom(EntityUid uid, Vector2 value, ContentEyeComponent? component = null)
{
if (Resolve(uid, ref component))
component.MaxZoom = value;
}
private void Zoom(EntityUid uid, bool zoomIn, ContentEyeComponent? component = null)
{
if (!Resolve(uid, ref component))

View File

@@ -133,35 +133,7 @@ namespace Content.Shared.Movement.Systems
}
}
var angleDiff = Angle.ShortestDistance(mover.RelativeRotation, mover.TargetRelativeRotation);
// if we've just traversed then lerp to our target rotation.
if (!angleDiff.EqualsApprox(Angle.Zero, 0.001))
{
var adjustment = angleDiff * 5f * frameTime;
var minAdjustment = 0.01 * frameTime;
if (angleDiff < 0)
{
adjustment = Math.Min(adjustment, -minAdjustment);
adjustment = Math.Clamp(adjustment, angleDiff, -angleDiff);
}
else
{
adjustment = Math.Max(adjustment, minAdjustment);
adjustment = Math.Clamp(adjustment, -angleDiff, angleDiff);
}
mover.RelativeRotation += adjustment;
mover.RelativeRotation.FlipPositive();
Dirty(mover);
}
else if (!angleDiff.Equals(Angle.Zero))
{
mover.TargetRelativeRotation.FlipPositive();
mover.RelativeRotation = mover.TargetRelativeRotation;
Dirty(mover);
}
LerpRotation(mover, frameTime);
if (!canMove
|| physicsComponent.BodyStatus != BodyStatus.OnGround
@@ -282,6 +254,39 @@ namespace Content.Shared.Movement.Systems
PhysicsSystem.SetAngularVelocity(physicsUid, 0, body: physicsComponent);
}
public void LerpRotation(InputMoverComponent mover, float frameTime)
{
var angleDiff = Angle.ShortestDistance(mover.RelativeRotation, mover.TargetRelativeRotation);
// if we've just traversed then lerp to our target rotation.
if (!angleDiff.EqualsApprox(Angle.Zero, 0.001))
{
var adjustment = angleDiff * 5f * frameTime;
var minAdjustment = 0.01 * frameTime;
if (angleDiff < 0)
{
adjustment = Math.Min(adjustment, -minAdjustment);
adjustment = Math.Clamp(adjustment, angleDiff, -angleDiff);
}
else
{
adjustment = Math.Max(adjustment, minAdjustment);
adjustment = Math.Clamp(adjustment, -angleDiff, angleDiff);
}
mover.RelativeRotation += adjustment;
mover.RelativeRotation.FlipPositive();
Dirty(mover);
}
else if (!angleDiff.Equals(Angle.Zero))
{
mover.TargetRelativeRotation.FlipPositive();
mover.RelativeRotation = mover.TargetRelativeRotation;
Dirty(mover);
}
}
private void Friction(float minimumFrictionSpeed, float frameTime, float friction, ref Vector2 velocity)
{
var speed = velocity.Length;