Re-organize all projects (#4166)
This commit is contained in:
23
Content.Shared/Projectiles/ProjectileSystem.cs
Normal file
23
Content.Shared/Projectiles/ProjectileSystem.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Shared.Projectiles
|
||||
{
|
||||
public sealed class ProjectileSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SharedProjectileComponent, PreventCollideEvent>(PreventCollision);
|
||||
}
|
||||
|
||||
private void PreventCollision(EntityUid uid, SharedProjectileComponent component, PreventCollideEvent args)
|
||||
{
|
||||
if (component.IgnoreShooter && args.BodyB.Owner.Uid == component.Shooter)
|
||||
{
|
||||
args.Cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Content.Shared/Projectiles/SharedProjectileComponent.cs
Normal file
42
Content.Shared/Projectiles/SharedProjectileComponent.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.NetIDs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Projectiles
|
||||
{
|
||||
public abstract class SharedProjectileComponent : Component
|
||||
{
|
||||
private bool _ignoreShooter = true;
|
||||
public override string Name => "Projectile";
|
||||
public override uint? NetID => ContentNetIDs.PROJECTILE;
|
||||
|
||||
public EntityUid Shooter { get; protected set; }
|
||||
|
||||
public bool IgnoreShooter
|
||||
{
|
||||
get => _ignoreShooter;
|
||||
set
|
||||
{
|
||||
if (_ignoreShooter == value) return;
|
||||
|
||||
_ignoreShooter = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
protected class ProjectileComponentState : ComponentState
|
||||
{
|
||||
public ProjectileComponentState(EntityUid shooter, bool ignoreShooter) : base(ContentNetIDs.PROJECTILE)
|
||||
{
|
||||
Shooter = shooter;
|
||||
IgnoreShooter = ignoreShooter;
|
||||
}
|
||||
|
||||
public EntityUid Shooter { get; }
|
||||
public bool IgnoreShooter { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user