2023-04-02 16:48:32 +03:00
|
|
|
using Content.Shared.Projectiles;
|
2022-07-09 13:46:11 +10:00
|
|
|
using Robust.Shared.Map;
|
2022-09-14 17:26:26 +10:00
|
|
|
using Robust.Shared.Physics.Events;
|
2022-07-09 13:46:11 +10:00
|
|
|
using Robust.Shared.Serialization;
|
2021-05-30 23:30:44 +10:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Projectiles
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
2022-05-21 18:04:47 +10:00
|
|
|
public abstract class SharedProjectileSystem : EntitySystem
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
2022-05-21 18:04:47 +10:00
|
|
|
public const string ProjectileFixture = "projectile";
|
|
|
|
|
|
2021-05-30 23:30:44 +10:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2022-12-24 23:28:21 -05:00
|
|
|
SubscribeLocalEvent<ProjectileComponent, PreventCollideEvent>(PreventCollision);
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|
|
|
|
|
|
2022-12-24 23:28:21 -05:00
|
|
|
private void PreventCollision(EntityUid uid, ProjectileComponent component, ref PreventCollideEvent args)
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
2021-12-03 16:30:34 +01:00
|
|
|
if (component.IgnoreShooter && args.BodyB.Owner == component.Shooter)
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
2022-09-14 17:26:26 +10:00
|
|
|
args.Cancelled = true;
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|
|
|
|
|
}
|
2022-07-09 13:46:11 +10:00
|
|
|
|
2022-12-24 23:28:21 -05:00
|
|
|
public void SetShooter(ProjectileComponent component, EntityUid uid)
|
2022-07-09 13:46:11 +10:00
|
|
|
{
|
|
|
|
|
if (component.Shooter == uid) return;
|
|
|
|
|
|
|
|
|
|
component.Shooter = uid;
|
|
|
|
|
Dirty(component);
|
|
|
|
|
}
|
2023-05-14 13:15:18 +10:00
|
|
|
}
|
2022-07-09 13:46:11 +10:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class ImpactEffectEvent : EntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public string Prototype;
|
|
|
|
|
public EntityCoordinates Coordinates;
|
2022-07-09 13:46:11 +10:00
|
|
|
|
2023-05-14 13:15:18 +10:00
|
|
|
public ImpactEffectEvent(string prototype, EntityCoordinates coordinates)
|
2022-07-09 13:46:11 +10:00
|
|
|
{
|
2023-05-14 13:15:18 +10:00
|
|
|
Prototype = prototype;
|
|
|
|
|
Coordinates = coordinates;
|
2022-07-09 13:46:11 +10:00
|
|
|
}
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-02 16:48:32 +03:00
|
|
|
|
|
|
|
|
/// <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);
|