Examine verbs + tooltip buttons (#6489)

This commit is contained in:
mirrorcult
2022-02-13 20:20:58 -07:00
committed by GitHub
parent b063a57584
commit cd0b9a4480
18 changed files with 410 additions and 80 deletions

View File

@@ -1,25 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.Power.Components;
using Content.Server.Power.Nodes;
using Content.Server.Power.Pow3r;
using Content.Server.Power.NodeGroups;
using Content.Server.Power.EntitySystems;
using Content.Server.Hands.Components;
using Content.Server.Tools;
using Content.Shared.Wires;
using Content.Shared.Examine;
using Content.Shared.Hands.Components;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
namespace Content.Server.Power.EntitySystems
{
@@ -28,32 +14,41 @@ namespace Content.Server.Power.EntitySystems
{
[Dependency] private readonly ToolSystem _toolSystem = default!;
[Dependency] private readonly PowerNetSystem _pnSystem = default!;
[Dependency] private readonly ExamineSystemShared _examineSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CableComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<CableComponent, GetVerbsEvent<ExamineVerb>>(OnGetExamineVerbs);
}
private void OnExamined(EntityUid uid, CableComponent component, ExaminedEvent args)
private void OnGetExamineVerbs(EntityUid uid, CableComponent component, GetVerbsEvent<ExamineVerb> args)
{
// Must be in details range to try this.
// Theoretically there should be a separate range at which a multitool works, but this does just fine.
if (args.IsInDetailsRange)
if (_examineSystem.IsInDetailsRange(args.User, args.Target))
{
// Determine if they are holding a multitool.
if (EntityManager.TryGetComponent<HandsComponent?>(args.Examiner, out var hands) && hands.TryGetActiveHand(out var hand))
var held = args.Using;
// Pulsing is hardcoded here because I don't think it needs to be more complex than that right now.
// Update if I'm wrong.
var enabled = held != null && _toolSystem.HasQuality(held.Value, "Pulsing");
var verb = new ExamineVerb
{
var held = hand.HeldEntity;
// Pulsing is hardcoded here because I don't think it needs to be more complex than that right now.
// Update if I'm wrong.
if (held != null && _toolSystem.HasQuality(held.Value, "Pulsing"))
Disabled = !enabled,
Message = Loc.GetString("cable-multitool-system-verb-tooltip"),
Text = Loc.GetString("cable-multitool-system-verb-name"),
Category = VerbCategory.Examine,
IconTexture = "/Textures/Interface/VerbIcons/zap.svg.192dpi.png",
Act = () =>
{
args.PushMarkup(GenerateCableMarkup(uid));
// args.PushFancyUpdatingPowerGraphs(uid);
var markup = FormattedMessage.FromMarkup(GenerateCableMarkup(uid));
_examineSystem.SendExamineTooltip(args.User, uid, markup, false, false);
}
}
};
args.Verbs.Add(verb);
}
}