Fix punching (#4141)
This commit is contained in:
committed by
GitHub
parent
3af9c334ea
commit
62ce603858
@@ -838,18 +838,40 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if(wideAttack)
|
||||
RaiseLocalEvent(item.Uid, new WideAttackEvent(item, player, coordinates), false);
|
||||
if (wideAttack)
|
||||
{
|
||||
var ev = new WideAttackEvent(item, player, coordinates);
|
||||
RaiseLocalEvent(item.Uid, ev, false);
|
||||
|
||||
if(ev.Handled)
|
||||
return;
|
||||
}
|
||||
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
|
||||
{
|
||||
// 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;
|
||||
Interaction(player, targetEnt);
|
||||
if (EntityManager.TryGetEntity(targetUid, out var targetEnt) && targetEnt.HasComponent<ItemComponent>())
|
||||
{
|
||||
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)
|
||||
{
|
||||
args.Handled = true;
|
||||
var curTime = _gameTiming.CurTime;
|
||||
|
||||
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)
|
||||
{
|
||||
args.Handled = true;
|
||||
var curTime = _gameTiming.CurTime;
|
||||
|
||||
if (curTime < comp.CooldownEnd)
|
||||
|
||||
Reference in New Issue
Block a user