diff --git a/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs b/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs index 087ff837a6..5f186801ca 100644 --- a/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs +++ b/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs @@ -1,113 +1,24 @@ -using Content.Shared.Atmos.Visuals; +using Content.Server.Atmos.EntitySystems; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Random; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.Components { - [RegisterComponent] - public sealed class AtmosPlaqueComponent : Component, IMapInit + [RegisterComponent, ComponentProtoName("AtmosPlaque")] + public sealed class AtmosPlaqueComponent : Component { - [Dependency] private readonly IEntityManager _entMan = default!; - - public override string Name => "AtmosPlaque"; - - [DataField("plaqueType")] - private PlaqueType _type = PlaqueType.Unset; + [DataField("plaqueType")] public PlaqueType Type = PlaqueType.Unset; [ViewVariables(VVAccess.ReadWrite)] - public PlaqueType Type + public PlaqueType TypeVV { - get => _type; + get => Type; set { - _type = value; - UpdateSign(); + Type = value; + EntitySystem.Get().UpdateSign(this); } } - - public void MapInit() - { - var random = IoCManager.Resolve(); - var rand = random.Next(100); - // Let's not pat ourselves on the back too hard. - // 1% chance of zumos - if (rand == 0) Type = PlaqueType.Zumos; - // 9% FEA - else if (rand <= 10) Type = PlaqueType.Fea; - // 45% ZAS - else if (rand <= 55) Type = PlaqueType.Zas; - // 45% LINDA - else Type = PlaqueType.Linda; - } - - protected override void Startup() - { - base.Startup(); - - UpdateSign(); - } - - private void UpdateSign() - { - if (!Running) - { - return; - } - - var metaData = _entMan.GetComponent(Owner); - - var val = _type switch - { - PlaqueType.Zumos => - "This plaque commemorates the rise of the Atmos ZUM division. May they carry the torch that the Atmos ZAS, LINDA and FEA divisions left behind.", - PlaqueType.Fea => - "This plaque commemorates the fall of the Atmos FEA division. For all the charred, dizzy, and brittle men who have died in its hands.", - PlaqueType.Linda => - "This plaque commemorates the fall of the Atmos LINDA division. For all the charred, dizzy, and brittle men who have died in its hands.", - PlaqueType.Zas => - "This plaque commemorates the fall of the Atmos ZAS division. For all the charred, dizzy, and brittle men who have died in its hands.", - PlaqueType.Unset => "Uhm", - _ => "Uhm", - }; - - metaData.EntityDescription = val; - - var val1 = _type switch - { - PlaqueType.Zumos => - "ZUM Atmospherics Division plaque", - PlaqueType.Fea => - "FEA Atmospherics Division plaque", - PlaqueType.Linda => - "LINDA Atmospherics Division plaque", - PlaqueType.Zas => - "ZAS Atmospherics Division plaque", - PlaqueType.Unset => "Uhm", - _ => "Uhm", - }; - - metaData.EntityName = val1; - - if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance)) - { - var state = _type == PlaqueType.Zumos ? "zumosplaque" : "atmosplaque"; - - appearance.SetData(AtmosPlaqueVisuals.State, state); - } - } - - public enum PlaqueType - { - Unset = 0, - Zumos, - Fea, - Linda, - Zas - } } } - -// If you get the ZUM plaque it means your round will be blessed with good engineering luck. diff --git a/Content.Server/Atmos/EntitySystems/AtmosPlaqueSystem.cs b/Content.Server/Atmos/EntitySystems/AtmosPlaqueSystem.cs new file mode 100644 index 0000000000..c483394f15 --- /dev/null +++ b/Content.Server/Atmos/EntitySystems/AtmosPlaqueSystem.cs @@ -0,0 +1,89 @@ +using Content.Server.Atmos.Components; +using Content.Shared.Atmos.Visuals; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Random; + +namespace Content.Server.Atmos.EntitySystems; + +public sealed class AtmosPlaqueSystem : EntitySystem +{ + [Dependency] private readonly IRobustRandom _random = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnPlaqueMapInit); + } + + private void OnPlaqueMapInit(EntityUid uid, AtmosPlaqueComponent component, MapInitEvent args) + { + var rand = _random.Next(100); + // Let's not pat ourselves on the back too hard. + // 1% chance of zumos + if (rand == 0) component.Type = PlaqueType.Zumos; + // 9% FEA + else if (rand <= 10) component.Type = PlaqueType.Fea; + // 45% ZAS + else if (rand <= 55) component.Type = PlaqueType.Zas; + // 45% LINDA + else component.Type = PlaqueType.Linda; + + UpdateSign(component); + } + + public void UpdateSign(AtmosPlaqueComponent component) + { + var metaData = MetaData(component.Owner); + + var val = component.Type switch + { + PlaqueType.Zumos => + Loc.GetString("atmos-plaque-component-desc-zum"), + PlaqueType.Fea => + Loc.GetString("atmos-plaque-component-desc-fea"), + PlaqueType.Linda => + Loc.GetString("atmos-plaque-component-desc-linda"), + PlaqueType.Zas => + Loc.GetString("atmos-plaque-component-desc-zas"), + PlaqueType.Unset => Loc.GetString("atmos-plaque-component-desc-unset"), + _ => Loc.GetString("atmos-plaque-component-desc-unset"), + }; + + metaData.EntityDescription = val; + + var val1 = component.Type switch + { + PlaqueType.Zumos => + Loc.GetString("atmos-plaque-component-name-zum"), + PlaqueType.Fea => + Loc.GetString("atmos-plaque-component-name-fea"), + PlaqueType.Linda => + Loc.GetString("atmos-plaque-component-name-linda"), + PlaqueType.Zas => + Loc.GetString("atmos-plaque-component-name-zas"), + PlaqueType.Unset => Loc.GetString("atmos-plaque-component-name-unset"), + _ => Loc.GetString("atmos-plaque-component-name-unset"), + }; + + metaData.EntityName = val1; + + if (TryComp(component.Owner, out var appearance)) + { + var state = component.Type == PlaqueType.Zumos ? "zumosplaque" : "atmosplaque"; + + appearance.SetData(AtmosPlaqueVisuals.State, state); + } + } +} + +// If you get the ZUM plaque it means your round will be blessed with good engineering luck. +public enum PlaqueType : byte +{ + Unset = 0, + Zumos, + Fea, + Linda, + Zas +} diff --git a/Resources/Locale/en-US/atmos/plaque-component.ftl b/Resources/Locale/en-US/atmos/plaque-component.ftl new file mode 100644 index 0000000000..9b2b23de18 --- /dev/null +++ b/Resources/Locale/en-US/atmos/plaque-component.ftl @@ -0,0 +1,11 @@ +atmos-plaque-component-desc-zum = This plaque commemorates the rise of the Atmos ZUM division. May they carry the torch that the Atmos ZAS, LINDA and FEA divisions left behind. +atmos-plaque-component-desc-fea = This plaque commemorates the fall of the Atmos FEA division. For all the charred, dizzy, and brittle men who have died in its hands. +atmos-plaque-component-desc-linda =This plaque commemorates the fall of the Atmos LINDA division. For all the charred, dizzy, and brittle men who have died in its hands. +atmos-plaque-component-desc-zas = This plaque commemorates the fall of the Atmos ZAS division. For all the charred, dizzy, and brittle men who have died in its hands. +atmos-plaque-component-desc-unset = Uhm + +atmos-plaque-component-name-zum = ZUM Atmospherics Division plaque +atmos-plaque-component-name-fea = FEA Atmospherics Division plaque +atmos-plaque-component-name-linda = LINDA Atmospherics Division plaque +atmos-plaque-component-name-zas = ZAS Atmospherics Division plaque +atmos-plaque-component-name-unset = Uhm \ No newline at end of file