Trigger Refactor (#39034)

This commit is contained in:
slarticodefast
2025-08-03 21:20:37 +02:00
committed by GitHub
parent 777e89ab3e
commit 2c40a950f7
256 changed files with 3987 additions and 2892 deletions

View File

@@ -0,0 +1,31 @@
using Content.Shared.Verbs;
using Content.Shared.Trigger.Components.Triggers;
namespace Content.Shared.Trigger.Systems;
public sealed partial class TriggerOnVerbSystem : EntitySystem
{
[Dependency] private readonly TriggerSystem _trigger = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TriggerOnVerbComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
}
private void OnGetAltVerbs(Entity<TriggerOnVerbComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess || args.Hands == null)
return;
var user = args.User;
args.Verbs.Add(new AlternativeVerb
{
Text = Loc.GetString(ent.Comp.Text),
Act = () => _trigger.Trigger(ent.Owner, user, ent.Comp.KeyOut),
Priority = 2 // should be above any timer settings
});
}
}