diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index 24a3df2528..6f3f67f496 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -7,21 +7,17 @@ using Content.Shared.Actions.ActionTypes; using Content.Shared.Atmos; using Content.Shared.Atmos.Components; using Content.Shared.Audio; -using Content.Shared.Examine; -using Content.Shared.Interaction; using Content.Shared.Sound; using Robust.Server.GameObjects; -using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Player; -using Robust.Shared.Utility; namespace Content.Server.Atmos.Components { [RegisterComponent] #pragma warning disable 618 - public sealed class GasTankComponent : Component, IExamine, IGasMixtureHolder + public sealed class GasTankComponent : Component, IGasMixtureHolder #pragma warning restore 618 { [Dependency] private readonly IEntityManager _entMan = default!; @@ -91,16 +87,6 @@ namespace Content.Server.Atmos.Components } } - public void Examine(FormattedMessage message, bool inDetailsRange) - { - message.AddMarkup(Loc.GetString("comp-gas-tank-examine", ("pressure", Math.Round(Air?.Pressure ?? 0)))); - if (IsConnected) - { - message.AddText("\n"); - message.AddMarkup(Loc.GetString("comp-gas-tank-connected")); - } - } - protected override void Shutdown() { base.Shutdown(); diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index 00ff85c222..981b18d917 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -3,9 +3,8 @@ using Content.Server.UserInterface; using Content.Shared.Actions; using Content.Shared.Interaction.Events; using Content.Shared.Toggleable; -using Content.Shared.Verbs; +using Content.Shared.Examine; using JetBrains.Annotations; -using Robust.Server.GameObjects; namespace Content.Server.Atmos.EntitySystems { @@ -22,6 +21,7 @@ namespace Content.Server.Atmos.EntitySystems base.Initialize(); SubscribeLocalEvent(BeforeUiOpen); SubscribeLocalEvent(OnGetActions); + SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnActionToggle); SubscribeLocalEvent(OnDropped); } @@ -42,6 +42,14 @@ namespace Content.Server.Atmos.EntitySystems args.Actions.Add(component.ToggleAction); } + private void OnExamined(EntityUid uid, GasTankComponent component, ExaminedEvent args) + { + if (args.IsInDetailsRange) + args.PushMarkup(Loc.GetString("comp-gas-tank-examine", ("pressure", Math.Round(component.Air?.Pressure ?? 0)))); + if (component.IsConnected) + args.PushMarkup(Loc.GetString("comp-gas-tank-connected")); + } + private void OnActionToggle(EntityUid uid, GasTankComponent component, ToggleActionEvent args) { if (args.Handled) diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index 1022edc164..e80597bb65 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -1,44 +1,32 @@ -using System; using System.Threading.Tasks; using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.Botany.Systems; using Content.Server.Chemistry.EntitySystems; -using Content.Server.Chemistry.Components; using Content.Server.Fluids.Components; using Content.Server.Hands.Components; using Content.Server.Kitchen.Components; -using Content.Server.Plants; using Content.Server.Popups; -using Content.Shared.ActionBlocker; using Content.Shared.Audio; using Content.Shared.Botany; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reagent; -using Content.Shared.Examine; using Content.Shared.FixedPoint; using Content.Shared.Interaction; using Content.Shared.Popups; using Content.Shared.Random.Helpers; using Content.Shared.Tag; using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Maths; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; -using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Timing; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Botany.Components { [RegisterComponent] #pragma warning disable 618 - public sealed class PlantHolderComponent : Component, IInteractUsing, IInteractHand, IActivate, IExamine + public sealed class PlantHolderComponent : Component, IInteractUsing, IInteractHand, IActivate #pragma warning restore 618 { public const float HydroponicsSpeedMultiplier = 1f; @@ -51,7 +39,7 @@ namespace Content.Server.Botany.Components [ViewVariables] private int _lastProduce; - [ViewVariables(VVAccess.ReadWrite)] private int _missingGas; + [ViewVariables(VVAccess.ReadWrite)] public int MissingGas; private readonly TimeSpan _cycleDelay = TimeSpan.FromSeconds(15f); @@ -255,22 +243,22 @@ namespace Content.Server.Botany.Components if (Seed.ConsumeGasses.Count > 0) { - _missingGas = 0; + MissingGas = 0; foreach (var (gas, amount) in Seed.ConsumeGasses) { if (environment.GetMoles(gas) < amount) { - _missingGas++; + MissingGas++; continue; } environment.AdjustMoles(gas, -amount); } - if (_missingGas > 0) + if (MissingGas > 0) { - Health -= _missingGas * HydroponicsSpeedMultiplier; + Health -= MissingGas * HydroponicsSpeedMultiplier; if (DrawWarnings) _updateSpriteAfterUpdate = true; } @@ -631,7 +619,7 @@ namespace Content.Server.Botany.Components appearanceComponent.SetData(PlantHolderVisuals.NutritionLight, NutritionLevel <= 2); appearanceComponent.SetData(PlantHolderVisuals.AlertLight, WeedLevel >= 5 || PestLevel >= 5 || Toxins >= 40 || ImproperHeat || ImproperLight || ImproperPressure || - _missingGas > 0); + MissingGas > 0); appearanceComponent.SetData(PlantHolderVisuals.HarvestLight, Harvest); } @@ -847,65 +835,5 @@ namespace Content.Server.Botany.Components // DoHarvest does the sanity checks. DoHarvest(eventArgs.User); } - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - if (!inDetailsRange) - return; - - if (Seed == null) - { - message.AddMarkup(Loc.GetString("plant-holder-component-nothing-planted-message") + "\n"); - } - else if (!Dead) - { - message.AddMarkup(Loc.GetString("plant-holder-component-something-already-growing-message", - ("seedName", Seed.DisplayName), - ("toBeForm", Seed.DisplayName.EndsWith('s') ? "are" : "is")) - + "\n"); - - if (Health <= Seed.Endurance / 2) - message.AddMarkup(Loc.GetString( - "plant-holder-component-something-already-growing-low-health-message", - ("healthState", - Loc.GetString(Age > Seed.Lifespan - ? "plant-holder-component-plant-old-adjective" - : "plant-holder-component-plant-unhealthy-adjective"))) - + "\n"); - } - else - { - message.AddMarkup(Loc.GetString("plant-holder-component-dead-plant-matter-message") + "\n"); - } - - if (WeedLevel >= 5) - message.AddMarkup(Loc.GetString("plant-holder-component-weed-high-level-message") + "\n"); - - if (PestLevel >= 5) - message.AddMarkup(Loc.GetString("plant-holder-component-pest-high-level-message") + "\n"); - - message.AddMarkup(Loc.GetString($"plant-holder-component-water-level-message", - ("waterLevel", (int) WaterLevel)) + "\n"); - message.AddMarkup(Loc.GetString($"plant-holder-component-nutrient-level-message", - ("nutritionLevel", (int) NutritionLevel)) + "\n"); - - if (DrawWarnings) - { - if (Toxins > 40f) - message.AddMarkup(Loc.GetString("plant-holder-component-toxins-high-warning") + "\n"); - - if (ImproperLight) - message.AddMarkup(Loc.GetString("plant-holder-component-light-improper-warning") + "\n"); - - if (ImproperHeat) - message.AddMarkup(Loc.GetString("plant-holder-component-heat-improper-warning") + "\n"); - - if (ImproperPressure) - message.AddMarkup(Loc.GetString("plant-holder-component-pressure-improper-warning") + "\n"); - - if (_missingGas > 0) - message.AddMarkup(Loc.GetString("plant-holder-component-gas-missing-warning") + "\n"); - } - } } } diff --git a/Content.Server/Botany/Systems/PlantHolderSystem.cs b/Content.Server/Botany/Systems/PlantHolderSystem.cs new file mode 100644 index 0000000000..a95bc52029 --- /dev/null +++ b/Content.Server/Botany/Systems/PlantHolderSystem.cs @@ -0,0 +1,72 @@ +using Content.Server.Botany.Components; +using Content.Shared.Examine; + +namespace Content.Server.Botany.Systems +{ + public sealed class PlantHolderSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnExamine); + } + + private void OnExamine(EntityUid uid, PlantHolderComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange) + return; + + if (component.Seed == null) + { + args.PushMarkup(Loc.GetString("plant-holder-component-nothing-planted-message")); + } + else if (!component.Dead) + { + args.PushMarkup(Loc.GetString("plant-holder-component-something-already-growing-message", + ("seedName", component.Seed.DisplayName), + ("toBeForm", component.Seed.DisplayName.EndsWith('s') ? "are" : "is"))); + + if (component.Health <= component.Seed.Endurance / 2) + args.PushMarkup(Loc.GetString( + "plant-holder-component-something-already-growing-low-health-message", + ("healthState", + Loc.GetString(component.Age > component.Seed.Lifespan + ? "plant-holder-component-plant-old-adjective" + : "plant-holder-component-plant-unhealthy-adjective")))); + } + else + { + args.PushMarkup(Loc.GetString("plant-holder-component-dead-plant-matter-message")); + } + + if (component.WeedLevel >= 5) + args.PushMarkup(Loc.GetString("plant-holder-component-weed-high-level-message")); + + if (component.PestLevel >= 5) + args.PushMarkup(Loc.GetString("plant-holder-component-pest-high-level-message")); + + args.PushMarkup(Loc.GetString($"plant-holder-component-water-level-message", + ("waterLevel", (int) component.WaterLevel))); + args.PushMarkup(Loc.GetString($"plant-holder-component-nutrient-level-message", + ("nutritionLevel", (int) component.NutritionLevel))); + + if (component.DrawWarnings) + { + if (component.Toxins > 40f) + args.PushMarkup(Loc.GetString("plant-holder-component-toxins-high-warning")); + + if (component.ImproperLight) + args.PushMarkup(Loc.GetString("plant-holder-component-light-improper-warning")); + + if (component.ImproperHeat) + args.PushMarkup(Loc.GetString("plant-holder-component-heat-improper-warning")); + + if (component.ImproperPressure) + args.PushMarkup(Loc.GetString("plant-holder-component-pressure-improper-warning")); + + if (component.MissingGas > 0) + args.PushMarkup(Loc.GetString("plant-holder-component-gas-missing-warning")); + } + } + } +} diff --git a/Content.Server/Construction/Components/MachineBoardComponent.cs b/Content.Server/Construction/Components/MachineBoardComponent.cs index 2e0aa7e9a0..efbf16b470 100644 --- a/Content.Server/Construction/Components/MachineBoardComponent.cs +++ b/Content.Server/Construction/Components/MachineBoardComponent.cs @@ -1,21 +1,10 @@ -using System; -using System.Collections.Generic; -using Content.Shared.Examine; using Content.Shared.Stacks; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Construction.Components { [RegisterComponent] -#pragma warning disable 618 - public sealed class MachineBoardComponent : Component, IExamine -#pragma warning restore 618 + public sealed class MachineBoardComponent : Component { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; @@ -50,42 +39,6 @@ namespace Content.Server.Construction.Components } } } - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - message.AddMarkup(Loc.GetString("machine-board-component-on-examine-label") + "\n"); - foreach (var (part, amount) in Requirements) - { - message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text", - ("amount", amount), - ("requiredElement", Loc.GetString(part.ToString()))) - + "\n"); - } - - foreach (var (material, amount) in MaterialRequirements) - { - message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text", - ("amount", amount), - ("requiredElement", Loc.GetString(material.Name))) - + "\n"); - } - - foreach (var (_, info) in ComponentRequirements) - { - message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text", - ("amount", info.Amount), - ("requiredElement", Loc.GetString(info.ExamineName))) - + "\n"); - } - - foreach (var (_, info) in TagRequirements) - { - message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text", - ("amount", info.Amount), - ("requiredElement", Loc.GetString(info.ExamineName))) - + "\n"); - } - } } [Serializable] diff --git a/Content.Server/Construction/Components/MachinePartComponent.cs b/Content.Server/Construction/Components/MachinePartComponent.cs index de2a21c7c9..dcfed6913c 100644 --- a/Content.Server/Construction/Components/MachinePartComponent.cs +++ b/Content.Server/Construction/Components/MachinePartComponent.cs @@ -1,17 +1,7 @@ -using System.Collections.Generic; -using Content.Shared.Examine; -using Robust.Shared.GameObjects; -using Robust.Shared.Localization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; - namespace Content.Server.Construction.Components { [RegisterComponent] -#pragma warning disable 618 - public sealed class MachinePartComponent : Component, IExamine -#pragma warning restore 618 + public sealed class MachinePartComponent : Component { // I'm so sorry for hard-coding this. But trust me, it should make things less painful. public static IReadOnlyDictionary Prototypes { get; } = new Dictionary() @@ -34,11 +24,5 @@ namespace Content.Server.Construction.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("rating")] public int Rating { get; private set; } = 1; - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - message.AddMarkup(Loc.GetString("machine-part-component-on-examine-rating-text", ("rating", Rating)) + "\n"); - message.AddMarkup(Loc.GetString("machine-part-component-on-examine-type-text", ("type", PartType)) + "\n"); - } } } diff --git a/Content.Server/Construction/MachinePartSystem.cs b/Content.Server/Construction/MachinePartSystem.cs new file mode 100644 index 0000000000..acd6695269 --- /dev/null +++ b/Content.Server/Construction/MachinePartSystem.cs @@ -0,0 +1,60 @@ +using Content.Server.Construction.Components; +using Content.Shared.Examine; + +namespace Content.Server.Construction +{ + /// + /// Deals with machine parts and machine boards. + /// + public sealed class MachinePartSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnMachineBoardExamined); + SubscribeLocalEvent(OnMachinePartExamined); + } + + private void OnMachineBoardExamined(EntityUid uid, MachineBoardComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange) + return; + args.PushMarkup(Loc.GetString("machine-board-component-on-examine-label")); + foreach (var (part, amount) in component.Requirements) + { + args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text", + ("amount", amount), + ("requiredElement", Loc.GetString(part.ToString())))); + } + + foreach (var (material, amount) in component.MaterialRequirements) + { + args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text", + ("amount", amount), + ("requiredElement", Loc.GetString(material.Name)))); + } + + foreach (var (_, info) in component.ComponentRequirements) + { + args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text", + ("amount", info.Amount), + ("requiredElement", Loc.GetString(info.ExamineName)))); + } + + foreach (var (_, info) in component.TagRequirements) + { + args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text", + ("amount", info.Amount), + ("requiredElement", Loc.GetString(info.ExamineName)))); + } + } + + private void OnMachinePartExamined(EntityUid uid, MachinePartComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange) + return; + args.PushMarkup(Loc.GetString("machine-part-component-on-examine-rating-text", ("rating", component.Rating))); + args.PushMarkup(Loc.GetString("machine-part-component-on-examine-type-text", ("type", component.PartType))); + } + } +} diff --git a/Content.Server/Drone/DroneSystem.cs b/Content.Server/Drone/DroneSystem.cs index c5d46f63b5..474827983e 100644 --- a/Content.Server/Drone/DroneSystem.cs +++ b/Content.Server/Drone/DroneSystem.cs @@ -76,16 +76,13 @@ namespace Content.Server.Drone private void OnExamined(EntityUid uid, DroneComponent component, ExaminedEvent args) { - if (args.IsInDetailsRange) + if (TryComp(uid, out var mind) && mind.HasMind) { - if (TryComp(uid, out var mind) && mind.HasMind) - { - args.PushMarkup(Loc.GetString("drone-active")); - } - else - { - args.PushMarkup(Loc.GetString("drone-dormant")); - } + args.PushMarkup(Loc.GetString("drone-active")); + } + else + { + args.PushMarkup(Loc.GetString("drone-dormant")); } } diff --git a/Content.Server/Headset/HeadsetComponent.cs b/Content.Server/Headset/HeadsetComponent.cs index 2dc6f29bf7..1bdbefafac 100644 --- a/Content.Server/Headset/HeadsetComponent.cs +++ b/Content.Server/Headset/HeadsetComponent.cs @@ -1,17 +1,9 @@ -using System.Collections.Generic; using Content.Server.Radio.Components; using Content.Server.Radio.EntitySystems; using Content.Shared.Chat; -using Content.Shared.Examine; using Robust.Server.GameObjects; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Network; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Headset { @@ -19,7 +11,7 @@ namespace Content.Server.Headset [ComponentReference(typeof(IRadio))] [ComponentReference(typeof(IListen))] #pragma warning disable 618 - public sealed class HeadsetComponent : Component, IListen, IRadio, IExamine + public sealed class HeadsetComponent : Component, IListen, IRadio #pragma warning restore 618 { [Dependency] private readonly IEntityManager _entMan = default!; @@ -32,7 +24,7 @@ namespace Content.Server.Headset [ViewVariables(VVAccess.ReadWrite)] [DataField("broadcastChannel")] - private int BroadcastFrequency { get; set; } = 1459; + public int BroadcastFrequency { get; set; } = 1459; [ViewVariables(VVAccess.ReadWrite)] [DataField("listenRange")] @@ -83,14 +75,5 @@ namespace Content.Server.Headset _radioSystem.SpreadMessage(this, speaker, message, BroadcastFrequency); RadioRequested = false; } - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - message.AddText(Loc.GetString("examine-radio-frequency", ("frequency", BroadcastFrequency))); - message.AddText("\n"); - message.AddText(Loc.GetString("examine-headset")); - message.AddText("\n"); - message.AddText(Loc.GetString("examine-headset-chat-prefix", ("prefix", ";"))); - } } } diff --git a/Content.Server/Headset/HeadsetSystem.cs b/Content.Server/Headset/HeadsetSystem.cs new file mode 100644 index 0000000000..a4013166e2 --- /dev/null +++ b/Content.Server/Headset/HeadsetSystem.cs @@ -0,0 +1,22 @@ +using Content.Shared.Examine; + +namespace Content.Server.Headset +{ + public sealed class HeadsetSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnExamined); + } + + private void OnExamined(EntityUid uid, HeadsetComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange) + return; + args.PushMarkup(Loc.GetString("examine-radio-frequency", ("frequency", component.BroadcastFrequency))); + args.PushMarkup(Loc.GetString("examine-headset")); + args.PushMarkup(Loc.GetString("examine-headset-chat-prefix", ("prefix", ";"))); + } + } +} diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index 8bbdc0e138..d47719d4d7 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -5,7 +5,6 @@ using Content.Server.GameTicking; using Content.Server.Players; using Content.Server.Popups; using Content.Server.Storage.Components; -using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Morgue; using Content.Shared.Popups; @@ -13,13 +12,7 @@ using Content.Shared.Sound; using Content.Shared.Standing; using Robust.Server.GameObjects; using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Player; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Morgue.Components { @@ -29,7 +22,7 @@ namespace Content.Server.Morgue.Components [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] #pragma warning disable 618 - public sealed class CrematoriumEntityStorageComponent : MorgueEntityStorageComponent, IExamine, ISuicideAct + public sealed class CrematoriumEntityStorageComponent : MorgueEntityStorageComponent, ISuicideAct #pragma warning restore 618 { [Dependency] private readonly IEntityManager _entities = default!; @@ -45,28 +38,6 @@ namespace Content.Server.Morgue.Components private CancellationTokenSource? _cremateCancelToken; - void IExamine.Examine(FormattedMessage message, bool inDetailsRange) - { - if (!_entities.TryGetComponent(Owner, out var appearance)) return; - - if (inDetailsRange) - { - if (appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning) - { - message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", Owner)) + "\n"); - } - - if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) - { - message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-has-contents")); - } - else - { - message.AddText(Loc.GetString("crematorium-entity-storage-component-on-examine-details-empty")); - } - } - } - public override bool CanOpen(EntityUid user, bool silent = false) { if (Cooking) diff --git a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs index 0d6ca40b62..7dceca810d 100644 --- a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs @@ -1,10 +1,7 @@ -using System.Collections.Generic; using Content.Server.Storage.Components; using Content.Shared.Body.Components; using Content.Shared.Directions; -using Content.Shared.Examine; using Content.Shared.Interaction; -using Content.Shared.Interaction.Helpers; using Content.Shared.Morgue; using Content.Shared.Physics; using Content.Shared.Popups; @@ -13,17 +10,10 @@ using Content.Shared.Standing; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Map; -using Robust.Shared.Maths; using Robust.Shared.Player; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Morgue.Components { @@ -32,9 +22,7 @@ namespace Content.Server.Morgue.Components [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] [Virtual] -#pragma warning disable 618 - public class MorgueEntityStorageComponent : EntityStorageComponent, IExamine -#pragma warning restore 618 + public class MorgueEntityStorageComponent : EntityStorageComponent { [Dependency] private readonly IEntityManager _entMan = default!; @@ -179,30 +167,5 @@ namespace Content.Server.Morgue.Components SoundSystem.Play(Filter.Pvs(Owner), _occupantHasSoulAlarmSound.GetSound(), Owner); } } - - void IExamine.Examine(FormattedMessage message, bool inDetailsRange) - { - if (!_entMan.TryGetComponent(Owner, out var appearance)) return; - - if (inDetailsRange) - { - if (appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) - { - message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-soul")); - } - else if (appearance.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob) - { - message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-no-soul")); - } - else if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) - { - message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents")); - } - else - { - message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty")); - } - } - } } } diff --git a/Content.Server/Morgue/MorgueSystem.cs b/Content.Server/Morgue/MorgueSystem.cs index 8ce75a3cf1..ef345c5c6e 100644 --- a/Content.Server/Morgue/MorgueSystem.cs +++ b/Content.Server/Morgue/MorgueSystem.cs @@ -1,10 +1,9 @@ using Content.Server.Morgue.Components; -using Content.Shared.Administration.Logs; +using Content.Shared.Morgue; +using Content.Shared.Examine; using Content.Shared.Database; using Content.Shared.Verbs; using JetBrains.Annotations; -using Robust.Shared.GameObjects; -using Robust.Shared.Localization; namespace Content.Server.Morgue { @@ -19,6 +18,8 @@ namespace Content.Server.Morgue base.Initialize(); SubscribeLocalEvent>(AddCremateVerb); + SubscribeLocalEvent(OnCrematoriumExamined); + SubscribeLocalEvent(OnMorgueExamined); } private void AddCremateVerb(EntityUid uid, CrematoriumEntityStorageComponent component, GetVerbsEvent args) @@ -34,6 +35,53 @@ namespace Content.Server.Morgue args.Verbs.Add(verb); } + private void OnCrematoriumExamined(EntityUid uid, CrematoriumEntityStorageComponent component, ExaminedEvent args) + { + if (!TryComp(uid, out var appearance)) + return; + + if (args.IsInDetailsRange) + { + if (appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning) + { + args.PushMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", uid))); + } + + if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) + { + args.PushMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-has-contents")); + } + else + { + args.PushMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-empty")); + } + } + } + + private void OnMorgueExamined(EntityUid uid, MorgueEntityStorageComponent component, ExaminedEvent args) + { + if (!TryComp(uid, out var appearance)) return; + + if (args.IsInDetailsRange) + { + if (appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) + { + args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-soul")); + } + else if (appearance.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob) + { + args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-no-soul")); + } + else if (appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) + { + args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents")); + } + else + { + args.PushMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty")); + } + } + } public override void Update(float frameTime) { _accumulatedFrameTime += frameTime; diff --git a/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs b/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs index 01e3ac9f1b..c0a987ded9 100644 --- a/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs +++ b/Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs @@ -1,7 +1,7 @@ using Content.Server.NodeContainer.Nodes; +using Content.Server.NodeContainer.NodeGroups; +using Content.Shared.Examine; using JetBrains.Annotations; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; namespace Content.Server.NodeContainer.EntitySystems { @@ -23,6 +23,7 @@ namespace Content.Server.NodeContainer.EntitySystems SubscribeLocalEvent(OnShutdownEvent); SubscribeLocalEvent(OnAnchorStateChanged); SubscribeLocalEvent(OnRotateEvent); + SubscribeLocalEvent(OnExamine); } private void OnInitEvent(EntityUid uid, NodeContainerComponent component, ComponentInit args) @@ -92,5 +93,31 @@ namespace Content.Server.NodeContainer.EntitySystems _nodeGroupSystem.QueueReflood(node); } } + + private void OnExamine(EntityUid uid, NodeContainerComponent component, ExaminedEvent args) + { + if (!component.Examinable || !args.IsInDetailsRange) + return; + + foreach (var node in component.Nodes.Values) + { + if (node == null) continue; + switch (node.NodeGroupID) + { + case NodeGroupID.HVPower: + args.PushMarkup( + Loc.GetString("node-container-component-on-examine-details-hvpower")); + break; + case NodeGroupID.MVPower: + args.PushMarkup( + Loc.GetString("node-container-component-on-examine-details-mvpower")); + break; + case NodeGroupID.Apc: + args.PushMarkup( + Loc.GetString("node-container-component-on-examine-details-apc")); + break; + } + } + } } } diff --git a/Content.Server/NodeContainer/NodeContainerComponent.cs b/Content.Server/NodeContainer/NodeContainerComponent.cs index 39530354f8..6156d74f12 100644 --- a/Content.Server/NodeContainer/NodeContainerComponent.cs +++ b/Content.Server/NodeContainer/NodeContainerComponent.cs @@ -1,13 +1,5 @@ -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Content.Server.NodeContainer.NodeGroups; using Content.Server.NodeContainer.Nodes; -using Content.Shared.Examine; -using Robust.Shared.GameObjects; -using Robust.Shared.Localization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.NodeContainer { @@ -15,14 +7,12 @@ namespace Content.Server.NodeContainer /// Creates and maintains a set of s. /// [RegisterComponent] -#pragma warning disable 618 - public sealed class NodeContainerComponent : Component, IExamine -#pragma warning restore 618 + public sealed class NodeContainerComponent : Component { //HACK: THIS BEING readOnly IS A FILTHY HACK AND I HATE IT --moony [DataField("nodes", readOnly: true)] [ViewVariables] public Dictionary Nodes { get; } = new(); - [DataField("examinable")] private bool _examinable = false; + [DataField("examinable")] public bool Examinable = false; public T GetNode(string identifier) where T : Node { @@ -40,30 +30,5 @@ namespace Content.Server.NodeContainer node = null; return false; } - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - if (!_examinable || !inDetailsRange) return; - - foreach (var node in Nodes.Values) - { - if (node == null) continue; - switch (node.NodeGroupID) - { - case NodeGroupID.HVPower: - message.AddMarkup( - Loc.GetString("node-container-component-on-examine-details-hvpower") + "\n"); - break; - case NodeGroupID.MVPower: - message.AddMarkup( - Loc.GetString("node-container-component-on-examine-details-mvpower") + "\n"); - break; - case NodeGroupID.Apc: - message.AddMarkup( - Loc.GetString("node-container-component-on-examine-details-apc") + "\n"); - break; - } - } - } } } diff --git a/Content.Server/Paper/PaperComponent.cs b/Content.Server/Paper/PaperComponent.cs index 5259b896cc..c7ae68ac14 100644 --- a/Content.Server/Paper/PaperComponent.cs +++ b/Content.Server/Paper/PaperComponent.cs @@ -1,19 +1,16 @@ using System.Threading.Tasks; using Content.Server.UserInterface; -using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Paper; using Content.Shared.Tag; using Robust.Server.GameObjects; -using Robust.Shared.Utility; - namespace Content.Server.Paper { [RegisterComponent] #pragma warning disable 618 [ComponentReference(typeof(SharedPaperComponent))] - public sealed class PaperComponent : SharedPaperComponent, IExamine, IInteractUsing + public sealed class PaperComponent : SharedPaperComponent, IInteractUsing #pragma warning restore 618 { [Dependency] private readonly IEntityManager _entMan = default!; @@ -61,21 +58,6 @@ namespace Content.Server.Paper { UserInterface?.SetState(new PaperBoundUserInterfaceState(Content, Mode)); } - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - if (!inDetailsRange) - return; - if (Content == "") - return; - - message.AddMarkup( - Loc.GetString( - "paper-component-examine-detail-has-words" - ) - ); - } - private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj) { var msg = (PaperInputText) obj.Message; diff --git a/Content.Server/Paper/PaperSystem.cs b/Content.Server/Paper/PaperSystem.cs index edf578d61d..5d4f1cd796 100644 --- a/Content.Server/Paper/PaperSystem.cs +++ b/Content.Server/Paper/PaperSystem.cs @@ -1,4 +1,5 @@ using Content.Server.UserInterface; +using Content.Shared.Examine; using Content.Shared.Paper; namespace Content.Server.Paper @@ -9,6 +10,7 @@ namespace Content.Server.Paper { base.Initialize(); SubscribeLocalEvent(AfterUIOpen); + SubscribeLocalEvent(OnExamined); } private void AfterUIOpen(EntityUid uid, PaperComponent component, BeforeActivatableUIOpenEvent args) @@ -16,5 +18,19 @@ namespace Content.Server.Paper component.Mode = SharedPaperComponent.PaperAction.Read; component.UpdateUserInterface(); } + + private void OnExamined(EntityUid uid, PaperComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange) + return; + if (component.Content == "") + return; + + args.PushMarkup( + Loc.GetString( + "paper-component-examine-detail-has-words" + ) + ); + } } } diff --git a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs index 71b6bfc0dc..6ec6531d06 100644 --- a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs +++ b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs @@ -1,17 +1,6 @@ -using System; -using System.Diagnostics.CodeAnalysis; using Content.Server.Power.NodeGroups; using Content.Server.Power.Pow3r; -using Content.Shared.Examine; using Content.Shared.Power; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Maths; -using Robust.Shared.Physics; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Power.Components { @@ -20,9 +9,7 @@ namespace Content.Server.Power.Components /// so that it can receive power from a . /// [RegisterComponent] -#pragma warning disable 618 - public sealed class ApcPowerReceiverComponent : Component, IExamine -#pragma warning restore 618 + public sealed class ApcPowerReceiverComponent : Component { [Dependency] private readonly IEntityManager _entMan = default!; @@ -89,16 +76,6 @@ namespace Content.Server.Power.Components appearance.SetData(PowerDeviceVisuals.Powered, Powered); } } - - /// - ///Adds some markup to the examine text of whatever object is using this component to tell you if it's powered or not, even if it doesn't have an icon state to do this for you. - /// - public void Examine(FormattedMessage message, bool inDetailsRange) - { - message.AddMarkup(Loc.GetString("power-receiver-component-on-examine-main", - ("stateText", Loc.GetString( Powered ? "power-receiver-component-on-examine-powered" : - "power-receiver-component-on-examine-unpowered")))); - } } /// diff --git a/Content.Server/Power/Components/ExaminableBatteryComponent.cs b/Content.Server/Power/Components/ExaminableBatteryComponent.cs index 466621d5ce..de4154afbc 100644 --- a/Content.Server/Power/Components/ExaminableBatteryComponent.cs +++ b/Content.Server/Power/Components/ExaminableBatteryComponent.cs @@ -1,38 +1,6 @@ -using Content.Shared.Examine; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; - namespace Content.Server.Power.Components { [RegisterComponent] -#pragma warning disable 618 - public sealed class ExaminableBatteryComponent : Component, IExamine -#pragma warning restore 618 - { - [Dependency] private readonly IEntityManager _entityManager = default!; - - void IExamine.Examine(FormattedMessage message, bool inDetailsRange) - { - if (!_entityManager.TryGetComponent(Owner, out var batteryComponent)) - return; - if (inDetailsRange) - { - var effectiveMax = batteryComponent.MaxCharge; - if (effectiveMax == 0) - effectiveMax = 1; - var chargeFraction = batteryComponent.CurrentCharge / effectiveMax; - var chargePercentRounded = (int) (chargeFraction * 100); - message.AddMarkup( - Loc.GetString( - "examinable-battery-component-examine-detail", - ("percent", chargePercentRounded), - ("markupPercentColor", "green") - ) - ); - } - } - } + public sealed class ExaminableBatteryComponent : Component + {} } diff --git a/Content.Server/Power/EntitySystems/ApcSystem.cs b/Content.Server/Power/EntitySystems/ApcSystem.cs index c7a1b64e60..e4c805d61f 100644 --- a/Content.Server/Power/EntitySystems/ApcSystem.cs +++ b/Content.Server/Power/EntitySystems/ApcSystem.cs @@ -1,7 +1,5 @@ -using System; using Content.Server.Popups; using Content.Server.Power.Components; -using Content.Server.Power.Pow3r; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.APC; @@ -9,10 +7,6 @@ using Content.Shared.Emag.Systems; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Maths; using Robust.Shared.Player; using Robust.Shared.Timing; @@ -48,7 +42,6 @@ namespace Content.Server.Power.EntitySystems { UpdateApcState(uid, component); } - private void OnToggleMainBreaker(EntityUid uid, ApcComponent component, ApcToggleMainBreakerMessage args) { TryComp(uid, out var access); diff --git a/Content.Server/Power/EntitySystems/BatterySystem.cs b/Content.Server/Power/EntitySystems/BatterySystem.cs index 723e25a5bb..80d2998511 100644 --- a/Content.Server/Power/EntitySystems/BatterySystem.cs +++ b/Content.Server/Power/EntitySystems/BatterySystem.cs @@ -1,6 +1,6 @@ using Content.Server.Power.Components; +using Content.Shared.Examine; using JetBrains.Annotations; -using Robust.Shared.GameObjects; namespace Content.Server.Power.EntitySystems { @@ -11,10 +11,33 @@ namespace Content.Server.Power.EntitySystems { base.Initialize(); + SubscribeLocalEvent(OnExamine); + SubscribeLocalEvent(PreSync); SubscribeLocalEvent(PostSync); } + private void OnExamine(EntityUid uid, ExaminableBatteryComponent component, ExaminedEvent args) + { + if (!TryComp(uid, out var batteryComponent)) + return; + if (args.IsInDetailsRange) + { + var effectiveMax = batteryComponent.MaxCharge; + if (effectiveMax == 0) + effectiveMax = 1; + var chargeFraction = batteryComponent.CurrentCharge / effectiveMax; + var chargePercentRounded = (int) (chargeFraction * 100); + args.PushMarkup( + Loc.GetString( + "examinable-battery-component-examine-detail", + ("percent", chargePercentRounded), + ("markupPercentColor", "green") + ) + ); + } + } + private void PreSync(NetworkBatteryPreSync ev) { foreach (var (netBat, bat) in EntityManager.EntityQuery()) diff --git a/Content.Server/Power/EntitySystems/PowerReceiverSystem.cs b/Content.Server/Power/EntitySystems/PowerReceiverSystem.cs index d2004f084e..0bcaf1f4af 100644 --- a/Content.Server/Power/EntitySystems/PowerReceiverSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerReceiverSystem.cs @@ -1,6 +1,5 @@ using Content.Server.Power.Components; -using Robust.Shared.GameObjects; - +using Content.Shared.Examine; namespace Content.Server.Power.EntitySystems { public sealed class PowerReceiverSystem : EntitySystem @@ -8,6 +7,7 @@ namespace Content.Server.Power.EntitySystems public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnProviderConnected); SubscribeLocalEvent(OnProviderDisconnected); @@ -17,6 +17,16 @@ namespace Content.Server.Power.EntitySystems SubscribeLocalEvent(OnReceiverDisconnected); } + /// + ///Adds some markup to the examine text of whatever object is using this component to tell you if it's powered or not, even if it doesn't have an icon state to do this for you. + /// + private void OnExamined(EntityUid uid, ApcPowerReceiverComponent component, ExaminedEvent args) + { + args.PushMarkup(Loc.GetString("power-receiver-component-on-examine-main", + ("stateText", Loc.GetString( component.Powered ? "power-receiver-component-on-examine-powered" : + "power-receiver-component-on-examine-unpowered")))); + } + private void OnProviderShutdown(EntityUid uid, ApcPowerProviderComponent component, ComponentShutdown args) { foreach (var receiver in component.LinkedReceivers) diff --git a/Content.Server/Radio/Components/HandheldRadioComponent.cs b/Content.Server/Radio/Components/HandheldRadioComponent.cs index 493a58f488..3cd28c453f 100644 --- a/Content.Server/Radio/Components/HandheldRadioComponent.cs +++ b/Content.Server/Radio/Components/HandheldRadioComponent.cs @@ -2,16 +2,8 @@ using System.Collections.Generic; using Content.Server.Chat; using Content.Server.Chat.Managers; using Content.Server.Radio.EntitySystems; -using Content.Shared.Examine; using Content.Shared.Interaction; -using Content.Shared.Interaction.Helpers; using Content.Shared.Popups; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Radio.Components { @@ -21,7 +13,7 @@ namespace Content.Server.Radio.Components [ComponentReference(typeof(IListen))] [ComponentReference(typeof(IActivate))] #pragma warning disable 618 - public sealed class HandheldRadioComponent : Component, IListen, IRadio, IActivate, IExamine + public sealed class HandheldRadioComponent : Component, IListen, IRadio, IActivate #pragma warning restore 618 { private ChatSystem _chatSystem = default!; @@ -33,7 +25,7 @@ namespace Content.Server.Radio.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("broadcastChannel")] - private int BroadcastFrequency { get; set; } = 1459; + public int BroadcastFrequency { get; set; } = 1459; [ViewVariables(VVAccess.ReadWrite)] [DataField("listenRange")] public int ListenRange { get; private set; } = 7; @@ -104,10 +96,5 @@ namespace Content.Server.Radio.Components { Use(eventArgs.User); } - - public void Examine(FormattedMessage message, bool inDetailsRange) - { - message.AddText(Loc.GetString("handheld-radio-component-on-examine",("frequency", BroadcastFrequency))); - } } } diff --git a/Content.Server/Radio/EntitySystems/RadioSystem.cs b/Content.Server/Radio/EntitySystems/RadioSystem.cs index 872f2e2086..4136698723 100644 --- a/Content.Server/Radio/EntitySystems/RadioSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioSystem.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; -using System.Linq; +using System.Linq; +using Content.Shared.Examine; using Content.Server.Radio.Components; using JetBrains.Annotations; -using Robust.Shared.GameObjects; namespace Content.Server.Radio.EntitySystems { @@ -11,6 +10,19 @@ namespace Content.Server.Radio.EntitySystems { private readonly List _messages = new(); + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnExamine); + } + + private void OnExamine(EntityUid uid, HandheldRadioComponent component, ExaminedEvent args) + { + if (!args.IsInDetailsRange) + return; + args.PushMarkup(Loc.GetString("handheld-radio-component-on-examine",("frequency", component.BroadcastFrequency))); + } + public void SpreadMessage(IRadio source, EntityUid speaker, string message, int channel) { if (_messages.Contains(message)) return; diff --git a/Content.Server/Suspicion/SuspicionRoleComponent.cs b/Content.Server/Suspicion/SuspicionRoleComponent.cs index a7e28c9245..c5726c76f3 100644 --- a/Content.Server/Suspicion/SuspicionRoleComponent.cs +++ b/Content.Server/Suspicion/SuspicionRoleComponent.cs @@ -1,25 +1,15 @@ -using System; -using System.Collections.Generic; using System.Linq; using Content.Server.GameTicking.Rules; using Content.Server.Mind.Components; using Content.Server.Roles; using Content.Server.Suspicion.Roles; -using Content.Shared.Examine; using Content.Shared.MobState.Components; using Content.Shared.Suspicion; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Utility; -using Robust.Shared.ViewVariables; namespace Content.Server.Suspicion { [RegisterComponent] -#pragma warning disable 618 - public sealed class SuspicionRoleComponent : SharedSuspicionRoleComponent, IExamine -#pragma warning restore 618 + public sealed class SuspicionRoleComponent : SharedSuspicionRoleComponent { [Dependency] private readonly IEntityManager _entMan = default!; @@ -123,27 +113,6 @@ namespace Content.Server.Suspicion Dirty(); } - - void IExamine.Examine(FormattedMessage message, bool inDetailsRange) - { - if (!IsDead()) - { - return; - } - - var traitor = IsTraitor(); - var color = traitor ? "red" : "green"; - var role = traitor ? "suspicion-role-component-role-traitor" : "suspicion-role-component-role-innocent"; - var article = traitor ? "generic-article-a" : "generic-article-an"; - - var tooltip = Loc.GetString("suspicion-role-component-on-examine-tooltip", - ("article", Loc.GetString(article)), - ("colorName", color), - ("role",Loc.GetString(role))); - - message.AddMarkup(tooltip); - } - public override ComponentState GetComponentState() { if (Role == null) diff --git a/Content.Server/Suspicion/SuspicionRoleSystem.cs b/Content.Server/Suspicion/SuspicionRoleSystem.cs new file mode 100644 index 0000000000..d23269b95c --- /dev/null +++ b/Content.Server/Suspicion/SuspicionRoleSystem.cs @@ -0,0 +1,32 @@ +using Content.Shared.Examine; + +namespace Content.Server.Suspicion +{ + public sealed class SuspicionRoleSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnExamined); + } + private void OnExamined(EntityUid uid, SuspicionRoleComponent component, ExaminedEvent args) + { + if (!component.IsDead()) + { + return; + } + + var traitor = component.IsTraitor(); + var color = traitor ? "red" : "green"; + var role = traitor ? "suspicion-role-component-role-traitor" : "suspicion-role-component-role-innocent"; + var article = traitor ? "generic-article-a" : "generic-article-an"; + + var tooltip = Loc.GetString("suspicion-role-component-on-examine-tooltip", + ("article", Loc.GetString(article)), + ("colorName", color), + ("role",Loc.GetString(role))); + + args.PushMarkup(tooltip); + } + } +} diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 72ed6651cd..12073c2e29 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -1,34 +1,16 @@ -using System; -using System.Collections.Generic; using System.Linq; using Content.Shared.DragDrop; using Content.Shared.Interaction; -using Content.Shared.Interaction.Helpers; using Content.Shared.MobState.Components; using JetBrains.Annotations; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Log; using Robust.Shared.Map; -using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Utility; using static Content.Shared.Interaction.SharedInteractionSystem; namespace Content.Shared.Examine { - [Obsolete("Use ExaminedEvent instead.")] - public interface IExamine - { - /// - /// Returns a status examine value for components appended to the end of the description of the entity - /// - /// The message to append to which will be displayed. - /// Whether the examiner is within the 'Details' range, allowing you to show information logically only availabe when close to the examined entity. - void Examine(FormattedMessage message, bool inDetailsRange); - } - public abstract class ExamineSystemShared : EntitySystem { [Dependency] private readonly SharedContainerSystem _containerSystem = default!; @@ -269,21 +251,6 @@ namespace Content.Shared.Examine var examinedEvent = new ExaminedEvent(message, entity, examiner.Value, isInDetailsRange, doNewline); RaiseLocalEvent(entity, examinedEvent); - //Add component statuses from components that report one - foreach (var examineComponent in EntityManager.GetComponents(entity)) - { - var subMessage = new FormattedMessage(); - examineComponent.Examine(subMessage, isInDetailsRange); - if (subMessage.Tags.Count == 0) - continue; - - if (doNewline) - message.AddText("\n"); - - message.AddMessage(subMessage); - doNewline = true; - } - message.Pop(); return message;