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);
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);
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");
component.ItemIconStyle = state.ItemIconStyle;
component.Sound = state.Sound;
- if (_playerManager.LocalPlayer?.ControlledEntity == component.AttachedEntity)
+ if (_playerManager.LocalEntity == component.AttachedEntity)
ActionsUpdated?.Invoke();
}
return;
base.UpdateAction(actionId, action);
- if (_playerManager.LocalPlayer?.ControlledEntity != action.AttachedEntity)
+ if (_playerManager.LocalEntity != action.AttachedEntity)
return;
ActionsUpdated?.Invoke();
_added.Add((actionId, action));
}
- if (_playerManager.LocalPlayer?.ControlledEntity != uid)
+ if (_playerManager.LocalEntity != uid)
return;
foreach (var action in _removed)
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);
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);
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);
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;
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;
/// </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();
[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;
}
_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();
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;
public AdminData? GetAdminData(bool includeDeAdmin = false)
{
- if (_player.LocalPlayer is { Session: { } session })
+ if (_player.LocalSession is { } session)
return GetAdminData(session, includeDeAdmin);
return null;
{
UpdateMapOptions();
- if (!_entMan.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out TransformComponent? transform))
+ if (!_entMan.TryGetComponent(_playerManager.LocalEntity, out TransformComponent? transform))
return;
_pausePreview = true;
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;
{
_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>();
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)" : "")}");
}
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));
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));
{
get
{
- var ent = _playerManager.LocalPlayer?.ControlledEntity;
+ var ent = _playerManager.LocalEntity;
return ent is not null
? GetActiveAlerts(ent.Value)
: null;
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);
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);
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);
{
base.HandleComponentShutdown(uid, component, args);
- if (_playerManager.LocalPlayer?.ControlledEntity != uid)
+ if (_playerManager.LocalEntity != uid)
return;
ClearAlerts?.Invoke(this, EventArgs.Empty);
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 =
[GenerateTypedNameReferences]
public sealed partial class AnomalyGeneratorWindow : FancyWindow
{
- [Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
private TimeSpan _cooldownEnd = TimeSpan.Zero;
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;
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>
CBoundLabel.Text = controlLabel;
CSpinner.Value = ScaledValue;
- CBoundEnabled.Pressed = _value != null;
CSpinner.OnValueChanged += SpinnerValueChanged;
CBoundEnabled.OnToggled += CheckboxToggled;
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);
}
{
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)
{
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;
{
base.Shutdown();
- _configManager.UnsubValueChanged(CCVars.LobbyMusicEnabled, LobbyMusicCVarChanged);
- _configManager.UnsubValueChanged(CCVars.LobbyMusicVolume, LobbyMusicVolumeCVarChanged);
-
_stateManager.OnStateChanged -= StateManagerOnStateChanged;
_client.PlayerLeaveServer -= OnLeave;
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);
}
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
private void ShutdownAmbientMusic()
{
- _configManager.UnsubValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged);
_state.OnStateChanged -= OnStateChange;
_ambientMusicStream = _audio.Stop(_ambientMusicStream);
}
private AmbientMusicPrototype? GetAmbience()
{
- var player = _player.LocalPlayer?.ControlledEntity;
+ var player = _player.LocalEntity;
if (player == null)
return null;
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();
{
[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)
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();
public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
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
//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);
}
}
[GenerateTypedNameReferences]
public sealed partial class BountyEntry : BoxContainer
{
- [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
public Action? OnButtonPressed;
-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;
}
[DataDefinition]
- public sealed partial class ChangelogEntry : ISerializationHooks
+ public sealed partial class ChangelogEntry
{
[DataField("id")]
public int Id { get; private set; }
[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]
public void RequestCharacterInfo()
{
- var entity = _players.LocalPlayer?.ControlledEntity;
+ var entity = _players.LocalEntity;
if (entity == null)
{
return;
public override void Initialize()
{
base.Initialize();
- _cfg.OnValueChanged(CCVars.ChatShowTypingIndicator, OnShowTypingChanged);
+
+ Subs.CVar(_cfg, CCVars.ChatShowTypingIndicator, OnShowTypingChanged);
}
public void ClientChangedChatText()
_isClientTyping = isClientTyping;
// check if player controls any pawn
- if (_playerManager.LocalPlayer?.ControlledEntity == null)
+ if (_playerManager.LocalEntity == null)
return;
// send a networked event to server
namespace Content.Client.CloningConsole.UI
{
[GenerateTypedNameReferences]
- public partial class CloningConsoleWindow : DefaultWindow
+ public sealed partial class CloningConsoleWindow : DefaultWindow
{
public CloningConsoleWindow()
{
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)
public override void Shutdown()
{
- _cfg.UnsubValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged);
_overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>();
base.Shutdown();
public bool IsInCombatMode()
{
- var entity = _playerManager.LocalPlayer?.ControlledEntity;
+ var entity = _playerManager.LocalEntity;
if (entity == null)
return false;
private void UpdateHud(EntityUid entity)
{
- if (entity != _playerManager.LocalPlayer?.ControlledEntity || !Timing.IsFirstTimePredicted)
+ if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted)
{
return;
}
}
}
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length > 1)
{
[NotNullWhen(true)] out EntityUid? ghost)
{
ghost = null;
- if (_playerManager.LocalPlayer?.ControlledEntity is not { } user ||
+ if (_playerManager.LocalEntity is not { } user ||
!user.IsValid())
{
return false;
Uid = entity.Value,
};
- var session = _playerManager.LocalPlayer?.Session;
+ var session = _playerManager.LocalSession;
if (session != null)
{
inputSys.HandleInputCommand(session, func, message);
if (!_context.RootMenu.Visible)
return;
- if (_playerManager.LocalPlayer?.ControlledEntity is not { } player ||
+ if (_playerManager.LocalEntity is not { } player ||
!player.IsValid())
return;
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- private const string SawmillName = "DamageVisuals";
-
public override void Initialize()
{
base.Initialize();
{
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;
}
{
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;
}
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;
}
{
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;
}
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}.");
}
}
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;
}
{
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;
}
{
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;
}
{
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;
}
{
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;
}
{
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;
}
// 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;
}
// 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;
out float progress)
where T : DoAfterEvent
{
- var playerEntity = _player.LocalPlayer?.ControlledEntity;
+ var playerEntity = _player.LocalEntity;
doAfter = null;
@event = null;
public sealed class FirelockSystem : EntitySystem
{
- [Dependency] protected readonly SharedAppearanceSystem _appearanceSystem = default!;
+ [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
public override void Initialize()
{
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);
protected override void FrameUpdate(FrameEventArgs args)
{
- var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
+ var playerEntity = _playerManager.LocalEntity;
if (playerEntity == null)
return;
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)
protected override void FrameUpdate(FrameEventArgs args)
{
- var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
+ var playerEntity = _playerManager.LocalEntity;
if (playerEntity == null)
return;
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)
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);
[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";
{
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();
}
return false;
}
- _playerEntity = _playerManager.LocalPlayer?.ControlledEntity ?? default;
+ _playerEntity = _playerManager.LocalEntity ?? default;
if (_playerEntity == default || !CanExamine(_playerEntity, entity))
{
private void OnExamineInfoResponse(ExamineSystemMessages.ExamineInfoResponseMessage ev)
{
- var player = _playerManager.LocalPlayer?.ControlledEntity;
+ var player = _playerManager.LocalEntity;
if (player == null)
return;
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;
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!;
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);
}
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);
}
private void OnEyeStartup(EntityUid uid, EyeComponent component, ComponentStartup args)
{
- if (_playerManager.LocalPlayer?.ControlledEntity == uid)
+ if (_playerManager.LocalEntity == uid)
AddEye(uid, component, true);
}
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);
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)
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;
}
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!;
Text="{Loc 'forensic-scanner-interface-clear'}" />
</BoxContainer>
<Label
- Name="Name"
+ Name="NameLabel"
Align="Center" />
<Label
Name="Diagnostics"
{
Print.Disabled = true;
Clear.Disabled = true;
- Name.Text = string.Empty;
+ NameLabel.Text = string.Empty;
Diagnostics.Text = string.Empty;
return;
}
Print.Disabled = (msg.PrintReadyAt > _gameTiming.CurTime);
Clear.Disabled = false;
- Name.Text = msg.LastScannedName;
+ NameLabel.Text = msg.LastScannedName;
var text = new StringBuilder();
[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;
}; // 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();
[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; }
}
}
- 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;
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)
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;
/// </summary>
public EntityUid GetGuidebookUser()
{
- var user = _playerManager.LocalPlayer!.ControlledEntity;
+ var user = _playerManager.LocalEntity;
if (user != null)
return user.Value;
[UsedImplicitly]
public sealed class HandsSystem : SharedHandsSystem
{
- [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IUserInterfaceManager _ui = default!;
/// </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);
}
UpdateHandVisuals(uid, args.Entity, hand);
_stripSys.UpdateUi(uid);
- if (uid != _playerManager.LocalPlayer?.ControlledEntity)
+ if (uid != _playerManager.LocalEntity)
return;
OnPlayerItemAdded?.Invoke(hand.Name, args.Entity);
UpdateHandVisuals(uid, args.Entity, hand);
_stripSys.UpdateUi(uid);
- if (uid != _playerManager.LocalPlayer?.ControlledEntity)
+ if (uid != _playerManager.LocalEntity)
return;
OnPlayerItemRemoved?.Invoke(hand.Name, args.Entity);
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)
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
{
base.AddHand(uid, handName, handLocation, handsComp);
- if (uid == _playerManager.LocalPlayer?.ControlledEntity)
+ if (uid == _playerManager.LocalEntity)
OnPlayerAddHand?.Invoke(handName, handLocation);
if (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 ==
- _playerManager.LocalPlayer?.ControlledEntity)
+ _playerManager.LocalEntity)
{
OnPlayerRemoveHand?.Invoke(handName);
}
if (ent is not { } hand)
return;
- if (_playerManager.LocalPlayer?.ControlledEntity != hand.Owner)
+ if (_playerManager.LocalEntity != hand.Owner)
return;
if (hand.Comp.ActiveHand == null)
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)
{
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)));
}
}
}
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);
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);
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>();
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)
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();
public override void Shutdown()
{
- _cfgMan.UnsubValueChanged(CCVars.DragDropDeadZone, SetDeadZone);
CommandBinds.Unregister<DragDropSystem>();
base.Shutdown();
}
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))
return false;
}
- var localPlayer = _playerManager.LocalPlayer?.ControlledEntity;
+ var localPlayer = _playerManager.LocalEntity;
if (localPlayer == null || !Exists(_draggedEntity))
{
return;
}
- var user = _playerManager.LocalPlayer?.ControlledEntity;
+ var user = _playerManager.LocalEntity;
if (user == null)
return;
[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]
[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!;
<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">
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();
{
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);
}
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;
public void RequestToggleFov()
{
- if (_player.LocalPlayer?.ControlledEntity is { } player)
+ if (_player.LocalEntity is { } player)
RequestToggleFov(player);
}
/// </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;
{
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);
}
{
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;
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
}
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;
private void HighlightTargets()
{
- if (_playerManager.LocalPlayer?.ControlledEntity is not { Valid: true } player)
+ if (_playerManager.LocalEntity is not { Valid: true } player)
return;
// remove current highlights
[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";
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;
}
// 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;
{
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))
return true;
}
- var player = _playerManager.LocalPlayer?.Session;
+ var player = _playerManager.LocalSession;
if (player == null)
return true;
// 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:
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;
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)
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) ||
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");
}
[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);
{
base.FrameUpdate(frameTime);
- var player = _playerManager.LocalPlayer?.ControlledEntity;
+ var player = _playerManager.LocalEntity;
var spriteQuery = GetEntityQuery<SpriteComponent>();
var change = ChangeRate * frameTime;
/// <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)
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))
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 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;
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;
if (!_timing.IsFirstTimePredicted)
return;
- if (_player.LocalPlayer?.ControlledEntity is not EntityUid localPlayer)
+ if (_player.LocalEntity is not EntityUid localPlayer)
return;
PlayParacusiaSounds(localPlayer);
namespace Content.Client.UserInterface.Controls
{
[GenerateTypedNameReferences]
+ [Virtual]
public partial class SplitBar : BoxContainer
{
public Vector2 MinBarSize = new(24, 0);
return;
UIHelper?.Dispose();
- var ownerUserId = _playerManager.LocalPlayer!.UserId;
+ var ownerUserId = _playerManager.LocalUser!.Value;
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
UIHelper.DiscordRelayChanged(_discordRelayActive);
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)
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
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);
}
_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;
ChatInput.ChannelSelector.Select(toSelect);
}
- private void OnKeyBindDown(GUIBoundKeyEventArgs args)
+ private void OnInputKeyBindDown(GUIBoundKeyEventArgs args)
{
if (args.Function == EngineKeyFunctions.TextReleaseFocus)
{
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;
}
private void OnMobStateChanged(MobStateChangedEvent args)
{
- if (args.Target != _playerManager.LocalPlayer?.ControlledEntity)
+ if (args.Target != _playerManager.LocalEntity)
return;
UpdateOverlays(args.Target, args.Component);
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);
}
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)
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;
}
$"\"{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();
// 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;
if (_stateManager.CurrentState is not GameplayStateBase gameScreenBase)
return false;
- var player = _playerManager.LocalPlayer?.ControlledEntity;
+ var player = _playerManager.LocalEntity;
if (player == null)
return false;
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))
if (!Timing.IsFirstTimePredicted)
return;
- var entityNull = _player.LocalPlayer?.ControlledEntity;
+ var entityNull = _player.LocalEntity;
if (entityNull == null)
return;
if (!Timing.IsFirstTimePredicted)
return;
- var local = _player.LocalPlayer?.ControlledEntity;
+ var local = _player.LocalEntity;
var handUid = _hands.GetActiveHandEntity();
if (!TryComp<GrapplingGunComponent>(handUid, out var grappling))
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) ||
{
var worldHandle = args.WorldHandle;
- var player = _player.LocalPlayer?.ControlledEntity;
+ var player = _player.LocalEntity;
if (player == null ||
!_entManager.TryGetComponent<TransformComponent>(player, out var xform))
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 ||
if (!Timing.IsFirstTimePredicted)
return;
- var entityNull = _player.LocalPlayer?.ControlledEntity;
+ var entityNull = _player.LocalEntity;
if (entityNull == null || !TryComp<CombatModeComponent>(entityNull, out var combat) || !combat.IsInCombatMode)
{
[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()
var sPlayer = Server.ResolveDependency<IPlayerManager>();
Assert.That(sPlayer.Sessions.Count(), Is.EqualTo(1));
var session = sPlayer.Sessions.Single();
- Assert.That(cPlayer.LocalPlayer?.Session.UserId, Is.EqualTo(session.UserId));
+ Assert.That(cPlayer.LocalSession?.UserId, Is.EqualTo(session.UserId));
if (ticker.DummyTicker)
return;
var client = pair.Client;
var sEntMan = server.ResolveDependency<IEntityManager>();
var cEntMan = client.ResolveDependency<IEntityManager>();
- var clientSession = client.ResolveDependency<Robust.Client.Player.IPlayerManager>().LocalPlayer?.Session;
+ var clientSession = client.Session;
var serverSession = server.ResolveDependency<IPlayerManager>().Sessions.Single();
var sActionSystem = server.System<SharedActionsSystem>();
var cActionSystem = client.System<SharedActionsSystem>();
var server = pair.Server;
var client = pair.Client;
- var clientPlayerMgr = client.ResolveDependency<Robust.Client.Player.IPlayerManager>();
var clientUIMgr = client.ResolveDependency<IUserInterfaceManager>();
var clientEntManager = client.ResolveDependency<IEntityManager>();
AlertsUI clientAlertsUI = default;
await client.WaitAssertion(() =>
{
- var local = clientPlayerMgr.LocalPlayer;
+ var local = client.Session;
Assert.That(local, Is.Not.Null);
- var controlled = local.ControlledEntity;
+ var controlled = local.AttachedEntity;
#pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(controlled, Is.Not.Null);
// Making sure it exists
// Get player data
var sPlayerMan = Server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
var cPlayerMan = Client.ResolveDependency<Robust.Client.Player.IPlayerManager>();
- if (cPlayerMan.LocalPlayer?.Session == null)
+ if (Client.Session == null)
Assert.Fail("No player");
- ClientSession = cPlayerMan.LocalPlayer!.Session!;
- ServerSession = sPlayerMan.GetSessionByUserId(ClientSession.UserId);
+ ClientSession = Client.Session!;
+ ServerSession = sPlayerMan.GetSessionById(ClientSession.UserId);
// Spawn player entity & attach
EntityUid? old = default;
Assert.Multiple(() =>
{
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalEntity), Is.EqualTo(Player));
- Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(SEntMan.GetEntity(Player)));
+ Assert.That(sPlayerMan.GetSessionById(ClientSession.UserId).AttachedEntity, Is.EqualTo(SEntMan.GetEntity(Player)));
});
}
}
var transform = _sEntityManager.GetComponent<TransformComponent>(serverEntity);
- if (_sMapManager.TryGetGrid(transform.GridUid, out var grid))
+ if (_sEntityManager.TryGetComponent(transform.GridUid, out MapGridComponent? grid))
{
var position = transform.LocalPosition;
public const int TileImageSize = EyeManager.PixelsPerMeter;
private readonly ITileDefinitionManager _sTileDefinitionManager;
+ private readonly SharedMapSystem _sMapSystem;
private readonly IResourceManager _resManager;
public TilePainter(ClientIntegrationInstance client, ServerIntegrationInstance server)
{
_sTileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
_resManager = client.ResolveDependency<IResourceManager>();
+ var esm = server.ResolveDependency<IEntitySystemManager>();
+ _sMapSystem = esm.GetEntitySystem<SharedMapSystem>();
}
public void Run(Image gridCanvas, EntityUid gridUid, MapGridComponent grid)
var images = GetTileImages(_sTileDefinitionManager, _resManager, tileSize);
var i = 0;
- grid.GetAllTiles().AsParallel().ForAll(tile =>
+ _sMapSystem.GetAllTiles(gridUid, grid).AsParallel().ForAll(tile =>
{
var path = _sTileDefinitionManager[tile.Tile.TypeId].Sprite.ToString();
{
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
comp.Enabled = false;
- EntityManager.Dirty(comp);
+ EntityManager.Dirty(wire.Owner, comp);
return true;
}
if (!EntityManager.HasComponent<EmaggedComponent>(wire.Owner))
{
comp.Enabled = true;
- EntityManager.Dirty(comp);
+ EntityManager.Dirty(wire.Owner, comp);
}
return true;
}
public override void Pulse(EntityUid user, Wire wire, AccessReaderComponent comp)
{
comp.Enabled = false;
- EntityManager.Dirty(comp);
+ EntityManager.Dirty(wire.Owner, comp);
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitPulseCancel, wire));
}
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access) && !EntityManager.HasComponent<EmaggedComponent>(wire.Owner))
{
access.Enabled = true;
- EntityManager.Dirty(access);
+ EntityManager.Dirty(wire.Owner, access);
}
}
}
$"{ToPrettyString(player):player} has modified {ToPrettyString(component.TargetAccessReaderId):entity} with the following allowed access level holders: [{string.Join(", ", addedTags.Union(removedTags))}] [{string.Join(", ", newAccessList)}]");
accessReader.AccessLists = ConvertAccessListToHashSet(newAccessList);
- Dirty(accessReader);
+ Dirty(component.TargetAccessReaderId, accessReader);
}
/// <summary>
return;
}
- Dirty(access);
+ Dirty(uid, access);
if (addedLength == 1)
{
_popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-bricked", ("id", uid)), uid);
access.Tags.Clear();
- Dirty(access);
+ Dirty(uid, access);
_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(args.Microwave)} cleared access on {ToPrettyString(uid):entity}");
var random = _random.Pick(_prototypeManager.EnumeratePrototypes<AccessLevelPrototype>().ToArray());
access.Tags.Add(random.ID);
- Dirty(access);
+ Dirty(uid, access);
_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(args.Microwave)} added {random.ID} access to {ToPrettyString(uid):entity}");
if (id.JobTitle == jobTitle)
return true;
id.JobTitle = jobTitle;
- Dirty(id);
+ Dirty(uid, id);
UpdateEntityName(uid, id);
if (player != null)
if (id.FullName == fullName)
return true;
id.FullName = fullName;
- Dirty(id);
+ Dirty(uid, id);
UpdateEntityName(uid, id);
if (player != null)
[Dependency] private readonly IBanManager _bans = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
+ [Dependency] private readonly ILogManager _logManager = default!;
public override string Command => "ban";
uint minutes;
if (!Enum.TryParse(_cfg.GetCVar(CCVars.ServerBanDefaultSeverity), out NoteSeverity severity))
{
- Logger.WarningS("admin.server_ban", "Server ban severity could not be parsed from config! Defaulting to high.");
+ _logManager.GetSawmill("admin.server_ban")
+ .Warning("Server ban severity could not be parsed from config! Defaulting to high.");
severity = NoteSeverity.High;
}
using Content.Server.EUI;
using Content.Shared.Database;
using Content.Shared.Verbs;
-using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
namespace Content.Server.Administration.Notes;
-public sealed class AdminNotesSystem : EntitySystem, IPostInjectInit
+public sealed class AdminNotesSystem : EntitySystem
{
[Dependency] private readonly IConsoleHost _console = default!;
[Dependency] private readonly IAdminNotesManager _notes = default!;
- [Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly EuiManager _euis = default!;
- public const string SawmillId = "admin.notes_system";
- private ISawmill _sawmill = default!;
-
public override void Initialize()
{
SubscribeLocalEvent<GetVerbsEvent<Verb>>(AddVerbs);
if (!_playerManager.TryGetPlayerData(e.Session.UserId, out var playerData))
{
- _sawmill.Error($"Could not get player data for ID {e.Session.UserId}");
+ Log.Error($"Could not get player data for ID {e.Session.UserId}");
}
var username = playerData?.UserName ?? e.Session.UserId.ToString();
var ui = new AdminMessageEui();
_euis.OpenEui(ui, e.Session);
ui.SetMessage(message);
-
+
// Only send the message if they haven't seen it yet
_chat.DispatchServerMessage(e.Session, messageString);
}
}
}
-
- public void PostInject()
- {
- _sawmill = _logManager.GetSawmill(SawmillId);
- }
}
Task<LocatedPlayerData?> LookupIdAsync(NetUserId userId, CancellationToken cancel = default);
}
- internal sealed class PlayerLocator : IPlayerLocator, IDisposable
+ internal sealed class PlayerLocator : IPlayerLocator, IDisposable, IPostInjectInit
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IServerDbManager _db = default!;
+ [Dependency] private readonly ILogManager _logManager = default!;
private readonly HttpClient _httpClient = new();
+ private ISawmill _sawmill = default!;
public PlayerLocator()
{
if (!resp.IsSuccessStatusCode)
{
- Logger.ErrorS("PlayerLocate", "Auth server returned bad response {StatusCode}!", resp.StatusCode);
+ _sawmill.Error("Auth server returned bad response {StatusCode}!", resp.StatusCode);
return null;
}
if (responseData == null)
{
- Logger.ErrorS("PlayerLocate", "Auth server returned null response!");
+ _sawmill.Error("Auth server returned null response!");
return null;
}
if (!resp.IsSuccessStatusCode)
{
- Logger.ErrorS("PlayerLocate", "Auth server returned bad response {StatusCode}!", resp.StatusCode);
+ _sawmill.Error("Auth server returned bad response {StatusCode}!", resp.StatusCode);
return null;
}
if (responseData == null)
{
- Logger.ErrorS("PlayerLocate", "Auth server returned null response!");
+ _sawmill.Error("Auth server returned null response!");
return null;
}
{
_httpClient.Dispose();
}
+
+ void IPostInjectInit.PostInject()
+ {
+ _sawmill = _logManager.GetSawmill("PlayerLocate");
+ }
}
}
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_adminManager.OnPermsChanged += OnAdminPermsChanged;
- _config.OnValueChanged(CCVars.PanicBunkerEnabled, OnPanicBunkerChanged, true);
- _config.OnValueChanged(CCVars.PanicBunkerDisableWithAdmins, OnPanicBunkerDisableWithAdminsChanged, true);
- _config.OnValueChanged(CCVars.PanicBunkerEnableWithoutAdmins, OnPanicBunkerEnableWithoutAdminsChanged, true);
- _config.OnValueChanged(CCVars.PanicBunkerCountDeadminnedAdmins, OnPanicBunkerCountDeadminnedAdminsChanged, true);
- _config.OnValueChanged(CCVars.PanicBunkerShowReason, OnShowReasonChanged, true);
- _config.OnValueChanged(CCVars.PanicBunkerMinAccountAge, OnPanicBunkerMinAccountAgeChanged, true);
- _config.OnValueChanged(CCVars.PanicBunkerMinOverallHours, OnPanicBunkerMinOverallHoursChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerEnabled, OnPanicBunkerChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerDisableWithAdmins, OnPanicBunkerDisableWithAdminsChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerEnableWithoutAdmins, OnPanicBunkerEnableWithoutAdminsChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerCountDeadminnedAdmins, OnPanicBunkerCountDeadminnedAdminsChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerShowReason, OnShowReasonChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerMinAccountAge, OnPanicBunkerMinAccountAgeChanged, true);
+ Subs.CVar(_config, CCVars.PanicBunkerMinOverallHours, OnPanicBunkerMinOverallHoursChanged, true);
SubscribeLocalEvent<IdentityChangedEvent>(OnIdentityChanged);
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
base.Shutdown();
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
_adminManager.OnPermsChanged -= OnAdminPermsChanged;
-
- _config.UnsubValueChanged(CCVars.PanicBunkerEnabled, OnPanicBunkerChanged);
- _config.UnsubValueChanged(CCVars.PanicBunkerDisableWithAdmins, OnPanicBunkerDisableWithAdminsChanged);
- _config.UnsubValueChanged(CCVars.PanicBunkerEnableWithoutAdmins, OnPanicBunkerEnableWithoutAdminsChanged);
- _config.UnsubValueChanged(CCVars.PanicBunkerCountDeadminnedAdmins, OnPanicBunkerCountDeadminnedAdminsChanged);
- _config.UnsubValueChanged(CCVars.PanicBunkerShowReason, OnShowReasonChanged);
- _config.UnsubValueChanged(CCVars.PanicBunkerMinAccountAge, OnPanicBunkerMinAccountAgeChanged);
- _config.UnsubValueChanged(CCVars.PanicBunkerMinOverallHours, OnPanicBunkerMinOverallHoursChanged);
}
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
public override void Initialize()
{
base.Initialize();
- _config.OnValueChanged(CCVars.DiscordAHelpWebhook, OnWebhookChanged, true);
- _config.OnValueChanged(CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged, true);
- _config.OnValueChanged(CCVars.DiscordAHelpAvatar, OnAvatarChanged, true);
- _config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
- _config.OnValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
+ Subs.CVar(_config, CCVars.DiscordAHelpWebhook, OnWebhookChanged, true);
+ Subs.CVar(_config, CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged, true);
+ Subs.CVar(_config, CCVars.DiscordAHelpAvatar, OnAvatarChanged, true);
+ Subs.CVar(_config, CVars.GameHostName, OnServerNameChanged, true);
+ Subs.CVar(_config, CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_serverName = obj;
}
- public override void Shutdown()
- {
- base.Shutdown();
- _config.UnsubValueChanged(CCVars.DiscordAHelpWebhook, OnWebhookChanged);
- _config.UnsubValueChanged(CCVars.DiscordAHelpFooterIcon, OnFooterIconChanged);
- _config.UnsubValueChanged(CVars.GameHostName, OnServerNameChanged);
- _config.UnsubValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged);
- }
-
private async void OnWebhookChanged(string url)
{
_webhookUrl = url;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly IAdminManager _adminManager = default!;
+ [Dependency] private readonly ILogManager _logManager = default!;
+ private readonly ISawmill _sawmill;
private bool _isLoading;
private readonly List<(Admin a, string? lastUserName)> _admins = new List<(Admin, string? lastUserName)>();
public PermissionsEui()
{
IoCManager.InjectDependencies(this);
+ _sawmill = _logManager.GetSawmill("admin.perms");
}
public override void Opened()
if (!CanTouchRank(rank))
{
- Logger.WarningS("admin.perms", $"{Player} tried to remove higher-ranked admin rank {rank.Name}");
+ _sawmill.Warning($"{Player} tried to remove higher-ranked admin rank {rank.Name}");
return;
}
if (!CanTouchRank(rank))
{
- Logger.WarningS("admin.perms", $"{Player} tried to update higher-ranked admin rank {rank.Name}");
+ _sawmill.Warning($"{Player} tried to update higher-ranked admin rank {rank.Name}");
return;
}
if (!UserAdminFlagCheck(ur.Flags))
{
- Logger.WarningS("admin.perms", $"{Player} tried to give a rank permissions above their authorization.");
+ _sawmill.Warning($"{Player} tried to give a rank permissions above their authorization.");
return;
}
await _db.UpdateAdminRankAsync(rank);
var flagText = string.Join(' ', AdminFlagsHelper.FlagsToNames(ur.Flags).Select(f => $"+{f}"));
- Logger.InfoS("admin.perms", $"{Player} updated admin rank {rank.Name}/{flagText}.");
+ _sawmill.Info($"{Player} updated admin rank {rank.Name}/{flagText}.");
_adminManager.ReloadAdminsWithRank(ur.Id);
}
{
if (!UserAdminFlagCheck(ar.Flags))
{
- Logger.WarningS("admin.perms", $"{Player} tried to give a rank permissions above their authorization.");
+ _sawmill.Warning($"{Player} tried to give a rank permissions above their authorization.");
return;
}
await _db.AddAdminRankAsync(rank);
var flagText = string.Join(' ', AdminFlagsHelper.FlagsToNames(ar.Flags).Select(f => $"+{f}"));
- Logger.InfoS("admin.perms", $"{Player} added admin rank {rank.Name}/{flagText}.");
+ _sawmill.Info($"{Player} added admin rank {rank.Name}/{flagText}.");
}
private async Task HandleRemoveAdmin(RemoveAdmin ra)
if (!CanTouchAdmin(admin))
{
- Logger.WarningS("admin.perms", $"{Player} tried to remove higher-ranked admin {ra.UserId.ToString()}");
+ _sawmill.Warning($"{Player} tried to remove higher-ranked admin {ra.UserId.ToString()}");
return;
}
await _db.RemoveAdminAsync(ra.UserId);
var record = await _db.GetPlayerRecordByUserId(ra.UserId);
- Logger.InfoS("admin.perms", $"{Player} removed admin {record?.LastSeenUserName ?? ra.UserId.ToString()}");
+ _sawmill.Info($"{Player} removed admin {record?.LastSeenUserName ?? ra.UserId.ToString()}");
if (_playerManager.TryGetSessionById(ra.UserId, out var player))
{
if (!CanTouchAdmin(admin))
{
- Logger.WarningS("admin.perms", $"{Player} tried to modify higher-ranked admin {ua.UserId.ToString()}");
+ _sawmill.Warning($"{Player} tried to modify higher-ranked admin {ua.UserId.ToString()}");
return;
}
var title = ua.Title ?? "<no title>";
var flags = AdminFlagsHelper.PosNegFlagsText(ua.PosFlags, ua.NegFlags);
- Logger.InfoS("admin.perms", $"{Player} updated admin {name} to {title}/{rankName}/{flags}");
+ _sawmill.Info($"{Player} updated admin {name} to {title}/{rankName}/{flags}");
if (_playerManager.TryGetSessionById(ua.UserId, out var player))
{
{
// username not in DB.
// TODO: Notify user.
- Logger.WarningS("admin.perms",
- $"{Player} tried to add admin with unknown username {ca.UserNameOrId}.");
+ _sawmill.Warning($"{Player} tried to add admin with unknown username {ca.UserNameOrId}.");
return;
}
var title = ca.Title ?? "<no title>";
var flags = AdminFlagsHelper.PosNegFlagsText(ca.PosFlags, ca.NegFlags);
- Logger.InfoS("admin.perms", $"{Player} added admin {name} as {title}/{rankName}/{flags}");
+ _sawmill.Info($"{Player} added admin {name} as {title}/{rankName}/{flags}");
if (_playerManager.TryGetSessionById(userId, out var player))
{
if (!UserAdminFlagCheck(posFlags))
{
// Can't create an admin with higher perms than yourself, obviously.
- Logger.WarningS("admin.perms", $"{Player} tried to grant admin powers above their authorization.");
+ _sawmill.Warning($"{Player} tried to grant admin powers above their authorization.");
return false;
}
if (rank == null)
{
// Tried to set to nonexistent rank.
- Logger.WarningS("admin.perms", $"{Player} tried to assign nonexistent admin rank.");
+ _sawmill.Warning($"{Player} tried to assign nonexistent admin rank.");
return (true, null);
}
if (!UserAdminFlagCheck(rankFlags))
{
// Can't assign a rank with flags you don't have yourself.
- Logger.WarningS("admin.perms", $"{Player} tried to assign admin rank above their authorization.");
+ _sawmill.Warning($"{Player} tried to assign admin rank above their authorization.");
return (true, null);
}
}
[UsedImplicitly]
public sealed class SpawnExplosionEui : BaseEui
{
+ private readonly ExplosionSystem _explosionSystem;
+ private readonly ISawmill _sawmill;
+
+ public SpawnExplosionEui()
+ {
+ _explosionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ExplosionSystem>();
+ _sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("explosion");
+ }
+
public override void HandleMessage(EuiMessageBase msg)
{
base.HandleMessage(msg);
if (explosion == null)
{
- Logger.Error("Failed to generate explosion preview.");
+ _sawmill.Error("Failed to generate explosion preview.");
return;
}
{
base.Initialize();
_playerManager.PlayerStatusChanged += OnPlayerChange;
- _configManager.OnValueChanged(CCVars.AfkTime, SetAfkDelay, true);
+ Subs.CVar(_configManager, CCVars.AfkTime, SetAfkDelay, true);
SubscribeNetworkEvent<FullInputCmdMessage>(HandleInputCmd);
}
base.Shutdown();
_afkPlayers.Clear();
_playerManager.PlayerStatusChanged -= OnPlayerChange;
- _configManager.UnsubValueChanged(CCVars.AfkTime, SetAfkDelay);
}
public override void Update(float frameTime)
if (detail.Sound != null)
{
var filter = _stationSystem.GetInOwningStation(station);
- _audio.PlayGlobal(detail.Sound.GetSound(), filter, true, detail.Sound.Params);
+ _audio.PlayGlobal(detail.Sound, filter, true, detail.Sound.Params);
}
else
{
{
[UsedImplicitly]
[AdminCommand(AdminFlags.Admin)]
- public sealed class SetAlertLevelCommand : IConsoleCommand
+ public sealed class SetAlertLevelCommand : LocalizedCommands
{
- public string Command => "setalertlevel";
- public string Description => Loc.GetString("cmd-setalertlevel-desc");
- public string Help => Loc.GetString("cmd-setalertlevel-help");
+ [Dependency] private readonly IEntitySystemManager _entitySystems = default!;
- public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ public override string Command => "setalertlevel";
+
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
var levelNames = new string[] {};
var player = shell.Player;
if (player?.AttachedEntity != null)
{
- var stationUid = EntitySystem.Get<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
+ var stationUid = _entitySystems.GetEntitySystem<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
if (stationUid != null)
{
levelNames = GetStationLevelNames(stationUid.Value);
return args.Length switch
{
1 => CompletionResult.FromHintOptions(levelNames,
- Loc.GetString("cmd-setalertlevel-hint-1")),
+ LocalizationManager.GetString("cmd-setalertlevel-hint-1")),
2 => CompletionResult.FromHintOptions(CompletionHelper.Booleans,
- Loc.GetString("cmd-setalertlevel-hint-2")),
+ LocalizationManager.GetString("cmd-setalertlevel-hint-2")),
_ => CompletionResult.Empty,
};
}
- public void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 1)
{
- shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
+ shell.WriteError(LocalizationManager.GetString("shell-wrong-arguments-number"));
return;
}
var locked = false;
if (args.Length > 1 && !bool.TryParse(args[1], out locked))
{
- shell.WriteLine(Loc.GetString("shell-argument-must-be-boolean"));
+ shell.WriteLine(LocalizationManager.GetString("shell-argument-must-be-boolean"));
return;
}
var player = shell.Player;
if (player?.AttachedEntity == null)
{
- shell.WriteLine(Loc.GetString("shell-only-players-can-run-this-command"));
+ shell.WriteLine(LocalizationManager.GetString("shell-only-players-can-run-this-command"));
return;
}
- var stationUid = EntitySystem.Get<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
+ var stationUid = _entitySystems.GetEntitySystem<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
if (stationUid == null)
{
- shell.WriteLine(Loc.GetString("cmd-setalertlevel-invalid-grid"));
+ shell.WriteLine(LocalizationManager.GetString("cmd-setalertlevel-invalid-grid"));
return;
}
var levelNames = GetStationLevelNames(stationUid.Value);
if (!levelNames.Contains(level))
{
- shell.WriteLine(Loc.GetString("cmd-setalertlevel-invalid-level"));
+ shell.WriteLine(LocalizationManager.GetString("cmd-setalertlevel-invalid-level"));
return;
}
- EntitySystem.Get<AlertLevelSystem>().SetLevel(stationUid.Value, level, true, true, true, locked);
+ _entitySystems.GetEntitySystem<AlertLevelSystem>().SetLevel(stationUid.Value, level, true, true, true, locked);
}
private string[] GetStationLevelNames(EntityUid station)
using Content.Server.Explosion.EntitySystems;
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.NodeContainer.Nodes;
-using Robust.Shared.Map;
+using Robust.Server.GameObjects;
+using Robust.Shared.Map.Components;
using Robust.Shared.Random;
namespace Content.Server.Ame;
{
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
- [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
/// <summary>
var ameControllerSystem = _entMan.System<AmeControllerSystem>();
var ameShieldingSystem = _entMan.System<AmeShieldingSystem>();
+ var mapSystem = _entMan.System<MapSystem>();
var shieldQuery = _entMan.GetEntityQuery<AmeShieldComponent>();
var controllerQuery = _entMan.GetEntityQuery<AmeControllerComponent>();
continue;
if (!xformQuery.TryGetComponent(nodeOwner, out var xform))
continue;
- if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
+ if (!_entMan.TryGetComponent(xform.GridUid, out MapGridComponent? grid))
continue;
if (gridEnt == null)
else if (gridEnt != xform.GridUid)
continue;
- var nodeNeighbors = grid.GetCellsInSquareArea(xform.Coordinates, 1)
+ var nodeNeighbors = mapSystem.GetCellsInSquareArea(xform.GridUid.Value, grid, xform.Coordinates, 1)
.Where(entity => entity != nodeOwner && shieldQuery.HasComponent(entity));
if (nodeNeighbors.Count() >= 8)
private void InitializeCVars()
{
- _cfg.OnValueChanged(CCVars.SpaceWind, value => SpaceWind = value, true);
- _cfg.OnValueChanged(CCVars.SpaceWindPressureForceDivisorThrow, value => SpaceWindPressureForceDivisorThrow = value, true);
- _cfg.OnValueChanged(CCVars.SpaceWindPressureForceDivisorPush, value => SpaceWindPressureForceDivisorPush = value, true);
- _cfg.OnValueChanged(CCVars.SpaceWindMaxVelocity, value => SpaceWindMaxVelocity = value, true);
- _cfg.OnValueChanged(CCVars.SpaceWindMaxPushForce, value => SpaceWindMaxPushForce = value, true);
- _cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true);
- _cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
- _cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
- _cfg.OnValueChanged(CCVars.AtmosGridImpulse, value => GridImpulse = value, true);
- _cfg.OnValueChanged(CCVars.AtmosSpacingEscapeRatio, value => SpacingEscapeRatio = value, true);
- _cfg.OnValueChanged(CCVars.AtmosSpacingMinGas, value => SpacingMinGas = value, true);
- _cfg.OnValueChanged(CCVars.AtmosSpacingMaxWind, value => SpacingMaxWind = value, true);
- _cfg.OnValueChanged(CCVars.Superconduction, value => Superconduction = value, true);
- _cfg.OnValueChanged(CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true);
- _cfg.OnValueChanged(CCVars.AtmosTickRate, value => AtmosTickRate = value, true);
- _cfg.OnValueChanged(CCVars.AtmosSpeedup, value => Speedup = value, true);
- _cfg.OnValueChanged(CCVars.AtmosHeatScale, value => { HeatScale = value; InitializeGases(); }, true);
- _cfg.OnValueChanged(CCVars.ExcitedGroups, value => ExcitedGroups = value, true);
- _cfg.OnValueChanged(CCVars.ExcitedGroupsSpaceIsAllConsuming, value => ExcitedGroupsSpaceIsAllConsuming = value, true);
+ Subs.CVar(_cfg, CCVars.SpaceWind, value => SpaceWind = value, true);
+ Subs.CVar(_cfg, CCVars.SpaceWindPressureForceDivisorThrow, value => SpaceWindPressureForceDivisorThrow = value, true);
+ Subs.CVar(_cfg, CCVars.SpaceWindPressureForceDivisorPush, value => SpaceWindPressureForceDivisorPush = value, true);
+ Subs.CVar(_cfg, CCVars.SpaceWindMaxVelocity, value => SpaceWindMaxVelocity = value, true);
+ Subs.CVar(_cfg, CCVars.SpaceWindMaxPushForce, value => SpaceWindMaxPushForce = value, true);
+ Subs.CVar(_cfg, CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true);
+ Subs.CVar(_cfg, CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
+ Subs.CVar(_cfg, CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosGridImpulse, value => GridImpulse = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosSpacingEscapeRatio, value => SpacingEscapeRatio = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosSpacingMinGas, value => SpacingMinGas = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosSpacingMaxWind, value => SpacingMaxWind = value, true);
+ Subs.CVar(_cfg, CCVars.Superconduction, value => Superconduction = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosTickRate, value => AtmosTickRate = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosSpeedup, value => Speedup = value, true);
+ Subs.CVar(_cfg, CCVars.AtmosHeatScale, value => { HeatScale = value; InitializeGases(); }, true);
+ Subs.CVar(_cfg, CCVars.ExcitedGroups, value => ExcitedGroups = value, true);
+ Subs.CVar(_cfg, CCVars.ExcitedGroupsSpaceIsAllConsuming, value => ExcitedGroupsSpaceIsAllConsuming = value, true);
}
}
}
};
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
- _confMan.OnValueChanged(CCVars.NetGasOverlayTickRate, UpdateTickRate, true);
- _confMan.OnValueChanged(CCVars.GasOverlayThresholds, UpdateThresholds, true);
- _confMan.OnValueChanged(CVars.NetPVS, OnPvsToggle, true);
+ Subs.CVar(_confMan, CCVars.NetGasOverlayTickRate, UpdateTickRate, true);
+ Subs.CVar(_confMan, CCVars.GasOverlayThresholds, UpdateThresholds, true);
+ Subs.CVar(_confMan, CVars.NetPVS, OnPvsToggle, true);
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<GasTileOverlayComponent, ComponentStartup>(OnStartup);
{
base.Shutdown();
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
- _confMan.UnsubValueChanged(CCVars.NetGasOverlayTickRate, UpdateTickRate);
- _confMan.UnsubValueChanged(CCVars.GasOverlayThresholds, UpdateThresholds);
- _confMan.UnsubValueChanged(CVars.NetPVS, OnPvsToggle);
}
private void OnPvsToggle(bool value)
SubscribeLocalEvent<HeatExchangerComponent, AtmosDeviceUpdateEvent>(OnAtmosUpdate);
// Getting CVars is expensive, don't do it every tick
- _cfg.OnValueChanged(CCVars.SuperconductionTileLoss, CacheTileLoss, true);
- }
-
- public override void Shutdown()
- {
- base.Shutdown();
- _cfg.UnsubValueChanged(CCVars.SuperconductionTileLoss, CacheTileLoss);
+ Subs.CVar(_cfg, CCVars.SuperconductionTileLoss, CacheTileLoss, true);
}
private void CacheTileLoss(float val)
SubscribeLocalEvent<CrewManifestCartridgeComponent, CartridgeMessageEvent>(OnUiMessage);
SubscribeLocalEvent<CrewManifestCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady);
SubscribeLocalEvent<ProgramInstallationAttempt>(OnInstallationAttempt);
- _configManager.OnValueChanged(CCVars.CrewManifestUnsecure, OnCrewManifestUnsecureChanged, true);
+ Subs.CVar(_configManager, CCVars.CrewManifestUnsecure, OnCrewManifestUnsecureChanged, true);
}
/// <summary>
_cartridgeLoader.UninstallProgram(loaderUid, program.Value, comp);
}
}
-
- public override void Shutdown()
- {
- base.Shutdown();
- _configManager.UnsubValueChanged(CCVars.CrewManifestUnsecure, OnCrewManifestUnsecureChanged);
- }
}
{
base.Initialize();
CacheEmotes();
- _configurationManager.OnValueChanged(CCVars.LoocEnabled, OnLoocEnabledChanged, true);
- _configurationManager.OnValueChanged(CCVars.DeadLoocEnabled, OnDeadLoocEnabledChanged, true);
- _configurationManager.OnValueChanged(CCVars.CritLoocEnabled, OnCritLoocEnabledChanged, true);
+ Subs.CVar(_configurationManager, CCVars.LoocEnabled, OnLoocEnabledChanged, true);
+ Subs.CVar(_configurationManager, CCVars.DeadLoocEnabled, OnDeadLoocEnabledChanged, true);
+ Subs.CVar(_configurationManager, CCVars.CritLoocEnabled, OnCritLoocEnabledChanged, true);
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameChange);
}
- public override void Shutdown()
- {
- base.Shutdown();
- _configurationManager.UnsubValueChanged(CCVars.LoocEnabled, OnLoocEnabledChanged);
- _configurationManager.UnsubValueChanged(CCVars.DeadLoocEnabled, OnDeadLoocEnabledChanged);
- _configurationManager.UnsubValueChanged(CCVars.CritLoocEnabled, OnCritLoocEnabledChanged);
- }
-
private void OnLoocEnabledChanged(bool val)
{
if (_loocEnabled == val) return;
{
base.Initialize();
_xformQuery = GetEntityQuery<TransformComponent>();
- _configurationManager.OnValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged, true);
- }
-
- public override void Shutdown()
- {
- base.Shutdown();
- _configurationManager.UnsubValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged);
+ Subs.CVar(_configurationManager, CVars.NetMaxUpdateRange, OnPvsRangeChanged, true);
}
private void OnPvsRangeChanged(float value)
if (!TryComp(newEntity, out ConstructionComponent? construction))
{
- _sawmill.Error($"Initial construction does not have a valid target entity! It is missing a ConstructionComponent.\nGraph: {graph.ID}, Initial Target: {edge.Target}, Ent. Prototype: {newEntityProto}\nCreated Entity {ToPrettyString(newEntity)} will be deleted.");
+ Log.Error($"Initial construction does not have a valid target entity! It is missing a ConstructionComponent.\nGraph: {graph.ID}, Initial Target: {edge.Target}, Ent. Prototype: {newEntityProto}\nCreated Entity {ToPrettyString(newEntity)} will be deleted.");
Del(newEntity); // Screw you, make proper construction graphs.
return null;
}
{
if (!_prototypeManager.TryIndex(prototype, out ConstructionPrototype? constructionPrototype))
{
- _sawmill.Error($"Tried to start construction of invalid recipe '{prototype}'!");
+ Log.Error($"Tried to start construction of invalid recipe '{prototype}'!");
return false;
}
if (!_prototypeManager.TryIndex(constructionPrototype.Graph,
out ConstructionGraphPrototype? constructionGraph))
{
- _sawmill.Error(
+ Log.Error(
$"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{prototype}'!");
return false;
}
{
if (!_prototypeManager.TryIndex(ev.PrototypeName, out ConstructionPrototype? constructionPrototype))
{
- _sawmill.Error($"Tried to start construction of invalid recipe '{ev.PrototypeName}'!");
+ Log.Error($"Tried to start construction of invalid recipe '{ev.PrototypeName}'!");
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack));
return;
}
if (!_prototypeManager.TryIndex(constructionPrototype.Graph, out ConstructionGraphPrototype? constructionGraph))
{
- _sawmill.Error($"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{ev.PrototypeName}'!");
+ Log.Error($"Invalid construction graph '{constructionPrototype.Graph}' in recipe '{ev.PrototypeName}'!");
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack));
return;
}
if (args.SenderSession.AttachedEntity is not {Valid: true} user)
{
- _sawmill.Error($"Client sent {nameof(TryStartStructureConstructionMessage)} with no attached entity!");
+ Log.Error($"Client sent {nameof(TryStartStructureConstructionMessage)} with no attached entity!");
return;
}
if (step == null)
{
- _sawmill.Warning($"Called {nameof(HandleEdge)} on entity {ToPrettyString(uid)} but the current state is not valid for that!");
+ Log.Warning($"Called {nameof(HandleEdge)} on entity {ToPrettyString(uid)} but the current state is not valid for that!");
return HandleResult.False;
}
{
if (construction.Deleted)
{
- _sawmill.Error($"Construction component was deleted while still processing interactions." +
- $"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
- $"Next: {interaction.GetType().Name}, " +
- $"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
+ Log.Error($"Construction component was deleted while still processing interactions." +
+ $"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
+ $"Next: {interaction.GetType().Name}, " +
+ $"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
break;
}
}
catch (Exception e)
{
- _sawmill.Error($"Caught exception while processing construction queue. Entity {ToPrettyString(uid)}, graph: {construction.Graph}");
+ Log.Error($"Caught exception while processing construction queue. Entity {ToPrettyString(uid)}, graph: {construction.Graph}");
_runtimeLog.LogException(e, $"{nameof(ConstructionSystem)}.{nameof(UpdateInteractions)}");
Del(uid);
}
using Content.Server.Stack;
using Content.Shared.Construction;
using Content.Shared.DoAfter;
-using Content.Shared.Tools;
using JetBrains.Annotations;
using Robust.Server.Containers;
using Robust.Shared.Prototypes;
[UsedImplicitly]
public sealed partial class ConstructionSystem : SharedConstructionSystem
{
- [Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
- private const string SawmillName = "Construction";
- private ISawmill _sawmill = default!;
-
public override void Initialize()
{
base.Initialize();
- _sawmill = _logManager.GetSawmill(SawmillName);
-
InitializeComputer();
InitializeGraphs();
InitializeGuided();
var construction = ent.Comp;
if (GetCurrentGraph(ent, construction) is not {} graph)
{
- _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
+ Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
return;
}
if (GetNodeFromGraph(graph, construction.Node) is not {} node)
{
- _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
+ Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
return;
}
{
if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
{
- _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
+ Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
return;
}
{
if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
{
- _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
+ Log.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
return;
}
SubscribeNetworkEvent<RequestDecalRemovalEvent>(OnDecalRemovalRequest);
SubscribeLocalEvent<PostGridSplitEvent>(OnGridSplit);
- _conf.OnValueChanged(CVars.NetPVS, OnPvsToggle, true);
+ Subs.CVar(_conf, CVars.NetPVS, OnPvsToggle, true);
}
private void OnPvsToggle(bool value)
base.Shutdown();
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
- _conf.UnsubValueChanged(CVars.NetPVS, OnPvsToggle);
}
private void OnTileChanged(ref TileChangedEvent args)
using Content.Server.Explosion.Components;
using Content.Shared.Flash.Components;
-using Content.Shared.Explosion;
using Content.Shared.Interaction;
-using Content.Shared.Interaction.Events;
using Content.Shared.Throwing;
using Robust.Shared.Containers;
using Robust.Shared.Random;
using Content.Server.Weapons.Ranged.Systems;
using System.Numerics;
using Content.Shared.Explosion.Components;
-using Content.Shared.Flash.Components;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
private void SubscribeCvars()
{
- _cfg.OnValueChanged(CCVars.ExplosionTilesPerTick, SetTilesPerTick, true);
- _cfg.OnValueChanged(CCVars.ExplosionThrowLimit, SetThrowLimit, true);
- _cfg.OnValueChanged(CCVars.ExplosionSleepNodeSys, SetSleepNodeSys, true);
- _cfg.OnValueChanged(CCVars.ExplosionMaxArea, SetMaxArea, true);
- _cfg.OnValueChanged(CCVars.ExplosionMaxIterations, SetMaxIterations, true);
- _cfg.OnValueChanged(CCVars.ExplosionMaxProcessingTime, SetMaxProcessingTime, true);
- _cfg.OnValueChanged(CCVars.ExplosionIncrementalTileBreaking, SetIncrementalTileBreaking, true);
- _cfg.OnValueChanged(CCVars.ExplosionSingleTickAreaLimit, SetSingleTickAreaLimit, true);
+ Subs.CVar(_cfg, CCVars.ExplosionTilesPerTick, value => TilesPerTick = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionThrowLimit, value => ThrowLimit = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionSleepNodeSys, value => SleepNodeSys = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionMaxArea, value => MaxArea = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionMaxIterations, value => MaxIterations = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionMaxProcessingTime, value => MaxProcessingTime = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionIncrementalTileBreaking, value => IncrementalTileBreaking = value, true);
+ Subs.CVar(_cfg, CCVars.ExplosionSingleTickAreaLimit, value => SingleTickAreaLimit = value, true);
}
-
- private void UnsubscribeCvars()
- {
- _cfg.UnsubValueChanged(CCVars.ExplosionTilesPerTick, SetTilesPerTick);
- _cfg.UnsubValueChanged(CCVars.ExplosionThrowLimit, SetThrowLimit);
- _cfg.UnsubValueChanged(CCVars.ExplosionSleepNodeSys, SetSleepNodeSys);
- _cfg.UnsubValueChanged(CCVars.ExplosionMaxArea, SetMaxArea);
- _cfg.UnsubValueChanged(CCVars.ExplosionMaxIterations, SetMaxIterations);
- _cfg.UnsubValueChanged(CCVars.ExplosionMaxProcessingTime, SetMaxProcessingTime);
- _cfg.UnsubValueChanged(CCVars.ExplosionIncrementalTileBreaking, SetIncrementalTileBreaking);
- _cfg.UnsubValueChanged(CCVars.ExplosionSingleTickAreaLimit, SetSingleTickAreaLimit);
- }
-
- private void SetTilesPerTick(int value) => TilesPerTick = value;
- private void SetThrowLimit(int value) => ThrowLimit = value;
- private void SetSleepNodeSys(bool value) => SleepNodeSys = value;
- private void SetMaxArea(int value) => MaxArea = value;
- private void SetMaxIterations(int value) => MaxIterations = value;
- private void SetMaxProcessingTime(float value) => MaxProcessingTime = value;
- private void SetIncrementalTileBreaking(bool value) => IncrementalTileBreaking = value;
- private void SetSingleTickAreaLimit(int value) => SingleTickAreaLimit = value;
}
public override void Shutdown()
{
base.Shutdown();
- UnsubscribeCvars();
_nodeGroupSystem.PauseUpdating = false;
_pathfindingSystem.PauseUpdating = false;
}
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Coordinates.Helpers;
-using Content.Shared.Explosion.Components.OnTrigger;
-using Content.Shared.Explosion.EntitySystems;
using Content.Shared.Maps;
using Robust.Shared.Map;
using Content.Shared.Charges.Systems;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Flash;
-using Content.Shared.Flash.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
-using Robust.Shared.Player;
using Robust.Shared.Timing;
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
private void InitializeCVars()
{
- _configurationManager.OnValueChanged(CCVars.GameLobbyEnabled, value =>
+ Subs.CVar(_configurationManager, CCVars.GameLobbyEnabled, value =>
{
LobbyEnabled = value;
foreach (var (userId, status) in _playerGameStatuses)
LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
}
}, true);
- _configurationManager.OnValueChanged(CCVars.GameDummyTicker, value => DummyTicker = value, true);
- _configurationManager.OnValueChanged(CCVars.GameLobbyDuration, value => LobbyDuration = TimeSpan.FromSeconds(value), true);
- _configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins,
+ Subs.CVar(_configurationManager, CCVars.GameDummyTicker, value => DummyTicker = value, true);
+ Subs.CVar(_configurationManager, CCVars.GameLobbyDuration, value => LobbyDuration = TimeSpan.FromSeconds(value), true);
+ Subs.CVar(_configurationManager, CCVars.GameDisallowLateJoins,
value => { DisallowLateJoin = value; UpdateLateJoinStatus(); }, true);
- _configurationManager.OnValueChanged(CCVars.AdminLogsServerName, value =>
+ Subs.CVar(_configurationManager, CCVars.AdminLogsServerName, value =>
{
// TODO why tf is the server name on admin logs
ServerName = value;
}, true);
- _configurationManager.OnValueChanged(CCVars.DiscordRoundUpdateWebhook, value =>
+ Subs.CVar(_configurationManager, CCVars.DiscordRoundUpdateWebhook, value =>
{
if (!string.IsNullOrWhiteSpace(value))
{
_discord.GetWebhook(value, data => _webhookIdentifier = data.ToIdentifier());
}
}, true);
- _configurationManager.OnValueChanged(CCVars.DiscordRoundEndRoleWebhook, value =>
+ Subs.CVar(_configurationManager, CCVars.DiscordRoundEndRoleWebhook, value =>
{
DiscordRoundEndRole = value;
}
}, true);
#if EXCEPTION_TOLERANCE
- _configurationManager.OnValueChanged(CCVars.RoundStartFailShutdownCount, value => RoundStartFailShutdownCount = value, true);
+ Subs.CVar(_configurationManager, CCVars.RoundStartFailShutdownCount, value => RoundStartFailShutdownCount = value, true);
#endif
}
}
{
if (job == null)
{
- var playerSession = _playerManager.GetSessionByUserId(netUser);
+ var playerSession = _playerManager.GetSessionById(netUser);
_chatManager.DispatchServerMessage(playerSession, Loc.GetString("job-not-available-wait-in-lobby"));
}
else
if (job == null)
continue;
- SpawnPlayer(_playerManager.GetSessionByUserId(player), profiles[player], station, job, false);
+ SpawnPlayer(_playerManager.GetSessionById(player), profiles[player], station, job, false);
}
RefreshLateJoinAllowed();
// Allow rules to add roles to players who have been spawned in. (For example, on-station traitors)
- RaiseLocalEvent(new RulePlayerJobsAssignedEvent(assignedJobs.Keys.Select(x => _playerManager.GetSessionByUserId(x)).ToArray(), profiles, force));
+ RaiseLocalEvent(new RulePlayerJobsAssignedEvent(assignedJobs.Keys.Select(x => _playerManager.GetSessionById(x)).ToArray(), profiles, force));
}
private void SpawnPlayer(ICommonSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
public override void Initialize()
{
- _configManager.OnValueChanged(CCVars.HolidaysEnabled, OnHolidaysEnableChange);
+ Subs.CVar(_configManager, CCVars.HolidaysEnabled, OnHolidaysEnableChange);
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRunLevelChanged);
SubscribeLocalEvent<HolidayVisualsComponent, ComponentInit>(OnVisualsInit);
}
using Content.Shared.Info;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
-using Robust.Shared.Log;
namespace Content.Server.Info;
SubscribeNetworkEvent<RequestRulesMessage>(OnRequestRules);
}
- protected void OnRequestRules(RequestRulesMessage message, EntitySessionEventArgs eventArgs)
+ private void OnRequestRules(RequestRulesMessage message, EntitySessionEventArgs eventArgs)
{
- Logger.DebugS("info", "Client requested rules.");
+ Log.Debug("info", "Client requested rules.");
var title = Loc.GetString(_cfg.GetCVar(CCVars.RulesHeader));
var path = _cfg.GetCVar(CCVars.RulesFile);
var rules = "Server could not read its rules.";
}
catch (Exception)
{
- Logger.ErrorS("info", "Could not read server rules file.");
+ Log.Debug("info", "Could not read server rules file.");
}
var response = new RulesMessage(title, rules);
RaiseNetworkEvent(response, eventArgs.SenderSession.Channel);
var message = new SharedRulesManager.ShowRulesPopupMessage();
message.PopupTime = seconds;
- var player = IoCManager.Resolve<IPlayerManager>().GetSessionByUserId(located.UserId);
+ var player = IoCManager.Resolve<IPlayerManager>().GetSessionById(located.UserId);
netManager.ServerSendMessage(message, player.Channel);
}
}
private void InitializeCVars()
{
- _cfg.OnValueChanged(CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged, true);
- _cfg.OnValueChanged(CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged, true);
- _cfg.OnValueChanged(CCVars.MaxMidiBatchesDropped, OnMaxMidiBatchesDroppedChanged, true);
- _cfg.OnValueChanged(CCVars.MaxMidiLaggedBatches, OnMaxMidiLaggedBatchesChanged, true);
- }
-
- private void ShutdownCVars()
- {
- _cfg.UnsubValueChanged(CCVars.MaxMidiEventsPerSecond, OnMaxMidiEventsPerSecondChanged);
- _cfg.UnsubValueChanged(CCVars.MaxMidiEventsPerBatch, OnMaxMidiEventsPerBatchChanged);
- _cfg.UnsubValueChanged(CCVars.MaxMidiBatchesDropped, OnMaxMidiBatchesDroppedChanged);
- _cfg.UnsubValueChanged(CCVars.MaxMidiLaggedBatches, OnMaxMidiLaggedBatchesChanged);
- }
-
- private void OnMaxMidiLaggedBatchesChanged(int obj)
- {
- MaxMidiLaggedBatches = obj;
- }
-
- private void OnMaxMidiBatchesDroppedChanged(int obj)
- {
- MaxMidiBatchesDropped = obj;
- }
-
- private void OnMaxMidiEventsPerBatchChanged(int obj)
- {
- MaxMidiEventsPerBatch = obj;
- }
-
- private void OnMaxMidiEventsPerSecondChanged(int obj)
- {
- MaxMidiEventsPerSecond = obj;
+ Subs.CVar(_cfg, CCVars.MaxMidiEventsPerSecond, obj => MaxMidiEventsPerSecond = obj, true);
+ Subs.CVar(_cfg, CCVars.MaxMidiEventsPerBatch, obj => MaxMidiEventsPerBatch = obj, true);
+ Subs.CVar(_cfg, CCVars.MaxMidiBatchesDropped, obj => MaxMidiBatchesDropped = obj, true);
+ Subs.CVar(_cfg, CCVars.MaxMidiLaggedBatches, obj => MaxMidiLaggedBatches = obj, true);
}
}
Dirty(uid, instrument);
}
- public override void Shutdown()
- {
- base.Shutdown();
-
- ShutdownCVars();
- }
-
private void OnBoundUIClosed(EntityUid uid, InstrumentComponent component, BoundUIClosedEvent args)
{
if (HasComp<ActiveInstrumentComponent>(uid)
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Timing;
-using Content.Shared.DoAfter;
-using Content.Server.Emp;
-using Content.Server.DeviceLinking.Events;
-using Content.Server.DeviceLinking.Systems;
-using Content.Shared.Inventory;
using Robust.Shared.Audio.Systems;
namespace Content.Server.Light.EntitySystems
ToggleAutosaveCommand);
_sawmill = Logger.GetSawmill("autosave");
- _cfg.OnValueChanged(CCVars.AutosaveEnabled, SetAutosaveEnabled, true);
- }
-
- public override void Shutdown()
- {
- base.Shutdown();
-
- _cfg.UnsubValueChanged(CCVars.AutosaveEnabled, SetAutosaveEnabled);
+ Subs.CVar(_cfg, CCVars.AutosaveEnabled, SetAutosaveEnabled, true);
}
private void SetAutosaveEnabled(bool b)
using Content.Shared.MassMedia.Systems;
using Content.Shared.PDA;
using Robust.Server.GameObjects;
-using System.Linq;
-using Content.Server.Administration.Logs;
-using Content.Server.CartridgeLoader.Cartridges;
-using Content.Shared.CartridgeLoader;
-using Content.Shared.CartridgeLoader.Cartridges;
-using Content.Server.CartridgeLoader;
-using Content.Server.GameTicking;
using Robust.Shared.Timing;
-using Content.Server.Popups;
-using Content.Server.StationRecords.Systems;
-using Content.Shared.Database;
-using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Player;
-using Robust.Shared.Timing;
namespace Content.Server.MassMedia.Systems;
return false;
}
- public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out ICommonSession? session)
- {
- session = null;
- return TryComp(mindId, out MindComponent? mind) && (session = mind.Session) != null;
- }
-
public ICommonSession? GetSession(MindComponent mind)
{
return mind.Session;
var position = Deleted(mind.OwnedEntity)
? _gameTicker.GetObserverSpawnPoint().ToMap(EntityManager, _transform)
- : Transform(mind.OwnedEntity.Value).MapPosition;
+ : _transform.GetMapCoordinates(mind.OwnedEntity.Value);
entity = Spawn(GameTicker.ObserverPrototypeName, position);
component = EnsureComp<MindContainerComponent>(entity.Value);
public override void Initialize()
{
base.Initialize();
- _configurationManager.OnValueChanged(CCVars.MOTD, OnMOTDChanged, invokeImmediately: true);
+ Subs.CVar(_configurationManager, CCVars.MOTD, OnMOTDChanged, invokeImmediately: true);
SubscribeLocalEvent<PlayerJoinedLobbyEvent>(OnPlayerJoinedLobby);
}
- public override void Shutdown()
- {
- _configurationManager.UnsubValueChanged(CCVars.MOTD, OnMOTDChanged);
- base.Shutdown();
- }
-
/// <summary>
/// Sends the Message Of The Day, if any, to all connected players.
/// </summary>
using System.Numerics;
using Content.Server.NPC.Components;
-using Content.Server.NPC.Events;
using Content.Shared.CombatMode;
using Content.Shared.NPC;
-using Content.Shared.NPC;
-using Content.Shared.Weapons.Melee;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Random;
}
UpdatesBefore.Add(typeof(SharedPhysicsSystem));
- _configManager.OnValueChanged(CCVars.NPCEnabled, SetNPCEnabled, true);
- _configManager.OnValueChanged(CCVars.NPCPathfinding, SetNPCPathfinding, true);
+ Subs.CVar(_configManager, CCVars.NPCEnabled, SetNPCEnabled, true);
+ Subs.CVar(_configManager, CCVars.NPCPathfinding, SetNPCPathfinding, true);
SubscribeLocalEvent<NPCSteeringComponent, ComponentShutdown>(OnSteeringShutdown);
SubscribeLocalEvent<NPCSteeringComponent, EntityUnpausedEvent>(OnSteeringUnpaused);
}
}
- public override void Shutdown()
- {
- base.Shutdown();
- _configManager.UnsubValueChanged(CCVars.NPCEnabled, SetNPCEnabled);
- _configManager.UnsubValueChanged(CCVars.NPCPathfinding, SetNPCPathfinding);
- }
-
private void OnDebugRequest(RequestNPCSteeringDebugEvent msg, EntitySessionEventArgs args)
{
if (!_admin.IsAdmin(args.SenderSession))
{
base.Initialize();
- _configurationManager.OnValueChanged(CCVars.NPCEnabled, SetEnabled, true);
- _configurationManager.OnValueChanged(CCVars.NPCMaxUpdates, SetMaxUpdates, true);
+ Subs.CVar(_configurationManager, CCVars.NPCEnabled, value => Enabled = value, true);
+ Subs.CVar(_configurationManager, CCVars.NPCMaxUpdates, obj => _maxUpdates = obj, true);
}
public void OnPlayerNPCAttach(EntityUid uid, HTNComponent component, PlayerAttachedEvent args)
WakeNPC(uid, component);
}
- private void SetMaxUpdates(int obj) => _maxUpdates = obj;
- private void SetEnabled(bool value) => Enabled = value;
-
- public override void Shutdown()
- {
- base.Shutdown();
- _configurationManager.UnsubValueChanged(CCVars.NPCEnabled, SetEnabled);
- _configurationManager.UnsubValueChanged(CCVars.NPCMaxUpdates, SetMaxUpdates);
- }
-
public void OnNPCMapInit(EntityUid uid, HTNComponent component, MapInitEvent args)
{
component.Blackboard.SetValue(NPCBlackboard.Owner, uid);
if (!Resolve(mindId, ref mind))
return false;
- foreach (var objective in mind.AllObjectives)
+ foreach (var objective in mind.Objectives)
{
if (Prototype(objective)?.ID == proto)
return true;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
-using System.Linq;
using Robust.Server.Audio;
namespace Content.Server.PDA.Ringer
SubscribeLocalEvent<BiomeComponent, MapInitEvent>(OnBiomeMapInit);
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
SubscribeLocalEvent<ShuttleFlattenEvent>(OnShuttleFlatten);
- _configManager.OnValueChanged(CVars.NetMaxUpdateRange, SetLoadRange, true);
+ Subs.CVar(_configManager, CVars.NetMaxUpdateRange, SetLoadRange, true);
InitializeCommands();
SubscribeLocalEvent<PrototypesReloadedEventArgs>(ProtoReload);
}
- public override void Shutdown()
- {
- base.Shutdown();
- _configManager.UnsubValueChanged(CVars.NetMaxUpdateRange, SetLoadRange);
- }
-
private void ProtoReload(PrototypesReloadedEventArgs obj)
{
if (!obj.ByType.TryGetValue(typeof(BiomeTemplatePrototype), out var reloads))
SubscribeLocalEvent<FTLCompletedEvent>(OnLocateTarget);
}
- public bool TogglePinpointer(EntityUid uid, PinpointerComponent? pinpointer = null)
+ public override bool TogglePinpointer(EntityUid uid, PinpointerComponent? pinpointer = null)
{
if (!Resolve(uid, ref pinpointer))
return false;
}
/// <summary>
- /// Set pinpointers target to track
+ /// Update direction from pinpointer to selected target (if it was set)
/// </summary>
- public void SetTarget(EntityUid uid, EntityUid? target, PinpointerComponent? pinpointer = null)
+ protected override void UpdateDirectionToTarget(EntityUid uid, PinpointerComponent? pinpointer = null)
{
if (!Resolve(uid, ref pinpointer))
return;
- if (pinpointer.Target == target)
- return;
-
- pinpointer.Target = target;
- if (pinpointer.IsActive)
- UpdateDirectionToTarget(uid, pinpointer);
- }
-
- /// <summary>
- /// Update direction from pinpointer to selected target (if it was set)
- /// </summary>
- private void UpdateDirectionToTarget(EntityUid uid, PinpointerComponent pinpointer)
- {
if (!pinpointer.IsActive)
return;
private void SubscribeCvars()
{
- _cfg.OnValueChanged(CCVars.RadiationMinIntensity, SetMinRadiationIntensity, true);
- _cfg.OnValueChanged(CCVars.RadiationGridcastUpdateRate, SetGridcastUpdateRate, true);
- _cfg.OnValueChanged(CCVars.RadiationGridcastSimplifiedSameGrid, SetGridcastSimplifiedSameGrid, true);
- _cfg.OnValueChanged(CCVars.RadiationGridcastMaxDistance, SetGridcastMaxDistance, true);
- }
-
- private void UnsubscribeCvars()
- {
- _cfg.UnsubValueChanged(CCVars.RadiationMinIntensity, SetMinRadiationIntensity);
- _cfg.UnsubValueChanged(CCVars.RadiationGridcastUpdateRate, SetGridcastUpdateRate);
- _cfg.UnsubValueChanged(CCVars.RadiationGridcastSimplifiedSameGrid, SetGridcastSimplifiedSameGrid);
- _cfg.UnsubValueChanged(CCVars.RadiationGridcastMaxDistance, SetGridcastMaxDistance);
- }
-
- private void SetMinRadiationIntensity(float radiationMinIntensity)
- {
- MinIntensity = radiationMinIntensity;
- }
-
- private void SetGridcastUpdateRate(float updateRate)
- {
- GridcastUpdateRate = updateRate;
- }
-
- private void SetGridcastSimplifiedSameGrid(bool simplifiedSameGrid)
- {
- GridcastSimplifiedSameGrid = simplifiedSameGrid;
- }
-
- private void SetGridcastMaxDistance(float maxDistance)
- {
- GridcastMaxDistance = maxDistance;
+ Subs.CVar(_cfg, CCVars.RadiationMinIntensity, radiationMinIntensity => MinIntensity = radiationMinIntensity, true);
+ Subs.CVar(_cfg, CCVars.RadiationGridcastUpdateRate, updateRate => GridcastUpdateRate = updateRate, true);
+ Subs.CVar(_cfg, CCVars.RadiationGridcastSimplifiedSameGrid, simplifiedSameGrid => GridcastSimplifiedSameGrid = simplifiedSameGrid, true);
+ Subs.CVar(_cfg, CCVars.RadiationGridcastMaxDistance, maxDistance => GridcastMaxDistance = maxDistance, true);
}
}
InitRadBlocking();
}
- public override void Shutdown()
- {
- base.Shutdown();
- UnsubscribeCvars();
- }
-
public override void Update(float frameTime)
{
base.Update(frameTime);
-using Robust.Shared.Reflection;
-using Robust.Shared.Serialization;
+using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Server.RandomAppearance;
[RegisterComponent]
[Access(typeof(RandomAppearanceSystem))]
-public sealed partial class RandomAppearanceComponent : Component, ISerializationHooks
+public sealed partial class RandomAppearanceComponent : Component
{
[DataField("spriteStates")]
public string[] SpriteStates = { "0", "1", "2", "3", "4" };
/// <summary>
/// What appearance enum key should be set to the random sprite state?
/// </summary>
- [DataField("key", required: true)]
- public string EnumKeyRaw = default!;
-
- /// <summary>
- /// The actual enum after reflection.
- /// </summary>
+ [DataField(required: true, customTypeSerializer: typeof(EnumSerializer))]
public Enum? EnumKey;
-
- void ISerializationHooks.AfterDeserialization()
- {
- if (IoCManager.Resolve<IReflectionManager>().TryParseEnumReference(EnumKeyRaw, out var @enum))
- {
- EnumKey = @enum;
- }
- else
- {
- Logger.Error($"RandomAppearance enum key {EnumKeyRaw} could not be parsed!");
- }
- }
}
SubscribeLocalEvent<SalvageStructureComponent, ExaminedEvent>(OnStructureExamine);
_cooldown = _configurationManager.GetCVar(CCVars.SalvageExpeditionCooldown);
- _configurationManager.OnValueChanged(CCVars.SalvageExpeditionCooldown, SetCooldownChange);
+ Subs.CVar(_configurationManager, CCVars.SalvageExpeditionCooldown, SetCooldownChange);
}
private void OnExpeditionGetState(EntityUid uid, SalvageExpeditionComponent component, ref ComponentGetState args)
};
}
- private void ShutdownExpeditions()
- {
- _configurationManager.UnsubValueChanged(CCVars.SalvageExpeditionCooldown, SetCooldownChange);
- }
-
private void SetCooldownChange(float obj)
{
// Update the active cooldowns if we change it.
InitializeRunner();
}
- public override void Shutdown()
- {
- base.Shutdown();
- ShutdownExpeditions();
- }
-
private void Report(EntityUid source, string channelName, string messageKey, params (string, object)[] args)
{
var message = args.Length == 0 ? Loc.GetString(messageKey) : Loc.GetString(messageKey, args);
// Don't invoke immediately as it will get set in the natural course of things.
Enabled = _cfgManager.GetCVar(CCVars.ArrivalsShuttles);
- _cfgManager.OnValueChanged(CCVars.ArrivalsShuttles, SetArrivals);
+ Subs.CVar(_cfgManager, CCVars.ArrivalsShuttles, SetArrivals);
// Command so admins can set these for funsies
_console.RegisterCommand("arrivals", ArrivalsCommand, ArrivalsCompletion);
}
}
- public override void Shutdown()
- {
- base.Shutdown();
- _cfgManager.UnsubValueChanged(CCVars.ArrivalsShuttles, SetArrivals);
- }
-
/// <summary>
/// First sends shuttle timer data, then kicks people off the shuttle if it isn't leaving the arrivals terminal
/// </summary>
private void InitializeEmergencyConsole()
{
- _configManager.OnValueChanged(CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime, true);
- _configManager.OnValueChanged(CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime, true);
- _configManager.OnValueChanged(CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime, true);
+ Subs.CVar(_configManager, CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime, true);
+ Subs.CVar(_configManager, CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime, true);
+ Subs.CVar(_configManager, CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime, true);
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, ComponentStartup>(OnEmergencyStartup);
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, EmergencyShuttleAuthorizeMessage>(OnEmergencyAuthorize);
SubscribeLocalEvent<EmergencyShuttleConsoleComponent, EmergencyShuttleRepealMessage>(OnEmergencyRepeal);
MaximumTransitTime = Math.Max(MinimumTransitTime, obj);
}
- private void ShutdownEmergencyConsole()
- {
- _configManager.UnsubValueChanged(CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime);
- _configManager.UnsubValueChanged(CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime);
- _configManager.UnsubValueChanged(CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime);
- }
-
private void OnEmergencyStartup(EntityUid uid, EmergencyShuttleConsoleComponent component, ComponentStartup args)
{
UpdateConsoleState(uid, component);
_sawmill = Logger.GetSawmill("shuttle.emergency");
_emergencyShuttleEnabled = _configManager.GetCVar(CCVars.EmergencyShuttleEnabled);
// Don't immediately invoke as roundstart will just handle it.
- _configManager.OnValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled);
+ Subs.CVar(_configManager, CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled);
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
SubscribeLocalEvent<StationEmergencyShuttleComponent, ComponentStartup>(OnStationStartup);
UpdateEmergencyConsole(frameTime);
}
- public override void Shutdown()
- {
- _configManager.UnsubValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled);
- ShutdownEmergencyConsole();
- }
-
/// <summary>
/// If the client is requesting debug info on where an emergency shuttle would dock.
/// </summary>
SubscribeLocalEvent<GridFillComponent, MapInitEvent>(OnGridFillMapInit);
- _cfg.OnValueChanged(CCVars.GridFill, OnGridFillChange);
- }
-
- private void ShutdownGridFills()
- {
- _cfg.UnsubValueChanged(CCVars.GridFill, OnGridFillChange);
+ Subs.CVar(_cfg, CCVars.GridFill, OnGridFillChange);
}
private void OnGridFillChange(bool obj)
SubscribeLocalEvent<FixturesComponent, GridFixtureChangeEvent>(OnGridFixtureChange);
}
- public override void Shutdown()
- {
- base.Shutdown();
- ShutdownGridFills();
- }
-
-
public override void Update(float frameTime)
{
base.Update(frameTime);
SubscribeLocalEvent<StationJobsComponent, StationRenamedEvent>(OnStationRenamed);
SubscribeLocalEvent<StationJobsComponent, ComponentShutdown>(OnStationDeletion);
SubscribeLocalEvent<PlayerJoinedLobbyEvent>(OnPlayerJoinedLobby);
- _configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins, _ => UpdateJobsAvailable(), true);
+ Subs.CVar(_configurationManager, CCVars.GameDisallowLateJoins, _ => UpdateJobsAvailable(), true);
}
public override void Update(float _)
/// <inheritdoc/>
public override void Initialize()
{
- _configurationManager.OnValueChanged(CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
+ Subs.CVar(_configurationManager, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
_spawnerCallbacks = new Dictionary<SpawnPriorityPreference, Action<PlayerSpawningEvent>>()
{
SubscribeLocalEvent<StationMemberComponent, ComponentShutdown>(OnStationGridDeleted);
SubscribeLocalEvent<StationMemberComponent, PostGridSplitEvent>(OnStationSplitEvent);
- _configurationManager.OnValueChanged(CCVars.StationOffset, x => _randomStationOffset = x, true);
- _configurationManager.OnValueChanged(CCVars.MaxStationOffset, x => _maxRandomStationOffset = x, true);
- _configurationManager.OnValueChanged(CCVars.StationRotation, x => _randomStationRotation = x, true);
+ Subs.CVar(_configurationManager, CCVars.StationOffset, x => _randomStationOffset = x, true);
+ Subs.CVar(_configurationManager, CCVars.MaxStationOffset, x => _maxRandomStationOffset = x, true);
+ Subs.CVar(_configurationManager, CCVars.StationRotation, x => _randomStationRotation = x, true);
_player.PlayerStatusChanged += OnPlayerStatusChanged;
}
_sawmill = Logger.GetSawmill("events");
- _configurationManager.OnValueChanged(CCVars.EventsEnabled, SetEnabled, true);
+ Subs.CVar(_configurationManager, CCVars.EventsEnabled, SetEnabled, true);
SubscribeLocalEvent<StationEventComponent, EntityUnpausedEvent>(OnUnpaused);
}
component.EndTime = component.EndTime.Value + args.PausedTime;
}
- public override void Shutdown()
- {
- base.Shutdown();
- _configurationManager.UnsubValueChanged(CCVars.EventsEnabled, SetEnabled);
- }
-
/// <summary>
/// Randomly runs a valid event.
/// </summary>
using Content.Server.Storage.Components;
using Content.Shared.Audio;
using Content.Shared.Storage.Components;
-using Robust.Shared.Audio;
-using Robust.Shared.Player;
using Robust.Shared.Random;
-using System.Linq;
-using Content.Shared.Storage.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
-using Content.Server.Humanoid;
using Content.Shared.Humanoid;
using Content.Shared.Store;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
-using Content.Shared.Humanoid;
namespace Content.Server.Store.Conditions;
base.Initialize();
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
- _cfg.OnValueChanged(CCVars.TipFrequencyOutOfRound, SetOutOfRound, true);
- _cfg.OnValueChanged(CCVars.TipFrequencyInRound, SetInRound, true);
- _cfg.OnValueChanged(CCVars.TipsEnabled, SetEnabled, true);
- _cfg.OnValueChanged(CCVars.TipsDataset, SetDataset, true);
+ Subs.CVar(_cfg, CCVars.TipFrequencyOutOfRound, SetOutOfRound, true);
+ Subs.CVar(_cfg, CCVars.TipFrequencyInRound, SetInRound, true);
+ Subs.CVar(_cfg, CCVars.TipsEnabled, SetEnabled, true);
+ Subs.CVar(_cfg, CCVars.TipsDataset, SetDataset, true);
RecalculateNextTipTime();
}
using Robust.Shared.Player;
-using Robust.Shared.Reflection;
-using Robust.Shared.Serialization;
+using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Server.UserInterface
{
[RegisterComponent]
- public sealed partial class ActivatableUIComponent : Component,
- ISerializationHooks
+ public sealed partial class ActivatableUIComponent : Component
{
- [ViewVariables]
+ [DataField(required: true, customTypeSerializer:typeof(EnumSerializer))]
public Enum? Key { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public bool AdminOnly { get; set; } = false;
- [DataField("key", required: true)]
- private string _keyRaw = default!;
-
[DataField]
public LocId VerbText = "ui-verb-toggle-open";
/// </summary>
[ViewVariables]
public ICommonSession? CurrentSingleUser;
-
- void ISerializationHooks.AfterDeserialization()
- {
- var reflectionManager = IoCManager.Resolve<IReflectionManager>();
- if (reflectionManager.TryParseEnumReference(_keyRaw, out var key))
- Key = key;
- }
}
}
{
SubscribeLocalEvent<RoundStartingEvent>(OnLoadingMaps);
_conHost.RegisterCommand("applyworldgenconfig", Loc.GetString("cmd-applyworldgenconfig-description"), Loc.GetString("cmd-applyworldgenconfig-help"), ApplyWorldgenConfigCommand);
- _cfg.OnValueChanged(CCVars.WorldgenEnabled, b => _enabled = b, true);
- _cfg.OnValueChanged(CCVars.WorldgenConfig, s => _worldgenConfig = s, true);
+ Subs.CVar(_cfg, CCVars.WorldgenEnabled, b => _enabled = b, true);
+ Subs.CVar(_cfg, CCVars.WorldgenConfig, s => _worldgenConfig = s, true);
}
[AdminCommand(AdminFlags.Mapping)]
continue;
component.Tags.UnionWith(proto.Tags);
- Dirty(component);
+ Dirty(uid, component);
}
}
access.Tags.Clear();
access.Tags.UnionWith(newTags);
- Dirty(access);
+ Dirty(uid, access);
return true;
}
access.Tags.UnionWith(proto.Tags);
}
- Dirty(access);
+ Dirty(uid, access);
return true;
}
access.Tags.Clear();
access.Tags.UnionWith(prototype.Access);
- Dirty(access);
+ Dirty(uid, access);
TryAddGroups(uid, prototype.AccessGroups, access);
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
- [Dependency] private readonly MetaDataSystem _metaData = default!;
public override void Initialize()
{
using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Alert
/// An alert popup with associated icon, tooltip, and other data.
/// </summary>
[Prototype("alert")]
- public sealed partial class AlertPrototype : IPrototype, ISerializationHooks
+ public sealed partial class AlertPrototype : IPrototype
{
[ViewVariables]
string IPrototype.ID => AlertType.ToString();
/// Key which is unique w.r.t category semantics (alerts with same category have equal keys,
/// alerts with no category have different keys).
/// </summary>
- public AlertKey AlertKey { get; private set; }
+ public AlertKey AlertKey => new(AlertType, Category);
/// <summary>
/// -1 (no effect) unless MaxSeverity is specified. Defaults to 1. Minimum severity level supported by this state.
[DataField("onClick", serverOnly: true)]
public IAlertClick? OnClick { get; private set; }
- void ISerializationHooks.AfterDeserialization()
- {
- if (AlertType == AlertType.Error)
- {
- Logger.ErrorS("alert", "missing or invalid alertType for alert with name {0}", Name);
- }
-
- AlertKey = new AlertKey(AlertType, Category);
- }
-
/// <param name="severity">severity level, if supported by this alert</param>
/// <returns>the icon path to the texture for the provided severity level</returns>
public SpriteSpecifier GetIcon(short? severity = null)
using Content.Shared.Throwing;
using Robust.Shared.Map;
using Content.Shared.Physics;
+using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
namespace Content.Shared.Anomaly.Effects;
public abstract class SharedGravityAnomalySystem : EntitySystem
{
- [Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!;
+ [Dependency] private readonly SharedMapSystem _mapSystem = default!;
/// <inheritdoc/>
public override void Initialize()
private void OnSupercritical(EntityUid uid, GravityAnomalyComponent component, ref AnomalySupercriticalEvent args)
{
var xform = Transform(uid);
- if (!_map.TryGetGrid(xform.GridUid, out var grid))
+ if (!TryComp(xform.GridUid, out MapGridComponent? grid))
return;
var worldPos = _xform.GetWorldPosition(xform);
- var tileref = grid.GetTilesIntersecting(new Circle(worldPos, component.SpaceRange)).ToArray();
+ var tileref = _mapSystem.GetTilesIntersecting(
+ xform.GridUid.Value,
+ grid,
+ new Circle(worldPos, component.SpaceRange))
+ .ToArray();
+
var tiles = tileref.Select(t => (t.GridIndices, Tile.Empty)).ToList();
- grid.SetTiles(tiles);
+ _mapSystem.SetTiles(xform.GridUid.Value, grid, tiles);
var range = component.MaxThrowRange * 2;
var strength = component.MaxThrowStrength * 2;
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] protected readonly IRobustRandom Random = default!;
- [Dependency] protected readonly ISharedAdminLogManager Log = default!;
+ [Dependency] protected readonly ISharedAdminLogManager AdminLog = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
private void OnAnomalyUnpause(EntityUid uid, AnomalyComponent component, ref EntityUnpausedEvent args)
{
component.NextPulseTime += args.PausedTime;
- Dirty(component);
+ Dirty(uid, component);
}
private void OnPulsingUnpause(EntityUid uid, AnomalyPulsingComponent component, ref EntityUnpausedEvent args)
private void OnSupercriticalUnpause(EntityUid uid, AnomalySupercriticalComponent component, ref EntityUnpausedEvent args)
{
component.EndTime += args.PausedTime;
- Dirty(component);
+ Dirty(uid, component);
}
public void DoAnomalyPulse(EntityUid uid, AnomalyComponent? component = null)
var stability = Random.NextFloat(minStability, maxStability);
ChangeAnomalyStability(uid, stability, component);
- Log.Add(LogType.Anomaly, LogImpact.Medium, $"Anomaly {ToPrettyString(uid)} pulsed with severity {component.Severity}.");
+ AdminLog.Add(LogType.Anomaly, LogImpact.Medium, $"Anomaly {ToPrettyString(uid)} pulsed with severity {component.Severity}.");
if (_net.IsServer)
Audio.PlayPvs(component.PulseSound, uid);
if (HasComp<AnomalySupercriticalComponent>(uid))
return;
- Log.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(uid)} began to go supercritical.");
+ AdminLog.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(uid)} began to go supercritical.");
if (_net.IsServer)
_sawmill.Info($"Anomaly is going supercritical. Entity: {ToPrettyString(uid)}");
- var super = EnsureComp<AnomalySupercriticalComponent>(uid);
+ var super = AddComp<AnomalySupercriticalComponent>(uid);
super.EndTime = Timing.CurTime + super.SupercriticalDuration;
Appearance.SetData(uid, AnomalyVisuals.Supercritical, true);
- Dirty(super);
+ Dirty(uid, super);
}
/// <summary>
// Logging before resolve, in case the anomaly has deleted itself.
if (_net.IsServer)
_sawmill.Info($"Ending anomaly. Entity: {ToPrettyString(uid)}");
- Log.Add(LogType.Anomaly, LogImpact.Extreme, $"Anomaly {ToPrettyString(uid)} went supercritical.");
+ AdminLog.Add(LogType.Anomaly, LogImpact.Extreme, $"Anomaly {ToPrettyString(uid)} went supercritical.");
if (!Resolve(uid, ref component))
return;
var newVal = component.Stability + change;
component.Stability = Math.Clamp(newVal, 0, 1);
- Dirty(component);
+ Dirty(uid, component);
var ev = new AnomalyStabilityChangedEvent(uid, component.Stability, component.Severity);
RaiseLocalEvent(uid, ref ev, true);
StartSupercriticalEvent(uid);
component.Severity = Math.Clamp(newVal, 0, 1);
- Dirty(component);
+ Dirty(uid, component);
var ev = new AnomalySeverityChangedEvent(uid, component.Stability, component.Severity);
RaiseLocalEvent(uid, ref ev, true);
}
component.Health = Math.Clamp(newVal, 0, 1);
- Dirty(component);
+ Dirty(uid, component);
var ev = new AnomalyHealthChangedEvent(uid, component.Health);
RaiseLocalEvent(uid, ref ev, true);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
- _configuration.OnValueChanged(CCVars.GameCryoSleepRejoining, OnCvarChanged, true);
- }
-
- public override void Shutdown()
- {
- base.Shutdown();
-
- _configuration.UnsubValueChanged(CCVars.GameCryoSleepRejoining, OnCvarChanged);
+ Subs.CVar(_configuration, CCVars.GameCryoSleepRejoining, OnCvarChanged, true);
}
private void OnCvarChanged(bool value)
public abstract class SharedSleepingSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
- [Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly BlindableSystem _blindableSystem = default!;
public sealed partial class BlockingSystem : EntitySystem
{
- [Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
- [Dependency] private readonly INetManager _netMan = default!;
public override void Initialize()
{
var old = comp.Charges;
comp.Charges = Math.Clamp(comp.Charges + change, 0, comp.MaxCharges);
if (comp.Charges != old)
- Dirty(comp);
+ Dirty(uid, comp);
}
/// <summary>
/// <summary>
/// Raised on the stealth clothing when attempting to add an action.
/// </summary>
-public class AddStealthActionEvent : CancellableEntityEventArgs
+public sealed class AddStealthActionEvent : CancellableEntityEventArgs
{
/// <summary>
/// User that equipped the stealth clothing.
/// <summary>
/// Raised on the stealth clothing when the user is attemping to enable it.
/// </summary>
-public class AttemptStealthEvent : CancellableEntityEventArgs
+public sealed class AttemptStealthEvent : CancellableEntityEventArgs
{
/// <summary>
/// User that is attempting to enable the stealth clothing.
public abstract class SharedFlatpackSystem : EntitySystem
{
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
- [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
public sealed class DamageableSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly MobThresholdSystem _mobThreshold = default!;
{
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly IGameTiming _timing = default!;
- [Dependency] private readonly MobStateSystem _mobState = default!;
public override void Initialize()
{
// Go through every entity with the component
var query = EntityQueryEnumerator<PassiveDamageComponent, DamageableComponent, MobStateComponent>();
while (query.MoveNext(out var uid, out var comp, out var damage, out var mobState))
- {
+ {
// Make sure they're up for a damage tick
if (comp.NextDamage > curTime)
continue;
if (comp.DamageCap != 0 && damage.TotalDamage >= comp.DamageCap)
continue;
-
+
// Set the next time they can take damage
comp.NextDamage = curTime + TimeSpan.FromSeconds(1f);
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing;
-using Content.Shared.Prying.Components;
using Robust.Shared.Audio.Systems;
namespace Content.Shared.Doors.Systems;
{
public abstract partial class ExamineSystemShared : EntitySystem
{
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] protected readonly MobStateSystem MobStateSystem = default!;
if (IsClientSide(examined))
return true;
- return !Deleted(examined) && CanExamine(examiner, EntityManager.GetComponent<TransformComponent>(examined).MapPosition,
+ return !Deleted(examined) && CanExamine(examiner, _transform.GetMapCoordinates(examined),
entity => entity == examiner || entity == examined, examined);
}
return false;
return InRangeUnOccluded(
- EntityManager.GetComponent<TransformComponent>(examiner).MapPosition,
+ _transform.GetMapCoordinates(examiner),
target,
GetExaminerRange(examiner),
predicate: predicate,
using Content.Shared.Explosion.EntitySystems;
using Content.Shared.Chemistry.Components;
-using Content.Shared.Explosion.EntitySystems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
-using Robust.Shared.GameStates;
namespace Content.Shared.Explosion.Components;
public sealed class BlurryVisionSystem : EntitySystem
{
- [Dependency] private readonly IEntityManager _entityManager = default!;
-
public override void Initialize()
{
base.Initialize();
namespace Content.Shared.Fluids;
-public partial class SharedDrainSystem : EntitySystem
+public abstract partial class SharedDrainSystem : EntitySystem
{
[Serializable, NetSerializable]
public sealed partial class DrainDoAfterEvent : SimpleDoAfterEvent
{
base.Initialize();
- _configManager.OnValueChanged(CCVars.TileFrictionModifier, SetFrictionModifier, true);
- _configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true);
- }
-
- private void SetStopSpeed(float value) => _stopSpeed = value;
-
- private void SetFrictionModifier(float value) => _frictionModifier = value;
-
- public override void Shutdown()
- {
- base.Shutdown();
-
- _configManager.UnsubValueChanged(CCVars.TileFrictionModifier, SetFrictionModifier);
- _configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed);
+ Subs.CVar(_configManager, CCVars.TileFrictionModifier, value => _frictionModifier = value, true);
+ Subs.CVar(_configManager, CCVars.StopSpeed, value => _stopSpeed = value, true);
}
public override void UpdateBeforeMapSolve(bool prediction, PhysicsMapComponent mapComponent, float frameTime)
{
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
- [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
- [Dependency] private readonly SharedItemSystem _items = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
[Dependency] private readonly SharedVirtualItemSystem _virtualSystem = default!;
if (!TryGetSlot(uid, slot, out slotDefinition, inventory: inventory))
return false;
- if (!containerComp.TryGetContainer(slotDefinition.Name, out var container))
+ if (!_containerSystem.TryGetContainer(uid, slotDefinition.Name, out var container, containerComp))
{
if (inventory.LifeStage >= ComponentLifeStage.Initialized)
Log.Error($"Missing inventory container {slot} on entity {ToPrettyString(uid)}");
SubscribeLocalEvent<FollowedComponent, EntParentChangedMessage>(OnFollowedParentChange);
- _configManager.OnValueChanged(CCVars.CameraRotationLocked, SetCameraRotationLocked, true);
- _configManager.OnValueChanged(CCVars.GameDiagonalMovement, SetDiagonalMovement, true);
- }
-
- private void SetCameraRotationLocked(bool obj)
- {
- CameraRotationLocked = obj;
+ Subs.CVar(_configManager, CCVars.CameraRotationLocked, obj => CameraRotationLocked = obj, true);
+ Subs.CVar(_configManager, CCVars.GameDiagonalMovement, value => DiagonalMovementEnabled = value, true);
}
/// <summary>
private void ShutdownInput()
{
CommandBinds.Unregister<SharedMoverController>();
- _configManager.UnsubValueChanged(CCVars.CameraRotationLocked, SetCameraRotationLocked);
- _configManager.UnsubValueChanged(CCVars.GameDiagonalMovement, SetDiagonalMovement);
}
public bool DiagonalMovementEnabled { get; private set; }
- private void SetDiagonalMovement(bool value) => DiagonalMovementEnabled = value;
-
protected virtual void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state) {}
private void OnAutoParentChange(EntityUid uid, AutoOrientComponent component, ref EntParentChangedMessage args)
Physics.UpdateIsPredicted(relayEntity);
component.RelayEntity = relayEntity;
targetComp.Source = uid;
- Dirty(component);
- Dirty(targetComp);
+ Dirty(uid, component);
+ Dirty(relayEntity, targetComp);
}
private void OnRelayShutdown(EntityUid uid, RelayInputMoverComponent component, ComponentShutdown args)
InitializeInput();
InitializeRelay();
- _configManager.OnValueChanged(CCVars.RelativeMovement, SetRelativeMovement, true);
- _configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true);
+ Subs.CVar(_configManager, CCVars.RelativeMovement, value => _relativeMovement = value, true);
+ Subs.CVar(_configManager, CCVars.StopSpeed, value => _stopSpeed = value, true);
UpdatesBefore.Add(typeof(TileFrictionController));
}
- private void SetRelativeMovement(bool value) => _relativeMovement = value;
- private void SetStopSpeed(float value) => _stopSpeed = value;
-
public override void Shutdown()
{
base.Shutdown();
ShutdownInput();
- _configManager.UnsubValueChanged(CCVars.RelativeMovement, SetRelativeMovement);
- _configManager.UnsubValueChanged(CCVars.StopSpeed, SetStopSpeed);
}
public override void UpdateAfterSolve(bool prediction, float frameTime)
/// <summary>
/// Set pinpointers target to track
/// </summary>
- public void SetTarget(EntityUid uid, EntityUid? target, PinpointerComponent? pinpointer = null)
+ public virtual void SetTarget(EntityUid uid, EntityUid? target, PinpointerComponent? pinpointer = null)
{
if (!Resolve(uid, ref pinpointer))
return;
return;
pinpointer.DistanceToTarget = distance;
- Dirty(pinpointer);
+ Dirty(uid, pinpointer);
}
/// <summary>
return false;
pinpointer.ArrowAngle = arrowAngle;
- Dirty(pinpointer);
+ Dirty(uid, pinpointer);
return true;
}
return;
pinpointer.IsActive = isActive;
- Dirty(pinpointer);
+ Dirty(uid, pinpointer);
}
/// Toggle Pinpointer screen. If it has target it will start tracking it.
/// </summary>
/// <returns>True if pinpointer was activated, false otherwise</returns>
- public bool TogglePinpointer(EntityUid uid, PinpointerComponent? pinpointer = null)
+ public virtual bool TogglePinpointer(EntityUid uid, PinpointerComponent? pinpointer = null)
{
if (!Resolve(uid, ref pinpointer))
return false;
{
[Dependency] private readonly CollisionWakeSystem _wake = default!;
[Dependency] private readonly PlaceableSurfaceSystem _placeableSurface = default!;
- [Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize()
{
-using Content.Shared.DoAfter;
-
namespace Content.Shared.Power.Generator;
public sealed class ActiveGeneratorRevvingSystem: EntitySystem
{
- [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
- [Dependency] private readonly EntityManager _entity = default!;
-
public override void Initialize()
{
base.Initialize();
[Dependency] private readonly SharedChargesSystem _charges = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
- [Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly TurfSystem _turf = default!;
public abstract class SharedSpiderSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _action = default!;
- [Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly SharedDoAfterSystem DoAfter = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
- [Dependency] private readonly SharedUserInterfaceSystem _ui = default!;
public List<AirlockStyle> Styles { get; private set; } = new();
public List<AirlockGroupPrototype> Groups { get; private set; } = new();
public abstract class SharedStealthSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
- [Dependency] private readonly MobStateSystem _mobState = default!;
public override void Initialize()
{
{
var transform = Transform(entity);
_container.AttachParentToContainerOrGrid((entity, transform));
- _transformSystem.SetLocalPositionRotation(transform, transform.LocalPosition + _random.NextVector2Box() / 2, _random.NextAngle());
+ _transformSystem.SetLocalPositionRotation(entity, transform.LocalPosition + _random.NextVector2Box() / 2, _random.NextAngle(), transform);
}
if (args.Args.Target == null)
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly INetManager _netManager = default!;
- [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
using Content.Shared.Actions;
-using Robust.Shared.Reflection;
-using Robust.Shared.Serialization;
+using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Shared.UserInterface;
-public sealed partial class OpenUiActionEvent : InstantActionEvent, ISerializationHooks
+public sealed partial class OpenUiActionEvent : InstantActionEvent
{
- [ViewVariables]
+ [DataField(required: true, customTypeSerializer: typeof(EnumSerializer))]
public Enum? Key { get; private set; }
-
- [DataField("key", required: true)]
- private string _keyRaw = default!;
-
- void ISerializationHooks.AfterDeserialization()
- {
- var reflectionManager = IoCManager.Resolve<IReflectionManager>();
- if (reflectionManager.TryParseEnumReference(_keyRaw, out var key))
- Key = key;
- else
- Logger.Error($"Invalid UI key ({_keyRaw}) in open-UI action");
- }
}