Fix SSD indicator (#24589)

Fix ssd indicator
This commit is contained in:
Kot
2024-02-01 12:30:07 +04:00
committed by GitHub
parent ed48bd415b
commit fed43f05d0
3 changed files with 20 additions and 25 deletions

View File

@@ -1,4 +1,7 @@
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.NPC;
using Content.Shared.SSDIndicator; using Content.Shared.SSDIndicator;
using Content.Shared.StatusIcon; using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components; using Content.Shared.StatusIcon.Components;
@@ -14,6 +17,7 @@ public sealed class SSDIndicatorSystem : EntitySystem
{ {
[Dependency] private readonly IPrototypeManager _prototype = default!; [Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -24,11 +28,15 @@ public sealed class SSDIndicatorSystem : EntitySystem
private void OnGetStatusIcon(EntityUid uid, SSDIndicatorComponent component, ref GetStatusIconsEvent args) private void OnGetStatusIcon(EntityUid uid, SSDIndicatorComponent component, ref GetStatusIconsEvent args)
{ {
if (!component.IsSSD || if (component.IsSSD &&
!_cfg.GetCVar(CCVars.ICShowSSDIndicator) || _cfg.GetCVar(CCVars.ICShowSSDIndicator) &&
args.InContainer) !args.InContainer &&
return; !_mobState.IsDead(uid) &&
!HasComp<ActiveNPCComponent>(uid) &&
TryComp<MindContainerComponent>(uid, out var mindContainer) &&
mindContainer.ShowExamineInfo)
{
args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.Icon)); args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.Icon));
} }
}
} }

View File

@@ -13,7 +13,7 @@ public sealed partial class SSDIndicatorComponent : Component
{ {
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField] [AutoNetworkedField]
public bool IsSSD = false; public bool IsSSD = true;
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer<StatusIconPrototype>))] [DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer<StatusIconPrototype>))]

View File

@@ -1,5 +1,4 @@
using Content.Shared.Mind.Components; using Robust.Shared.Player;
using Content.Shared.NPC;
namespace Content.Shared.SSDIndicator; namespace Content.Shared.SSDIndicator;
@@ -10,30 +9,18 @@ public sealed class SSDIndicatorSystem : EntitySystem
{ {
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<SSDIndicatorComponent, ComponentInit>(OnInit); SubscribeLocalEvent<SSDIndicatorComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<SSDIndicatorComponent, MindAddedMessage>(OnMindAdded); SubscribeLocalEvent<SSDIndicatorComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<SSDIndicatorComponent, MindRemovedMessage>(OnMindRemoved);
} }
private void OnInit(EntityUid uid, SSDIndicatorComponent component, ComponentInit args) private void OnPlayerAttached(EntityUid uid, SSDIndicatorComponent component, PlayerAttachedEvent args)
{
if (HasComp<ActiveNPCComponent>(uid))
return;
component.IsSSD = !HasComp<MindContainerComponent>(uid);
}
private void OnMindAdded(EntityUid uid, SSDIndicatorComponent component, MindAddedMessage args)
{ {
component.IsSSD = false; component.IsSSD = false;
Dirty(uid, component); Dirty(uid, component);
} }
private void OnMindRemoved(EntityUid uid, SSDIndicatorComponent component, MindRemovedMessage args) private void OnPlayerDetached(EntityUid uid, SSDIndicatorComponent component, PlayerDetachedEvent args)
{ {
if (HasComp<ActiveNPCComponent>(uid))
return;
component.IsSSD = true; component.IsSSD = true;
Dirty(uid, component); Dirty(uid, component);
} }