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,
float lambda)
{
ref var sva = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(endPoint1));
ref var svb = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(endPoint2));
ref var sva = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(in endPoint1));
ref var svb = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(in endPoint2));
var res = SysVector4.Lerp(svb, sva, lambda);
@@ -156,8 +156,8 @@ namespace Content.Benchmarks
public static Color InterpolateSimdIn(in Color a, in Color b,
float lambda)
{
var vecA = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(a));
var vecB = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(b));
var vecA = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(in a));
var vecB = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(in b));
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)
{
MainAsync(args).GetAwaiter().GetResult();
}
public static async Task MainAsync(string[] args)
{
#if DEBUG
Console.ForegroundColor = ConsoleColor.Red;
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.Sound = state.Sound;
if (_playerManager.LocalPlayer?.ControlledEntity == component.AttachedEntity)
if (_playerManager.LocalEntity == component.AttachedEntity)
ActionsUpdated?.Invoke();
}
@@ -111,7 +111,7 @@ namespace Content.Client.Actions
return;
base.UpdateAction(actionId, action);
if (_playerManager.LocalPlayer?.ControlledEntity != action.AttachedEntity)
if (_playerManager.LocalEntity != action.AttachedEntity)
return;
ActionsUpdated?.Invoke();
@@ -144,7 +144,7 @@ namespace Content.Client.Actions
_added.Add((actionId, action));
}
if (_playerManager.LocalPlayer?.ControlledEntity != uid)
if (_playerManager.LocalEntity != uid)
return;
foreach (var action in _removed)
@@ -177,7 +177,7 @@ namespace Content.Client.Actions
protected override void ActionAdded(EntityUid performer, EntityUid actionId, ActionsComponent comp,
BaseActionComponent action)
{
if (_playerManager.LocalPlayer?.ControlledEntity != performer)
if (_playerManager.LocalEntity != performer)
return;
OnActionAdded?.Invoke(actionId);
@@ -185,7 +185,7 @@ namespace Content.Client.Actions
protected override void ActionRemoved(EntityUid performer, EntityUid actionId, ActionsComponent comp, BaseActionComponent action)
{
if (_playerManager.LocalPlayer?.ControlledEntity != performer)
if (_playerManager.LocalEntity != performer)
return;
OnActionRemoved?.Invoke(actionId);
@@ -193,7 +193,7 @@ namespace Content.Client.Actions
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 GetActions(user);
@@ -216,7 +216,7 @@ namespace Content.Client.Actions
public void LinkAllActions(ActionsComponent? actions = null)
{
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user ||
if (_playerManager.LocalEntity is not { } user ||
!Resolve(user, ref actions, false))
{
return;
@@ -233,7 +233,7 @@ namespace Content.Client.Actions
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))
{
return;
@@ -261,7 +261,7 @@ namespace Content.Client.Actions
/// </summary>
public void LoadActionAssignments(string path, bool userData)
{
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user)
if (_playerManager.LocalEntity is not { } user)
return;
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 IClientConGroupController _conGroup = default!;
[Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly ILogManager _logManager = default!;
private AdminData? _adminData;
private readonly HashSet<string> _availableCommands = new();
private readonly AdminCommandPermissions _localCommandPermissions = new();
private ISawmill _sawmill = default!;
public event Action? AdminStatusUpdated;
@@ -92,17 +94,17 @@ namespace Content.Client.Administration.Managers
}
_availableCommands.UnionWith(message.AvailableCommands);
Logger.DebugS("admin", $"Have {message.AvailableCommands.Length} commands available");
_sawmill.Debug($"Have {message.AvailableCommands.Length} commands available");
_adminData = message.Admin;
if (_adminData != null)
{
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
{
Logger.InfoS("admin", "Updated admin status: Not admin");
_sawmill.Info("Updated admin status: Not admin");
}
AdminStatusUpdated?.Invoke();
@@ -114,18 +116,17 @@ namespace Content.Client.Administration.Managers
void IPostInjectInit.PostInject()
{
_conGroup.Implementation = this;
_sawmill = _logManager.GetSawmill("admin");
}
public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false)
{
return uid == _player.LocalPlayer?.ControlledEntity
? _adminData
: null;
return uid == _player.LocalEntity ? _adminData : null;
}
public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
{
if (_player.LocalPlayer?.UserId == session.UserId)
if (_player.LocalUser == session.UserId)
return _adminData;
return null;
@@ -133,7 +134,7 @@ namespace Content.Client.Administration.Managers
public AdminData? GetAdminData(bool includeDeAdmin = false)
{
if (_player.LocalPlayer is { Session: { } session })
if (_player.LocalSession is { } session)
return GetAdminData(session, includeDeAdmin);
return null;

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
{
_data.Clear();
var player = _players.LocalPlayer?.ControlledEntity;
var player = _players.LocalEntity;
var playerGrid = _entities.GetComponentOrNull<TransformComponent>(player)?.GridUid;
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 _))
{
_gridData.Add(entManager.GetNetEntity(uid));
var player = playerManager.LocalPlayer?.ControlledEntity;
var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
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 _))
{
var player = playerManager.LocalPlayer?.ControlledEntity;
var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
_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 _))
{
var player = playerManager.LocalPlayer?.ControlledEntity;
var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
_data.Add(entManager.GetNetEntity(uid));

View File

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

View File

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

View File

@@ -11,7 +11,6 @@ namespace Content.Client.Anomaly.Ui;
[GenerateTypedNameReferences]
public sealed partial class AnomalyGeneratorWindow : FancyWindow
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
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<AirAlarmMode>? AirAlarmModeChanged;
public event Action<bool>? AutoModeChanged;
public event Action<string>? ResyncDeviceRequested;
public event Action? ResyncAllRequested;
public event Action<AirAlarmTab>? AirAlarmTabChange;

View File

@@ -2,6 +2,6 @@
HorizontalExpand="True" Orientation="Vertical"
Margin = "20 0 0 0" MinSize="160 0" >
<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" />
</BoxContainer>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,18 +1,11 @@
using Content.Shared.Audio;
using Content.Shared.GameTicking;
using Robust.Client.Audio;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using AudioComponent = Robust.Shared.Audio.Components.AudioComponent;
namespace Content.Client.Audio;
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"
private readonly Dictionary<EntityUid, float> _fadingOut = new();

View File

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

View File

@@ -10,6 +10,7 @@ namespace Content.Client.CardboardBox;
public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
@@ -29,7 +30,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
if (!xformQuery.TryGetComponent(source, out var xform))
return;
var sourcePos = xform.MapPosition;
var sourcePos = _transform.GetMapCoordinates(source, xform);
//Any mob that can move should be surprised?
//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.
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;
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))
continue;
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]
public sealed partial class BountyEntry : BoxContainer
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
public Action? OnButtonPressed;

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
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)
@@ -38,7 +38,6 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
public override void Shutdown()
{
_cfg.UnsubValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged);
_overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>();
base.Shutdown();
@@ -46,7 +45,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
public bool IsInCombatMode()
{
var entity = _playerManager.LocalPlayer?.ControlledEntity;
var entity = _playerManager.LocalEntity;
if (entity == null)
return false;
@@ -67,7 +66,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
private void UpdateHud(EntityUid entity)
{
if (entity != _playerManager.LocalPlayer?.ControlledEntity || !Timing.IsFirstTimePredicted)
if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted)
{
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)
{

View File

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

View File

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

View File

@@ -28,8 +28,6 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private const string SawmillName = "DamageVisuals";
public override void Initialize()
{
base.Initialize();
@@ -54,14 +52,14 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
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;
return;
}
@@ -70,21 +68,21 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
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;
return;
}
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;
return;
}
@@ -92,7 +90,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
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;
return;
}
@@ -101,21 +99,21 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
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;
return;
}
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;
return;
}
@@ -123,12 +121,12 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
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)
{
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)
{
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;
return;
}
@@ -163,7 +161,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
@@ -177,7 +175,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
@@ -197,7 +195,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
@@ -208,7 +206,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
return;
}
@@ -232,7 +230,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
{
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;
}
@@ -244,7 +242,7 @@ public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponen
// invalidate the visualizer without crashing.
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;
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
// predictable by clients.
var playerEntity = _player.LocalPlayer?.ControlledEntity;
var playerEntity = _player.LocalEntity;
if (!TryComp(playerEntity, out ActiveDoAfterComponent? active))
return;
@@ -69,7 +69,7 @@ public sealed class DoAfterSystem : SharedDoAfterSystem
out float progress)
where T : DoAfterEvent
{
var playerEntity = _player.LocalPlayer?.ControlledEntity;
var playerEntity = _player.LocalEntity;
doAfter = null;
@event = null;

View File

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

View File

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

View File

@@ -34,7 +34,7 @@ public sealed class RainbowOverlay : Overlay
protected override void FrameUpdate(FrameEventArgs args)
{
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
var playerEntity = _playerManager.LocalEntity;
if (playerEntity == null)
return;
@@ -53,7 +53,7 @@ public sealed class RainbowOverlay : Overlay
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;
if (args.Viewport.Eye != eyeComp.Eye)

View File

@@ -36,7 +36,7 @@ public sealed class DrunkOverlay : Overlay
protected override void FrameUpdate(FrameEventArgs args)
{
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
var playerEntity = _playerManager.LocalEntity;
if (playerEntity == null)
return;
@@ -58,7 +58,7 @@ public sealed class DrunkOverlay : Overlay
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;
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)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
if (_player.LocalEntity == uid)
_overlayMan.AddOverlay(_overlay);
}
private void OnDrunkShutdown(EntityUid uid, DrunkComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
if (_player.LocalEntity == uid)
{
_overlay.CurrentBoozePower = 0;
_overlayMan.RemoveOverlay(_overlay);

View File

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

View File

@@ -14,7 +14,6 @@ namespace Content.Client.Explosion;
public sealed class ExplosionOverlay : Overlay
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entMan = 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)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
if (_player.LocalEntity == uid)
_overlayMan.AddOverlay(_overlay);
}
private void OnBlindShutdown(EntityUid uid, BlindableComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
if (_player.LocalEntity == uid)
{
_overlayMan.RemoveOverlay(_overlay);
}

View File

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

View File

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

View File

@@ -51,7 +51,7 @@ namespace Content.Client.Flash
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;
if (args.Viewport.Eye != eyeComp.Eye)

View File

@@ -25,7 +25,7 @@ namespace Content.Client.Flash
return;
// 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;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -203,7 +203,7 @@ namespace Content.Client.Gameplay
}; // TODO make entityUid nullable
// 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))
{
kArgs.Handle();

View File

@@ -15,7 +15,6 @@ namespace Content.Client.Ghost
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
[Dependency] private readonly EyeSystem _eye = default!;
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 event Action<GhostComponent>? PlayerRemoved;

View File

@@ -23,7 +23,7 @@ public sealed partial class GravitySystem
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) ||
xform.GridUid != uid && xform.MapUid != uid)
@@ -44,7 +44,7 @@ public sealed partial class GravitySystem
if (!Resolve(uid, ref gravity) || !Timing.IsFirstTimePredicted)
return;
var localPlayer = _playerManager.LocalPlayer?.ControlledEntity;
var localPlayer = _playerManager.LocalEntity;
if (!TryComp<TransformComponent>(localPlayer, out var xform))
return;

