2020-06-22 05:47:15 +10:00
|
|
|
using Content.Server.GameObjects.Components.Mobs;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-03-08 04:09:59 +11:00
|
|
|
using Robust.Shared.Physics;
|
|
|
|
|
using Robust.Shared.Physics.Collision;
|
|
|
|
|
using Robust.Shared.Serialization;
|
2020-06-22 05:47:15 +10:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Projectiles
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds stun when it collides with an entity
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent]
|
2021-03-08 04:09:59 +11:00
|
|
|
public sealed class StunnableProjectileComponent : Component, IStartCollide
|
2020-06-22 05:47:15 +10:00
|
|
|
{
|
|
|
|
|
public override string Name => "StunnableProjectile";
|
|
|
|
|
|
|
|
|
|
// See stunnable for what these do
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("stunAmount")]
|
|
|
|
|
private int _stunAmount = default;
|
|
|
|
|
[DataField("knockdownAmount")]
|
|
|
|
|
private int _knockdownAmount = default;
|
|
|
|
|
[DataField("slowdownAmount")]
|
|
|
|
|
private int _slowdownAmount = default;
|
2020-06-22 05:47:15 +10:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2020-08-24 13:39:00 +02:00
|
|
|
|
2020-12-04 13:26:54 +01:00
|
|
|
Owner.EnsureComponentWarn(out ProjectileComponent _);
|
2020-06-22 05:47:15 +10:00
|
|
|
}
|
|
|
|
|
|
2021-03-08 04:09:59 +11:00
|
|
|
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
|
2020-06-22 05:47:15 +10:00
|
|
|
{
|
2021-03-08 04:09:59 +11:00
|
|
|
if (otherBody.Entity.TryGetComponent(out StunnableComponent stunnableComponent))
|
2020-06-22 05:47:15 +10:00
|
|
|
{
|
|
|
|
|
stunnableComponent.Stun(_stunAmount);
|
|
|
|
|
stunnableComponent.Knockdown(_knockdownAmount);
|
|
|
|
|
stunnableComponent.Slowdown(_slowdownAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|