SSD Indicator (#19701)

This commit is contained in:
Morb
2023-09-11 08:52:56 +03:00
committed by GitHub
parent d80aca5d16
commit 2a143c873c
8 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using Content.Shared.CCVar;
using Content.Shared.SSDIndicator;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
namespace Content.Client.SSDIndicator;
/// <summary>
/// Handles displaying SSD indicator as status icon
/// </summary>
public sealed class SSDIndicatorSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SSDIndicatorComponent, GetStatusIconsEvent>(OnGetStatusIcon);
}
private void OnGetStatusIcon(EntityUid uid, SSDIndicatorComponent component, ref GetStatusIconsEvent args)
{
if (!component.IsSSD || !_cfg.GetCVar(CCVars.ICShowSSDIndicator))
return;
args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.Icon));
}
}

View File

@@ -1461,6 +1461,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<string> ICRandomSpeciesWeights = public static readonly CVarDef<string> ICRandomSpeciesWeights =
CVarDef.Create("ic.random_species_weights", "SpeciesWeights", CVar.SERVER); CVarDef.Create("ic.random_species_weights", "SpeciesWeights", CVar.SERVER);
/// <summary>
/// Control displaying SSD indicators near players
/// </summary>
public static readonly CVarDef<bool> ICShowSSDIndicator =
CVarDef.Create("ic.show_ssd_indicator", true, CVar.CLIENTONLY);
/* /*
* Salvage * Salvage
*/ */

View File

@@ -0,0 +1,21 @@
using Content.Shared.StatusIcon;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.SSDIndicator;
/// <summary>
/// Shows status icon when player in SSD
/// </summary>
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState]
public sealed partial class SSDIndicatorComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public bool IsSSD = true;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer<StatusIconPrototype>))]
public string Icon = "SSDIcon";
}

View File

@@ -0,0 +1,27 @@
using Content.Shared.Mind.Components;
namespace Content.Shared.SSDIndicator;
/// <summary>
/// Handle changing player SSD indicator status
/// </summary>
public sealed class SSDIndicatorSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<SSDIndicatorComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<SSDIndicatorComponent, MindRemovedMessage>(OnMindRemoved);
}
private void OnMindAdded(EntityUid uid, SSDIndicatorComponent component, MindAddedMessage args)
{
component.IsSSD = false;
Dirty(uid, component);
}
private void OnMindRemoved(EntityUid uid, SSDIndicatorComponent component, MindRemovedMessage args)
{
component.IsSSD = true;
Dirty(uid, component);
}
}

View File

@@ -312,6 +312,7 @@
deathPenalty: 0.01 # However they really ought to be living and intact, otherwise they're worth 100x less. deathPenalty: 0.01 # However they really ought to be living and intact, otherwise they're worth 100x less.
- type: ContentEye - type: ContentEye
- type: SleepEmitSound - type: SleepEmitSound
- type: SSDIndicator
- type: entity - type: entity
save: false save: false

View File

@@ -0,0 +1,6 @@
- type: statusIcon
id: SSDIcon
icon:
sprite: /Textures/Effects/ssd.rsi
state: default0
locationPreference: Left

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

View File

@@ -0,0 +1,14 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Take from https://github.com/Skyrat-SS13/Skyrat-tg/blob/92377cd6203bc4d93a6e289d7b857e19bb6cf338/modular_skyrat/modules/indicators/icons/ssd_indicator.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "default0"
}
]
}