Remove InteractedWithEvent and friends. (#11939)

This commit is contained in:
Leon Friedrich
2022-10-26 14:15:48 +13:00
committed by GitHub
parent b03f17bda2
commit c0b657ca18
21 changed files with 133 additions and 101 deletions

View File

@@ -154,6 +154,23 @@ namespace Content.Shared.Verbs
/// <remarks>
/// This will try to call the action delegates and raise the local events for the given verb.
/// </remarks>
public abstract void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bool forced = false);
public virtual void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, bool forced = false)
{
// invoke any relevant actions
verb.Act?.Invoke();
// Maybe raise a local event
if (verb.ExecutionEventArgs != null)
{
if (verb.EventTarget.IsValid())
RaiseLocalEvent(verb.EventTarget, verb.ExecutionEventArgs);
else
RaiseLocalEvent(verb.ExecutionEventArgs);
}
// Perform any contact interactions
if (verb.DoContactInteraction ?? (verb.DefaultDoContactInteraction && _interactionSystem.InRangeUnobstructed(user, target)))
_interactionSystem.DoContactInteraction(user, target);
}
}
}

View File

@@ -146,6 +146,15 @@ namespace Content.Shared.Verbs
/// </summary>
public bool ConfirmationPopup = false;
/// <summary>
/// If true, this verb will raise <see cref="ContactInteractionEvent"/>s when executed. If not explicitly
/// specified, this will just default to raising the event if <see cref="DefaultDoContactInteraction"/> is
/// true and the user is in range.
/// </summary>
public bool? DoContactInteraction;
public virtual bool DefaultDoContactInteraction => false;
/// <summary>
/// Compares two verbs based on their <see cref="Priority"/>, <see cref="Category"/>, <see cref="Text"/>,
/// and <see cref="IconTexture"/>.
@@ -235,6 +244,7 @@ namespace Content.Shared.Verbs
{
public new static string DefaultTextStyleClass = "InteractionVerb";
public override int TypePriority => 4;
public override bool DefaultDoContactInteraction => true;
public InteractionVerb() : base()
{
@@ -256,6 +266,7 @@ namespace Content.Shared.Verbs
public sealed class UtilityVerb : Verb
{
public override int TypePriority => 3;
public override bool DefaultDoContactInteraction => true;
public UtilityVerb() : base()
{
@@ -293,6 +304,7 @@ namespace Content.Shared.Verbs
{
public override int TypePriority => 2;
public new static string DefaultTextStyleClass = "AlternativeVerb";
public override bool DefaultDoContactInteraction => true;
public AlternativeVerb() : base()
{
@@ -314,6 +326,7 @@ namespace Content.Shared.Verbs
{
public override int TypePriority => 1;
public new static string DefaultTextStyleClass = "ActivationVerb";
public override bool DefaultDoContactInteraction => true;
public ActivationVerb() : base()
{