Skip to content

Commit

Permalink
[Fix] Trown Item / Брошенный Предмет (#44)
Browse files Browse the repository at this point in the history
fix: The thrown item is now triggered once
  • Loading branch information
Spatison authored Sep 3, 2024
1 parent ccac202 commit d672bf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Content.Shared/Throwing/ThrownItemComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ public sealed partial class ThrownItemComponent : Component
/// </summary>
[DataField]
public Vector2? OriginalScale = null;

public readonly List<EntityUid> Processed = new(); // WD EDIT
}
}
11 changes: 9 additions & 2 deletions Content.Shared/Throwing/ThrownItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ private void HandleCollision(EntityUid uid, ThrownItemComponent component, ref S
if (args.OtherEntity == component.Thrower)
return;

// WD EDIT START
if (component.Processed.Contains(args.OtherEntity))
return;
// WD EDIT END

ThrowCollideInteraction(component, args.OurEntity, args.OtherEntity);
component.Processed.Add(args.OtherEntity); // WD EDIT
}

private void PreventCollision(EntityUid uid, ThrownItemComponent component, ref PreventCollideEvent args)
Expand Down Expand Up @@ -110,6 +116,7 @@ public void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent)

EntityManager.EventBus.RaiseLocalEvent(uid, new StopThrowEvent { User = thrownItemComponent.Thrower }, true);
EntityManager.RemoveComponent<ThrownItemComponent>(uid);
thrownItemComponent.Processed.Clear(); // WD EDIT
}

public void LandComponent(EntityUid uid, ThrownItemComponent thrownItem, PhysicsComponent physics, bool playSound)
Expand Down Expand Up @@ -137,10 +144,10 @@ public void ThrowCollideInteraction(ThrownItemComponent component, EntityUid thr
_adminLogger.Add(LogType.ThrowHit, LogImpact.Low,
$"{ToPrettyString(thrown):thrown} thrown by {ToPrettyString(component.Thrower.Value):thrower} hit {ToPrettyString(target):target}.");

if (component.Thrower is not null)// Nyano - Summary: Gotta check if there was a thrower.
if (component.Thrower is not null)// Nyano - Summary: Gotta check if there was a thrower.
RaiseLocalEvent(target, new ThrowHitByEvent(component.Thrower.Value, thrown, target, component), true); // Nyano - Summary: Gotta update for who threw it.
else
RaiseLocalEvent(target, new ThrowHitByEvent(null, thrown, target, component), true); // Nyano - Summary: No thrower.
RaiseLocalEvent(target, new ThrowHitByEvent(null, thrown, target, component), true); // Nyano - Summary: No thrower.
RaiseLocalEvent(thrown, new ThrowDoHitEvent(thrown, target, component), true);
}

Expand Down

0 comments on commit d672bf4

Please sign in to comment.