Light verb is now predicted (#33622)

Fix
This commit is contained in:
beck-thompson
2024-11-28 05:41:01 -08:00
committed by GitHub
parent f6813e39c7
commit a790955b76
3 changed files with 43 additions and 22 deletions

View 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))