Random spontaneous cleanup PR (#25131)

* Use new Subs.CVar helper

Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe.

This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown.

* Fix a bunch of warnings

* More warning fixes

* Use new DateTime serializer to get rid of ISerializationHooks in changelog code.

* Get rid of some more ISerializationHooks for enums

* And a little more

* Apply suggestions from code review

Co-authored-by: 0x6273 <0x40@keemail.me>

---------

Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
Pieter-Jan Briers
2024-02-13 22:48:39 +01:00
committed by GitHub
parent d0c174388c
commit 68ce53ae17
210 changed files with 481 additions and 930 deletions

View File

@@ -131,8 +131,8 @@ namespace Content.Benchmarks
public static Color InterpolateSysVector4In(in Color endPoint1, in Color endPoint2, public static Color InterpolateSysVector4In(in Color endPoint1, in Color endPoint2,
float lambda) float lambda)
{ {
ref var sva = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(endPoint1)); ref var sva = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(in endPoint1));
ref var svb = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(endPoint2)); ref var svb = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(in endPoint2));
var res = SysVector4.Lerp(svb, sva, lambda); var res = SysVector4.Lerp(svb, sva, lambda);
@@ -156,8 +156,8 @@ namespace Content.Benchmarks
public static Color InterpolateSimdIn(in Color a, in Color b, public static Color InterpolateSimdIn(in Color a, in Color b,
float lambda) float lambda)
{ {
var vecA = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(a)); var vecA = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(in a));
var vecB = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(b)); var vecB = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(in b));
vecB = Fma.MultiplyAdd(Sse.Subtract(vecB, vecA), Vector128.Create(lambda), vecA); vecB = Fma.MultiplyAdd(Sse.Subtract(vecB, vecA), Vector128.Create(lambda), vecA);

View File

