Files
tbd-station-14/Content.Server/GameObjects/Components/Projectiles/StunnableProjectileComponent.cs
Pieter-Jan Briers 1eb0fbd8d0 Revert "Physics (#3452)"
This reverts commit 3e64fd56a1.
2021-02-28 18:49:48 +01:00

48 lines
1.5 KiB
C#

using Content.Server.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Projectiles
{
/// <summary>
/// Adds stun when it collides with an entity
/// </summary>
[RegisterComponent]
public sealed class StunnableProjectileComponent : Component, ICollideBehavior
{
public override string Name => "StunnableProjectile";
// See stunnable for what these do
private int _stunAmount;
private int _knockdownAmount;
private int _slowdownAmount;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _stunAmount, "stunAmount", 0);
serializer.DataField(ref _knockdownAmount, "knockdownAmount", 0);
serializer.DataField(ref _slowdownAmount, "slowdownAmount", 0);
}
public override void Initialize()
{
base.Initialize();
Owner.EnsureComponentWarn(out ProjectileComponent _);
}
void ICollideBehavior.CollideWith(IEntity entity)
{
if (entity.TryGetComponent(out StunnableComponent stunnableComponent))
{
stunnableComponent.Stun(_stunAmount);
stunnableComponent.Knockdown(_knockdownAmount);
stunnableComponent.Slowdown(_slowdownAmount);
}
}
void ICollideBehavior.PostCollide(int collidedCount) {}
}
}