Adds weapons (#48)
* Adds weapons - Adds melee weapons - Adds projectile weapons - Adds hitscan weapons (like lasers) * Adds a separate sprite for projectile weapons
This commit is contained in:
committed by
Pieter-Jan Briers
parent
63b5d83728
commit
128728bfcb
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.Serialization;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
public override void ExposeData(EntitySerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref Damage, "damage", 5);
|
||||
serializer.DataField(ref Range, "damage", 1);
|
||||
serializer.DataField(ref ArcWidth, "damage", 90);
|
||||
|
||||
}
|
||||
|
||||
void IAfterAttack.Afterattack(IEntity user, LocalCoordinates clicklocation)
|
||||
{
|
||||
var location = user.GetComponent<TransformComponent>().LocalPosition;
|
||||
var angle = new Angle(clicklocation.ToWorld().Position - location.ToWorld().Position);
|
||||
var entities = IoCManager.Resolve<IServerEntityManager>().GetEntitiesInArc(user.GetComponent<TransformComponent>().LocalPosition, Range, angle, ArcWidth);
|
||||
|
||||
foreach(var entity in entities)
|
||||
{
|
||||
if (!entity.GetComponent<TransformComponent>().IsMapTransform || entity == user)
|
||||
continue;
|
||||
|
||||
if(entity.TryGetComponent(out DamageableComponent damagecomponent))
|
||||
{
|
||||
damagecomponent.TakeDamage(DamageType.Brute, Damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user