Remove InteractedWithEvent and friends. (#11939)
This commit is contained in:
@@ -263,21 +263,6 @@ namespace Content.Client.Verbs
|
|||||||
EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb));
|
EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override 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, true);
|
|
||||||
else
|
|
||||||
RaiseLocalEvent(verb.ExecutionEventArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleVerbResponse(VerbsResponseEvent msg)
|
private void HandleVerbResponse(VerbsResponseEvent msg)
|
||||||
{
|
{
|
||||||
if (!VerbMenu.RootMenu.Visible || VerbMenu.CurrentTarget != msg.Entity)
|
if (!VerbMenu.RootMenu.Visible || VerbMenu.CurrentTarget != msg.Entity)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace Content.Server.Cuffs
|
|||||||
Verb verb = new()
|
Verb verb = new()
|
||||||
{
|
{
|
||||||
Act = () => component.TryUncuff(args.User),
|
Act = () => component.TryUncuff(args.User),
|
||||||
|
DoContactInteraction = true,
|
||||||
Text = Loc.GetString("uncuff-verb-get-data-text")
|
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?
|
//TODO VERB ICON add uncuffing symbol? may re-use the alert symbol showing that you are currently cuffed?
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ using Content.Shared.Disease.Components;
|
|||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Content.Shared.Item;
|
|
||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
using Content.Shared.Rejuvenate;
|
using Content.Shared.Rejuvenate;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
@@ -46,8 +46,7 @@ namespace Content.Server.Disease
|
|||||||
SubscribeLocalEvent<DiseaseCarrierComponent, ComponentInit>(OnInit);
|
SubscribeLocalEvent<DiseaseCarrierComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<DiseaseCarrierComponent, CureDiseaseAttemptEvent>(OnTryCureDisease);
|
SubscribeLocalEvent<DiseaseCarrierComponent, CureDiseaseAttemptEvent>(OnTryCureDisease);
|
||||||
SubscribeLocalEvent<DiseaseCarrierComponent, RejuvenateEvent>(OnRejuvenate);
|
SubscribeLocalEvent<DiseaseCarrierComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
SubscribeLocalEvent<DiseasedComponent, UserInteractedWithItemEvent>(OnUserInteractDiseased);
|
SubscribeLocalEvent<DiseasedComponent, ContactInteractionEvent>(OnContactInteraction);
|
||||||
SubscribeLocalEvent<DiseasedComponent, ItemInteractedWithEvent>(OnTargetInteractDiseased);
|
|
||||||
SubscribeLocalEvent<DiseasedComponent, EntitySpokeEvent>(OnEntitySpeak);
|
SubscribeLocalEvent<DiseasedComponent, EntitySpokeEvent>(OnEntitySpeak);
|
||||||
SubscribeLocalEvent<DiseaseProtectionComponent, GotEquippedEvent>(OnEquipped);
|
SubscribeLocalEvent<DiseaseProtectionComponent, GotEquippedEvent>(OnEquipped);
|
||||||
SubscribeLocalEvent<DiseaseProtectionComponent, GotUnequippedEvent>(OnUnequipped);
|
SubscribeLocalEvent<DiseaseProtectionComponent, GotUnequippedEvent>(OnUnequipped);
|
||||||
@@ -256,17 +255,9 @@ namespace Content.Server.Disease
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// When a diseased person interacts with something, check infection.
|
/// When a diseased person interacts with something, check infection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnUserInteractDiseased(EntityUid uid, DiseasedComponent component, UserInteractedWithItemEvent args)
|
private void OnContactInteraction(EntityUid uid, DiseasedComponent component, ContactInteractionEvent args)
|
||||||
{
|
{
|
||||||
InteractWithDiseased(args.User, args.Item);
|
InteractWithDiseased(uid, args.Other);
|
||||||
}
|
|
||||||
|
|
||||||
/// <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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEntitySpeak(EntityUid uid, DiseasedComponent component, EntitySpokeEvent args)
|
private void OnEntitySpeak(EntityUid uid, DiseasedComponent component, EntitySpokeEvent args)
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
|||||||
Verb verb = new()
|
Verb verb = new()
|
||||||
{
|
{
|
||||||
Act = () => TryInsert(component.Owner, args.User, args.User),
|
Act = () => TryInsert(component.Owner, args.User, args.User),
|
||||||
|
DoContactInteraction = true,
|
||||||
Text = Loc.GetString("disposal-self-insert-verb-get-data-text")
|
Text = Loc.GetString("disposal-self-insert-verb-get-data-text")
|
||||||
};
|
};
|
||||||
// TODO VERN ICON
|
// TODO VERN ICON
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ public sealed class SpillableSystem : EntitySystem
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
verb.Impact = LogImpact.Medium; // dangerous reagent reaction are logged separately.
|
verb.Impact = LogImpact.Medium; // dangerous reagent reaction are logged separately.
|
||||||
|
verb.DoContactInteraction = true;
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Item;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Server.Forensics
|
namespace Content.Server.Forensics
|
||||||
@@ -10,13 +10,13 @@ namespace Content.Server.Forensics
|
|||||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<FingerprintComponent, UserInteractedWithItemEvent>(OnInteract);
|
SubscribeLocalEvent<FingerprintComponent, ContactInteractionEvent>(OnInteract);
|
||||||
SubscribeLocalEvent<FingerprintComponent, ComponentInit>(OnInit);
|
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)
|
private void OnInit(EntityUid uid, FingerprintComponent component, ComponentInit args)
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ namespace Content.Server.PneumaticCannon
|
|||||||
Verb ejectItems = new();
|
Verb ejectItems = new();
|
||||||
ejectItems.Act = () => TryEjectAllItems(component, args.User);
|
ejectItems.Act = () => TryEjectAllItems(component, args.User);
|
||||||
ejectItems.Text = Loc.GetString("pneumatic-cannon-component-verb-eject-items-name");
|
ejectItems.Text = Loc.GetString("pneumatic-cannon-component-verb-eject-items-name");
|
||||||
|
ejectItems.DoContactInteraction = true;
|
||||||
args.Verbs.Add(ejectItems);
|
args.Verbs.Add(ejectItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Content.Server.Rotatable
|
|||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
verb.Act = () => TryFlip(component, args.User);
|
verb.Act = () => TryFlip(component, args.User);
|
||||||
verb.Text = Loc.GetString("flippable-verb-get-data-text");
|
verb.Text = Loc.GetString("flippable-verb-get-data-text");
|
||||||
|
verb.DoContactInteraction = true;
|
||||||
// TODO VERB ICONS Add Uno reverse card style icon?
|
// TODO VERB ICONS Add Uno reverse card style icon?
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
@@ -43,6 +44,7 @@ namespace Content.Server.Rotatable
|
|||||||
|
|
||||||
Verb resetRotation = new ()
|
Verb resetRotation = new ()
|
||||||
{
|
{
|
||||||
|
DoContactInteraction = true,
|
||||||
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation = Angle.Zero,
|
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation = Angle.Zero,
|
||||||
Category = VerbCategory.Rotate,
|
Category = VerbCategory.Rotate,
|
||||||
IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",
|
IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Server.DoAfter;
|
using Content.Server.DoAfter;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Sticky.Components;
|
using Content.Server.Sticky.Components;
|
||||||
using Content.Server.Sticky.Events;
|
using Content.Server.Sticky.Events;
|
||||||
@@ -53,6 +53,7 @@ public sealed class StickySystem : EntitySystem
|
|||||||
|
|
||||||
args.Verbs.Add(new Verb
|
args.Verbs.Add(new Verb
|
||||||
{
|
{
|
||||||
|
DoContactInteraction = true,
|
||||||
Text = Loc.GetString("comp-sticky-unstick-verb-text"),
|
Text = Loc.GetString("comp-sticky-unstick-verb-text"),
|
||||||
IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png",
|
IconTexture = "/Textures/Interface/VerbIcons/eject.svg.192dpi.png",
|
||||||
Act = () => StartUnsticking(uid, args.User, component)
|
Act = () => StartUnsticking(uid, args.User, component)
|
||||||
|
|||||||
@@ -84,17 +84,7 @@ namespace Content.Server.Verbs
|
|||||||
// first, lets log the verb. Just in case it ends up crashing the server or something.
|
// first, lets log the verb. Just in case it ends up crashing the server or something.
|
||||||
LogVerb(verb, user, target, forced);
|
LogVerb(verb, user, target, forced);
|
||||||
|
|
||||||
// then invoke any relevant actions
|
base.ExecuteVerb(verb, user, target, forced);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogVerb(Verb verb, EntityUid user, EntityUid target, bool forced)
|
public void LogVerb(Verb verb, EntityUid user, EntityUid target, bool forced)
|
||||||
|
|||||||
@@ -150,6 +150,13 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
|||||||
ev.Target.Value
|
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.
|
// For stuff that cares about it being attacked.
|
||||||
RaiseLocalEvent(ev.Target.Value, new AttackedEvent(component.Owner, user, targetXform.Coordinates));
|
RaiseLocalEvent(ev.Target.Value, new AttackedEvent(component.Owner, user, targetXform.Coordinates));
|
||||||
|
|
||||||
@@ -249,9 +256,17 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
|||||||
var modifiers = itemDamage.ModifiersList;
|
var modifiers = itemDamage.ModifiersList;
|
||||||
modifiers.AddRange(hitEvent.ModifiersList);
|
modifiers.AddRange(hitEvent.ModifiersList);
|
||||||
|
|
||||||
|
_interaction.DoContactInteraction(user, ev.Weapon);
|
||||||
|
|
||||||
// For stuff that cares about it being attacked.
|
// For stuff that cares about it being attacked.
|
||||||
foreach (var target in targets)
|
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));
|
RaiseLocalEvent(target, new AttackedEvent(component.Owner, user, Transform(target).Coordinates));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,6 +353,8 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
|||||||
inTargetHand = targetHandsComponent.ActiveHand.HeldEntity!.Value;
|
inTargetHand = targetHandsComponent.ActiveHand.HeldEntity!.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_interaction.DoContactInteraction(user, ev.Target);
|
||||||
|
|
||||||
var attemptEvent = new DisarmAttemptEvent(target, user, inTargetHand);
|
var attemptEvent = new DisarmAttemptEvent(target, user, inTargetHand);
|
||||||
|
|
||||||
if (inTargetHand != null)
|
if (inTargetHand != null)
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
var targetEv = new GettingInteractedWithAttemptEvent(user, target);
|
var targetEv = new GettingInteractedWithAttemptEvent(user, target);
|
||||||
RaiseLocalEvent(target.Value, targetEv);
|
RaiseLocalEvent(target.Value, targetEv);
|
||||||
|
|
||||||
if (!targetEv.Cancelled)
|
|
||||||
InteractWithItem(user, target.Value);
|
|
||||||
|
|
||||||
return !targetEv.Cancelled;
|
return !targetEv.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,11 +133,7 @@ namespace Content.Shared.ActionBlocker
|
|||||||
var itemEv = new GettingPickedUpAttemptEvent(user, item);
|
var itemEv = new GettingPickedUpAttemptEvent(user, item);
|
||||||
RaiseLocalEvent(item, itemEv);
|
RaiseLocalEvent(item, itemEv);
|
||||||
|
|
||||||
if (!itemEv.Cancelled)
|
|
||||||
InteractWithItem(user, item);
|
|
||||||
|
|
||||||
return !itemEv.Cancelled;
|
return !itemEv.Cancelled;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanEmote(EntityUid uid)
|
public bool CanEmote(EntityUid uid)
|
||||||
@@ -186,13 +179,5 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InteractWithItem(EntityUid user, EntityUid item)
|
|
||||||
{
|
|
||||||
var userEvent = new UserInteractedWithItemEvent(user, item);
|
|
||||||
RaiseLocalEvent(user, userEvent);
|
|
||||||
var itemEvent = new ItemInteractedWithEvent(user, item);
|
|
||||||
RaiseLocalEvent(item, itemEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
Content.Shared/Interaction/Events/ContactInteractionEvent.cs
Normal file
17
Content.Shared/Interaction/Events/ContactInteractionEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace Content.Shared.Interaction.Events;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised directed at two entities to indicate that they came into contact, usually as a result of some other interaction.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is currently used by the forensics and disease systems to perform on-contact interactions.
|
||||||
|
/// </remarks>
|
||||||
|
public sealed class ContactInteractionEvent : HandledEntityEventArgs
|
||||||
|
{
|
||||||
|
public readonly EntityUid Other;
|
||||||
|
|
||||||
|
public ContactInteractionEvent(EntityUid other)
|
||||||
|
{
|
||||||
|
Other = other;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -261,7 +261,8 @@ namespace Content.Shared.Interaction
|
|||||||
if (target != null)
|
if (target != null)
|
||||||
{
|
{
|
||||||
var ev = new InteractNoHandEvent(user, target.Value);
|
var ev = new InteractNoHandEvent(user, target.Value);
|
||||||
RaiseLocalEvent(user, ev, true);
|
RaiseLocalEvent(user, ev);
|
||||||
|
DoContactInteraction(user, target.Value, ev);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -316,6 +317,7 @@ namespace Content.Shared.Interaction
|
|||||||
var message = new InteractHandEvent(user, target);
|
var message = new InteractHandEvent(user, target);
|
||||||
RaiseLocalEvent(target, message, true);
|
RaiseLocalEvent(target, message, true);
|
||||||
_adminLogger.Add(LogType.InteractHand, LogImpact.Low, $"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target}");
|
_adminLogger.Add(LogType.InteractHand, LogImpact.Low, $"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target}");
|
||||||
|
DoContactInteraction(user, target, message);
|
||||||
if (message.Handled)
|
if (message.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -337,6 +339,9 @@ namespace Content.Shared.Interaction
|
|||||||
var rangedMsg = new RangedInteractEvent(user, used, target.Value, clickLocation);
|
var rangedMsg = new RangedInteractEvent(user, used, target.Value, clickLocation);
|
||||||
RaiseLocalEvent(target.Value, rangedMsg, true);
|
RaiseLocalEvent(target.Value, rangedMsg, true);
|
||||||
|
|
||||||
|
// We contact the USED entity, but not the target.
|
||||||
|
DoContactInteraction(user, used, rangedMsg);
|
||||||
|
|
||||||
if (rangedMsg.Handled)
|
if (rangedMsg.Handled)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -722,6 +727,9 @@ namespace Content.Shared.Interaction
|
|||||||
{
|
{
|
||||||
var ev = new BeforeRangedInteractEvent(user, used, target, clickLocation, canReach);
|
var ev = new BeforeRangedInteractEvent(user, used, target, clickLocation, canReach);
|
||||||
RaiseLocalEvent(used, ev);
|
RaiseLocalEvent(used, ev);
|
||||||
|
|
||||||
|
// We contact the USED entity, but not the target.
|
||||||
|
DoContactInteraction(user, used, ev);
|
||||||
return ev.Handled;
|
return ev.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,6 +758,9 @@ namespace Content.Shared.Interaction
|
|||||||
// all interactions should only happen when in range / unobstructed, so no range check is needed
|
// all interactions should only happen when in range / unobstructed, so no range check is needed
|
||||||
var interactUsingEvent = new InteractUsingEvent(user, used, target, clickLocation);
|
var interactUsingEvent = new InteractUsingEvent(user, used, target, clickLocation);
|
||||||
RaiseLocalEvent(target, interactUsingEvent, true);
|
RaiseLocalEvent(target, interactUsingEvent, true);
|
||||||
|
DoContactInteraction(user, used, interactUsingEvent);
|
||||||
|
DoContactInteraction(user, target, interactUsingEvent);
|
||||||
|
DoContactInteraction(used, target, interactUsingEvent);
|
||||||
if (interactUsingEvent.Handled)
|
if (interactUsingEvent.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -765,7 +776,14 @@ namespace Content.Shared.Interaction
|
|||||||
target = null;
|
target = null;
|
||||||
|
|
||||||
var afterInteractEvent = new AfterInteractEvent(user, used, target, clickLocation, canReach);
|
var afterInteractEvent = new AfterInteractEvent(user, used, target, clickLocation, canReach);
|
||||||
RaiseLocalEvent(used, afterInteractEvent, false);
|
RaiseLocalEvent(used, afterInteractEvent);
|
||||||
|
DoContactInteraction(user, used, afterInteractEvent);
|
||||||
|
if (canReach)
|
||||||
|
{
|
||||||
|
DoContactInteraction(user, target, afterInteractEvent);
|
||||||
|
DoContactInteraction(used, target, afterInteractEvent);
|
||||||
|
}
|
||||||
|
|
||||||
if (afterInteractEvent.Handled)
|
if (afterInteractEvent.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -774,6 +792,13 @@ namespace Content.Shared.Interaction
|
|||||||
|
|
||||||
var afterInteractUsingEvent = new AfterInteractUsingEvent(user, used, target, clickLocation, canReach);
|
var afterInteractUsingEvent = new AfterInteractUsingEvent(user, used, target, clickLocation, canReach);
|
||||||
RaiseLocalEvent(target.Value, afterInteractUsingEvent);
|
RaiseLocalEvent(target.Value, afterInteractUsingEvent);
|
||||||
|
|
||||||
|
DoContactInteraction(user, used, afterInteractUsingEvent);
|
||||||
|
if (canReach)
|
||||||
|
{
|
||||||
|
DoContactInteraction(user, target, afterInteractUsingEvent);
|
||||||
|
DoContactInteraction(used, target, afterInteractUsingEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region ActivateItemInWorld
|
#region ActivateItemInWorld
|
||||||
@@ -832,6 +857,7 @@ namespace Content.Shared.Interaction
|
|||||||
if (!activateMsg.Handled)
|
if (!activateMsg.Handled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
DoContactInteraction(user, used, activateMsg);
|
||||||
_useDelay.BeginDelay(used, delayComponent);
|
_useDelay.BeginDelay(used, delayComponent);
|
||||||
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
|
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
|
||||||
return true;
|
return true;
|
||||||
@@ -869,6 +895,7 @@ namespace Content.Shared.Interaction
|
|||||||
RaiseLocalEvent(used, useMsg, true);
|
RaiseLocalEvent(used, useMsg, true);
|
||||||
if (useMsg.Handled)
|
if (useMsg.Handled)
|
||||||
{
|
{
|
||||||
|
DoContactInteraction(user, used, useMsg);
|
||||||
_useDelay.BeginDelay(used, delayComponent);
|
_useDelay.BeginDelay(used, delayComponent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -977,6 +1004,18 @@ namespace Content.Shared.Interaction
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Simple convenience function to raise contact events (disease, forensics, etc).
|
||||||
|
/// </summary>
|
||||||
|
public void DoContactInteraction(EntityUid uidA, EntityUid? uidB, HandledEntityEventArgs? args = null)
|
||||||
|
{
|
||||||
|
if (uidB == null || args?.Handled == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RaiseLocalEvent(uidA, new ContactInteractionEvent(uidB.Value));
|
||||||
|
RaiseLocalEvent(uidB.Value, new ContactInteractionEvent(uidA));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
namespace Content.Shared.Item;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised on the item after they do any sort of interaction with an item,
|
|
||||||
/// useful for when you want a component on the user to do something to the user
|
|
||||||
/// E.g. forensics, disease, etc.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class ItemInteractedWithEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
public EntityUid User;
|
|
||||||
public EntityUid Item;
|
|
||||||
public ItemInteractedWithEvent(EntityUid user, EntityUid item)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
Item = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -111,14 +111,13 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
if (args.Hands == null ||
|
if (args.Hands == null ||
|
||||||
args.Using != null ||
|
args.Using != null ||
|
||||||
!args.CanAccess ||
|
!args.CanAccess ||
|
||||||
!args.CanInteract) //||
|
!args.CanInteract ||
|
||||||
//!_handsSystem.CanPickupAnyHand(args.User, args.Target, handsComp: args.Hands, item: component))
|
!_handsSystem.CanPickupAnyHand(args.User, args.Target, handsComp: args.Hands, item: component))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InteractionVerb verb = new();
|
InteractionVerb verb = new();
|
||||||
// TODO ITEM
|
verb.Act = () => _handsSystem.TryPickupAnyHand(args.User, args.Target, checkActionBlocker: false,
|
||||||
//verb.Act = () => _handsSystem.TryPickupAnyHand(args.User, args.Target, checkActionBlocker: false,
|
handsComp: args.Hands, item: component);
|
||||||
// handsComp: args.Hands, item: component);
|
|
||||||
verb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";
|
verb.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";
|
||||||
|
|
||||||
// if the item already in a container (that is not the same as the user's), then change the text.
|
// if the item already in a container (that is not the same as the user's), then change the text.
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
namespace Content.Shared.Item;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised on the user after they do any sort of interaction with an item,
|
|
||||||
/// useful for when you want a component on the user to do something to the item.
|
|
||||||
/// E.g. forensics, disease, etc.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class UserInteractedWithItemEvent : EntityEventArgs
|
|
||||||
{
|
|
||||||
public EntityUid User;
|
|
||||||
public EntityUid Item;
|
|
||||||
public UserInteractedWithItemEvent(EntityUid user, EntityUid item)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
Item = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Physics.Pull;
|
using Content.Shared.Physics.Pull;
|
||||||
using Content.Shared.Pulling.Components;
|
using Content.Shared.Pulling.Components;
|
||||||
using Content.Shared.Pulling.Events;
|
using Content.Shared.Pulling.Events;
|
||||||
@@ -16,6 +17,7 @@ namespace Content.Shared.Pulling
|
|||||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||||
|
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||||
|
|
||||||
public bool CanPull(EntityUid puller, EntityUid pulled)
|
public bool CanPull(EntityUid puller, EntityUid pulled)
|
||||||
{
|
{
|
||||||
@@ -189,6 +191,8 @@ namespace Content.Shared.Pulling
|
|||||||
if (pullAttempt.Cancelled)
|
if (pullAttempt.Cancelled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
_interaction.DoContactInteraction(pullable.Owner, puller.Owner);
|
||||||
|
|
||||||
_pullSm.ForceRelationship(puller, pullable);
|
_pullSm.ForceRelationship(puller, pullable);
|
||||||
pullable.PrevFixedRotation = pullablePhysics.FixedRotation;
|
pullable.PrevFixedRotation = pullablePhysics.FixedRotation;
|
||||||
pullablePhysics.FixedRotation = pullable.FixedRotationOnPull;
|
pullablePhysics.FixedRotation = pullable.FixedRotationOnPull;
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ namespace Content.Shared.Pulling
|
|||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
verb.Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling");
|
verb.Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling");
|
||||||
verb.Act = () => TryStopPull(component, args.User);
|
verb.Act = () => TryStopPull(component, args.User);
|
||||||
|
verb.DoContactInteraction = false; // pulling handle its own contact interaction.
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
else if (CanPull(args.User, args.Target))
|
else if (CanPull(args.User, args.Target))
|
||||||
@@ -100,6 +101,7 @@ namespace Content.Shared.Pulling
|
|||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
verb.Text = Loc.GetString("pulling-verb-get-data-text");
|
verb.Text = Loc.GetString("pulling-verb-get-data-text");
|
||||||
verb.Act = () => TryStartPull(args.User, args.Target);
|
verb.Act = () => TryStartPull(args.User, args.Target);
|
||||||
|
verb.DoContactInteraction = false; // pulling handle its own contact interaction.
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,23 @@ namespace Content.Shared.Verbs
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This will try to call the action delegates and raise the local events for the given verb.
|
/// This will try to call the action delegates and raise the local events for the given verb.
|
||||||
/// </remarks>
|
/// </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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,15 @@ namespace Content.Shared.Verbs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ConfirmationPopup = false;
|
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>
|
/// <summary>
|
||||||
/// Compares two verbs based on their <see cref="Priority"/>, <see cref="Category"/>, <see cref="Text"/>,
|
/// Compares two verbs based on their <see cref="Priority"/>, <see cref="Category"/>, <see cref="Text"/>,
|
||||||
/// and <see cref="IconTexture"/>.
|
/// and <see cref="IconTexture"/>.
|
||||||
@@ -235,6 +244,7 @@ namespace Content.Shared.Verbs
|
|||||||
{
|
{
|
||||||
public new static string DefaultTextStyleClass = "InteractionVerb";
|
public new static string DefaultTextStyleClass = "InteractionVerb";
|
||||||
public override int TypePriority => 4;
|
public override int TypePriority => 4;
|
||||||
|
public override bool DefaultDoContactInteraction => true;
|
||||||
|
|
||||||
public InteractionVerb() : base()
|
public InteractionVerb() : base()
|
||||||
{
|
{
|
||||||
@@ -256,6 +266,7 @@ namespace Content.Shared.Verbs
|
|||||||
public sealed class UtilityVerb : Verb
|
public sealed class UtilityVerb : Verb
|
||||||
{
|
{
|
||||||
public override int TypePriority => 3;
|
public override int TypePriority => 3;
|
||||||
|
public override bool DefaultDoContactInteraction => true;
|
||||||
|
|
||||||
public UtilityVerb() : base()
|
public UtilityVerb() : base()
|
||||||
{
|
{
|
||||||
@@ -293,6 +304,7 @@ namespace Content.Shared.Verbs
|
|||||||
{
|
{
|
||||||
public override int TypePriority => 2;
|
public override int TypePriority => 2;
|
||||||
public new static string DefaultTextStyleClass = "AlternativeVerb";
|
public new static string DefaultTextStyleClass = "AlternativeVerb";
|
||||||
|
public override bool DefaultDoContactInteraction => true;
|
||||||
|
|
||||||
public AlternativeVerb() : base()
|
public AlternativeVerb() : base()
|
||||||
{
|
{
|
||||||
@@ -314,6 +326,7 @@ namespace Content.Shared.Verbs
|
|||||||
{
|
{
|
||||||
public override int TypePriority => 1;
|
public override int TypePriority => 1;
|
||||||
public new static string DefaultTextStyleClass = "ActivationVerb";
|
public new static string DefaultTextStyleClass = "ActivationVerb";
|
||||||
|
public override bool DefaultDoContactInteraction => true;
|
||||||
|
|
||||||
public ActivationVerb() : base()
|
public ActivationVerb() : base()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user