View File

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

View File

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

View File

@@ -2,10 +2,13 @@ using Content.Shared.HotPotato;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Client.HotPotato;
public sealed class HotPotatoSystem : SharedHotPotatoSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Update(float frameTime)
{
@@ -20,7 +23,7 @@ public sealed class HotPotatoSystem : SharedHotPotatoSystem
if (_timing.CurTime < comp.TargetTime)
continue;
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;
_cfg.OnValueChanged(CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged, true);
_cfg.OnValueChanged(CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged, true);
Subs.CVar(_cfg, CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged, true);
Subs.CVar(_cfg, CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged, true);
SubscribeNetworkEvent<InstrumentMidiEventEvent>(OnMidiEventRx);
SubscribeNetworkEvent<InstrumentStartMidiEvent>(OnMidiStart);
@@ -60,14 +60,6 @@ public sealed class InstrumentSystem : SharedInstrumentSystem
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)
{
EndRenderer(uid, false, component);

View File

@@ -168,14 +168,14 @@ namespace Content.Client.Instruments.UI
if (instrument == null)
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 (localPlayer?.ControlledEntity == null)
if (localEntity == null)
return false;
// By default, allow an instrument to play itself and skip all other checks
if (localPlayer.ControlledEntity == instrumentEnt)
if (localEntity == instrumentEnt)
return true;
var container = _owner.Entities.System<SharedContainerSystem>();
@@ -183,14 +183,14 @@ namespace Content.Client.Instruments.UI
container.TryGetContainingContainer(instrumentEnt, out var conMan);
// 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;
if (!_owner.ActionBlocker.CanInteract(localPlayer.ControlledEntity.Value, instrumentEnt))
if (!_owner.ActionBlocker.CanInteract(localEntity.Value, instrumentEnt))
return false;
// 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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -40,17 +40,10 @@ public sealed class InteractionOutlineSystem : EntitySystem
{
base.Initialize();
_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
Subs.CVar(_configManager, CCVars.OutlineEnabled, SetCvarEnabled);
UpdatesAfter.Add(typeof(SharedEyeSystem));
}
public override void Shutdown()
{
base.Shutdown();
_configManager.UnsubValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
}
public void SetCvarEnabled(bool cvarEnabled)
{
_cvarEnabled = cvarEnabled;
@@ -94,8 +87,8 @@ public sealed class InteractionOutlineSystem : EntitySystem
return;
// If there is no local player, there is no session, and therefore nothing to do here.
var localPlayer = _playerManager.LocalPlayer;
if (localPlayer == null)
var localSession = _playerManager.LocalSession;
if (localSession == null)
return;
// TODO InteractionOutlineComponent
@@ -135,9 +128,9 @@ public sealed class InteractionOutlineSystem : EntitySystem
}
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;

View File

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

View File

@@ -13,7 +13,6 @@ public sealed class ParallaxSystem : SharedParallaxSystem
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IOverlayManager _overlay = default!;
[Dependency] private readonly IParallaxManager _parallax = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[ValidatePrototypeId<ParallaxPrototype>]
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)
{
// Enable prediction if an entity is controlled by the player
if (uid == _playerManager.LocalPlayer?.ControlledEntity)
if (uid == _playerManager.LocalEntity)
args.IsPredicted = true;
}
private void OnUpdateRelayTargetPredicted(EntityUid uid, MovementRelayTargetComponent component, ref UpdateIsPredictedEvent args)
{
if (component.Source == _playerManager.LocalPlayer?.ControlledEntity)
if (component.Source == _playerManager.LocalEntity)
args.IsPredicted = true;
}
@@ -45,7 +45,7 @@ namespace Content.Client.Physics.Controllers
// Enable prediction if an entity is being pulled by the player.
// 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;
else if (component.Puller != null)
args.BlockPrediction = true;
@@ -84,7 +84,7 @@ namespace Content.Client.Physics.Controllers
{
base.UpdateBeforeSolve(prediction, frameTime);
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player)
if (_playerManager.LocalEntity is not {Valid: true} player)
return;
if (RelayQuery.TryGetComponent(player, out var relayMover))

