diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index a49452fbb9..8feabc1611 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -341,6 +341,7 @@ namespace Content.Client.Preferences.UI _jobPriorities = new List(); _jobCategories = new Dictionary(); + var spriteSystem = IoCManager.Resolve().GetEntitySystem(); var firstCategory = true; @@ -389,7 +390,7 @@ namespace Content.Client.Preferences.UI _jobList.AddChild(category); } - var selector = new JobPrioritySelector(job); + var selector = new JobPrioritySelector(job, spriteSystem); category.AddChild(selector); _jobPriorities.Add(selector); @@ -991,7 +992,7 @@ namespace Content.Client.Preferences.UI public event Action? PriorityChanged; - public JobPrioritySelector(JobPrototype job) + public JobPrioritySelector(JobPrototype job, SpriteSystem sprites) { Job = job; @@ -1020,12 +1021,9 @@ namespace Content.Client.Preferences.UI Stretch = TextureRect.StretchMode.KeepCentered }; - if (job.Icon != null) - { - var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), - job.Icon); - icon.Texture = specifier.Frame0(); - } + var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), + job.Icon); + icon.Texture = sprites.Frame0(specifier); AddChild(new BoxContainer { diff --git a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs index 0b8b83acc9..b1cde98993 100644 --- a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs @@ -43,17 +43,17 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface private void OnStopAutodockPressed(EntityUid obj) { - SendMessage(new StopAutodockRequestMessage() {Entity = obj}); + SendMessage(new StopAutodockRequestMessage() {DockEntity = obj}); } private void OnAutodockPressed(EntityUid obj) { - SendMessage(new AutodockRequestMessage() {Entity = obj}); + SendMessage(new AutodockRequestMessage() {DockEntity = obj}); } private void OnUndockPressed(EntityUid obj) { - SendMessage(new UndockRequestMessage() {Entity = obj}); + SendMessage(new UndockRequestMessage() {DockEntity = obj}); } private void OnShuttleModePressed(ShuttleMode obj) diff --git a/Content.Server/Bible/BibleSystem.cs b/Content.Server/Bible/BibleSystem.cs index a31f7198a1..b03ba09146 100644 --- a/Content.Server/Bible/BibleSystem.cs +++ b/Content.Server/Bible/BibleSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Actions; using Content.Server.Cooldown; using Content.Server.Bible.Components; +using Content.Server.MobState; using Content.Server.Popups; using Robust.Shared.Random; using Robust.Shared.Audio; @@ -25,6 +26,7 @@ namespace Content.Server.Bible [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; + [Dependency] private readonly MobStateSystem _mobStateSystem = default!; public override void Initialize() { @@ -37,8 +39,8 @@ namespace Content.Server.Bible SubscribeLocalEvent(OnFamiliarDeath); } - private Queue AddQueue = new(); - private Queue RemQueue = new(); + private readonly Queue _addQueue = new(); + private readonly Queue _remQueue = new(); /// /// This handles familiar respawning. @@ -47,17 +49,17 @@ namespace Content.Server.Bible { base.Update(frameTime); - foreach(var entity in AddQueue) + foreach(var entity in _addQueue) { EnsureComp(entity); } - AddQueue.Clear(); + _addQueue.Clear(); - foreach(var entity in RemQueue) + foreach(var entity in _remQueue) { RemComp(entity); } - RemQueue.Clear(); + _remQueue.Clear(); foreach (var (respawning, summonableComp) in EntityQuery()) { @@ -66,7 +68,7 @@ namespace Content.Server.Bible { continue; } - /// Clean up the old body + // Clean up the old body if (summonableComp.Summon != null) { EntityManager.DeleteEntity(summonableComp.Summon.Value); @@ -75,9 +77,9 @@ namespace Content.Server.Bible summonableComp.AlreadySummoned = false; _popupSystem.PopupEntity(Loc.GetString("bible-summon-respawn-ready", ("book", summonableComp.Owner)), summonableComp.Owner, Filter.Pvs(summonableComp.Owner)); SoundSystem.Play("/Audio/Effects/radpulse9.ogg", Filter.Pvs(summonableComp.Owner), summonableComp.Owner, AudioParams.Default.WithVolume(-4f)); - /// Clean up the accumulator and respawn tracking component + // Clean up the accumulator and respawn tracking component summonableComp.Accumulator = 0; - RemQueue.Enqueue(respawning.Owner); + _remQueue.Enqueue(respawning.Owner); } } @@ -92,9 +94,8 @@ namespace Content.Server.Bible { return; } - - if (args.Target == null || args.Target == args.User || !TryComp(args.Target, out var mobState) - || mobState.IsDead()) + + if (args.Target == null || args.Target == args.User || _mobStateSystem.IsDead(args.Target.Value)) { return; } @@ -152,8 +153,9 @@ namespace Content.Server.Bible { Act = () => { - TransformComponent? position = Comp(args.User); - AttemptSummon(component, args.User, position); + if (!TryComp(args.User, out var userXform)) return; + + AttemptSummon(component, args.User, userXform); }, Text = Loc.GetString("bible-summon-verb"), Priority = 2 @@ -179,13 +181,13 @@ namespace Content.Server.Bible /// private void OnFamiliarDeath(EntityUid uid, FamiliarComponent component, MobStateChangedEvent args) { - if (!args.Component.IsDead() || component.Source == null) + if (args.CurrentMobState != DamageState.Dead || component.Source == null) return; var source = component.Source; if (source != null && TryComp(source, out var summonable)) { - AddQueue.Enqueue(summonable.Owner); + _addQueue.Enqueue(summonable.Owner); } } @@ -207,10 +209,10 @@ namespace Content.Server.Bible var familiar = EntityManager.SpawnEntity(component.SpecialItemPrototype, position.Coordinates); component.Summon = familiar; - /// We only want to add the familiar component to mobs + // We only want to add the familiar component to mobs if (HasComp(familiar)) { - /// Make this Summon the familiar's source + // Make this Summon the familiar's source var familiarComp = EnsureComp(familiar); familiarComp.Source = component.Owner; } diff --git a/Content.Server/Chat/SuicideSystem.cs b/Content.Server/Chat/SuicideSystem.cs index 96ea5094ce..54e78115a1 100644 --- a/Content.Server/Chat/SuicideSystem.cs +++ b/Content.Server/Chat/SuicideSystem.cs @@ -1,5 +1,6 @@ using Content.Server.Administration.Logs; using Content.Server.Hands.Components; +using Content.Server.MobState; using Content.Server.Popups; using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; @@ -20,6 +21,7 @@ namespace Content.Server.Chat [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly TagSystem _tagSystem = default!; + [Dependency] private readonly MobStateSystem _mobState = default!; public bool Suicide(EntityUid victim) { @@ -30,7 +32,7 @@ namespace Content.Server.Chat } // Checks to see if the player is dead. - if (!EntityManager.TryGetComponent(victim, out var mobState) || mobState.IsDead()) + if (!TryComp(victim, out var mobState) || _mobState.IsDead(victim, mobState)) { return false; } @@ -41,7 +43,7 @@ namespace Content.Server.Chat var suicideEvent = new SuicideEvent(victim); // If you are critical, you wouldn't be able to use your surroundings to suicide, so you do the default suicide - if (!mobState.IsCritical()) + if (!_mobState.IsCritical(victim, mobState)) { EnvironmentSuicideHandler(victim, suicideEvent); } @@ -54,7 +56,6 @@ namespace Content.Server.Chat /// /// If not handled, does the default suicide, which is biting your own tongue /// - /// The person attempting to die private static void DefaultSuicideHandler(EntityUid victim, SuicideEvent suicideEvent) { if (suicideEvent.Handled) return; @@ -69,12 +70,11 @@ namespace Content.Server.Chat /// /// Raise event to attempt to use held item, or surrounding entities to commit suicide /// - /// The person attempting to die private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEvent) { // Suicide by held item if (EntityManager.TryGetComponent(victim, out HandsComponent? handsComponent) - && handsComponent.ActiveHandEntity is EntityUid item) + && handsComponent.ActiveHandEntity is { } item) { RaiseLocalEvent(item, suicideEvent, false); @@ -82,11 +82,13 @@ namespace Content.Server.Chat return; } + var itemQuery = GetEntityQuery(); + // Suicide by nearby entity (ex: Microwave) foreach (var entity in _entityLookupSystem.GetEntitiesInRange(victim, 1, LookupFlags.Approximate | LookupFlags.Anchored)) { // Skip any nearby items that can be picked up, we already checked the active held item above - if (EntityManager.HasComponent(entity)) + if (itemQuery.HasComponent(entity)) continue; RaiseLocalEvent(entity, suicideEvent, false); diff --git a/Content.Server/Salvage/SalvageMobRestrictionsSystem.cs b/Content.Server/Salvage/SalvageMobRestrictionsSystem.cs index 1819cf85e1..8fbc68a454 100644 --- a/Content.Server/Salvage/SalvageMobRestrictionsSystem.cs +++ b/Content.Server/Salvage/SalvageMobRestrictionsSystem.cs @@ -1,26 +1,5 @@ -using Content.Shared.CCVar; -using Content.Shared.Examine; -using Content.Shared.Interaction; -using Content.Shared.Damage; using Content.Shared.Damage; using Content.Server.Body.Components; -using Robust.Server.Maps; -using Robust.Shared.Configuration; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Log; -using Robust.Shared.Map; -using Robust.Shared.Maths; -using Robust.Shared.Player; -using Robust.Shared.Prototypes; -using Robust.Shared.Random; -using Robust.Shared.Timing; -using Robust.Shared.Utility; -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.CodeAnalysis; namespace Content.Server.Salvage; @@ -50,7 +29,7 @@ public sealed class SalvageMobRestrictionsSystem : EntitySystem { rg = AddComp(gridUid); } - rg!.MobsToKill.Add(uid); + rg.MobsToKill.Add(uid); component.LinkedGridEntity = gridUid; } diff --git a/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs b/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs index a87f721c31..0f04e3503e 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs @@ -66,10 +66,10 @@ public sealed partial class DockingSystem private void OnRequestUndock(EntityUid uid, ShuttleConsoleComponent component, UndockRequestMessage args) { - _sawmill.Debug($"Received undock request for {ToPrettyString(args.Entity)}"); + _sawmill.Debug($"Received undock request for {ToPrettyString(args.DockEntity)}"); // TODO: Validation - if (!TryComp(args.Entity, out var dock) || + if (!TryComp(args.DockEntity, out var dock) || !dock.Docked) return; Undock(dock); @@ -77,28 +77,28 @@ public sealed partial class DockingSystem private void OnRequestAutodock(EntityUid uid, ShuttleConsoleComponent component, AutodockRequestMessage args) { - _sawmill.Debug($"Received autodock request for {ToPrettyString(args.Entity)}"); + _sawmill.Debug($"Received autodock request for {ToPrettyString(args.DockEntity)}"); var player = args.Session.AttachedEntity; - if (player == null || !HasComp(args.Entity)) return; + if (player == null || !HasComp(args.DockEntity)) return; // TODO: Validation - var comp = EnsureComp(args.Entity); + var comp = EnsureComp(args.DockEntity); comp.Requesters.Add(player.Value); } private void OnRequestStopAutodock(EntityUid uid, ShuttleConsoleComponent component, StopAutodockRequestMessage args) { - _sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.Entity)}"); + _sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.DockEntity)}"); var player = args.Session.AttachedEntity; // TODO: Validation - if (player == null || !TryComp(args.Entity, out var comp)) return; + if (player == null || !TryComp(args.DockEntity, out var comp)) return; comp.Requesters.Remove(player.Value); if (comp.Requesters.Count == 0) - RemComp(args.Entity); + RemComp(args.DockEntity); } } diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index dff066e95e..456bd092b9 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -259,12 +259,12 @@ namespace Content.Server.Weapon.Melee } else if (type != null && damageSoundComp.SoundTypes?.TryGetValue(type, out var damageSoundType) == true) { - SoundSystem.Play(damageSoundType!.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation)); + SoundSystem.Play(damageSoundType.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation)); playedSound = true; } else if (type != null && damageSoundComp.SoundGroups?.TryGetValue(type, out var damageSoundGroup) == true) { - SoundSystem.Play(damageSoundGroup!.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation)); + SoundSystem.Play(damageSoundGroup.GetSound(), Filter.Pvs(target, entityManager: EntityManager), target, AudioHelpers.WithVariation(DamagePitchVariation)); playedSound = true; } } diff --git a/Content.Shared/Alert/AlertKey.cs b/Content.Shared/Alert/AlertKey.cs index e22ad148a2..c88249e1e3 100644 --- a/Content.Shared/Alert/AlertKey.cs +++ b/Content.Shared/Alert/AlertKey.cs @@ -9,7 +9,7 @@ namespace Content.Shared.Alert; /// falls back to the id. /// [Serializable, NetSerializable] -public struct AlertKey : ISerializationHooks, IPopulateDefaultValues +public struct AlertKey :IPopulateDefaultValues { public AlertType? AlertType { get; private set; } public readonly AlertCategory? AlertCategory; @@ -58,4 +58,4 @@ public struct AlertKey : ISerializationHooks, IPopulateDefaultValues { return new(null, category); } -} \ No newline at end of file +} diff --git a/Content.Shared/Body/Components/MechanismComponent.cs b/Content.Shared/Body/Components/MechanismComponent.cs index 90d66d136f..34cd683d7f 100644 --- a/Content.Shared/Body/Components/MechanismComponent.cs +++ b/Content.Shared/Body/Components/MechanismComponent.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.Body.Components { [RegisterComponent] - public sealed class MechanismComponent : Component, ISerializationHooks + public sealed class MechanismComponent : Component { [Dependency] private readonly IEntityManager _entMan = default!; private SharedBodyPartComponent? _part; diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 693c5feb0e..a2d7a28c31 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -2,6 +2,7 @@ using System.Linq; using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.MobState.Components; +using Content.Shared.MobState.EntitySystems; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.Map; @@ -15,6 +16,7 @@ namespace Content.Shared.Examine { [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + [Dependency] protected readonly SharedMobStateSystem MobStateSystem = default!; public const float MaxRaycastRange = 100; @@ -43,8 +45,8 @@ namespace Content.Shared.Examine public bool IsInDetailsRange(EntityUid examiner, EntityUid entity) { - // check if the mob is in ciritcal or dead - if (EntityManager.TryGetComponent(examiner, out MobStateComponent? mobState) && mobState.IsIncapacitated()) + // check if the mob is in critical or dead + if (MobStateSystem.IsIncapacitated(examiner)) return false; if (!_interactionSystem.InRangeUnobstructed(examiner, entity, ExamineDetailsRange)) @@ -94,9 +96,9 @@ namespace Content.Shared.Examine { if (Resolve(examiner, ref mobState, logMissing: false)) { - if (mobState.IsDead()) + if (MobStateSystem.IsDead(examiner, mobState)) return DeadExamineRange; - else if (mobState.IsCritical()) + else if (MobStateSystem.IsCritical(examiner, mobState)) return CritExamineRange; } return ExamineRange; diff --git a/Content.Shared/Hands/Components/HandVirtualItemComponent.cs b/Content.Shared/Hands/Components/HandVirtualItemComponent.cs index 41231dfd1c..e9e6bfe03a 100644 --- a/Content.Shared/Hands/Components/HandVirtualItemComponent.cs +++ b/Content.Shared/Hands/Components/HandVirtualItemComponent.cs @@ -37,7 +37,7 @@ namespace Content.Shared.Hands.Components _blockingEntity = pullState.BlockingEntity; // update hands GUI with new entity. - if (Owner.TryGetContainer(out var containter)) + if (Owner.TryGetContainer(out _)) EntitySystem.Get().VisualsChanged(Owner); } diff --git a/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs b/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs index 49c5040661..7e4f579038 100644 --- a/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class AutodockRequestMessage : BoundUserInterfaceMessage { - public EntityUid Entity; + public EntityUid DockEntity; } diff --git a/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs b/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs index f8773649bc..599c8b06e0 100644 --- a/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class StopAutodockRequestMessage : BoundUserInterfaceMessage { - public EntityUid Entity; + public EntityUid DockEntity; } diff --git a/Content.Shared/Shuttles/Events/UndockRequestMessage.cs b/Content.Shared/Shuttles/Events/UndockRequestMessage.cs index 9ee78aa4d6..b29bf36c04 100644 --- a/Content.Shared/Shuttles/Events/UndockRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/UndockRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class UndockRequestMessage : BoundUserInterfaceMessage { - public EntityUid Entity; + public EntityUid DockEntity; } diff --git a/Content.Shared/Stacks/SharedStackComponent.cs b/Content.Shared/Stacks/SharedStackComponent.cs index 06bbfdcedb..9a58ca1140 100644 --- a/Content.Shared/Stacks/SharedStackComponent.cs +++ b/Content.Shared/Stacks/SharedStackComponent.cs @@ -5,7 +5,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy namespace Content.Shared.Stacks { [NetworkedComponent, Access(typeof(SharedStackSystem))] - public abstract class SharedStackComponent : Component, ISerializationHooks + public abstract class SharedStackComponent : Component { [ViewVariables(VVAccess.ReadWrite)] [DataField("stackType", required:true, customTypeSerializer:typeof(PrototypeIdSerializer))] diff --git a/Content.Shared/Wires/SharedWiresComponent.cs b/Content.Shared/Wires/SharedWiresComponent.cs index f10c5dd292..0614d1344a 100644 --- a/Content.Shared/Wires/SharedWiresComponent.cs +++ b/Content.Shared/Wires/SharedWiresComponent.cs @@ -34,7 +34,7 @@ namespace Content.Shared.Wires } [Serializable, NetSerializable] - public class WiresActionMessage : BoundUserInterfaceMessage + public sealed class WiresActionMessage : BoundUserInterfaceMessage { public readonly int Id; public readonly WiresAction Action; @@ -116,7 +116,7 @@ namespace Content.Shared.Wires } [Serializable, NetSerializable] - public class WiresBoundUserInterfaceState : BoundUserInterfaceState + public sealed class WiresBoundUserInterfaceState : BoundUserInterfaceState { public string BoardName { get; } public string? SerialNumber { get; } @@ -167,7 +167,7 @@ namespace Content.Shared.Wires /// what wires there are on an entity. /// [Serializable, NetSerializable] - public class ClientWire + public sealed class ClientWire { /// /// ID of this wire, which corresponds to