Move id and health examinable to shared (#27867)
* Move id and health examinable to shared * Make GetInfo public
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
using Content.Server.Access.Systems;
|
|
||||||
|
|
||||||
namespace Content.Server.Access.Components;
|
|
||||||
|
|
||||||
[RegisterComponent, Access(typeof(IdExaminableSystem))]
|
|
||||||
public sealed partial class IdExaminableComponent : Component
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ using Content.Server.Chemistry.Containers.EntitySystems;
|
|||||||
using Content.Server.Chemistry.ReactionEffects;
|
using Content.Server.Chemistry.ReactionEffects;
|
||||||
using Content.Server.Fluids.EntitySystems;
|
using Content.Server.Fluids.EntitySystems;
|
||||||
using Content.Server.Forensics;
|
using Content.Server.Forensics;
|
||||||
using Content.Server.HealthExaminable;
|
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
@@ -13,6 +12,7 @@ using Content.Shared.Damage;
|
|||||||
using Content.Shared.Damage.Prototypes;
|
using Content.Shared.Damage.Prototypes;
|
||||||
using Content.Shared.Drunk;
|
using Content.Shared.Drunk;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
|
using Content.Shared.HealthExaminable;
|
||||||
using Content.Shared.Mobs.Systems;
|
using Content.Shared.Mobs.Systems;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Rejuvenate;
|
using Content.Shared.Rejuvenate;
|
||||||
|
|||||||
@@ -40,4 +40,10 @@ public sealed partial class IdCardComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool BypassLogging;
|
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";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using Content.Shared.Access.Systems;
|
||||||
|
|
||||||
|
namespace Content.Shared.Access.Components;
|
||||||
|
|
||||||
|
[RegisterComponent, Access(typeof(IdExaminableSystem))]
|
||||||
|
public sealed partial class IdExaminableComponent : Component;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Server.Access.Components;
|
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
@@ -6,7 +5,7 @@ using Content.Shared.PDA;
|
|||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.Access.Systems;
|
namespace Content.Shared.Access.Systems;
|
||||||
|
|
||||||
public sealed class IdExaminableSystem : EntitySystem
|
public sealed class IdExaminableSystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -22,7 +21,7 @@ public sealed class IdExaminableSystem : EntitySystem
|
|||||||
private void OnGetExamineVerbs(EntityUid uid, IdExaminableComponent component, GetVerbsEvent<ExamineVerb> args)
|
private void OnGetExamineVerbs(EntityUid uid, IdExaminableComponent component, GetVerbsEvent<ExamineVerb> args)
|
||||||
{
|
{
|
||||||
var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid);
|
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()
|
var verb = new ExamineVerb()
|
||||||
{
|
{
|
||||||
@@ -41,7 +40,12 @@ public sealed class IdExaminableSystem : EntitySystem
|
|||||||
args.Verbs.Add(verb);
|
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))
|
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 jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
|
||||||
|
|
||||||
var val = string.IsNullOrWhiteSpace(id.FullName)
|
var val = string.IsNullOrWhiteSpace(id.FullName)
|
||||||
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
? Loc.GetString(id.NameLocId,
|
||||||
("jobSuffix", jobSuffix))
|
("jobSuffix", jobSuffix))
|
||||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
: Loc.GetString(id.FullNameLocId,
|
||||||
("fullName", id.FullName),
|
("fullName", id.FullName),
|
||||||
("jobSuffix", jobSuffix));
|
("jobSuffix", jobSuffix));
|
||||||
|
|
||||||
@@ -207,9 +207,9 @@ public abstract class SharedIdCardSystem : EntitySystem
|
|||||||
var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
|
var jobSuffix = string.IsNullOrWhiteSpace(id.JobTitle) ? string.Empty : $" ({id.JobTitle})";
|
||||||
|
|
||||||
var val = string.IsNullOrWhiteSpace(id.FullName)
|
var val = string.IsNullOrWhiteSpace(id.FullName)
|
||||||
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
? Loc.GetString(id.NameLocId,
|
||||||
("jobSuffix", jobSuffix))
|
("jobSuffix", jobSuffix))
|
||||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
: Loc.GetString(id.FullNameLocId,
|
||||||
("fullName", id.FullName),
|
("fullName", id.FullName),
|
||||||
("jobSuffix", jobSuffix));
|
("jobSuffix", jobSuffix));
|
||||||
_metaSystem.SetEntityName(uid, val);
|
_metaSystem.SetEntityName(uid, val);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Content.Shared.Damage.Prototypes;
|
using Content.Shared.Damage.Prototypes;
|
||||||
using Content.Shared.FixedPoint;
|
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))]
|
[RegisterComponent, Access(typeof(HealthExaminableSystem))]
|
||||||
public sealed partial class HealthExaminableComponent : Component
|
public sealed partial class HealthExaminableComponent : Component
|
||||||
@@ -10,14 +10,14 @@ public sealed partial class HealthExaminableComponent : Component
|
|||||||
public List<FixedPoint2> Thresholds = new()
|
public List<FixedPoint2> Thresholds = new()
|
||||||
{ FixedPoint2.New(10), FixedPoint2.New(25), FixedPoint2.New(50), FixedPoint2.New(75) };
|
{ FixedPoint2.New(10), FixedPoint2.New(25), FixedPoint2.New(50), FixedPoint2.New(75) };
|
||||||
|
|
||||||
[DataField("examinableTypes", required: true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<DamageTypePrototype>))]
|
[DataField(required: true)]
|
||||||
public HashSet<string> ExaminableTypes = default!;
|
public HashSet<ProtoId<DamageTypePrototype>> ExaminableTypes = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Health examine text is automatically generated through creating loc string IDs, in the form:
|
/// Health examine text is automatically generated through creating loc string IDs, in the form:
|
||||||
/// `health-examine-[prefix]-[type]-[threshold]`
|
/// `health-examine-[prefix]-[type]-[threshold]`
|
||||||
/// This part determines the prefix.
|
/// This part determines the prefix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("locPrefix")]
|
[DataField]
|
||||||
public string LocPrefix = "carbon";
|
public string LocPrefix = "carbon";
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ using Content.Shared.IdentityManagement;
|
|||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.HealthExaminable;
|
namespace Content.Shared.HealthExaminable;
|
||||||
|
|
||||||
public sealed class HealthExaminableSystem : EntitySystem
|
public sealed class HealthExaminableSystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,7 @@ public sealed class HealthExaminableSystem : EntitySystem
|
|||||||
args.Verbs.Add(verb);
|
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();
|
var msg = new FormattedMessage();
|
||||||
|
|
||||||
Reference in New Issue
Block a user