]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Light verb is now predicted (#33622)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Thu, 28 Nov 2024 13:41:01 +0000 (05:41 -0800)
committerGitHub <noreply@github.com>
Thu, 28 Nov 2024 13:41:01 +0000 (00:41 +1100)
Fix

Content.Client/Light/HandheldLightSystem.cs
Content.Server/Light/EntitySystems/HandheldLightSystem.cs
Content.Shared/Light/SharedHandheldLightSystem.cs

index ddd99c7c48306ff65f376ff7c5fa0a97ad6fa902..d25b28756f8602c7594733a541264bf239e84913 100644 (file)
@@ -21,6 +21,22 @@ public sealed class HandheldLightSystem : SharedHandheldLightSystem
         SubscribeLocalEvent<HandheldLightComponent, AppearanceChangeEvent>(OnAppearanceChange);
     }
 
+    /// <remarks>
+    ///     TODO: Not properly predicted yet. Don't call this function if you want a the actual return value!
+    /// </remarks>
+    public override bool TurnOff(Entity<HandheldLightComponent> ent, bool makeNoise = true)
+    {
+        return true;
+    }
+
+    /// <remarks>
+    ///     TODO: Not properly predicted yet. Don't call this function if you want a the actual return value!
+    /// </remarks>
+    public override bool TurnOn(EntityUid user, Entity<HandheldLightComponent> uid)
+    {
+        return true;
+    }
+
     private void OnAppearanceChange(EntityUid uid, HandheldLightComponent? component, ref AppearanceChangeEvent args)
     {
         if (!Resolve(uid, ref component))
index a5a41bcc1052efe43db3572d700b57f4534f4e45..a1977d5a463f147cac888759609b10b98b64ea3c 100644 (file)
@@ -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<HandheldLightComponent, ComponentShutdown>(OnShutdown);
 
             SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
-            SubscribeLocalEvent<HandheldLightComponent, GetVerbsEvent<ActivationVerb>>(AddToggleLightVerb);
 
             SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate);
 
@@ -179,25 +177,7 @@ namespace Content.Server.Light.EntitySystems
             }
         }
 
-        private void AddToggleLightVerb(Entity<HandheldLightComponent> ent, ref GetVerbsEvent<ActivationVerb> 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<HandheldLightComponent> ent, bool makeNoise = true)
+        public override bool TurnOff(Entity<HandheldLightComponent> 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<HandheldLightComponent> uid)
+        public override bool TurnOn(EntityUid user, Entity<HandheldLightComponent> uid)
         {
             var component = uid.Comp;
             if (component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
index 9bec37a3140e91591a2810f99df5649e266f0d63..74c809797b0e49aa9c518c257d55e072bccb0666 100644 (file)
@@ -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<HandheldLightComponent, ComponentInit>(OnInit);
         SubscribeLocalEvent<HandheldLightComponent, ComponentHandleState>(OnHandleState);
+
+        SubscribeLocalEvent<HandheldLightComponent, GetVerbsEvent<ActivationVerb>>(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<HandheldLightComponent> ent, ref GetVerbsEvent<ActivationVerb> 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<HandheldLightComponent> ent, bool makeNoise = true);
+    public abstract bool TurnOn(EntityUid user, Entity<HandheldLightComponent> uid);
 }