View File

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

View File

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

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ public sealed class SalvageSystem : SharedSalvageSystem
if (ev.Cancelled)
return;
var player = _playerManager.LocalPlayer?.ControlledEntity;
var player = _playerManager.LocalEntity;
if (!TryComp<TransformComponent>(player, out var xform) ||
!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)
{
base.HandlePilotShutdown(uid, component, args);
if (_playerManager.LocalPlayer?.ControlledEntity != uid) return;
if (_playerManager.LocalEntity != uid) return;
_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 EntityManager _entityManager = default!;
public event Action<BaseButton.ButtonEventArgs>? OnLawAnnouncementButtonPressed;
public LawDisplay(EntityUid uid, SiliconLaw law, HashSet<string>? radioChannels)
{
RobustXamlLoader.Load(this);

View File

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

View File

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

View File

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

View File

@@ -64,7 +64,8 @@ namespace Content.Client.Tabletop
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))
{
@@ -85,7 +86,7 @@ namespace Content.Client.Tabletop
// 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
if (draggableComponent.DraggingPlayer != null &&
draggableComponent.DraggingPlayer != _playerManager.LocalPlayer?.Session.UserId)
draggableComponent.DraggingPlayer != _playerManager.LocalSession!.UserId)
{
StopDragging(false);
return;
@@ -186,7 +187,7 @@ namespace Content.Client.Tabletop
private bool OnMouseDown(in PointerInputCmdArgs args)
{
// Return if no player entity
if (_playerManager.LocalPlayer is not {ControlledEntity: { } playerEntity})
if (_playerManager.LocalEntity is not { } playerEntity)
return false;
var entity = args.EntityUid;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -48,7 +48,7 @@ public sealed class DamageOverlayUiController : UIController
private void OnMobStateChanged(MobStateChangedEvent args)
{
if (args.Target != _playerManager.LocalPlayer?.ControlledEntity)
if (args.Target != _playerManager.LocalEntity)
return;
UpdateOverlays(args.Target, args.Component);
@@ -57,7 +57,7 @@ public sealed class DamageOverlayUiController : UIController
private void OnThresholdCheck(ref MobThresholdChecked args)
{
if (args.Target != _playerManager.LocalPlayer?.ControlledEntity)
if (args.Target != _playerManager.LocalEntity)
return;
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)
{
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp))
return;
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)
{
var player = _playerManager.LocalPlayer;
if (player == null)
var session = _playerManager.LocalSession;
if (session == null)
{
return;
}
@@ -56,12 +56,12 @@ public sealed class MakeGhostRoleEui : BaseEui
$"\"{CommandParsing.Escape(description)}\" " +
$"\"{CommandParsing.Escape(rules)}\"";
_consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand);
_consoleHost.ExecuteCommand(session, makeGhostRoleCommand);
if (makeSentient)
{
var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(entity.ToString())}\"";
_consoleHost.ExecuteCommand(player.Session, makeSentientCommand);
_consoleHost.ExecuteCommand(session, makeSentientCommand);
}
_window.Close();

View File

@@ -80,7 +80,7 @@ public sealed class ViewportUIController : UIController
// 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)
return;

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,7 +54,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
if (!_timing.IsFirstTimePredicted)
return;
var player = _player.LocalPlayer?.ControlledEntity;
var player = _player.LocalEntity;
if (player == null ||
!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 player = _player.LocalPlayer?.ControlledEntity;
var player = _player.LocalEntity;
if (player == null ||
!_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)
{
var attachedEnt = _player.LocalPlayer?.ControlledEntity;
var attachedEnt = _player.LocalEntity;
// If it's not our ent or we shot it.
if (attachedEnt == null ||

View File

@@ -132,7 +132,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (!Timing.IsFirstTimePredicted)
return;
var entityNull = _player.LocalPlayer?.ControlledEntity;
var entityNull = _player.LocalEntity;
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 AudioSystem _audio = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()

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