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

@@ -56,6 +56,7 @@ namespace Content.Server.Cuffs
Verb verb = new()
{
Act = () => component.TryUncuff(args.User),
DoContactInteraction = true,
Text = Loc.GetString("uncuff-verb-get-data-text")
};
//TODO VERB ICON add uncuffing symbol? may re-use the alert symbol showing that you are currently cuffed?

View File

@@ -11,9 +11,9 @@ using Content.Shared.Disease.Components;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.MobState.Components;
using Content.Shared.Rejuvenate;
using Robust.Shared.Player;
@@ -46,8 +46,7 @@ namespace Content.Server.Disease
SubscribeLocalEvent<DiseaseCarrierComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<DiseaseCarrierComponent, CureDiseaseAttemptEvent>(OnTryCureDisease);
SubscribeLocalEvent<DiseaseCarrierComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<DiseasedComponent, UserInteractedWithItemEvent>(OnUserInteractDiseased);
SubscribeLocalEvent<DiseasedComponent, ItemInteractedWithEvent>(OnTargetInteractDiseased);
SubscribeLocalEvent<DiseasedComponent, ContactInteractionEvent>(OnContactInteraction);
SubscribeLocalEvent<DiseasedComponent, EntitySpokeEvent>(OnEntitySpeak);
SubscribeLocalEvent<DiseaseProtectionComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<DiseaseProtectionComponent, GotUnequippedEvent>(OnUnequipped);
@@ -256,17 +255,9 @@ namespace Content.Server.Disease
/// <summary>
/// When a diseased person interacts with something, check infection.
/// </summary>
private void OnUserInteractDiseased(EntityUid uid, DiseasedComponent component, UserInteractedWithItemEvent args)
private void OnContactInteraction(EntityUid uid, DiseasedComponent component, ContactInteractionEvent args)
{
InteractWithDiseased(args.User, args.Item);
}
/// <summary>
/// When a diseased person is interacted with, check infection.
/// </summary>
private void OnTargetInteractDiseased(EntityUid uid, DiseasedComponent component, ItemInteractedWithEvent args)
{
InteractWithDiseased(args.Item, args.User);
InteractWithDiseased(uid, args.Other);
}
private void OnEntitySpeak(EntityUid uid, DiseasedComponent component, EntitySpokeEvent args)

View File

@@ -123,6 +123,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
Verb verb = new()
{
Act = () => TryInsert(component.Owner, args.User, args.User),
DoContactInteraction = true,
Text = Loc.GetString("disposal-self-insert-verb-get-data-text")
};
// TODO VERN ICON

View File

@@ -159,6 +159,7 @@ public sealed class SpillableSystem : EntitySystem
};
}
verb.Impact = LogImpact.Medium; // dangerous reagent reaction are logged separately.
verb.DoContactInteraction = true;
args.Verbs.Add(verb);
}

View File

@@ -1,5 +1,5 @@
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Item;
using Robust.Shared.Random;
namespace Content.Server.Forensics
@@ -10,13 +10,13 @@ namespace Content.Server.Forensics
[Dependency] private readonly InventorySystem _inventory = default!;
public override void Initialize()
{
SubscribeLocalEvent<FingerprintComponent, UserInteractedWithItemEvent>(OnInteract);
SubscribeLocalEvent<FingerprintComponent, ContactInteractionEvent>(OnInteract);
SubscribeLocalEvent<FingerprintComponent, ComponentInit>(OnInit);
}
private void OnInteract(EntityUid uid, FingerprintComponent component, UserInteractedWithItemEvent args)
private void OnInteract(EntityUid uid, FingerprintComponent component, ContactInteractionEvent args)
{
ApplyEvidence(args.User, args.Item);
ApplyEvidence(uid, args.Other);
}
private void OnInit(EntityUid uid, FingerprintComponent component, ComponentInit args)

View File

@@ -303,6 +303,7 @@ namespace Content.Server.PneumaticCannon
Verb ejectItems = new();
ejectItems.Act = () => TryEjectAllItems(component, args.User);
ejectItems.Text = Loc.GetString("pneumatic-cannon-component-verb-eject-items-name");
ejectItems.DoContactInteraction = true;
args.Verbs.Add(ejectItems);
}

View File

@@ -24,6 +24,7 @@ namespace Content.Server.Rotatable
Verb verb = new();
verb.Act = () => TryFlip(component, args.User);
verb.Text = Loc.GetString("flippable-verb-get-data-text");
verb.DoContactInteraction = true;
// TODO VERB ICONS Add Uno reverse card style icon?
args.Verbs.Add(verb);
}
@@ -43,6 +44,7 @@ namespace Content.Server.Rotatable
Verb resetRotation = new ()
{
DoContactInteraction = true,
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation = Angle.Zero,
Category = VerbCategory.Rotate,
IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",

View File

@@ -1,4 +1,4 @@
using Content.Server.DoAfter;
using Content.Server.DoAfter;
using Content.Server.Popups;
using Content.Server.Sticky.Components;
using Content.Server.Sticky.Events;
@@ -53,6 +53,7 @@ public sealed class StickySystem : EntitySystem
args.Verbs.Add(new Verb
{
DoContactInteraction = true,
Text = Loc.GetString("comp-sticky-unstick-verb-text"),
IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png",
Act = () => StartUnsticking(uid, args.User, component)

View File

@@ -84,17 +84,7 @@ namespace Content.Server.Verbs
// first, lets log the verb. Just in case it ends up crashing the server or something.
LogVerb(verb, user, target, forced);
// then 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, true);
else
RaiseLocalEvent(verb.ExecutionEventArgs);
}
base.ExecuteVerb(verb, user, target, forced);
}
public void LogVerb(Verb verb, EntityUid user, EntityUid target, bool forced)

View File

@@ -150,6 +150,13 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
ev.Target.Value
};
_interaction.DoContactInteraction(ev.Weapon, ev.Target);
_interaction.DoContactInteraction(user, ev.Weapon);
// If the user is using a long-range weapon, this probably shouldn't be happening? But I'll interpret melee as a
// somewhat messy scuffle. See also, heavy attacks.
_interaction.DoContactInteraction(user, ev.Target);
// For stuff that cares about it being attacked.
RaiseLocalEvent(ev.Target.Value, new AttackedEvent(component.Owner, user, targetXform.Coordinates));
@@ -249,9 +256,17 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
var modifiers = itemDamage.ModifiersList;
modifiers.AddRange(hitEvent.ModifiersList);
_interaction.DoContactInteraction(user, ev.Weapon);
// For stuff that cares about it being attacked.
foreach (var target in targets)
{
_interaction.DoContactInteraction(ev.Weapon, target);
// If the user is using a long-range weapon, this probably shouldn't be happening? But I'll interpret melee as a
// somewhat messy scuffle. See also, light attacks.
_interaction.DoContactInteraction(user, target);
RaiseLocalEvent(target, new AttackedEvent(component.Owner, user, Transform(target).Coordinates));
}
@@ -338,6 +353,8 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
inTargetHand = targetHandsComponent.ActiveHand.HeldEntity!.Value;
}
_interaction.DoContactInteraction(user, ev.Target);
var attemptEvent = new DisarmAttemptEvent(target, user, inTargetHand);
if (inTargetHand != null)