Fix punching (#4141)
This commit is contained in:
committed by
GitHub
parent
3af9c334ea
commit
62ce603858
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||||
{
|
{
|
||||||
|
// TODO: Remove this, just use MeleeWeapon...
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
|
[ComponentReference(typeof(MeleeWeaponComponent))]
|
||||||
public class UnarmedCombatComponent : MeleeWeaponComponent
|
public class UnarmedCombatComponent : MeleeWeaponComponent
|
||||||
{
|
{
|
||||||
public override string Name => "UnarmedCombat";
|
public override string Name => "UnarmedCombat";
|
||||||
|
|||||||
@@ -838,18 +838,40 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
|||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
if(wideAttack)
|
if (wideAttack)
|
||||||
RaiseLocalEvent(item.Uid, new WideAttackEvent(item, player, coordinates), false);
|
{
|
||||||
|
var ev = new WideAttackEvent(item, player, coordinates);
|
||||||
|
RaiseLocalEvent(item.Uid, ev, false);
|
||||||
|
|
||||||
|
if(ev.Handled)
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RaiseLocalEvent(item.Uid, new ClickAttackEvent(item, player, coordinates, targetUid), false);
|
{
|
||||||
|
var ev = new ClickAttackEvent(item, player, coordinates, targetUid);
|
||||||
|
RaiseLocalEvent(item.Uid, ev, false);
|
||||||
|
|
||||||
|
if(ev.Handled)
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We pick up items if our hand is empty, even if we're in combat mode.
|
// We pick up items if our hand is empty, even if we're in combat mode.
|
||||||
if (!EntityManager.TryGetEntity(targetUid, out var targetEnt) || !targetEnt.HasComponent<ItemComponent>()) return;
|
if (EntityManager.TryGetEntity(targetUid, out var targetEnt) && targetEnt.HasComponent<ItemComponent>())
|
||||||
Interaction(player, targetEnt);
|
{
|
||||||
|
Interaction(player, targetEnt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make this saner?
|
||||||
|
// Attempt to do unarmed combat. We don't check for handled just because at this point it doesn't matter.
|
||||||
|
if(wideAttack)
|
||||||
|
RaiseLocalEvent(player.Uid, new WideAttackEvent(player, player, coordinates), false);
|
||||||
|
else
|
||||||
|
RaiseLocalEvent(player.Uid, new ClickAttackEvent(player, player, coordinates, targetUid), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ namespace Content.Server.GameObjects.EntitySystems.Weapon.Melee
|
|||||||
|
|
||||||
private void OnClickAttack(EntityUid uid, MeleeWeaponComponent comp, ClickAttackEvent args)
|
private void OnClickAttack(EntityUid uid, MeleeWeaponComponent comp, ClickAttackEvent args)
|
||||||
{
|
{
|
||||||
|
args.Handled = true;
|
||||||
var curTime = _gameTiming.CurTime;
|
var curTime = _gameTiming.CurTime;
|
||||||
|
|
||||||
if (curTime < comp.CooldownEnd || !args.Target.IsValid())
|
if (curTime < comp.CooldownEnd || !args.Target.IsValid())
|
||||||
@@ -105,6 +106,7 @@ namespace Content.Server.GameObjects.EntitySystems.Weapon.Melee
|
|||||||
|
|
||||||
private void OnWideAttack(EntityUid uid, MeleeWeaponComponent comp, WideAttackEvent args)
|
private void OnWideAttack(EntityUid uid, MeleeWeaponComponent comp, WideAttackEvent args)
|
||||||
{
|
{
|
||||||
|
args.Handled = true;
|
||||||
var curTime = _gameTiming.CurTime;
|
var curTime = _gameTiming.CurTime;
|
||||||
|
|
||||||
if (curTime < comp.CooldownEnd)
|
if (curTime < comp.CooldownEnd)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised directed on the used entity when a target entity is click attacked by a user.
|
/// Raised directed on the used entity when a target entity is click attacked by a user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ClickAttackEvent : EntityEventArgs
|
public class ClickAttackEvent : HandledEntityEventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Entity used to attack, for broadcast purposes.
|
/// Entity used to attack, for broadcast purposes.
|
||||||
@@ -49,7 +49,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised directed on the used entity when a target entity is wide attacked by a user.
|
/// Raised directed on the used entity when a target entity is wide attacked by a user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WideAttackEvent : EntityEventArgs
|
public class WideAttackEvent : HandledEntityEventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Entity used to attack, for broadcast purposes.
|
/// Entity used to attack, for broadcast purposes.
|
||||||
|
|||||||
Reference in New Issue
Block a user