* XAML verb menu * fix ghost FOV * spacing * rename missed "ContextMenu"->"EntityMenu" instances * move visibility checks to verb system * update comment * Remove CanSeeContainerCheck * use ScrollContainer measure option * MaxWidth / texxt line wrapping * verb category default Now when you click on a verb category, it should default to running the first member of that category. This makes it much more convenient to eject/insert when there is only a single option * only apply style to first verb category entry * Use new visibility flags * FoV -> Fov * Revert "only apply style to first verb category entry" This reverts commit 9a6a17dba600e3ae0421caed59fcab145c260c99. * make all entity menu visibility checks clientside * Fix empty unbuckle category * fix merge
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.Server.Light.Components;
|
|
using Content.Shared.Verbs;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Localization;
|
|
|
|
namespace Content.Server.Light.EntitySystems
|
|
{
|
|
[UsedImplicitly]
|
|
internal sealed class HandHeldLightSystem : EntitySystem
|
|
{
|
|
// TODO: Ideally you'd be able to subscribe to power stuff to get events at certain percentages.. or something?
|
|
// But for now this will be better anyway.
|
|
private HashSet<HandheldLightComponent> _activeLights = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ActivateHandheldLightMessage>(HandleActivate);
|
|
SubscribeLocalEvent<DeactivateHandheldLightMessage>(HandleDeactivate);
|
|
SubscribeLocalEvent<HandheldLightComponent, GetActivationVerbsEvent>(AddToggleLightVerb);
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
_activeLights.Clear();
|
|
}
|
|
|
|
private void HandleActivate(ActivateHandheldLightMessage message)
|
|
{
|
|
_activeLights.Add(message.Component);
|
|
}
|
|
|
|
private void HandleDeactivate(DeactivateHandheldLightMessage message)
|
|
{
|
|
_activeLights.Remove(message.Component);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
foreach (var handheld in _activeLights.ToArray())
|
|
{
|
|
if (handheld.Deleted || handheld.Paused) continue;
|
|
handheld.OnUpdate(frameTime);
|
|
}
|
|
}
|
|
|
|
private void AddToggleLightVerb(EntityUid uid, HandheldLightComponent component, GetActivationVerbsEvent args)
|
|
{
|
|
if (!args.CanAccess || !args.CanInteract)
|
|
return;
|
|
|
|
Verb verb = new();
|
|
verb.Text = Loc.GetString("verb-common-toggle-light");
|
|
verb.IconTexture = "/Textures/Interface/VerbIcons/light.svg.192dpi.png";
|
|
verb.Act = component.Activated
|
|
? () => component.TurnOff()
|
|
: () => component.TurnOn(args.User);
|
|
|
|
args.Verbs.Add(verb);
|
|
}
|
|
}
|
|
}
|