2018-04-05 17:32:51 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using SS14.Shared.GameObjects;
|
|
|
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
|
|
|
|
|
using SS14.Shared.Interfaces.GameObjects;
|
|
|
|
|
|
using SS14.Shared.Map;
|
|
|
|
|
|
using SS14.Shared.IoC;
|
|
|
|
|
|
using SS14.Server.GameObjects;
|
|
|
|
|
|
using SS14.Shared.Maths;
|
|
|
|
|
|
using SS14.Server.Interfaces.GameObjects;
|
|
|
|
|
|
using SS14.Shared.Interfaces.Timing;
|
|
|
|
|
|
using SS14.Shared.GameObjects.EntitySystemMessages;
|
2018-07-26 23:38:16 +02:00
|
|
|
|
using SS14.Shared.Serialization;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
using SS14.Shared.Interfaces.GameObjects.Components;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
using Content.Shared.GameObjects;
|
2018-04-05 17:32:51 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|
|
|
|
|
{
|
|
|
|
|
|
public class MeleeWeaponComponent : Component, IAfterAttack
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Name => "MeleeWeapon";
|
|
|
|
|
|
|
|
|
|
|
|
public int Damage = 1;
|
|
|
|
|
|
public float Range = 1;
|
|
|
|
|
|
public float ArcWidth = 90;
|
|
|
|
|
|
|
2018-07-26 23:38:16 +02:00
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
2018-04-05 17:32:51 -05:00
|
|
|
|
{
|
|
|
|
|
|
base.ExposeData(serializer);
|
|
|
|
|
|
|
|
|
|
|
|
serializer.DataField(ref Damage, "damage", 5);
|
2018-07-26 23:38:16 +02:00
|
|
|
|
serializer.DataField(ref Range, "range", 1);
|
|
|
|
|
|
serializer.DataField(ref ArcWidth, "arcwidth", 90);
|
2018-04-05 17:32:51 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-04-05 19:40:46 +02:00
|
|
|
|
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
|
2018-04-05 17:32:51 -05:00
|
|
|
|
{
|
2019-04-05 19:40:46 +02:00
|
|
|
|
var location = eventArgs.User.GetComponent<ITransformComponent>().GridPosition;
|
|
|
|
|
|
var angle = new Angle(eventArgs.ClickLocation.ToWorld().Position - location.ToWorld().Position);
|
|
|
|
|
|
var entities = IoCManager.Resolve<IServerEntityManager>().GetEntitiesInArc(eventArgs.User.GetComponent<ITransformComponent>().GridPosition, Range, angle, ArcWidth);
|
2018-04-05 17:32:51 -05:00
|
|
|
|
|
2018-05-27 16:44:50 +02:00
|
|
|
|
foreach (var entity in entities)
|
2018-04-05 17:32:51 -05:00
|
|
|
|
{
|
2019-04-05 19:40:46 +02:00
|
|
|
|
if (!entity.GetComponent<ITransformComponent>().IsMapTransform || entity == eventArgs.User)
|
2018-04-05 17:32:51 -05:00
|
|
|
|
continue;
|
2018-05-27 16:44:50 +02:00
|
|
|
|
|
|
|
|
|
|
if (entity.TryGetComponent(out DamageableComponent damagecomponent))
|
2018-04-05 17:32:51 -05:00
|
|
|
|
{
|
|
|
|
|
|
damagecomponent.TakeDamage(DamageType.Brute, Damage);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|