diff --git a/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs b/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs index 558ed39a2c..bd6c0d5dba 100644 --- a/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs +++ b/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs @@ -1,22 +1,26 @@ -using Content.Server.Light.Components; using Content.Server.Light.Events; using Content.Server.Mind.Components; using Content.Shared.Actions; +using Content.Shared.Decals; +using Content.Shared.Emag.Systems; using Content.Shared.Light; using Content.Shared.Light.Component; using Content.Shared.Toggleable; using Content.Shared.Verbs; using Robust.Server.GameObjects; -using Robust.Shared.Audio; -using Robust.Shared.Player; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; using Robust.Shared.Utility; namespace Content.Server.Light.EntitySystems { public sealed class UnpoweredFlashlightSystem : EntitySystem { + [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly SharedAudioSystem _audioSystem = default!; public override void Initialize() { @@ -26,6 +30,7 @@ namespace Content.Server.Light.EntitySystems SubscribeLocalEvent(OnGetActions); SubscribeLocalEvent(OnToggleAction); SubscribeLocalEvent(OnMindAdded); + SubscribeLocalEvent(OnGotEmagged); } private void OnToggleAction(EntityUid uid, UnpoweredFlashlightComponent component, ToggleActionEvent args) @@ -48,11 +53,13 @@ namespace Content.Server.Light.EntitySystems if (!args.CanAccess || !args.CanInteract) return; - ActivationVerb verb = new(); - verb.Text = Loc.GetString("toggle-flashlight-verb-get-data-text"); - verb.Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/light.svg.192dpi.png")); - verb.Act = () => ToggleLight(uid, component); - verb.Priority = -1; // For things like PDA's, Open-UI and other verbs that should be higher priority. + ActivationVerb verb = new() + { + Text = Loc.GetString("toggle-flashlight-verb-get-data-text"), + Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/light.svg.192dpi.png")), + Act = () => ToggleLight(uid, component), + Priority = -1 // For things like PDA's, Open-UI and other verbs that should be higher priority. + }; args.Verbs.Add(verb); } @@ -61,20 +68,35 @@ namespace Content.Server.Light.EntitySystems { _actionsSystem.AddAction(uid, component.ToggleAction, null); } + + private void OnGotEmagged(EntityUid uid, UnpoweredFlashlightComponent component, ref GotEmaggedEvent args) + { + if (!TryComp(uid, out var light)) + return; + + if (_prototypeManager.TryIndex(component.EmaggedColorsPrototype, out var possibleColors)) + { + var pick = _random.Pick(possibleColors.Colors.Values); + light.Color = pick; + } + + args.Repeatable = true; + args.Handled = true; + } + public void ToggleLight(EntityUid uid, UnpoweredFlashlightComponent flashlight) { - if (!EntityManager.TryGetComponent(flashlight.Owner, out PointLightComponent? light)) + if (!TryComp(uid, out var light)) return; flashlight.LightOn = !flashlight.LightOn; light.Enabled = flashlight.LightOn; - if (EntityManager.TryGetComponent(flashlight.Owner, out AppearanceComponent? appearance)) - _appearance.SetData(uid, UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn, appearance); + _appearance.SetData(uid, UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn); - SoundSystem.Play(flashlight.ToggleSound.GetSound(), Filter.Pvs(light.Owner), flashlight.Owner); + _audioSystem.PlayPvs(flashlight.ToggleSound, uid); - RaiseLocalEvent(flashlight.Owner, new LightToggleEvent(flashlight.LightOn), true); + RaiseLocalEvent(uid, new LightToggleEvent(flashlight.LightOn), true); _actionsSystem.SetToggled(flashlight.ToggleAction, flashlight.LightOn); } } diff --git a/Content.Shared/Light/Component/UnpoweredFlashlightComponent.cs b/Content.Shared/Light/Component/UnpoweredFlashlightComponent.cs index f9d572e69d..108c252b61 100644 --- a/Content.Shared/Light/Component/UnpoweredFlashlightComponent.cs +++ b/Content.Shared/Light/Component/UnpoweredFlashlightComponent.cs @@ -1,4 +1,5 @@ using Content.Shared.Actions.ActionTypes; +using Content.Shared.Decals; using Robust.Shared.Audio; namespace Content.Shared.Light.Component; @@ -17,4 +18,12 @@ public sealed class UnpoweredFlashlightComponent : Robust.Shared.GameObjects.Com [DataField("toggleAction", required: true)] public InstantAction ToggleAction = new(); + + /// + /// ID that determines the list + /// of colors to select from when we get emagged + /// + [DataField("emaggedColorsPrototype")] + [ViewVariables(VVAccess.ReadWrite)] + public string EmaggedColorsPrototype = "Emagged"; } diff --git a/Resources/Prototypes/Palettes/emagged.yml b/Resources/Prototypes/Palettes/emagged.yml new file mode 100644 index 0000000000..37b4e4e0b9 --- /dev/null +++ b/Resources/Prototypes/Palettes/emagged.yml @@ -0,0 +1,11 @@ +- type: palette + id: Emagged + name: Emagged + colors: + red: "#FF0000" + orange: "#FFA500" + yellow: "#FFFF00" + lime: "#32CD32" + bright_blue: "#0096FF" + cyan: "#00FFFF" + purple: "#A020F0"