2022-07-09 13:46:11 +10:00
|
|
|
using Robust.Shared.Map;
|
2021-05-30 23:30:44 +10:00
|
|
|
using Robust.Shared.Physics.Dynamics;
|
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();
|
|
|
|
|
SubscribeLocalEvent<SharedProjectileComponent, PreventCollideEvent>(PreventCollision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PreventCollision(EntityUid uid, SharedProjectileComponent component, PreventCollideEvent args)
|
|
|
|
|
{
|
2021-12-03 16:30:34 +01:00
|
|
|
if (component.IgnoreShooter && args.BodyB.Owner == component.Shooter)
|
2021-05-30 23:30:44 +10:00
|
|
|
{
|
|
|
|
|
args.Cancel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-09 13:46:11 +10:00
|
|
|
|
|
|
|
|
public void SetShooter(SharedProjectileComponent component, EntityUid uid)
|
|
|
|
|
{
|
|
|
|
|
if (component.Shooter == uid) return;
|
|
|
|
|
|
|
|
|
|
component.Shooter = uid;
|
|
|
|
|
Dirty(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NetSerializable, Serializable]
|
|
|
|
|
protected sealed class ProjectileComponentState : ComponentState
|
|
|
|
|
{
|
|
|
|
|
public ProjectileComponentState(EntityUid shooter, bool ignoreShooter)
|
|
|
|
|
{
|
|
|
|
|
Shooter = shooter;
|
|
|
|
|
IgnoreShooter = ignoreShooter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EntityUid Shooter { get; }
|
|
|
|
|
public bool IgnoreShooter { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
protected sealed class ImpactEffectEvent : EntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public string Prototype;
|
|
|
|
|
public EntityCoordinates Coordinates;
|
|
|
|
|
|
|
|
|
|
public ImpactEffectEvent(string prototype, EntityCoordinates coordinates)
|
|
|
|
|
{
|
|
|
|
|
Prototype = prototype;
|
|
|
|
|
Coordinates = coordinates;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-30 23:30:44 +10:00
|
|
|
}
|
|
|
|
|
}
|