Adds stunbaton
This commit is contained in:
@@ -75,6 +75,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
serializer.DataField(ref _cooldownTime, "cooldownTime", 1f);
|
||||
}
|
||||
|
||||
public virtual void OnHitEntities(IEnumerable<IEntity> entities)
|
||||
{
|
||||
}
|
||||
|
||||
void IAttack.Attack(AttackEventArgs eventArgs)
|
||||
{
|
||||
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
@@ -101,6 +105,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
}
|
||||
}
|
||||
|
||||
OnHitEntities(hitEntities);
|
||||
|
||||
var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||
var emitter = hitEntities.Count == 0 ? eventArgs.User : hitEntities[0];
|
||||
audioSystem.Play(hitEntities.Count > 0 ? _hitSound : "/Audio/weapons/punchmiss.ogg", emitter);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class StunbatonComponent : MeleeWeaponComponent
|
||||
{
|
||||
public override string Name => "Stunbaton";
|
||||
|
||||
private float _paralyzeTime = 10f;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _paralyzeTime, "paralyzeTime", 10f);
|
||||
}
|
||||
|
||||
public override void OnHitEntities(IEnumerable<IEntity> entities)
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if(entity.TryGetComponent(out StunnableComponent stunnable))
|
||||
stunnable.Paralyze(_paralyzeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user