@@ -21,6 +21,22 @@ public sealed class HandheldLightSystem : SharedHandheldLightSystem
|
|||||||
SubscribeLocalEvent<HandheldLightComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
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)
|
private void OnAppearanceChange(EntityUid uid, HandheldLightComponent? component, ref AppearanceChangeEvent args)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using Content.Shared.Light;
|
|||||||
using Content.Shared.Light.Components;
|
using Content.Shared.Light.Components;
|
||||||
using Content.Shared.Rounding;
|
using Content.Shared.Rounding;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
using Content.Shared.Verbs;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -46,7 +45,6 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
SubscribeLocalEvent<HandheldLightComponent, ComponentShutdown>(OnShutdown);
|
SubscribeLocalEvent<HandheldLightComponent, ComponentShutdown>(OnShutdown);
|
||||||
|
|
||||||
SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
|
||||||
SubscribeLocalEvent<HandheldLightComponent, GetVerbsEvent<ActivationVerb>>(AddToggleLightVerb);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate);
|
SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate);
|
||||||
|
|
||||||
@@ -179,25 +177,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddToggleLightVerb(Entity<HandheldLightComponent> ent, ref GetVerbsEvent<ActivationVerb> args)
|
public override bool TurnOff(Entity<HandheldLightComponent> ent, bool makeNoise = true)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (!ent.Comp.Activated || !_lights.TryGetLight(ent, out var pointLightComponent))
|
if (!ent.Comp.Activated || !_lights.TryGetLight(ent, out var pointLightComponent))
|
||||||
{
|
{
|
||||||
@@ -211,7 +191,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TurnOn(EntityUid user, Entity<HandheldLightComponent> uid)
|
public override bool TurnOn(EntityUid user, Entity<HandheldLightComponent> uid)
|
||||||
{
|
{
|
||||||
var component = uid.Comp;
|
var component = uid.Comp;
|
||||||
if (component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
|
if (component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ using Content.Shared.Clothing.EntitySystems;
|
|||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Light.Components;
|
using Content.Shared.Light.Components;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.Light;
|
namespace Content.Shared.Light;
|
||||||
|
|
||||||
@@ -22,6 +24,8 @@ public abstract class SharedHandheldLightSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<HandheldLightComponent, ComponentInit>(OnInit);
|
SubscribeLocalEvent<HandheldLightComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<HandheldLightComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<HandheldLightComponent, ComponentHandleState>(OnHandleState);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<HandheldLightComponent, GetVerbsEvent<ActivationVerb>>(AddToggleLightVerb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInit(EntityUid uid, HandheldLightComponent component, ComponentInit args)
|
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);
|
_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