From a790955b764b1ee0905917f99c79ff96d9a81dd3 Mon Sep 17 00:00:00 2001 From: beck-thompson <107373427+beck-thompson@users.noreply.github.com> Date: Thu, 28 Nov 2024 05:41:01 -0800 Subject: [PATCH] Light verb is now predicted (#33622) Fix --- Content.Client/Light/HandheldLightSystem.cs | 16 ++++++++++++ .../EntitySystems/HandheldLightSystem.cs | 24 ++---------------- .../Light/SharedHandheldLightSystem.cs | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Content.Client/Light/HandheldLightSystem.cs b/Content.Client/Light/HandheldLightSystem.cs index ddd99c7c48..d25b28756f 100644 --- a/Content.Client/Light/HandheldLightSystem.cs +++ b/Content.Client/Light/HandheldLightSystem.cs @@ -21,6 +21,22 @@ public sealed class HandheldLightSystem : SharedHandheldLightSystem SubscribeLocalEvent(OnAppearanceChange); } + /// + /// TODO: Not properly predicted yet. Don't call this function if you want a the actual return value! + /// + public override bool TurnOff(Entity ent, bool makeNoise = true) + { + return true; + } + + /// + /// TODO: Not properly predicted yet. Don't call this function if you want a the actual return value! + /// + public override bool TurnOn(EntityUid user, Entity uid) + { + return true; + } + private void OnAppearanceChange(EntityUid uid, HandheldLightComponent? component, ref AppearanceChangeEvent args) { if (!Resolve(uid, ref component)) diff --git a/Content.Server/Light/EntitySystems/HandheldLightSystem.cs b/Content.Server/Light/EntitySystems/HandheldLightSystem.cs index a5a41bcc10..a1977d5a46 100644 --- a/Content.Server/Light/EntitySystems/HandheldLightSystem.cs +++ b/Content.Server/Light/EntitySystems/HandheldLightSystem.cs @@ -9,7 +9,6 @@ using Content.Shared.Light; using Content.Shared.Light.Components; using Content.Shared.Rounding; using Content.Shared.Toggleable; -using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -46,7 +45,6 @@ namespace Content.Server.Light.EntitySystems SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnExamine); - SubscribeLocalEvent>(AddToggleLightVerb); SubscribeLocalEvent(OnActivate); @@ -179,25 +177,7 @@ namespace Content.Server.Light.EntitySystems } } - private void AddToggleLightVerb(Entity ent, ref GetVerbsEvent args) - { - if (!args.CanAccess || !args.CanInteract || !ent.Comp.ToggleOnInteract) - return; - - var @event = args; - ActivationVerb verb = new() - { - Text = Loc.GetString("verb-common-toggle-light"), - Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/light.svg.192dpi.png")), - Act = ent.Comp.Activated - ? () => TurnOff(ent) - : () => TurnOn(@event.User, ent) - }; - - args.Verbs.Add(verb); - } - - public bool TurnOff(Entity ent, bool makeNoise = true) + public override bool TurnOff(Entity ent, bool makeNoise = true) { if (!ent.Comp.Activated || !_lights.TryGetLight(ent, out var pointLightComponent)) { @@ -211,7 +191,7 @@ namespace Content.Server.Light.EntitySystems return true; } - public bool TurnOn(EntityUid user, Entity uid) + public override bool TurnOn(EntityUid user, Entity uid) { var component = uid.Comp; if (component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent)) diff --git a/Content.Shared/Light/SharedHandheldLightSystem.cs b/Content.Shared/Light/SharedHandheldLightSystem.cs index 9bec37a314..74c809797b 100644 --- a/Content.Shared/Light/SharedHandheldLightSystem.cs +++ b/Content.Shared/Light/SharedHandheldLightSystem.cs @@ -3,9 +3,11 @@ using Content.Shared.Clothing.EntitySystems; using Content.Shared.Item; using Content.Shared.Light.Components; using Content.Shared.Toggleable; +using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.GameStates; +using Robust.Shared.Utility; namespace Content.Shared.Light; @@ -22,6 +24,8 @@ public abstract class SharedHandheldLightSystem : EntitySystem base.Initialize(); SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnHandleState); + + SubscribeLocalEvent>(AddToggleLightVerb); } private void OnInit(EntityUid uid, HandheldLightComponent component, ComponentInit args) @@ -78,4 +82,25 @@ public abstract class SharedHandheldLightSystem : EntitySystem _appearance.SetData(uid, ToggleableLightVisuals.Enabled, component.Activated, appearance); } + + private void AddToggleLightVerb(Entity ent, ref GetVerbsEvent args) + { + if (!args.CanAccess || !args.CanInteract || !ent.Comp.ToggleOnInteract) + return; + + var @event = args; + ActivationVerb verb = new() + { + Text = Loc.GetString("verb-common-toggle-light"), + Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/light.svg.192dpi.png")), + Act = ent.Comp.Activated + ? () => TurnOff(ent) + : () => TurnOn(@event.User, ent) + }; + + args.Verbs.Add(verb); + } + + public abstract bool TurnOff(Entity ent, bool makeNoise = true); + public abstract bool TurnOn(EntityUid user, Entity uid); }