@@ -18,11 +18,6 @@ namespace Content.Benchmarks
public static void Main(string[] args) public static void Main(string[] args)
{ {
MainAsync(args).GetAwaiter().GetResult();
}
public static async Task MainAsync(string[] args)
{
#if DEBUG #if DEBUG
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nWARNING: YOU ARE RUNNING A DEBUG BUILD, USE A RELEASE BUILD FOR AN ACCURATE BENCHMARK"); Console.WriteLine("\nWARNING: YOU ARE RUNNING A DEBUG BUILD, USE A RELEASE BUILD FOR AN ACCURATE BENCHMARK");

View File

@@ -101,7 +101,7 @@ namespace Content.Client.Actions
component.ItemIconStyle = state.ItemIconStyle; component.ItemIconStyle = state.ItemIconStyle;
component.Sound = state.Sound; component.Sound = state.Sound;
if (_playerManager.LocalPlayer?.ControlledEntity == component.AttachedEntity) if (_playerManager.LocalEntity == component.AttachedEntity)
ActionsUpdated?.Invoke(); ActionsUpdated?.Invoke();
} }
@@ -111,7 +111,7 @@ namespace Content.Client.Actions
return; return;
base.UpdateAction(actionId, action); base.UpdateAction(actionId, action);
if (_playerManager.LocalPlayer?.ControlledEntity != action.AttachedEntity) if (_playerManager.LocalEntity != action.AttachedEntity)
return; return;
ActionsUpdated?.Invoke(); ActionsUpdated?.Invoke();
@@ -144,7 +144,7 @@ namespace Content.Client.Actions
_added.Add((actionId, action)); _added.Add((actionId, action));
} }
if (_playerManager.LocalPlayer?.ControlledEntity != uid) if (_playerManager.LocalEntity != uid)
return; return;
foreach (var action in _removed) foreach (var action in _removed)
@@ -177,7 +177,7 @@ namespace Content.Client.Actions
protected override void ActionAdded(EntityUid performer, EntityUid actionId, ActionsComponent comp, protected override void ActionAdded(EntityUid performer, EntityUid actionId, ActionsComponent comp,
BaseActionComponent action) BaseActionComponent action)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity != performer) if (_playerManager.LocalEntity != performer)
return; return;
OnActionAdded?.Invoke(actionId); OnActionAdded?.Invoke(actionId);
@@ -185,7 +185,7 @@ namespace Content.Client.Actions
protected override void ActionRemoved(EntityUid performer, EntityUid actionId, ActionsComponent comp, BaseActionComponent action) protected override void ActionRemoved(EntityUid performer, EntityUid actionId, ActionsComponent comp, BaseActionComponent action)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity != performer) if (_playerManager.LocalEntity != performer)
return; return;
OnActionRemoved?.Invoke(actionId); OnActionRemoved?.Invoke(actionId);
@@ -193,7 +193,7 @@ namespace Content.Client.Actions
public IEnumerable<(EntityUid Id, BaseActionComponent Comp)> GetClientActions() public IEnumerable<(EntityUid Id, BaseActionComponent Comp)> GetClientActions()
{ {
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user) if (_playerManager.LocalEntity is not { } user)
return Enumerable.Empty<(EntityUid, BaseActionComponent)>(); return Enumerable.Empty<(EntityUid, BaseActionComponent)>();
return GetActions(user); return GetActions(user);
@@ -216,7 +216,7 @@ namespace Content.Client.Actions
public void LinkAllActions(ActionsComponent? actions = null) public void LinkAllActions(ActionsComponent? actions = null)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user || if (_playerManager.LocalEntity is not { } user ||
!Resolve(user, ref actions, false)) !Resolve(user, ref actions, false))
{ {
return; return;
@@ -233,7 +233,7 @@ namespace Content.Client.Actions
public void TriggerAction(EntityUid actionId, BaseActionComponent action) public void TriggerAction(EntityUid actionId, BaseActionComponent action)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user || if (_playerManager.LocalEntity is not { } user ||
!TryComp(user, out ActionsComponent? actions)) !TryComp(user, out ActionsComponent? actions))
{ {
return; return;
@@ -261,7 +261,7 @@ namespace Content.Client.Actions
/// </summary> /// </summary>
public void LoadActionAssignments(string path, bool userData) public void LoadActionAssignments(string path, bool userData)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user) if (_playerManager.LocalEntity is not { } user)
return; return;
var file = new ResPath(path).ToRootedPath(); var file = new ResPath(path).ToRootedPath();

View File

@@ -15,11 +15,13 @@ namespace Content.Client.Administration.Managers
[Dependency] private readonly IClientNetManager _netMgr = default!; [Dependency] private readonly IClientNetManager _netMgr = default!;
[Dependency] private readonly IClientConGroupController _conGroup = default!; [Dependency] private readonly IClientConGroupController _conGroup = default!;
[Dependency] private readonly IResourceManager _res = default!; [Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly ILogManager _logManager = default!;
private AdminData? _adminData; private AdminData? _adminData;
private readonly HashSet<string> _availableCommands = new(); private readonly HashSet<string> _availableCommands = new();
private readonly AdminCommandPermissions _localCommandPermissions = new(); private readonly AdminCommandPermissions _localCommandPermissions = new();
private ISawmill _sawmill = default!;
public event Action? AdminStatusUpdated; public event Action? AdminStatusUpdated;
@@ -92,17 +94,17 @@ namespace Content.Client.Administration.Managers
} }
_availableCommands.UnionWith(message.AvailableCommands); _availableCommands.UnionWith(message.AvailableCommands);
Logger.DebugS("admin", $"Have {message.AvailableCommands.Length} commands available"); _sawmill.Debug($"Have {message.AvailableCommands.Length} commands available");
_adminData = message.Admin; _adminData = message.Admin;
if (_adminData != null) if (_adminData != null)
{ {
var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags)); var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags));
Logger.InfoS("admin", $"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}"); _sawmill.Info($"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}");
} }
else else
{ {
Logger.InfoS("admin", "Updated admin status: Not admin"); _sawmill.Info("Updated admin status: Not admin");
} }
AdminStatusUpdated?.Invoke(); AdminStatusUpdated?.Invoke();
@@ -114,18 +116,17 @@ namespace Content.Client.Administration.Managers
void IPostInjectInit.PostInject() void IPostInjectInit.PostInject()
{ {
_conGroup.Implementation = this; _conGroup.Implementation = this;
_sawmill = _logManager.GetSawmill("admin");
} }
public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false) public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false)
{ {
return uid == _player.LocalPlayer?.ControlledEntity return uid == _player.LocalEntity ? _adminData : null;
? _adminData
: null;
} }
public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
{ {
if (_player.LocalPlayer?.UserId == session.UserId) if (_player.LocalUser == session.UserId)
return _adminData; return _adminData;
return null; return null;
@@ -133,7 +134,7 @@ namespace Content.Client.Administration.Managers
public AdminData? GetAdminData(bool includeDeAdmin = false) public AdminData? GetAdminData(bool includeDeAdmin = false)
{ {
if (_player.LocalPlayer is { Session: { } session }) if (_player.LocalSession is { } session)
return GetAdminData(session, includeDeAdmin); return GetAdminData(session, includeDeAdmin);
return null; return null;

View File

@@ -99,7 +99,7 @@ public sealed partial class SpawnExplosionWindow : DefaultWindow
{ {
UpdateMapOptions(); UpdateMapOptions();
if (!_entMan.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out TransformComponent? transform)) if (!_entMan.TryGetComponent(_playerManager.LocalEntity, out TransformComponent? transform))
return; return;
_pausePreview = true; _pausePreview = true;

View File

@@ -42,7 +42,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab
var entManager = IoCManager.Resolve<IEntityManager>(); var entManager = IoCManager.Resolve<IEntityManager>();
var xformSystem = entManager.System<SharedTransformSystem>(); var xformSystem = entManager.System<SharedTransformSystem>();
var playerManager = IoCManager.Resolve<IPlayerManager>(); var playerManager = IoCManager.Resolve<IPlayerManager>();
var player = playerManager.LocalPlayer?.ControlledEntity; var player = playerManager.LocalEntity;
var currentMap = MapId.Nullspace; var currentMap = MapId.Nullspace;
var position = Vector2.Zero; var position = Vector2.Zero;

View File

@@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
{ {
_data.Clear(); _data.Clear();
var player = _players.LocalPlayer?.ControlledEntity; var player = _players.LocalEntity;
var playerGrid = _entities.GetComponentOrNull<TransformComponent>(player)?.GridUid; var playerGrid = _entities.GetComponentOrNull<TransformComponent>(player)?.GridUid;
var query = IoCManager.Resolve<IEntityManager>().AllEntityQueryEnumerator<MapGridComponent>(); var query = IoCManager.Resolve<IEntityManager>().AllEntityQueryEnumerator<MapGridComponent>();

View File

@@ -31,7 +31,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
while (gridQuery.MoveNext(out var uid, out _)) while (gridQuery.MoveNext(out var uid, out _))
{ {
_gridData.Add(entManager.GetNetEntity(uid)); _gridData.Add(entManager.GetNetEntity(uid));
var player = playerManager.LocalPlayer?.ControlledEntity; var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid; var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}"); GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
} }

View File

@@ -34,7 +34,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
while (gridQuery.MoveNext(out var uid, out _)) while (gridQuery.MoveNext(out var uid, out _))
{ {
var player = playerManager.LocalPlayer?.ControlledEntity; var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid; var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}"); GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
_gridData.Add(entManager.GetNetEntity(uid)); _gridData.Add(entManager.GetNetEntity(uid));

View File

@@ -30,7 +30,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
while (gridQuery.MoveNext(out var uid, out _)) while (gridQuery.MoveNext(out var uid, out _))
{ {
var player = playerManager.LocalPlayer?.ControlledEntity; var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid; var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}"); GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
_data.Add(entManager.GetNetEntity(uid)); _data.Add(entManager.GetNetEntity(uid));

View File

@@ -40,7 +40,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
{ {
get get
{ {
var ent = _playerManager.LocalPlayer?.ControlledEntity; var ent = _playerManager.LocalEntity;
return ent is not null return ent is not null
? GetActiveAlerts(ent.Value) ? GetActiveAlerts(ent.Value)
: null; : null;
@@ -49,7 +49,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
protected override void AfterShowAlert(Entity<AlertsComponent> alerts) protected override void AfterShowAlert(Entity<AlertsComponent> alerts)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity != alerts.Owner) if (_playerManager.LocalEntity != alerts.Owner)
return; return;
SyncAlerts?.Invoke(this, alerts.Comp.Alerts); SyncAlerts?.Invoke(this, alerts.Comp.Alerts);
@@ -57,7 +57,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
protected override void AfterClearAlert(Entity<AlertsComponent> alertsComponent) protected override void AfterClearAlert(Entity<AlertsComponent> alertsComponent)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity != alertsComponent.Owner) if (_playerManager.LocalEntity != alertsComponent.Owner)
return; return;
SyncAlerts?.Invoke(this, alertsComponent.Comp.Alerts); SyncAlerts?.Invoke(this, alertsComponent.Comp.Alerts);
@@ -65,13 +65,13 @@ public sealed class ClientAlertsSystem : AlertsSystem
private void ClientAlertsHandleState(EntityUid uid, AlertsComponent component, ref AfterAutoHandleStateEvent args) private void ClientAlertsHandleState(EntityUid uid, AlertsComponent component, ref AfterAutoHandleStateEvent args)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity == uid) if (_playerManager.LocalEntity == uid)
SyncAlerts?.Invoke(this, component.Alerts); SyncAlerts?.Invoke(this, component.Alerts);
} }
private void OnPlayerAttached(EntityUid uid, AlertsComponent component, LocalPlayerAttachedEvent args) private void OnPlayerAttached(EntityUid uid, AlertsComponent component, LocalPlayerAttachedEvent args)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity != uid) if (_playerManager.LocalEntity != uid)
return; return;
SyncAlerts?.Invoke(this, component.Alerts); SyncAlerts?.Invoke(this, component.Alerts);
@@ -81,7 +81,7 @@ public sealed class ClientAlertsSystem : AlertsSystem
{ {
base.HandleComponentShutdown(uid, component, args); base.HandleComponentShutdown(uid, component, args);
if (_playerManager.LocalPlayer?.ControlledEntity != uid) if (_playerManager.LocalEntity != uid)
return; return;
ClearAlerts?.Invoke(this, EventArgs.Empty); ClearAlerts?.Invoke(this, EventArgs.Empty);

View File

@@ -65,7 +65,7 @@ public sealed class EntityPickupAnimationSystem : EntitySystem
despawn.Lifetime = 0.25f; despawn.Lifetime = 0.25f;
_transform.SetLocalRotationNoLerp(animatableClone, initialAngle); _transform.SetLocalRotationNoLerp(animatableClone, initialAngle);
_animations.Play(animatableClone, animations, new Animation _animations.Play(new Entity<AnimationPlayerComponent>(animatableClone, animations), new Animation
{ {
Length = TimeSpan.FromMilliseconds(125), Length = TimeSpan.FromMilliseconds(125),
AnimationTracks = AnimationTracks =

View File

@@ -11,7 +11,6 @@ namespace Content.Client.Anomaly.Ui;
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class AnomalyGeneratorWindow : FancyWindow public sealed partial class AnomalyGeneratorWindow : FancyWindow
{ {
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
private TimeSpan _cooldownEnd = TimeSpan.Zero; private TimeSpan _cooldownEnd = TimeSpan.Zero;

View File

@@ -22,7 +22,6 @@ public sealed partial class AirAlarmWindow : FancyWindow
public event Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? AtmosAlarmThresholdChanged; public event Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? AtmosAlarmThresholdChanged;
public event Action<AirAlarmMode>? AirAlarmModeChanged; public event Action<AirAlarmMode>? AirAlarmModeChanged;
public event Action<bool>? AutoModeChanged; public event Action<bool>? AutoModeChanged;
public event Action<string>? ResyncDeviceRequested;
public event Action? ResyncAllRequested; public event Action? ResyncAllRequested;
public event Action<AirAlarmTab>? AirAlarmTabChange; public event Action<AirAlarmTab>? AirAlarmTabChange;

View File

@@ -2,6 +2,6 @@
HorizontalExpand="True" Orientation="Vertical" HorizontalExpand="True" Orientation="Vertical"
Margin = "20 0 0 0" MinSize="160 0" > Margin = "20 0 0 0" MinSize="160 0" >
<Label Name="CBoundLabel" HorizontalAlignment="Center" /> <Label Name="CBoundLabel" HorizontalAlignment="Center" />
<CheckBox Name="CBoundEnabled" HorizontalAlignment="Center" Text="{Loc 'Enable'}"/> <CheckBox Name="CBoundEnabled" HorizontalAlignment="Center" Text="{Loc 'Enable'}" Pressed="True" />
<FloatSpinBox Name="CSpinner" /> <FloatSpinBox Name="CSpinner" />
</BoxContainer> </BoxContainer>

View File

@@ -72,7 +72,6 @@ public sealed partial class ThresholdBoundControl : BoxContainer
CBoundLabel.Text = controlLabel; CBoundLabel.Text = controlLabel;
CSpinner.Value = ScaledValue; CSpinner.Value = ScaledValue;
CBoundEnabled.Pressed = _value != null;
CSpinner.OnValueChanged += SpinnerValueChanged; CSpinner.OnValueChanged += SpinnerValueChanged;
CBoundEnabled.OnToggled += CheckboxToggled; CBoundEnabled.OnToggled += CheckboxToggled;

View File

@@ -99,10 +99,10 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
UpdatesAfter.Add(typeof(AmbientSoundTreeSystem)); UpdatesAfter.Add(typeof(AmbientSoundTreeSystem));
_cfg.OnValueChanged(CCVars.AmbientCooldown, SetCooldown, true); Subs.CVar(_cfg, CCVars.AmbientCooldown, SetCooldown, true);
_cfg.OnValueChanged(CCVars.MaxAmbientSources, SetAmbientCount, true); Subs.CVar(_cfg, CCVars.MaxAmbientSources, SetAmbientCount, true);
_cfg.OnValueChanged(CCVars.AmbientRange, SetAmbientRange, true); Subs.CVar(_cfg, CCVars.AmbientRange, SetAmbientRange, true);
_cfg.OnValueChanged(CCVars.AmbienceVolume, SetAmbienceGain, true); Subs.CVar(_cfg, CCVars.AmbienceVolume, SetAmbienceGain, true);
SubscribeLocalEvent<AmbientSoundComponent, ComponentShutdown>(OnShutdown); SubscribeLocalEvent<AmbientSoundComponent, ComponentShutdown>(OnShutdown);
} }
@@ -138,11 +138,6 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
{ {
base.Shutdown(); base.Shutdown();
ClearSounds(); ClearSounds();
_cfg.UnsubValueChanged(CCVars.AmbientCooldown, SetCooldown);
_cfg.UnsubValueChanged(CCVars.MaxAmbientSources, SetAmbientCount);
_cfg.UnsubValueChanged(CCVars.AmbientRange, SetAmbientRange);
_cfg.UnsubValueChanged(CCVars.AmbienceVolume, SetAmbienceGain);
} }
private int PlayingCount(string countSound) private int PlayingCount(string countSound)

View File

@@ -34,8 +34,8 @@ public sealed class BackgroundAudioSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
_configManager.OnValueChanged(CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged); Subs.CVar(_configManager, CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged);
_configManager.OnValueChanged(CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged); Subs.CVar(_configManager, CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged);
_stateManager.OnStateChanged += StateManagerOnStateChanged; _stateManager.OnStateChanged += StateManagerOnStateChanged;
@@ -50,9 +50,6 @@ public sealed class BackgroundAudioSystem : EntitySystem
{ {
base.Shutdown(); base.Shutdown();
_configManager.UnsubValueChanged(CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged);
_configManager.UnsubValueChanged(CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged);
_stateManager.OnStateChanged -= StateManagerOnStateChanged; _stateManager.OnStateChanged -= StateManagerOnStateChanged;
_client.PlayerLeaveServer -= OnLeave; _client.PlayerLeaveServer -= OnLeave;

View File

@@ -26,11 +26,11 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
base.Initialize(); base.Initialize();
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart); SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
SubscribeNetworkEvent<AdminSoundEvent>(PlayAdminSound); SubscribeNetworkEvent<AdminSoundEvent>(PlayAdminSound);
_cfg.OnValueChanged(CCVars.AdminSoundsEnabled, ToggleAdminSound, true); Subs.CVar(_cfg, CCVars.AdminSoundsEnabled, ToggleAdminSound, true);
SubscribeNetworkEvent<StationEventMusicEvent>(PlayStationEventMusic); SubscribeNetworkEvent<StationEventMusicEvent>(PlayStationEventMusic);
SubscribeNetworkEvent<StopStationEventMusic>(StopStationEventMusic); SubscribeNetworkEvent<StopStationEventMusic>(StopStationEventMusic);
_cfg.OnValueChanged(CCVars.EventMusicEnabled, ToggleStationEventMusic, true); Subs.CVar(_cfg, CCVars.EventMusicEnabled, ToggleStationEventMusic, true);
SubscribeNetworkEvent<GameGlobalSoundEvent>(PlayGameSound); SubscribeNetworkEvent<GameGlobalSoundEvent>(PlayGameSound);
} }

View File

@@ -59,7 +59,7 @@ public sealed partial class ContentAudioSystem
private void InitializeAmbientMusic() private void InitializeAmbientMusic()
{ {
_configManager.OnValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged, true); Subs.CVar(_configManager, CCVars.AmbientMusicVolume, AmbienceCVarChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("audio.ambience"); _sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("audio.ambience");
// Reset audio // Reset audio
@@ -84,7 +84,6 @@ public sealed partial class ContentAudioSystem
private void ShutdownAmbientMusic() private void ShutdownAmbientMusic()
{ {
_configManager.UnsubValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged);
_state.OnStateChanged -= OnStateChange; _state.OnStateChanged -= OnStateChange;
_ambientMusicStream = _audio.Stop(_ambientMusicStream); _ambientMusicStream = _audio.Stop(_ambientMusicStream);
} }
@@ -229,7 +228,7 @@ public sealed partial class ContentAudioSystem
private AmbientMusicPrototype? GetAmbience() private AmbientMusicPrototype? GetAmbience()
{ {
var player = _player.LocalPlayer?.ControlledEntity; var player = _player.LocalEntity;
if (player == null) if (player == null)
return null; return null;

View File

@@ -1,18 +1,11 @@
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Robust.Client.Audio;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using AudioComponent = Robust.Shared.Audio.Components.AudioComponent; using AudioComponent = Robust.Shared.Audio.Components.AudioComponent;
namespace Content.Client.Audio; namespace Content.Client.Audio;
public sealed partial class ContentAudioSystem : SharedContentAudioSystem public sealed partial class ContentAudioSystem : SharedContentAudioSystem
{ {
[Dependency] private readonly IAudioManager _audioManager = default!;
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
// Need how much volume to change per tick and just remove it when it drops below "0" // Need how much volume to change per tick and just remove it when it drops below "0"
private readonly Dictionary<EntityUid, float> _fadingOut = new(); private readonly Dictionary<EntityUid, float> _fadingOut = new();

View File

@@ -9,26 +9,19 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
{ {
[Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IConfigurationManager _configManager = default!;
protected float Intensity; private float _intensity;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeNetworkEvent<CameraKickEvent>(OnCameraKick); SubscribeNetworkEvent<CameraKickEvent>(OnCameraKick);
_configManager.OnValueChanged(CCVars.ScreenShakeIntensity, OnCvarChanged, true); Subs.CVar(_configManager, CCVars.ScreenShakeIntensity, OnCvarChanged, true);
}
public override void Shutdown()
{
base.Shutdown();
_configManager.UnsubValueChanged(CCVars.ScreenShakeIntensity, OnCvarChanged);
} }
private void OnCvarChanged(float value) private void OnCvarChanged(float value)
{ {
Intensity = value; _intensity = value;
} }
private void OnCameraKick(CameraKickEvent ev) private void OnCameraKick(CameraKickEvent ev)
@@ -38,13 +31,13 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null) public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null)
{ {
if (Intensity == 0) if (_intensity == 0)
return; return;
if (!Resolve(uid, ref component, false)) if (!Resolve(uid, ref component, false))
return; return;
recoil *= Intensity; recoil *= _intensity;
// Use really bad math to "dampen" kicks when we're already kicked. // Use really bad math to "dampen" kicks when we're already kicked.
var existing = component.CurrentKick.Length(); var existing = component.CurrentKick.Length();

View File

@@ -10,6 +10,7 @@ namespace Content.Client.CardboardBox;
public sealed class CardboardBoxSystem : SharedCardboardBoxSystem public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{ {
[Dependency] private readonly EntityLookupSystem _entityLookup = default!; [Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -29,7 +30,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
if (!xformQuery.TryGetComponent(source, out var xform)) if (!xformQuery.TryGetComponent(source, out var xform))
return; return;
var sourcePos = xform.MapPosition; var sourcePos = _transform.GetMapCoordinates(source, xform);
//Any mob that can move should be surprised? //Any mob that can move should be surprised?
//God mind rework needs to come faster so it can just check for mind //God mind rework needs to come faster so it can just check for mind
@@ -53,16 +54,17 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
//Play the effect for the mobs as long as they can see the box and are in range. //Play the effect for the mobs as long as they can see the box and are in range.
foreach (var mob in mobMoverEntities) foreach (var mob in mobMoverEntities)
{ {
if (!xformQuery.TryGetComponent(mob, out var moverTransform) || !ExamineSystemShared.InRangeUnOccluded(sourcePos, moverTransform.MapPosition, box.Distance, null)) var mapPos = _transform.GetMapCoordinates(mob);
if (!ExamineSystemShared.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
continue; continue;
var ent = Spawn(box.Effect, moverTransform.MapPosition); var ent = Spawn(box.Effect, mapPos);
if (!xformQuery.TryGetComponent(ent, out var entTransform) || !TryComp<SpriteComponent>(ent, out var sprite)) if (!xformQuery.TryGetComponent(ent, out var entTransform) || !TryComp<SpriteComponent>(ent, out var sprite))
continue; continue;
sprite.Offset = new Vector2(0, 1); sprite.Offset = new Vector2(0, 1);
entTransform.AttachParent(mob); _transform.SetParent(ent, entTransform, mob);
} }
} }

View File

@@ -12,7 +12,6 @@ namespace Content.Client.Cargo.UI;
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class BountyEntry : BoxContainer public sealed partial class BountyEntry : BoxContainer
{ {
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!; [Dependency] private readonly IPrototypeManager _prototype = default!;
public Action? OnButtonPressed; public Action? OnButtonPressed;

View File

@@ -1,10 +1,8 @@
using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.ContentPack; using Robust.Shared.ContentPack;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Markdown; using Robust.Shared.Serialization.Markdown;
using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Mapping;
@@ -162,7 +160,7 @@ namespace Content.Client.Changelog
} }
[DataDefinition] [DataDefinition]
public sealed partial class ChangelogEntry : ISerializationHooks public sealed partial class ChangelogEntry
{ {
[DataField("id")] [DataField("id")]
public int Id { get; private set; } public int Id { get; private set; }
@@ -170,17 +168,11 @@ namespace Content.Client.Changelog
[DataField("author")] [DataField("author")]
public string Author { get; private set; } = ""; public string Author { get; private set; } = "";
[DataField("time")] private string _time = default!; [DataField]
public DateTime Time { get; private set; } public DateTime Time { get; private set; }
[DataField("changes")] [DataField("changes")]
public List<ChangelogChange> Changes { get; private set; } = default!; public List<ChangelogChange> Changes { get; private set; } = default!;
void ISerializationHooks.AfterDeserialization()
{
Time = DateTime.Parse(_time, null, DateTimeStyles.RoundtripKind);
}
} }
[DataDefinition] [DataDefinition]

View File

@@ -20,7 +20,7 @@ public sealed class CharacterInfoSystem : EntitySystem
public void RequestCharacterInfo() public void RequestCharacterInfo()
{ {
var entity = _players.LocalPlayer?.ControlledEntity; var entity = _players.LocalEntity;
if (entity == null) if (entity == null)
{ {
return; return;

View File

@@ -20,7 +20,8 @@ public sealed class TypingIndicatorSystem : SharedTypingIndicatorSystem
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
_cfg.OnValueChanged(CCVars.ChatShowTypingIndicator, OnShowTypingChanged);
Subs.CVar(_cfg, CCVars.ChatShowTypingIndicator, OnShowTypingChanged);
} }
public void ClientChangedChatText() public void ClientChangedChatText()
@@ -67,7 +68,7 @@ public sealed class TypingIndicatorSystem : SharedTypingIndicatorSystem
_isClientTyping = isClientTyping; _isClientTyping = isClientTyping;
// check if player controls any pawn // check if player controls any pawn
if (_playerManager.LocalPlayer?.ControlledEntity == null) if (_playerManager.LocalEntity == null)
return; return;
// send a networked event to server // send a networked event to server

View File

@@ -7,7 +7,7 @@ using Content.Shared.Cloning.CloningConsole;
namespace Content.Client.CloningConsole.UI namespace Content.Client.CloningConsole.UI
{ {
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public partial class CloningConsoleWindow : DefaultWindow public sealed partial class CloningConsoleWindow : DefaultWindow
{ {
public CloningConsoleWindow() public CloningConsoleWindow()
{ {

View File

@@ -28,7 +28,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
SubscribeLocalEvent<CombatModeComponent, AfterAutoHandleStateEvent>(OnHandleState); SubscribeLocalEvent<CombatModeComponent, AfterAutoHandleStateEvent>(OnHandleState);
_cfg.OnValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged, true); Subs.CVar(_cfg, CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged, true);
} }
private void OnHandleState(EntityUid uid, CombatModeComponent component, ref AfterAutoHandleStateEvent args) private void OnHandleState(EntityUid uid, CombatModeComponent component, ref AfterAutoHandleStateEvent args)
@@ -38,7 +38,6 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
public override void Shutdown() public override void Shutdown()
{ {
_cfg.UnsubValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged);
_overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>(); _overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>();
base.Shutdown(); base.Shutdown();
@@ -46,7 +45,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
public bool IsInCombatMode() public bool IsInCombatMode()
{ {
var entity = _playerManager.LocalPlayer?.ControlledEntity; var entity = _playerManager.LocalEntity;
if (entity == null) if (entity == null)
return false; return false;
@@ -67,7 +66,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
private void UpdateHud(EntityUid entity) private void UpdateHud(EntityUid entity)
{ {
if (entity != _playerManager.LocalPlayer?.ControlledEntity || !Timing.IsFirstTimePredicted) if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted)
{ {
return; return;
} }

View File

@@ -38,7 +38,7 @@ public sealed class DebugPathfindingCommand : LocalizedCommands
} }
} }
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{ {
if (args.Length > 1) if (args.Length > 1)
{ {

View File

@@ -185,7 +185,7 @@ namespace Content.Client.Construction
[NotNullWhen(true)] out EntityUid? ghost) [NotNullWhen(true)] out EntityUid? ghost)
{ {
ghost = null; ghost = null;
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user || if (_playerManager.LocalEntity is not { } user ||
!user.IsValid()) !user.IsValid())
{ {
return false; return false;

View File

@@ -148,7 +148,7 @@ namespace Content.Client.ContextMenu.UI
Uid = entity.Value, Uid = entity.Value,
}; };
var session = _playerManager.LocalPlayer?.Session; var session = _playerManager.LocalSession;
if (session != null) if (session != null)
{ {
inputSys.HandleInputCommand(session, func, message); inputSys.HandleInputCommand(session, func, message);
@@ -189,7 +189,7 @@ namespace Content.Client.ContextMenu.UI
if (!_context.RootMenu.Visible) if (!_context.RootMenu.Visible)
return; return;
if (_playerManager.LocalPlayer?.ControlledEntity is not { } player || if (_playerManager.LocalEntity is not { } player ||
!player.IsValid()) !player.IsValid())
return; return;

View File

@@ -28,8 +28,6 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private const string SawmillName = "DamageVisuals";
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -54,14 +52,14 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (damageVisComp.Thresholds.Count < 1) if (damageVisComp.Thresholds.Count < 1)
{ {
Logger.ErrorS(SawmillName, $"ThresholdsLookup were invalid for entity {entity}. ThresholdsLookup: {damageVisComp.Thresholds}"); Log.Error($"ThresholdsLookup were invalid for entity {entity}. ThresholdsLookup: {damageVisComp.Thresholds}");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
if (damageVisComp.Divisor == 0) if (damageVisComp.Divisor == 0)
{ {
Logger.ErrorS(SawmillName, $"Divisor for {entity} is set to zero."); Log.Error($"Divisor for {entity} is set to zero.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -70,21 +68,21 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (damageVisComp.DamageOverlayGroups == null && damageVisComp.DamageOverlay == null) if (damageVisComp.DamageOverlayGroups == null && damageVisComp.DamageOverlay == null)
{ {
Logger.ErrorS(SawmillName, $"Enabled overlay without defined damage overlay sprites on {entity}."); Log.Error($"Enabled overlay without defined damage overlay sprites on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
if (damageVisComp.TrackAllDamage && damageVisComp.DamageOverlay == null) if (damageVisComp.TrackAllDamage && damageVisComp.DamageOverlay == null)
{ {
Logger.ErrorS(SawmillName, $"Enabled all damage tracking without a damage overlay sprite on {entity}."); Log.Error($"Enabled all damage tracking without a damage overlay sprite on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
if (!damageVisComp.TrackAllDamage && damageVisComp.DamageOverlay != null) if (!damageVisComp.TrackAllDamage && damageVisComp.DamageOverlay != null)
{ {
Logger.WarningS(SawmillName, $"Disabled all damage tracking with a damage overlay sprite on {entity}."); Log.Warning($"Disabled all damage tracking with a damage overlay sprite on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -92,7 +90,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
if (damageVisComp.TrackAllDamage && damageVisComp.DamageOverlayGroups != null) if (damageVisComp.TrackAllDamage && damageVisComp.DamageOverlayGroups != null)
{ {
Logger.WarningS(SawmillName, $"Enabled all damage tracking with damage overlay groups on {entity}."); Log.Warning($"Enabled all damage tracking with damage overlay groups on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -101,21 +99,21 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (damageVisComp.TargetLayers == null) if (damageVisComp.TargetLayers == null)
{ {
Logger.ErrorS(SawmillName, $"Disabled overlay without target layers on {entity}."); Log.Error($"Disabled overlay without target layers on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
if (damageVisComp.DamageOverlayGroups != null || damageVisComp.DamageOverlay != null) if (damageVisComp.DamageOverlayGroups != null || damageVisComp.DamageOverlay != null)
{ {
Logger.ErrorS(SawmillName, $"Disabled overlay with defined damage overlay sprites on {entity}."); Log.Error($"Disabled overlay with defined damage overlay sprites on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
if (damageVisComp.DamageGroup == null) if (damageVisComp.DamageGroup == null)
{ {
Logger.ErrorS(SawmillName, $"Disabled overlay without defined damage group on {entity}."); Log.Error($"Disabled overlay without defined damage group on {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -123,12 +121,12 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
if (damageVisComp.DamageOverlayGroups != null && damageVisComp.DamageGroup != null) if (damageVisComp.DamageOverlayGroups != null && damageVisComp.DamageGroup != null)
{ {
Logger.WarningS(SawmillName, $"Damage overlay sprites and damage group are both defined on {entity}."); Log.Warning($"Damage overlay sprites and damage group are both defined on {entity}.");
} }
if (damageVisComp.DamageOverlay != null && damageVisComp.DamageGroup != null) if (damageVisComp.DamageOverlay != null && damageVisComp.DamageGroup != null)
{ {
Logger.WarningS(SawmillName, $"Damage overlay sprites and damage group are both defined on {entity}."); Log.Warning($"Damage overlay sprites and damage group are both defined on {entity}.");
} }
} }
@@ -144,7 +142,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
if (damageVisComp.Thresholds[0] != 0) if (damageVisComp.Thresholds[0] != 0)
{ {
Logger.ErrorS(SawmillName, $"ThresholdsLookup were invalid for entity {entity}. ThresholdsLookup: {damageVisComp.Thresholds}"); Log.Error($"ThresholdsLookup were invalid for entity {entity}. ThresholdsLookup: {damageVisComp.Thresholds}");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -163,7 +161,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (!damageContainer.SupportedGroups.Contains(damageType)) if (!damageContainer.SupportedGroups.Contains(damageType))
{ {
Logger.ErrorS(SawmillName, $"Damage key {damageType} was invalid for entity {entity}."); Log.Error($"Damage key {damageType} was invalid for entity {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -177,7 +175,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (!damageContainer.SupportedGroups.Contains(damageVisComp.DamageGroup)) if (!damageContainer.SupportedGroups.Contains(damageVisComp.DamageGroup))
{ {
Logger.ErrorS(SawmillName, $"Damage keys were invalid for entity {entity}."); Log.Error($"Damage keys were invalid for entity {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -197,7 +195,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (!damagePrototypeIdList.Contains(damageType)) if (!damagePrototypeIdList.Contains(damageType))
{ {
Logger.ErrorS(SawmillName, $"Damage keys were invalid for entity {entity}."); Log.Error($"Damage keys were invalid for entity {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -208,7 +206,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (!damagePrototypeIdList.Contains(damageVisComp.DamageGroup)) if (!damagePrototypeIdList.Contains(damageVisComp.DamageGroup))
{ {
Logger.ErrorS(SawmillName, $"Damage keys were invalid for entity {entity}."); Log.Error($"Damage keys were invalid for entity {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }
@@ -232,7 +230,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{ {
if (!spriteComponent.LayerMapTryGet(key, out var index)) if (!spriteComponent.LayerMapTryGet(key, out var index))
{ {
Logger.WarningS(SawmillName, $"Layer at key {key} was invalid for entity {entity}."); Log.Warning($"Layer at key {key} was invalid for entity {entity}.");
continue; continue;
} }
@@ -244,7 +242,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
// invalidate the visualizer without crashing. // invalidate the visualizer without crashing.
if (damageVisComp.TargetLayerMapKeys.Count == 0) if (damageVisComp.TargetLayerMapKeys.Count == 0)
{ {
Logger.ErrorS(SawmillName, $"Target layers were invalid for entity {entity}."); Log.Error($"Target layers were invalid for entity {entity}.");
damageVisComp.Valid = false; damageVisComp.Valid = false;
return; return;
} }

View File

@@ -38,7 +38,7 @@ public sealed class DoAfterSystem : SharedDoAfterSystem
// ones that depend on the target not moving, because the cancellation of those do afters should be readily // ones that depend on the target not moving, because the cancellation of those do afters should be readily
// predictable by clients. // predictable by clients.
var playerEntity = _player.LocalPlayer?.ControlledEntity; var playerEntity = _player.LocalEntity;
if (!TryComp(playerEntity, out ActiveDoAfterComponent? active)) if (!TryComp(playerEntity, out ActiveDoAfterComponent? active))
return; return;
@@ -69,7 +69,7 @@ public sealed class DoAfterSystem : SharedDoAfterSystem
out float progress) out float progress)
where T : DoAfterEvent where T : DoAfterEvent
{ {
var playerEntity = _player.LocalPlayer?.ControlledEntity; var playerEntity = _player.LocalEntity;
doAfter = null; doAfter = null;
@event = null; @event = null;

View File

@@ -5,7 +5,7 @@ namespace Content.Client.Doors;
public sealed class FirelockSystem : EntitySystem public sealed class FirelockSystem : EntitySystem
{ {
[Dependency] protected readonly SharedAppearanceSystem _appearanceSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
public override void Initialize() public override void Initialize()
{ {

View File

@@ -43,13 +43,13 @@ public sealed class DrugOverlaySystem : EntitySystem
private void OnInit(EntityUid uid, SeeingRainbowsComponent component, ComponentInit args) private void OnInit(EntityUid uid, SeeingRainbowsComponent component, ComponentInit args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnShutdown(EntityUid uid, SeeingRainbowsComponent component, ComponentShutdown args) private void OnShutdown(EntityUid uid, SeeingRainbowsComponent component, ComponentShutdown args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
{ {
_overlay.Intoxication = 0; _overlay.Intoxication = 0;
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);

View File

@@ -34,7 +34,7 @@ public sealed class RainbowOverlay : Overlay
protected override void FrameUpdate(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalEntity;
if (playerEntity == null) if (playerEntity == null)
return; return;
@@ -53,7 +53,7 @@ public sealed class RainbowOverlay : Overlay
protected override bool BeforeDraw(in OverlayDrawArgs args) protected override bool BeforeDraw(in OverlayDrawArgs args)
{ {
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp)) if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp))
return false; return false;
if (args.Viewport.Eye != eyeComp.Eye) if (args.Viewport.Eye != eyeComp.Eye)

View File

@@ -36,7 +36,7 @@ public sealed class DrunkOverlay : Overlay
protected override void FrameUpdate(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalEntity;
if (playerEntity == null) if (playerEntity == null)
return; return;
@@ -58,7 +58,7 @@ public sealed class DrunkOverlay : Overlay
protected override bool BeforeDraw(in OverlayDrawArgs args) protected override bool BeforeDraw(in OverlayDrawArgs args)
{ {
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp)) if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp))
return false; return false;
if (args.Viewport.Eye != eyeComp.Eye) if (args.Viewport.Eye != eyeComp.Eye)

View File

@@ -38,13 +38,13 @@ public sealed class DrunkSystem : SharedDrunkSystem
private void OnDrunkInit(EntityUid uid, DrunkComponent component, ComponentInit args) private void OnDrunkInit(EntityUid uid, DrunkComponent component, ComponentInit args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnDrunkShutdown(EntityUid uid, DrunkComponent component, ComponentShutdown args) private void OnDrunkShutdown(EntityUid uid, DrunkComponent component, ComponentShutdown args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
{ {
_overlay.CurrentBoozePower = 0; _overlay.CurrentBoozePower = 0;
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);

View File

@@ -33,7 +33,6 @@ namespace Content.Client.Examine
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly VerbSystem _verbSystem = default!; [Dependency] private readonly VerbSystem _verbSystem = default!;
[Dependency] private readonly IBaseClient _client = default!;
public const string StyleClassEntityTooltip = "entity-tooltip"; public const string StyleClassEntityTooltip = "entity-tooltip";
@@ -66,12 +65,10 @@ namespace Content.Client.Examine
{ {
if (!args.User.Valid) if (!args.User.Valid)
return; return;
if (_playerManager.LocalPlayer == null)
return;
if (_examineTooltipOpen == null) if (_examineTooltipOpen == null)
return; return;
if (item == _examinedEntity && args.User == _playerManager.LocalPlayer.ControlledEntity) if (item == _examinedEntity && args.User == _playerManager.LocalEntity)
CloseTooltip(); CloseTooltip();
} }
@@ -118,7 +115,7 @@ namespace Content.Client.Examine
return false; return false;
} }
_playerEntity = _playerManager.LocalPlayer?.ControlledEntity ?? default; _playerEntity = _playerManager.LocalEntity ?? default;
if (_playerEntity == default || !CanExamine(_playerEntity, entity)) if (_playerEntity == default || !CanExamine(_playerEntity, entity))
{ {
@@ -149,7 +146,7 @@ namespace Content.Client.Examine
private void OnExamineInfoResponse(ExamineSystemMessages.ExamineInfoResponseMessage ev) private void OnExamineInfoResponse(ExamineSystemMessages.ExamineInfoResponseMessage ev)
{ {
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
if (player == null) if (player == null)
return; return;
@@ -356,7 +353,7 @@ namespace Content.Client.Examine
public void DoExamine(EntityUid entity, bool centeredOnCursor = true, EntityUid? userOverride = null) public void DoExamine(EntityUid entity, bool centeredOnCursor = true, EntityUid? userOverride = null)
{ {
var playerEnt = userOverride ?? _playerManager.LocalPlayer?.ControlledEntity; var playerEnt = userOverride ?? _playerManager.LocalEntity;
if (playerEnt == null) if (playerEnt == null)
return; return;

View File

@@ -14,7 +14,6 @@ namespace Content.Client.Explosion;
public sealed class ExplosionOverlay : Overlay public sealed class ExplosionOverlay : Overlay
{ {
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] private readonly IPrototypeManager _proto = default!;

View File

@@ -43,13 +43,13 @@ public sealed class BlindingSystem : EntitySystem
private void OnBlindInit(EntityUid uid, BlindableComponent component, ComponentInit args) private void OnBlindInit(EntityUid uid, BlindableComponent component, ComponentInit args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnBlindShutdown(EntityUid uid, BlindableComponent component, ComponentShutdown args) private void OnBlindShutdown(EntityUid uid, BlindableComponent component, ComponentShutdown args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
{ {
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);
} }

View File

@@ -36,13 +36,13 @@ public sealed class BlurryVisionSystem : EntitySystem
private void OnBlurryInit(EntityUid uid, BlurryVisionComponent component, ComponentInit args) private void OnBlurryInit(EntityUid uid, BlurryVisionComponent component, ComponentInit args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
_overlayMan.AddOverlay(_overlay); _overlayMan.AddOverlay(_overlay);
} }
private void OnBlurryShutdown(EntityUid uid, BlurryVisionComponent component, ComponentShutdown args) private void OnBlurryShutdown(EntityUid uid, BlurryVisionComponent component, ComponentShutdown args)
{ {
if (_player.LocalPlayer?.ControlledEntity == uid) if (_player.LocalEntity == uid)
{ {
_overlayMan.RemoveOverlay(_overlay); _overlayMan.RemoveOverlay(_overlay);
} }

View File

@@ -41,7 +41,7 @@ public sealed class EyeLerpingSystem : EntitySystem
private void OnEyeStartup(EntityUid uid, EyeComponent component, ComponentStartup args) private void OnEyeStartup(EntityUid uid, EyeComponent component, ComponentStartup args)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity == uid) if (_playerManager.LocalEntity == uid)
AddEye(uid, component, true); AddEye(uid, component, true);
} }
@@ -77,7 +77,7 @@ public sealed class EyeLerpingSystem : EntitySystem
return; return;
// If this is the currently controlled entity, we keep the component. // If this is the currently controlled entity, we keep the component.
if (_playerManager.LocalPlayer?.ControlledEntity == uid) if (_playerManager.LocalEntity == uid)
lerp.ManuallyAdded = false; lerp.ManuallyAdded = false;
else else
RemComp(uid, lerp); RemComp(uid, lerp);

View File

@@ -51,7 +51,7 @@ namespace Content.Client.Flash
protected override void Draw(in OverlayDrawArgs args) protected override void Draw(in OverlayDrawArgs args)
{ {
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp)) if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp))
return; return;
if (args.Viewport.Eye != eyeComp.Eye) if (args.Viewport.Eye != eyeComp.Eye)

View File

@@ -25,7 +25,7 @@ namespace Content.Client.Flash
return; return;
// Yes, this code is awful. I'm just porting it to an entity system so don't blame me. // Yes, this code is awful. I'm just porting it to an entity system so don't blame me.
if (_playerManager.LocalPlayer != null && _playerManager.LocalPlayer.Session.AttachedEntity != uid) if (_playerManager.LocalEntity != uid)
{ {
return; return;
} }

View File

@@ -9,7 +9,6 @@ namespace Content.Client.Fluids;
public sealed class PuddleOverlay : Overlay public sealed class PuddleOverlay : Overlay
{ {
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;

View File

@@ -18,7 +18,7 @@
Text="{Loc 'forensic-scanner-interface-clear'}" /> Text="{Loc 'forensic-scanner-interface-clear'}" />
</BoxContainer> </BoxContainer>
<Label <Label
Name="Name" Name="NameLabel"
Align="Center" /> Align="Center" />
<Label <Label
Name="Diagnostics" Name="Diagnostics"

View File

@@ -29,7 +29,7 @@ namespace Content.Client.Forensics
{ {
Print.Disabled = true; Print.Disabled = true;
Clear.Disabled = true; Clear.Disabled = true;
Name.Text = string.Empty; NameLabel.Text = string.Empty;
Diagnostics.Text = string.Empty; Diagnostics.Text = string.Empty;
return; return;
} }
@@ -37,7 +37,7 @@ namespace Content.Client.Forensics
Print.Disabled = (msg.PrintReadyAt > _gameTiming.CurTime); Print.Disabled = (msg.PrintReadyAt > _gameTiming.CurTime);
Clear.Disabled = false; Clear.Disabled = false;
Name.Text = msg.LastScannedName; NameLabel.Text = msg.LastScannedName;
var text = new StringBuilder(); var text = new StringBuilder();

View File

@@ -38,7 +38,6 @@ namespace Content.Client.GameTicking.Managers
[ViewVariables] public bool DisallowedLateJoin { get; private set; } [ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string? ServerInfoBlob { get; private set; } [ViewVariables] public string? ServerInfoBlob { get; private set; }
[ViewVariables] public TimeSpan StartTime { get; private set; } [ViewVariables] public TimeSpan StartTime { get; private set; }
[ViewVariables] public TimeSpan RoundStartTimeSpan { get; private set; }
[ViewVariables] public new bool Paused { get; private set; } [ViewVariables] public new bool Paused { get; private set; }
[ViewVariables] public IReadOnlyDictionary<NetEntity, Dictionary<string, uint?>> JobsAvailable => _jobsAvailable; [ViewVariables] public IReadOnlyDictionary<NetEntity, Dictionary<string, uint?>> JobsAvailable => _jobsAvailable;

View File

@@ -203,7 +203,7 @@ namespace Content.Client.Gameplay
}; // TODO make entityUid nullable }; // TODO make entityUid nullable
// client side command handlers will always be sent the local player session. // client side command handlers will always be sent the local player session.
var session = _playerManager.LocalPlayer?.Session; var session = _playerManager.LocalSession;
if (inputSys.HandleInputCommand(session, func, message)) if (inputSys.HandleInputCommand(session, func, message))
{ {
kArgs.Handle(); kArgs.Handle();

View File

@@ -15,7 +15,6 @@ namespace Content.Client.Ghost
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!; [Dependency] private readonly ContentEyeSystem _contentEye = default!;
[Dependency] private readonly EyeSystem _eye = default!;
public int AvailableGhostRoleCount { get; private set; } public int AvailableGhostRoleCount { get; private set; }
@@ -41,7 +40,7 @@ namespace Content.Client.Ghost
} }
} }
public GhostComponent? Player => CompOrNull<GhostComponent>(_playerManager.LocalPlayer?.ControlledEntity); public GhostComponent? Player => CompOrNull<GhostComponent>(_playerManager.LocalEntity);
public bool IsGhost => Player != null; public bool IsGhost => Player != null;
public event Action<GhostComponent>? PlayerRemoved; public event Action<GhostComponent>? PlayerRemoved;

View File

@@ -23,7 +23,7 @@ public sealed partial class GravitySystem
private void OnShakeInit(EntityUid uid, GravityShakeComponent component, ComponentInit args) private void OnShakeInit(EntityUid uid, GravityShakeComponent component, ComponentInit args)
{ {
var localPlayer = _playerManager.LocalPlayer?.ControlledEntity; var localPlayer = _playerManager.LocalEntity;
if (!TryComp<TransformComponent>(localPlayer, out var xform) || if (!TryComp<TransformComponent>(localPlayer, out var xform) ||
xform.GridUid != uid && xform.MapUid != uid) xform.GridUid != uid && xform.MapUid != uid)
@@ -44,7 +44,7 @@ public sealed partial class GravitySystem
if (!Resolve(uid, ref gravity) || !Timing.IsFirstTimePredicted) if (!Resolve(uid, ref gravity) || !Timing.IsFirstTimePredicted)
return; return;
var localPlayer = _playerManager.LocalPlayer?.ControlledEntity; var localPlayer = _playerManager.LocalEntity;
if (!TryComp<TransformComponent>(localPlayer, out var xform)) if (!TryComp<TransformComponent>(localPlayer, out var xform))
return; return;

View File

@@ -55,7 +55,7 @@ public sealed class GuidebookSystem : EntitySystem
/// </summary> /// </summary>
public EntityUid GetGuidebookUser() public EntityUid GetGuidebookUser()
{ {
var user = _playerManager.LocalPlayer!.ControlledEntity; var user = _playerManager.LocalEntity;
if (user != null) if (user != null)
return user.Value; return user.Value;

View File

@@ -22,7 +22,6 @@ namespace Content.Client.Hands.Systems
[UsedImplicitly] [UsedImplicitly]
public sealed class HandsSystem : SharedHandsSystem public sealed class HandsSystem : SharedHandsSystem
{ {
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IUserInterfaceManager _ui = default!; [Dependency] private readonly IUserInterfaceManager _ui = default!;
@@ -147,7 +146,7 @@ namespace Content.Client.Hands.Systems
/// </summary> /// </summary>
public bool TryGetPlayerHands([NotNullWhen(true)] out HandsComponent? hands) public bool TryGetPlayerHands([NotNullWhen(true)] out HandsComponent? hands)
{ {
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
hands = null; hands = null;
return player != null && TryComp(player.Value, out hands); return player != null && TryComp(player.Value, out hands);
} }
@@ -248,7 +247,7 @@ namespace Content.Client.Hands.Systems
UpdateHandVisuals(uid, args.Entity, hand); UpdateHandVisuals(uid, args.Entity, hand);
_stripSys.UpdateUi(uid); _stripSys.UpdateUi(uid);
if (uid != _playerManager.LocalPlayer?.ControlledEntity) if (uid != _playerManager.LocalEntity)
return; return;
OnPlayerItemAdded?.Invoke(hand.Name, args.Entity); OnPlayerItemAdded?.Invoke(hand.Name, args.Entity);
@@ -266,7 +265,7 @@ namespace Content.Client.Hands.Systems
UpdateHandVisuals(uid, args.Entity, hand); UpdateHandVisuals(uid, args.Entity, hand);
_stripSys.UpdateUi(uid); _stripSys.UpdateUi(uid);
if (uid != _playerManager.LocalPlayer?.ControlledEntity) if (uid != _playerManager.LocalEntity)
return; return;
OnPlayerItemRemoved?.Invoke(hand.Name, args.Entity); OnPlayerItemRemoved?.Invoke(hand.Name, args.Entity);
@@ -284,7 +283,7 @@ namespace Content.Client.Hands.Systems
return; return;
// visual update might involve changes to the entity's effective sprite -> need to update hands GUI. // visual update might involve changes to the entity's effective sprite -> need to update hands GUI.
if (uid == _playerManager.LocalPlayer?.ControlledEntity) if (uid == _playerManager.LocalEntity)
OnPlayerItemAdded?.Invoke(hand.Name, held); OnPlayerItemAdded?.Invoke(hand.Name, held);
if (!handComp.ShowInHands) if (!handComp.ShowInHands)
@@ -375,13 +374,13 @@ namespace Content.Client.Hands.Systems
private void OnHandsStartup(EntityUid uid, HandsComponent component, ComponentStartup args) private void OnHandsStartup(EntityUid uid, HandsComponent component, ComponentStartup args)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity == uid) if (_playerManager.LocalEntity == uid)
OnPlayerHandsAdded?.Invoke(component); OnPlayerHandsAdded?.Invoke(component);
} }
private void OnHandsShutdown(EntityUid uid, HandsComponent component, ComponentShutdown args) private void OnHandsShutdown(EntityUid uid, HandsComponent component, ComponentShutdown args)
{ {
if (_playerManager.LocalPlayer?.ControlledEntity == uid) if (_playerManager.LocalEntity == uid)
OnPlayerHandsRemoved?.Invoke(); OnPlayerHandsRemoved?.Invoke();
} }
#endregion #endregion
@@ -395,7 +394,7 @@ namespace Content.Client.Hands.Systems
{ {
base.AddHand(uid, handName, handLocation, handsComp); base.AddHand(uid, handName, handLocation, handsComp);
if (uid == _playerManager.LocalPlayer?.ControlledEntity) if (uid == _playerManager.LocalEntity)
OnPlayerAddHand?.Invoke(handName, handLocation); OnPlayerAddHand?.Invoke(handName, handLocation);
if (handsComp == null) if (handsComp == null)
@@ -406,9 +405,9 @@ namespace Content.Client.Hands.Systems
} }
public override void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null) public override void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
{ {
if (uid == _playerManager.LocalPlayer?.ControlledEntity && handsComp != null && if (uid == _playerManager.LocalEntity && handsComp != null &&
handsComp.Hands.ContainsKey(handName) && uid == handsComp.Hands.ContainsKey(handName) && uid ==
_playerManager.LocalPlayer?.ControlledEntity) _playerManager.LocalEntity)
{ {
OnPlayerRemoveHand?.Invoke(handName); OnPlayerRemoveHand?.Invoke(handName);
} }
@@ -421,7 +420,7 @@ namespace Content.Client.Hands.Systems
if (ent is not { } hand) if (ent is not { } hand)
return; return;
if (_playerManager.LocalPlayer?.ControlledEntity != hand.Owner) if (_playerManager.LocalEntity != hand.Owner)
return; return;
if (hand.Comp.ActiveHand == null) if (hand.Comp.ActiveHand == null)

View File

@@ -2,10 +2,13 @@ using Content.Shared.HotPotato;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Client.HotPotato;
public sealed class HotPotatoSystem : SharedHotPotatoSystem public sealed class HotPotatoSystem : SharedHotPotatoSystem
{ {
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
@@ -20,7 +23,7 @@ public sealed class HotPotatoSystem : SharedHotPotatoSystem
if (_timing.CurTime < comp.TargetTime) if (_timing.CurTime < comp.TargetTime)
continue; continue;
comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(comp.EffectCooldown); comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(comp.EffectCooldown);
Spawn("HotPotatoEffect", Transform(uid).MapPosition.Offset(_random.NextVector2(0.25f))); Spawn("HotPotatoEffect", _transform.GetMapCoordinates(uid).Offset(_random.NextVector2(0.25f)));
} }
} }
} }

View File

@@ -29,8 +29,8 @@ public sealed class InstrumentSystem : SharedInstrumentSystem
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
_cfg.OnValueChanged(CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged, true); Subs.CVar(_cfg, CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged, true);
_cfg.OnValueChanged(CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged, true); Subs.CVar(_cfg, CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged, true);
SubscribeNetworkEvent<InstrumentMidiEventEvent>(OnMidiEventRx); SubscribeNetworkEvent<InstrumentMidiEventEvent>(OnMidiEventRx);
SubscribeNetworkEvent<InstrumentStartMidiEvent>(OnMidiStart); SubscribeNetworkEvent<InstrumentStartMidiEvent>(OnMidiStart);
@@ -60,14 +60,6 @@ public sealed class InstrumentSystem : SharedInstrumentSystem
EndRenderer(uid, true, component); EndRenderer(uid, true, component);
} }
public override void Shutdown()
{
base.Shutdown();
_cfg.UnsubValueChanged(CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged);
_cfg.UnsubValueChanged(CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged);
}
private void OnShutdown(EntityUid uid, InstrumentComponent component, ComponentShutdown args) private void OnShutdown(EntityUid uid, InstrumentComponent component, ComponentShutdown args)
{ {
EndRenderer(uid, false, component); EndRenderer(uid, false, component);

View File

@@ -168,14 +168,14 @@ namespace Content.Client.Instruments.UI
if (instrument == null) if (instrument == null)
return false; return false;
var localPlayer = _owner.PlayerManager.LocalPlayer; var localEntity = _owner.PlayerManager.LocalEntity;
// If we don't have a player or controlled entity, we return. // If we don't have a player or controlled entity, we return.
if (localPlayer?.ControlledEntity == null) if (localEntity == null)
return false; return false;
// By default, allow an instrument to play itself and skip all other checks // By default, allow an instrument to play itself and skip all other checks
if (localPlayer.ControlledEntity == instrumentEnt) if (localEntity == instrumentEnt)
return true; return true;
var container = _owner.Entities.System<SharedContainerSystem>(); var container = _owner.Entities.System<SharedContainerSystem>();
@@ -183,14 +183,14 @@ namespace Content.Client.Instruments.UI
container.TryGetContainingContainer(instrumentEnt, out var conMan); container.TryGetContainingContainer(instrumentEnt, out var conMan);
// If the instrument is handheld and we're not holding it, we return. // If the instrument is handheld and we're not holding it, we return.
if ((instrument.Handheld && (conMan == null || conMan.Owner != localPlayer.ControlledEntity))) if ((instrument.Handheld && (conMan == null || conMan.Owner != localEntity)))
return false; return false;
if (!_owner.ActionBlocker.CanInteract(localPlayer.ControlledEntity.Value, instrumentEnt)) if (!_owner.ActionBlocker.CanInteract(localEntity.Value, instrumentEnt))
return false; return false;
// We check that we're in range unobstructed just in case. // We check that we're in range unobstructed just in case.
return _owner.Interactions.InRangeUnobstructed(localPlayer.ControlledEntity.Value, instrumentEnt); return _owner.Interactions.InRangeUnobstructed(localEntity.Value, instrumentEnt);
} }
private void MidiStopButtonOnPressed(ButtonEventArgs? obj) private void MidiStopButtonOnPressed(ButtonEventArgs? obj)

View File

@@ -109,7 +109,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
UpdatesAfter.Add(typeof(SharedEyeSystem)); UpdatesAfter.Add(typeof(SharedEyeSystem));
_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true); Subs.CVar(_cfgMan, CCVars.DragDropDeadZone, SetDeadZone, true);
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance(); _dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance(); _dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
@@ -126,7 +126,6 @@ public sealed class DragDropSystem : SharedDragDropSystem
public override void Shutdown() public override void Shutdown()
{ {
_cfgMan.UnsubValueChanged(CCVars.DragDropDeadZone, SetDeadZone);
CommandBinds.Unregister<DragDropSystem>(); CommandBinds.Unregister<DragDropSystem>();
base.Shutdown(); base.Shutdown();
} }
@@ -269,7 +268,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
return false; return false;
} }
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
// still in range of the thing we are dragging? // still in range of the thing we are dragging?
if (player == null || !_interactionSystem.InRangeUnobstructed(player.Value, _draggedEntity.Value)) if (player == null || !_interactionSystem.InRangeUnobstructed(player.Value, _draggedEntity.Value))
@@ -346,7 +345,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
return false; return false;
} }
var localPlayer = _playerManager.LocalPlayer?.ControlledEntity; var localPlayer = _playerManager.LocalEntity;
if (localPlayer == null || !Exists(_draggedEntity)) if (localPlayer == null || !Exists(_draggedEntity))
{ {
@@ -410,7 +409,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
return; return;
} }
var user = _playerManager.LocalPlayer?.ControlledEntity; var user = _playerManager.LocalEntity;
if (user == null) if (user == null)
return; return;

View File

@@ -30,10 +30,9 @@ namespace Content.Client.Inventory
[UsedImplicitly] [UsedImplicitly]
public sealed class StrippableBoundUserInterface : BoundUserInterface public sealed class StrippableBoundUserInterface : BoundUserInterface
{ {
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly IUserInterfaceManager _ui = default!; [Dependency] private readonly IUserInterfaceManager _ui = default!;
private readonly ExamineSystem _examine = default!; private readonly ExamineSystem _examine;
private readonly InventorySystem _inv = default!; private readonly InventorySystem _inv;
private readonly SharedCuffableSystem _cuffable; private readonly SharedCuffableSystem _cuffable;
[ViewVariables] [ViewVariables]

View File

@@ -23,7 +23,6 @@ namespace Content.Client.LateJoin
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystem = default!; [Dependency] private readonly IEntitySystemManager _entitySystem = default!;
[Dependency] private readonly JobRequirementsManager _jobRequirements = default!; [Dependency] private readonly JobRequirementsManager _jobRequirements = default!;

View File

@@ -6,7 +6,7 @@
<PanelContainer.PanelOverride> <PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#4c6530"/> <gfx:StyleBoxFlat BackgroundColor="#4c6530"/>
</PanelContainer.PanelOverride> </PanelContainer.PanelOverride>
<Label Name="Name" Margin="6 6 6 6" HorizontalAlignment="Center"/> <Label Name="NameLabel" Margin="6 6 6 6" HorizontalAlignment="Center"/>
</PanelContainer> </PanelContainer>
</BoxContainer> </BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True"> <BoxContainer Orientation="Horizontal" HorizontalExpand="True">

View File

@@ -13,13 +13,13 @@ namespace Content.Client.MassMedia.Ui;
public sealed partial class MiniArticleCardControl : Control public sealed partial class MiniArticleCardControl : Control
{ {
public Action? OnDeletePressed; public Action? OnDeletePressed;
public int ArtcileNum; public int ArticleNum;
public MiniArticleCardControl(string name, string author) public MiniArticleCardControl(string name, string author)
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
Name.Text = name; NameLabel.Text = name;
Author.SetMarkup(author); Author.SetMarkup(author);
Delete.OnPressed += _ => OnDeletePressed?.Invoke(); Delete.OnPressed += _ => OnDeletePressed?.Invoke();

View File

@@ -31,8 +31,8 @@ public sealed partial class NewsWriteMenu : DefaultWindow
{ {
var article = articles[i]; var article = articles[i];
var mini = new MiniArticleCardControl(article.Name, (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author"))); var mini = new MiniArticleCardControl(article.Name, (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
mini.ArtcileNum = i; mini.ArticleNum = i;
mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArtcileNum); mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArticleNum);
ArticleCardsContainer.AddChild(mini); ArticleCardsContainer.AddChild(mini);
} }

View File

@@ -23,7 +23,7 @@ public sealed class MouseRotatorSystem : SharedMouseRotatorSystem
if (!_timing.IsFirstTimePredicted || !_input.MouseScreenPosition.IsValid) if (!_timing.IsFirstTimePredicted || !_input.MouseScreenPosition.IsValid)
return; return;
var player = _player.LocalPlayer?.ControlledEntity; var player = _player.LocalEntity;
if (player == null || !TryComp<MouseRotatorComponent>(player, out var rotator)) if (player == null || !TryComp<MouseRotatorComponent>(player, out var rotator))
return; return;

View File

@@ -23,7 +23,7 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem
public void RequestToggleFov() public void RequestToggleFov()
{ {
if (_player.LocalPlayer?.ControlledEntity is { } player) if (_player.LocalEntity is { } player)
RequestToggleFov(player); RequestToggleFov(player);
} }

View File

@@ -52,8 +52,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
/// </summary> /// </summary>
public void ToggleVisualization(EntityUid uid, bool toggle, NetworkConfiguratorComponent? component = null) public void ToggleVisualization(EntityUid uid, bool toggle, NetworkConfiguratorComponent? component = null)
{ {
if (_playerManager.LocalPlayer == null if (_playerManager.LocalEntity == null
|| _playerManager.LocalPlayer.ControlledEntity == null
|| !Resolve(uid, ref component) || !Resolve(uid, ref component)
|| component.ActiveDeviceList == null) || component.ActiveDeviceList == null)
return; return;
@@ -77,7 +76,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
{ {
var overlay = new NetworkConfiguratorLinkOverlay(); var overlay = new NetworkConfiguratorLinkOverlay();
_overlay.AddOverlay(overlay); _overlay.AddOverlay(overlay);
var player = _playerManager.LocalPlayer.ControlledEntity.Value; var player = _playerManager.LocalEntity.Value;
overlay.Action = Spawn(Action); overlay.Action = Spawn(Action);
_actions.AddActionDirect(player, overlay.Action.Value); _actions.AddActionDirect(player, overlay.Action.Value);
} }

View File

@@ -40,17 +40,10 @@ public sealed class InteractionOutlineSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled); Subs.CVar(_configManager, CCVars.OutlineEnabled, SetCvarEnabled);
UpdatesAfter.Add(typeof(SharedEyeSystem)); UpdatesAfter.Add(typeof(SharedEyeSystem));
} }
public override void Shutdown()
{
base.Shutdown();
_configManager.UnsubValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
}
public void SetCvarEnabled(bool cvarEnabled) public void SetCvarEnabled(bool cvarEnabled)
{ {
_cvarEnabled = cvarEnabled; _cvarEnabled = cvarEnabled;
@@ -94,8 +87,8 @@ public sealed class InteractionOutlineSystem : EntitySystem
return; return;
// If there is no local player, there is no session, and therefore nothing to do here. // If there is no local player, there is no session, and therefore nothing to do here.
var localPlayer = _playerManager.LocalPlayer; var localSession = _playerManager.LocalSession;
if (localPlayer == null) if (localSession == null)
return; return;
// TODO InteractionOutlineComponent // TODO InteractionOutlineComponent
@@ -135,9 +128,9 @@ public sealed class InteractionOutlineSystem : EntitySystem
} }
var inRange = false; var inRange = false;
if (localPlayer.ControlledEntity != null && !Deleted(entityToClick)) if (localSession.AttachedEntity != null && !Deleted(entityToClick))
{ {
inRange = _interactionSystem.InRangeUnobstructed(localPlayer.ControlledEntity.Value, entityToClick.Value); inRange = _interactionSystem.InRangeUnobstructed(localSession.AttachedEntity.Value, entityToClick.Value);
} }
InteractionOutlineComponent? outline; InteractionOutlineComponent? outline;

View File

@@ -114,7 +114,7 @@ public sealed class TargetOutlineSystem : EntitySystem
private void HighlightTargets() private void HighlightTargets()
{ {
if (_playerManager.LocalPlayer?.ControlledEntity is not { Valid: true } player) if (_playerManager.LocalEntity is not { Valid: true } player)
return; return;
// remove current highlights // remove current highlights

View File

@@ -13,7 +13,6 @@ public sealed class ParallaxSystem : SharedParallaxSystem
[Dependency] private readonly IMapManager _map = default!; [Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IOverlayManager _overlay = default!; [Dependency] private readonly IOverlayManager _overlay = default!;
[Dependency] private readonly IParallaxManager _parallax = default!; [Dependency] private readonly IParallaxManager _parallax = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[ValidatePrototypeId<ParallaxPrototype>] [ValidatePrototypeId<ParallaxPrototype>]
private const string Fallback = "Default"; private const string Fallback = "Default";

View File

@@ -30,13 +30,13 @@ namespace Content.Client.Physics.Controllers
private void OnUpdatePredicted(EntityUid uid, InputMoverComponent component, ref UpdateIsPredictedEvent args) private void OnUpdatePredicted(EntityUid uid, InputMoverComponent component, ref UpdateIsPredictedEvent args)
{ {
// Enable prediction if an entity is controlled by the player // Enable prediction if an entity is controlled by the player
if (uid == _playerManager.LocalPlayer?.ControlledEntity) if (uid == _playerManager.LocalEntity)
args.IsPredicted = true; args.IsPredicted = true;
} }
private void OnUpdateRelayTargetPredicted(EntityUid uid, MovementRelayTargetComponent component, ref UpdateIsPredictedEvent args) private void OnUpdateRelayTargetPredicted(EntityUid uid, MovementRelayTargetComponent component, ref UpdateIsPredictedEvent args)
{ {
if (component.Source == _playerManager.LocalPlayer?.ControlledEntity) if (component.Source == _playerManager.LocalEntity)
args.IsPredicted = true; args.IsPredicted = true;
} }
@@ -45,7 +45,7 @@ namespace Content.Client.Physics.Controllers
// Enable prediction if an entity is being pulled by the player. // Enable prediction if an entity is being pulled by the player.
// Disable prediction if an entity is being pulled by some non-player entity. // Disable prediction if an entity is being pulled by some non-player entity.
if (component.Puller == _playerManager.LocalPlayer?.ControlledEntity) if (component.Puller == _playerManager.LocalEntity)
args.IsPredicted = true; args.IsPredicted = true;
else if (component.Puller != null) else if (component.Puller != null)
args.BlockPrediction = true; args.BlockPrediction = true;
@@ -84,7 +84,7 @@ namespace Content.Client.Physics.Controllers
{ {
base.UpdateBeforeSolve(prediction, frameTime); base.UpdateBeforeSolve(prediction, frameTime);
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player) if (_playerManager.LocalEntity is not {Valid: true} player)
return; return;
if (RelayQuery.TryGetComponent(player, out var relayMover)) if (RelayQuery.TryGetComponent(player, out var relayMover))

View File

@@ -94,7 +94,7 @@ public sealed class JobRequirementsManager
return true; return true;
} }
var player = _playerManager.LocalPlayer?.Session; var player = _playerManager.LocalSession;
if (player == null) if (player == null)
return true; return true;

View File

@@ -121,7 +121,7 @@ public sealed class ContentReplayPlaybackManager
// Mark as handled -- the event won't get raised. // Mark as handled -- the event won't get raised.
return true; return true;
case TickerJoinGameEvent: case TickerJoinGameEvent:
if (!_entMan.EntityExists(_player.LocalPlayer?.ControlledEntity)) if (!_entMan.EntityExists(_player.LocalEntity))
_entMan.System<ReplaySpectatorSystem>().SetSpectatorPosition(default); _entMan.System<ReplaySpectatorSystem>().SetSpectatorPosition(default);
return true; return true;
case ChatMessage chat: case ChatMessage chat:

View File

@@ -4,7 +4,7 @@ namespace Content.Client.Replay;
public sealed class ReplayConGroup : IClientConGroupImplementation public sealed class ReplayConGroup : IClientConGroupImplementation
{ {
public event Action? ConGroupUpdated; public event Action? ConGroupUpdated { add { } remove { } }
public bool CanAdminMenu() => true; public bool CanAdminMenu() => true;
public bool CanAdminPlace() => true; public bool CanAdminPlace() => true;
public bool CanCommand(string cmdName) => true; public bool CanCommand(string cmdName) => true;

View File

@@ -63,7 +63,7 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
MinHeight = 10 MinHeight = 10
}); });
var hasAccess = _player.LocalPlayer?.ControlledEntity is not { } local || var hasAccess = _player.LocalEntity is not { } local ||
!_entity.TryGetComponent<AccessReaderComponent>(Entity, out var access) || !_entity.TryGetComponent<AccessReaderComponent>(Entity, out var access) ||
_accessReader.IsAllowed(local, Entity, access); _accessReader.IsAllowed(local, Entity, access);
foreach (var techId in _technologyDatabase.CurrentTechnologyCards) foreach (var techId in _technologyDatabase.CurrentTechnologyCards)

View File

@@ -36,7 +36,7 @@ public sealed class SalvageSystem : SharedSalvageSystem
if (ev.Cancelled) if (ev.Cancelled)
return; return;
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
if (!TryComp<TransformComponent>(player, out var xform) || if (!TryComp<TransformComponent>(player, out var xform) ||
!TryComp<SalvageExpeditionComponent>(xform.MapUid, out var expedition) || !TryComp<SalvageExpeditionComponent>(xform.MapUid, out var expedition) ||

View File

@@ -35,7 +35,7 @@ namespace Content.Client.Shuttles.Systems
protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args)
{ {
base.HandlePilotShutdown(uid, component, args); base.HandlePilotShutdown(uid, component, args);
if (_playerManager.LocalPlayer?.ControlledEntity != uid) return; if (_playerManager.LocalEntity != uid) return;
_input.Contexts.SetActiveContext("human"); _input.Contexts.SetActiveContext("human");
} }

View File

@@ -19,8 +19,6 @@ public sealed partial class LawDisplay : Control
[Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly EntityManager _entityManager = default!; [Dependency] private readonly EntityManager _entityManager = default!;
public event Action<BaseButton.ButtonEventArgs>? OnLawAnnouncementButtonPressed;
public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels) public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);

View File

@@ -39,7 +39,7 @@ public sealed class SpriteFadeSystem : EntitySystem
{ {
base.FrameUpdate(frameTime); base.FrameUpdate(frameTime);
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
var spriteQuery = GetEntityQuery<SpriteComponent>(); var spriteQuery = GetEntityQuery<SpriteComponent>();
var change = ChangeRate * frameTime; var change = ChangeRate * frameTime;

View File

@@ -20,16 +20,8 @@ public sealed class StatusIconSystem : SharedStatusIconSystem
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize() public override void Initialize()
{ {
_configuration.OnValueChanged(CCVars.LocalStatusIconsEnabled, OnLocalStatusIconChanged, true); Subs.CVar(_configuration, CCVars.LocalStatusIconsEnabled, OnLocalStatusIconChanged, true);
_configuration.OnValueChanged(CCVars.GlobalStatusIconsEnabled, OnGlobalStatusIconChanged, true); Subs.CVar(_configuration, CCVars.GlobalStatusIconsEnabled, OnGlobalStatusIconChanged, true);
}
public override void Shutdown()
{
base.Shutdown();
_configuration.UnsubValueChanged(CCVars.LocalStatusIconsEnabled, OnLocalStatusIconChanged);
_configuration.UnsubValueChanged(CCVars.GlobalStatusIconsEnabled, OnGlobalStatusIconChanged);
} }
private void OnLocalStatusIconChanged(bool obj) private void OnLocalStatusIconChanged(bool obj)

View File

@@ -33,7 +33,7 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
return; return;
// TODO: Multiple viewports or w/e // TODO: Multiple viewports or w/e
var player = _player.LocalPlayer?.ControlledEntity; var player = _player.LocalEntity;
var xformQuery = GetEntityQuery<TransformComponent>(); var xformQuery = GetEntityQuery<TransformComponent>();
if (!xformQuery.TryGetComponent(player, out var playerXform)) if (!xformQuery.TryGetComponent(player, out var playerXform))

View File

@@ -64,7 +64,8 @@ namespace Content.Client.Tabletop
return; return;
// If there is no player entity, return // If there is no player entity, return
if (_playerManager.LocalPlayer is not { ControlledEntity: { } playerEntity }) return; if (_playerManager.LocalEntity is not { } playerEntity)
return;
if (!CanSeeTable(playerEntity, _table)) if (!CanSeeTable(playerEntity, _table))
{ {
@@ -85,7 +86,7 @@ namespace Content.Client.Tabletop
// If the dragged entity has another dragging player, drop the item // If the dragged entity has another dragging player, drop the item
// This should happen if the local player is dragging an item, and another player grabs it out of their hand // This should happen if the local player is dragging an item, and another player grabs it out of their hand
if (draggableComponent.DraggingPlayer != null && if (draggableComponent.DraggingPlayer != null &&
draggableComponent.DraggingPlayer != _playerManager.LocalPlayer?.Session.UserId) draggableComponent.DraggingPlayer != _playerManager.LocalSession!.UserId)
{ {
StopDragging(false); StopDragging(false);
return; return;
@@ -186,7 +187,7 @@ namespace Content.Client.Tabletop
private bool OnMouseDown(in PointerInputCmdArgs args) private bool OnMouseDown(in PointerInputCmdArgs args)
{ {
// Return if no player entity // Return if no player entity
if (_playerManager.LocalPlayer is not {ControlledEntity: { } playerEntity}) if (_playerManager.LocalEntity is not { } playerEntity)
return false; return false;
var entity = args.EntityUid; var entity = args.EntityUid;

View File

@@ -30,7 +30,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem
if (!_timing.IsFirstTimePredicted) if (!_timing.IsFirstTimePredicted)
return; return;
if (_player.LocalPlayer?.ControlledEntity is not EntityUid localPlayer) if (_player.LocalEntity is not EntityUid localPlayer)
return; return;
PlayParacusiaSounds(localPlayer); PlayParacusiaSounds(localPlayer);

View File

@@ -7,6 +7,7 @@ using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface.Controls namespace Content.Client.UserInterface.Controls
{ {
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
[Virtual]
public partial class SplitBar : BoxContainer public partial class SplitBar : BoxContainer
{ {
public Vector2 MinBarSize = new(24, 0); public Vector2 MinBarSize = new(24, 0);

View File

@@ -169,7 +169,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
return; return;
UIHelper?.Dispose(); UIHelper?.Dispose();
var ownerUserId = _playerManager.LocalPlayer!.UserId; var ownerUserId = _playerManager.LocalUser!.Value;
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId); UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
UIHelper.DiscordRelayChanged(_discordRelayActive); UIHelper.DiscordRelayChanged(_discordRelayActive);
@@ -182,15 +182,15 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
public void Open() public void Open()
{ {
var localPlayer = _playerManager.LocalPlayer; var localUser = _playerManager.LocalUser;
if (localPlayer == null) if (localUser == null)
{ {
return; return;
} }
EnsureUIHelper(); EnsureUIHelper();
if (UIHelper!.IsOpen) if (UIHelper!.IsOpen)
return; return;
UIHelper!.Open(localPlayer.UserId, _discordRelayActive); UIHelper!.Open(localUser.Value, _discordRelayActive);
} }
public void Open(NetUserId userId) public void Open(NetUserId userId)

View File

@@ -587,7 +587,7 @@ public sealed class ChatUIController : UIController
CreateSpeechBubble(entity, msg); CreateSpeechBubble(entity, msg);
} }
var player = _player.LocalPlayer?.ControlledEntity; var player = _player.LocalEntity;
var predicate = static (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data) var predicate = static (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data)
=> uid == data.compOwner || uid == data.attachedEntity; => uid == data.compOwner || uid == data.attachedEntity;
var playerPos = player != null var playerPos = player != null
@@ -644,7 +644,7 @@ public sealed class ChatUIController : UIController
private bool TryGetRadioChannel(string text, out RadioChannelPrototype? radioChannel) private bool TryGetRadioChannel(string text, out RadioChannelPrototype? radioChannel)
{ {
radioChannel = null; radioChannel = null;
return _player.LocalPlayer?.ControlledEntity is EntityUid { Valid: true } uid return _player.LocalEntity is EntityUid { Valid: true } uid
&& _chatSys != null && _chatSys != null
&& _chatSys.TryProccessRadioMessage(uid, text, out _, out radioChannel, quiet: true); && _chatSys.TryProccessRadioMessage(uid, text, out _, out radioChannel, quiet: true);
} }

View File

@@ -33,7 +33,7 @@ public partial class ChatBox : UIWidget
_entManager = IoCManager.Resolve<IEntityManager>(); _entManager = IoCManager.Resolve<IEntityManager>();
ChatInput.Input.OnTextEntered += OnTextEntered; ChatInput.Input.OnTextEntered += OnTextEntered;
ChatInput.Input.OnKeyBindDown += OnKeyBindDown; ChatInput.Input.OnKeyBindDown += OnInputKeyBindDown;
ChatInput.Input.OnTextChanged += OnTextChanged; ChatInput.Input.OnTextChanged += OnTextChanged;
ChatInput.ChannelSelector.OnChannelSelect += OnChannelSelect; ChatInput.ChannelSelector.OnChannelSelect += OnChannelSelect;
ChatInput.FilterButton.Popup.OnChannelFilter += OnChannelFilter; ChatInput.FilterButton.Popup.OnChannelFilter += OnChannelFilter;
@@ -142,7 +142,7 @@ public partial class ChatBox : UIWidget
ChatInput.ChannelSelector.Select(toSelect); ChatInput.ChannelSelector.Select(toSelect);
} }
private void OnKeyBindDown(GUIBoundKeyEventArgs args) private void OnInputKeyBindDown(GUIBoundKeyEventArgs args)
{ {
if (args.Function == EngineKeyFunctions.TextReleaseFocus) if (args.Function == EngineKeyFunctions.TextReleaseFocus)
{ {
@@ -182,7 +182,7 @@ public partial class ChatBox : UIWidget
if (!disposing) return; if (!disposing) return;
_controller.UnregisterChat(this); _controller.UnregisterChat(this);
ChatInput.Input.OnTextEntered -= OnTextEntered; ChatInput.Input.OnTextEntered -= OnTextEntered;
ChatInput.Input.OnKeyBindDown -= OnKeyBindDown; ChatInput.Input.OnKeyBindDown -= OnInputKeyBindDown;
ChatInput.Input.OnTextChanged -= OnTextChanged; ChatInput.Input.OnTextChanged -= OnTextChanged;
ChatInput.ChannelSelector.OnChannelSelect -= OnChannelSelect; ChatInput.ChannelSelector.OnChannelSelect -= OnChannelSelect;
} }

View File

@@ -48,7 +48,7 @@ public sealed class DamageOverlayUiController : UIController
private void OnMobStateChanged(MobStateChangedEvent args) private void OnMobStateChanged(MobStateChangedEvent args)
{ {
if (args.Target != _playerManager.LocalPlayer?.ControlledEntity) if (args.Target != _playerManager.LocalEntity)
return; return;
UpdateOverlays(args.Target, args.Component); UpdateOverlays(args.Target, args.Component);
@@ -57,7 +57,7 @@ public sealed class DamageOverlayUiController : UIController
private void OnThresholdCheck(ref MobThresholdChecked args) private void OnThresholdCheck(ref MobThresholdChecked args)
{ {
if (args.Target != _playerManager.LocalPlayer?.ControlledEntity) if (args.Target != _playerManager.LocalEntity)
return; return;
UpdateOverlays(args.Target, args.MobState, args.Damageable, args.Threshold); UpdateOverlays(args.Target, args.MobState, args.Damageable, args.Threshold);
} }

View File

@@ -56,7 +56,7 @@ public sealed class DamageOverlay : Overlay
protected override void Draw(in OverlayDrawArgs args) protected override void Draw(in OverlayDrawArgs args)
{ {
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp)) if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp))
return; return;
if (args.Viewport.Eye != eyeComp.Eye) if (args.Viewport.Eye != eyeComp.Eye)

View File

@@ -43,8 +43,8 @@ public sealed class MakeGhostRoleEui : BaseEui
private void OnMake(NetEntity entity, string name, string description, string rules, bool makeSentient) private void OnMake(NetEntity entity, string name, string description, string rules, bool makeSentient)
{ {
var player = _playerManager.LocalPlayer; var session = _playerManager.LocalSession;
if (player == null) if (session == null)
{ {
return; return;
} }
@@ -56,12 +56,12 @@ public sealed class MakeGhostRoleEui : BaseEui
$"\"{CommandParsing.Escape(description)}\" " + $"\"{CommandParsing.Escape(description)}\" " +
$"\"{CommandParsing.Escape(rules)}\""; $"\"{CommandParsing.Escape(rules)}\"";
_consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand); _consoleHost.ExecuteCommand(session, makeGhostRoleCommand);
if (makeSentient) if (makeSentient)
{ {
var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(entity.ToString())}\""; var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(entity.ToString())}\"";
_consoleHost.ExecuteCommand(player.Session, makeSentientCommand); _consoleHost.ExecuteCommand(session, makeSentientCommand);
} }
_window.Close(); _window.Close();

View File

@@ -80,7 +80,7 @@ public sealed class ViewportUIController : UIController
// verify that the current eye is not "null". Fuck IEyeManager. // verify that the current eye is not "null". Fuck IEyeManager.
var ent = _playerMan.LocalPlayer?.ControlledEntity; var ent = _playerMan.LocalEntity;
if (_eyeManager.CurrentEye.Position != default || ent == null) if (_eyeManager.CurrentEye.Position != default || ent == null)
return; return;

View File

@@ -57,7 +57,7 @@ namespace Content.Client.Verbs
if (_stateManager.CurrentState is not GameplayStateBase gameScreenBase) if (_stateManager.CurrentState is not GameplayStateBase gameScreenBase)
return false; return false;
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
if (player == null) if (player == null)
return false; return false;

View File

@@ -35,7 +35,7 @@ public sealed class MeleeArcOverlay : Overlay
protected override void Draw(in OverlayDrawArgs args) protected override void Draw(in OverlayDrawArgs args)
{ {
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalEntity;
if (!_entManager.TryGetComponent<TransformComponent>(player, out var xform) || if (!_entManager.TryGetComponent<TransformComponent>(player, out var xform) ||
!_combatMode.IsInCombatMode(player)) !_combatMode.IsInCombatMode(player))

View File

@@ -50,7 +50,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
if (!Timing.IsFirstTimePredicted) if (!Timing.IsFirstTimePredicted)
return; return;
var entityNull = _player.LocalPlayer?.ControlledEntity; var entityNull = _player.LocalEntity;
if (entityNull == null) if (entityNull == null)
return; return;

View File

@@ -26,7 +26,7 @@ public sealed class GrapplingGunSystem : SharedGrapplingGunSystem
if (!Timing.IsFirstTimePredicted) if (!Timing.IsFirstTimePredicted)
return; return;
var local = _player.LocalPlayer?.ControlledEntity; var local = _player.LocalEntity;
var handUid = _hands.GetActiveHandEntity(); var handUid = _hands.GetActiveHandEntity();
if (!TryComp<GrapplingGunComponent>(handUid, out var grappling)) if (!TryComp<GrapplingGunComponent>(handUid, out var grappling))

View File

@@ -54,7 +54,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
if (!_timing.IsFirstTimePredicted) if (!_timing.IsFirstTimePredicted)
return; return;
var player = _player.LocalPlayer?.ControlledEntity; var player = _player.LocalEntity;
if (player == null || if (player == null ||
!TryGetTetherGun(player.Value, out var gunUid, out var gun) || !TryGetTetherGun(player.Value, out var gunUid, out var gun) ||

View File

@@ -33,7 +33,7 @@ public sealed class GunSpreadOverlay : Overlay
{ {
var worldHandle = args.WorldHandle; var worldHandle = args.WorldHandle;
var player = _player.LocalPlayer?.ControlledEntity; var player = _player.LocalEntity;
if (player == null || if (player == null ||
!_entManager.TryGetComponent<TransformComponent>(player, out var xform)) !_entManager.TryGetComponent<TransformComponent>(player, out var xform))

View File

@@ -24,7 +24,7 @@ public sealed class FlyBySoundSystem : SharedFlyBySoundSystem
private void OnCollide(EntityUid uid, FlyBySoundComponent component, ref StartCollideEvent args) private void OnCollide(EntityUid uid, FlyBySoundComponent component, ref StartCollideEvent args)
{ {
var attachedEnt = _player.LocalPlayer?.ControlledEntity; var attachedEnt = _player.LocalEntity;
// If it's not our ent or we shot it. // If it's not our ent or we shot it.
if (attachedEnt == null || if (attachedEnt == null ||

View File

@@ -132,7 +132,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (!Timing.IsFirstTimePredicted) if (!Timing.IsFirstTimePredicted)
return; return;
var entityNull = _player.LocalPlayer?.ControlledEntity; var entityNull = _player.LocalEntity;
if (entityNull == null || !TryComp<CombatModeComponent>(entityNull, out var combat) || !combat.IsInCombatMode) if (entityNull == null || !TryComp<CombatModeComponent>(entityNull, out var combat) || !combat.IsInCombatMode)
{ {

View File

@@ -22,7 +22,6 @@ public sealed class WeatherSystem : SharedWeatherSystem
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly AudioSystem _audio = default!; [Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly MapSystem _mapSystem = default!; [Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize() public override void Initialize()

Some files were not shown because too many files have changed in this diff Show More