Skip to content

Commit

Permalink
Switch to just not raising the event
Browse files Browse the repository at this point in the history
  • Loading branch information
themias committed Jul 25, 2024
1 parent 8d34063 commit 2550588
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Content.Server/Forensics/Systems/ForensicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public override void Initialize()

private void OnInteract(EntityUid uid, FingerprintComponent component, ContactInteractionEvent args)
{
if(args.HandContact)
ApplyEvidence(uid, args.Other);
ApplyEvidence(uid, args.Other);
}

private void OnFingerprintInit(EntityUid uid, FingerprintComponent component, MapInitEvent args)
Expand Down
4 changes: 1 addition & 3 deletions Content.Shared/Interaction/Events/ContactInteractionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ namespace Content.Shared.Interaction.Events;
public sealed class ContactInteractionEvent : HandledEntityEventArgs
{
public readonly EntityUid Other;
public bool HandContact;

public ContactInteractionEvent(EntityUid other, bool handContact = false)
public ContactInteractionEvent(EntityUid other)
{
Other = other;
HandContact = handContact;
}
}
14 changes: 7 additions & 7 deletions Content.Shared/Interaction/SharedInteractionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public void InteractHand(EntityUid user, EntityUid target)
var message = new InteractHandEvent(user, target);
RaiseLocalEvent(target, message, true);
_adminLogger.Add(LogType.InteractHand, LogImpact.Low, $"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target}");
DoContactInteraction(user, target, message, true);
DoContactInteraction(user, target, message);
if (message.Handled)
return;

Expand Down Expand Up @@ -952,7 +952,7 @@ public void InteractUsing(
RaiseLocalEvent(target, interactUsingEvent, true);
DoContactInteraction(user, used, interactUsingEvent);
DoContactInteraction(user, target, interactUsingEvent);
DoContactInteraction(used, target, interactUsingEvent);
// Contact interactions are currently only used for forensics, so we don't raise used -> target
if (interactUsingEvent.Handled)
return;

Expand All @@ -973,7 +973,7 @@ public void InteractDoAfter(EntityUid user, EntityUid used, EntityUid? target, E
if (canReach)
{
DoContactInteraction(user, target, afterInteractEvent);
DoContactInteraction(used, target, afterInteractEvent);
// Contact interactions are currently only used for forensics, so we don't raise used -> target
}

if (afterInteractEvent.Handled)
Expand All @@ -989,7 +989,7 @@ public void InteractDoAfter(EntityUid user, EntityUid used, EntityUid? target, E
if (canReach)
{
DoContactInteraction(user, target, afterInteractUsingEvent);
DoContactInteraction(used, target, afterInteractUsingEvent);
// Contact interactions are currently only used for forensics, so we don't raise used -> target
}
}

Expand Down Expand Up @@ -1047,7 +1047,7 @@ public bool InteractionActivate(
if (!activateMsg.Handled && !userEv.Handled)
return false;

DoContactInteraction(user, used, activateMsg, true);
DoContactInteraction(user, used, activateMsg);
// Still need to call this even without checkUseDelay in case this gets relayed from Activate.
if (delayComponent != null)
_useDelay.TryResetDelay(used, component: delayComponent);
Expand Down Expand Up @@ -1253,7 +1253,7 @@ protected bool ValidateClientInput(ICommonSession? session, EntityCoordinates co
/// <summary>
/// Simple convenience function to raise contact events (disease, forensics, etc).
/// </summary>
public void DoContactInteraction(EntityUid uidA, EntityUid? uidB, HandledEntityEventArgs? args = null, bool handContact = false)
public void DoContactInteraction(EntityUid uidA, EntityUid? uidB, HandledEntityEventArgs? args = null)
{
if (uidB == null || args?.Handled == false)
return;
Expand All @@ -1265,7 +1265,7 @@ public void DoContactInteraction(EntityUid uidA, EntityUid? uidB, HandledEntityE
if (Paused(uidA) || Paused(uidB.Value))
return;

RaiseLocalEvent(uidA, new ContactInteractionEvent(uidB.Value, handContact));
RaiseLocalEvent(uidA, new ContactInteractionEvent(uidB.Value));
RaiseLocalEvent(uidB.Value, new ContactInteractionEvent(uidA));
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Movement/Pulling/Systems/PullingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public bool TryStartPull(EntityUid pullerUid, EntityUid pullableUid,

// Pulling confirmed

_interaction.DoContactInteraction(pullerUid, pullableUid, handContact: true);
_interaction.DoContactInteraction(pullableUid, pullerUid);

// Use net entity so it's consistent across client and server.
pullableComp.PullJointId = $"pull-joint-{GetNetEntity(pullableUid)}";
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Verbs/SharedVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public virtual void ExecuteVerb(Verb verb, EntityUid user, EntityUid target, boo

// Perform any contact interactions
if (verb.DoContactInteraction ?? (verb.DefaultDoContactInteraction && _interactionSystem.InRangeUnobstructed(user, target)))
_interactionSystem.DoContactInteraction(user, target, handContact: true);
_interactionSystem.DoContactInteraction(user, target);
}
}
}
12 changes: 6 additions & 6 deletions Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@ protected virtual void DoLightAttack(EntityUid user, LightAttackEvent ev, Entity

var weapon = GetEntity(ev.Weapon);

Interaction.DoContactInteraction(weapon, target, handContact: user == weapon);
Interaction.DoContactInteraction(user, weapon, handContact: true);
// We skip weapon -> target interaction, as forensics system applies DNA on hit
Interaction.DoContactInteraction(user, 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, target, handContact: user == weapon);
Interaction.DoContactInteraction(user, target);

// For stuff that cares about it being attacked.
var attackedEvent = new AttackedEvent(meleeUid, user, targetXform.Coordinates);
Expand Down Expand Up @@ -611,16 +611,16 @@ private bool DoHeavyAttack(EntityUid user, HeavyAttackEvent ev, EntityUid meleeU

var weapon = GetEntity(ev.Weapon);

Interaction.DoContactInteraction(user, weapon, handContact: true);
Interaction.DoContactInteraction(user, weapon);

// For stuff that cares about it being attacked.
foreach (var target in targets)
{
Interaction.DoContactInteraction(weapon, target, handContact: user == weapon);
// We skip weapon -> target interaction, as forensics system applies DNA on hit

// 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, handContact: user == weapon);
Interaction.DoContactInteraction(user, target);
}

var appliedDamage = new DamageSpecifier();
Expand Down

0 comments on commit 2550588

Please sign in to comment.