Files
tbd-station-14/Content.Server/GameObjects/Components/Damage/DamageOnLandComponent.cs
2021-02-04 17:44:49 +01:00

35 lines
1.1 KiB
C#

using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Damage
{
[RegisterComponent]
public class DamageOnLandComponent : Component, ILand
{
public override string Name => "DamageOnLand";
private DamageType _damageType;
private int _amount;
private bool _ignoreResistances;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _damageType, "damageType", DamageType.Blunt);
serializer.DataField(ref _amount, "amount", 1);
serializer.DataField(ref _ignoreResistances, "ignoreResistances", false);
}
void ILand.Land(LandEventArgs eventArgs)
{
if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return;
damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User);
}
}
}