fix reflected projectiles dealing stamina damage (#17648)

This commit is contained in:
Slava0135
2023-08-06 16:44:41 +03:00
committed by GitHub
parent c6f80b2efb
commit b49f0df05e
5 changed files with 46 additions and 54 deletions

View File

@@ -1,7 +0,0 @@
namespace Content.Shared.Projectiles;
/// <summary>
/// Raised directed on what a projectile collides with. Can have its deletion cancelled.
/// </summary>
[ByRefEvent]
public record struct ProjectileCollideEvent(EntityUid OtherEntity, bool Cancelled);

View File

@@ -28,7 +28,7 @@ namespace Content.Shared.Projectiles
{
base.Initialize();
SubscribeLocalEvent<ProjectileComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<EmbeddableProjectileComponent, ProjectileCollideEvent>(OnEmbedProjectileCollide);
SubscribeLocalEvent<EmbeddableProjectileComponent, ProjectileHitEvent>(OnEmbedProjectileHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ThrowDoHitEvent>(OnEmbedThrowDoHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate);
SubscribeLocalEvent<EmbeddableProjectileComponent, RemoveEmbeddedProjectileEvent>(OnEmbedRemove);
@@ -80,14 +80,14 @@ namespace Content.Shared.Projectiles
Embed(uid, args.Target, component);
}
private void OnEmbedProjectileCollide(EntityUid uid, EmbeddableProjectileComponent component, ref ProjectileCollideEvent args)
private void OnEmbedProjectileHit(EntityUid uid, EmbeddableProjectileComponent component, ref ProjectileHitEvent args)
{
Embed(uid, args.OtherEntity, component);
Embed(uid, args.Target, component);
// Raise a specific event for projectiles.
if (TryComp<ProjectileComponent>(uid, out var projectile))
{
var ev = new ProjectileEmbedEvent(projectile.Shooter, projectile.Weapon, args.OtherEntity);
var ev = new ProjectileEmbedEvent(projectile.Shooter, projectile.Weapon, args.Target);
RaiseLocalEvent(uid, ref ev);
}
}
@@ -142,10 +142,16 @@ namespace Content.Shared.Projectiles
Coordinates = coordinates;
}
}
}
/// <summary>
/// Raised when entity is just about to be hit with projectile but can reflect it
/// </summary>
[ByRefEvent]
public record struct ProjectileReflectAttemptEvent(EntityUid ProjUid, ProjectileComponent Component, bool Cancelled);
/// <summary>
/// Raised when entity is just about to be hit with projectile but can reflect it
/// </summary>
[ByRefEvent]
public record struct ProjectileReflectAttemptEvent(EntityUid ProjUid, ProjectileComponent Component, bool Cancelled);
/// <summary>
/// Raised when projectile hits other entity
/// </summary>
[ByRefEvent]
public readonly record struct ProjectileHitEvent(EntityUid Target);
}