Merge pull request #1184 from ShadowCommander/UnarmedAttack

Implement unarmed combat
This commit is contained in:
ShadowCommander
2020-06-23 08:17:32 -07:00
committed by GitHub
6 changed files with 49 additions and 12 deletions

View File

@@ -0,0 +1,10 @@
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.Components.Weapon.Melee
{
[RegisterComponent]
public class UnarmedCombatComponent : MeleeWeaponComponent
{
public override string Name => "UnarmedCombat";
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Timing;
@@ -955,22 +955,34 @@ namespace Content.Server.GameObjects.EntitySystems
return;
}
// Verify player has a hand, and find what object he is currently holding in his active hand
if (!player.TryGetComponent<IHandsComponent>(out var hands))
{
return;
}
var item = hands.GetActiveHand?.Owner;
// TODO: If item is null we need some kinda unarmed combat.
if (!ActionBlockerSystem.CanAttack(player) || item == null)
if (!ActionBlockerSystem.CanAttack(player))
{
return;
}
var eventArgs = new AttackEventArgs(player, coordinates);
foreach (var attackComponent in item.GetAllComponents<IAttack>())
// Verify player has a hand, and find what object he is currently holding in his active hand
if (player.TryGetComponent<IHandsComponent>(out var hands))
{
var item = hands.GetActiveHand?.Owner;
if (item != null)
{
var attacked = false;
foreach (var attackComponent in item.GetAllComponents<IAttack>())
{
attackComponent.Attack(eventArgs);
attacked = true;
}
if (attacked)
{
return;
}
}
}
foreach (var attackComponent in player.GetAllComponents<IAttack>())
{
attackComponent.Attack(eventArgs);
}

View File

@@ -134,6 +134,10 @@
- type: HumanoidAppearance
- type: Stunnable
- type: AnimationPlayer
- type: UnarmedCombat
range: 0.8
arcwidth: 30
arc: fist
- type: entity
save: false

View File

@@ -5,3 +5,10 @@
length: 0.1
color: 255,255,255,1020
colorDelta: 0,0,0,-5100
- type: MeleeWeaponAnimation
id: fist
state: fist
arcType: Poke
length: 0.15
speed: 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

View File

@@ -13,6 +13,10 @@
{
"name": "slash",
"directions": 1
},
{
"name": "fist",
"directions": 1
}
]
}