@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user