From 0e3a2b3ba1d7bd0cd192e162a1d15a69dc8feaa9 Mon Sep 17 00:00:00 2001 From: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Date: Thu, 9 May 2024 18:26:39 -0700 Subject: [PATCH] Move id and health examinable to shared (#27867) * Move id and health examinable to shared * Make GetInfo public --- .../Access/Components/IdExaminableComponent.cs | 8 -------- Content.Server/Body/Systems/BloodstreamSystem.cs | 2 +- .../Access/Components/IdCardComponent.cs | 6 ++++++ .../Access/Components/IdExaminableComponent.cs | 6 ++++++ .../Access/Systems/IdExaminableSystem.cs | 16 ++++++++++------ .../Access/Systems/SharedIdCardSystem.cs | 4 ++-- .../HealthExaminableComponent.cs | 10 +++++----- .../HealthExaminable/HealthExaminableSystem.cs | 4 ++-- 8 files changed, 32 insertions(+), 24 deletions(-) delete mode 100644 Content.Server/Access/Components/IdExaminableComponent.cs create mode 100644 Content.Shared/Access/Components/IdExaminableComponent.cs rename {Content.Server => Content.Shared}/Access/Systems/IdExaminableSystem.cs (85%) rename {Content.Server => Content.Shared}/HealthExaminable/HealthExaminableComponent.cs (64%) rename {Content.Server => Content.Shared}/HealthExaminable/HealthExaminableSystem.cs (95%) diff --git a/Content.Server/Access/Components/IdExaminableComponent.cs b/Content.Server/Access/Components/IdExaminableComponent.cs deleted file mode 100644 index 2def517f40..0000000000 --- a/Content.Server/Access/Components/IdExaminableComponent.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Content.Server.Access.Systems; - -namespace Content.Server.Access.Components; - -[RegisterComponent, Access(typeof(IdExaminableSystem))] -public sealed partial class IdExaminableComponent : Component -{ -} diff --git a/Content.Server/Body/Systems/BloodstreamSystem.cs b/Content.Server/Body/Systems/BloodstreamSystem.cs index 9e29fdf756..ddeb154e79 100644 --- a/Content.Server/Body/Systems/BloodstreamSystem.cs +++ b/Content.Server/Body/Systems/BloodstreamSystem.cs @@ -3,7 +3,6 @@ using Content.Server.Chemistry.Containers.EntitySystems; using Content.Server.Chemistry.ReactionEffects; using Content.Server.Fluids.EntitySystems; using Content.Server.Forensics; -using Content.Server.HealthExaminable; using Content.Server.Popups; using Content.Shared.Alert; using Content.Shared.Chemistry.Components; @@ -13,6 +12,7 @@ using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; using Content.Shared.Drunk; using Content.Shared.FixedPoint; +using Content.Shared.HealthExaminable; using Content.Shared.Mobs.Systems; using Content.Shared.Popups; using Content.Shared.Rejuvenate; diff --git a/Content.Shared/Access/Components/IdCardComponent.cs b/Content.Shared/Access/Components/IdCardComponent.cs index 26e83c5586..39d5d9d27f 100644 --- a/Content.Shared/Access/Components/IdCardComponent.cs +++ b/Content.Shared/Access/Components/IdCardComponent.cs @@ -40,4 +40,10 @@ public sealed partial class IdCardComponent : Component /// [DataField, ViewVariables(VVAccess.ReadWrite)] public bool BypassLogging; + + [DataField] + public LocId NameLocId = "access-id-card-component-owner-name-job-title-text"; + + [DataField] + public LocId FullNameLocId = "access-id-card-component-owner-full-name-job-title-text"; } diff --git a/Content.Shared/Access/Components/IdExaminableComponent.cs b/Content.Shared/Access/Components/IdExaminableComponent.cs new file mode 100644 index 0000000000..87d3e03a14 --- /dev/null +++ b/Content.Shared/Access/Components/IdExaminableComponent.cs @@ -0,0 +1,6 @@ +using Content.Shared.Access.Systems; + +namespace Content.Shared.Access.Components; + +[RegisterComponent, Access(typeof(IdExaminableSystem))] +public sealed partial class IdExaminableComponent : Component; diff --git a/Content.Server/Access/Systems/IdExaminableSystem.cs b/Content.Shared/Access/Systems/IdExaminableSystem.cs similarity index 85% rename from Content.Server/Access/Systems/IdExaminableSystem.cs rename to Content.Shared/Access/Systems/IdExaminableSystem.cs index c2231605e4..333272e27a 100644 --- a/Content.Server/Access/Systems/IdExaminableSystem.cs +++ b/Content.Shared/Access/Systems/IdExaminableSystem.cs @@ -1,4 +1,3 @@ -using Content.Server.Access.Components; using Content.Shared.Access.Components; using Content.Shared.Examine; using Content.Shared.Inventory; @@ -6,7 +5,7 @@ using Content.Shared.PDA; using Content.Shared.Verbs; using Robust.Shared.Utility; -namespace Content.Server.Access.Systems; +namespace Content.Shared.Access.Systems; public sealed class IdExaminableSystem : EntitySystem { @@ -22,7 +21,7 @@ public sealed class IdExaminableSystem : EntitySystem private void OnGetExamineVerbs(EntityUid uid, IdExaminableComponent component, GetVerbsEvent args) { var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid); - var info = GetInfo(uid) ?? Loc.GetString("id-examinable-component-verb-no-id"); + var info = GetMessage(uid); var verb = new ExamineVerb() { @@ -41,7 +40,12 @@ public sealed class IdExaminableSystem : EntitySystem args.Verbs.Add(verb); } - private string? GetInfo(EntityUid uid) + public string GetMessage(EntityUid uid) + { + return GetInfo(uid) ?? Loc.GetString("id-examinable-component-verb-no-id"); + } + + public string? GetInfo(EntityUid uid) { if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid)) { @@ -65,9 +69,9 @@ public sealed class IdExaminableSystem : EntitySystem var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})"; var val = string.IsNullOrWhiteSpace(id.FullName) - ? Loc.GetString("access-id-card-component-owner-name-job-title-text", + ? Loc.GetString(id.NameLocId, ("jobSuffix", jobSuffix)) - : Loc.GetString("access-id-card-component-owner-full-name-job-title-text", + : Loc.GetString(id.FullNameLocId, ("fullName", id.FullName), ("jobSuffix", jobSuffix)); diff --git a/Content.Shared/Access/Systems/SharedIdCardSystem.cs b/Content.Shared/Access/Systems/SharedIdCardSystem.cs index 11a61c7bf3..bfde70f504 100644 --- a/Content.Shared/Access/Systems/SharedIdCardSystem.cs +++ b/Content.Shared/Access/Systems/SharedIdCardSystem.cs @@ -207,9 +207,9 @@ public abstract class SharedIdCardSystem : EntitySystem var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})"; var val = string.IsNullOrWhiteSpace(id.FullName) - ? Loc.GetString("access-id-card-component-owner-name-job-title-text", + ? Loc.GetString(id.NameLocId, ("jobSuffix", jobSuffix)) - : Loc.GetString("access-id-card-component-owner-full-name-job-title-text", + : Loc.GetString(id.FullNameLocId, ("fullName", id.FullName), ("jobSuffix", jobSuffix)); _metaSystem.SetEntityName(uid, val); diff --git a/Content.Server/HealthExaminable/HealthExaminableComponent.cs b/Content.Shared/HealthExaminable/HealthExaminableComponent.cs similarity index 64% rename from Content.Server/HealthExaminable/HealthExaminableComponent.cs rename to Content.Shared/HealthExaminable/HealthExaminableComponent.cs index 3f434a93cf..e63a4cde15 100644 --- a/Content.Server/HealthExaminable/HealthExaminableComponent.cs +++ b/Content.Shared/HealthExaminable/HealthExaminableComponent.cs @@ -1,8 +1,8 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set; +using Robust.Shared.Prototypes; -namespace Content.Server.HealthExaminable; +namespace Content.Shared.HealthExaminable; [RegisterComponent, Access(typeof(HealthExaminableSystem))] public sealed partial class HealthExaminableComponent : Component @@ -10,14 +10,14 @@ public sealed partial class HealthExaminableComponent : Component public List Thresholds = new() { FixedPoint2.New(10), FixedPoint2.New(25), FixedPoint2.New(50), FixedPoint2.New(75) }; - [DataField("examinableTypes", required: true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer))] - public HashSet ExaminableTypes = default!; + [DataField(required: true)] + public HashSet> ExaminableTypes = default!; /// /// Health examine text is automatically generated through creating loc string IDs, in the form: /// `health-examine-[prefix]-[type]-[threshold]` /// This part determines the prefix. /// - [DataField("locPrefix")] + [DataField] public string LocPrefix = "carbon"; } diff --git a/Content.Server/HealthExaminable/HealthExaminableSystem.cs b/Content.Shared/HealthExaminable/HealthExaminableSystem.cs similarity index 95% rename from Content.Server/HealthExaminable/HealthExaminableSystem.cs rename to Content.Shared/HealthExaminable/HealthExaminableSystem.cs index ed69a1c096..141f3be512 100644 --- a/Content.Server/HealthExaminable/HealthExaminableSystem.cs +++ b/Content.Shared/HealthExaminable/HealthExaminableSystem.cs @@ -5,7 +5,7 @@ using Content.Shared.IdentityManagement; using Content.Shared.Verbs; using Robust.Shared.Utility; -namespace Content.Server.HealthExaminable; +namespace Content.Shared.HealthExaminable; public sealed class HealthExaminableSystem : EntitySystem { @@ -42,7 +42,7 @@ public sealed class HealthExaminableSystem : EntitySystem args.Verbs.Add(verb); } - private FormattedMessage CreateMarkup(EntityUid uid, HealthExaminableComponent component, DamageableComponent damage) + public FormattedMessage CreateMarkup(EntityUid uid, HealthExaminableComponent component, DamageableComponent damage) { var msg = new FormattedMessage();