Adds click attacks
This commit is contained in:
@@ -176,7 +176,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
|
||||
if (userEntity.TryGetComponent(out CombatModeComponent combatMode) && combatMode.IsInCombatMode)
|
||||
{
|
||||
DoAttack(userEntity, coords);
|
||||
DoAttack(userEntity, coords, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -198,7 +198,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
|
||||
if (entity.TryGetComponent(out CombatModeComponent combatMode) && combatMode.IsInCombatMode)
|
||||
{
|
||||
DoAttack(entity, coords);
|
||||
DoAttack(entity, coords, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -229,7 +229,10 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return true;
|
||||
}
|
||||
|
||||
UserInteraction(userEntity, coords, uid);
|
||||
if(userEntity.TryGetComponent(out CombatModeComponent combat) && combat.IsInCombatMode)
|
||||
DoAttack(userEntity, coords, false, uid);
|
||||
else
|
||||
UserInteraction(userEntity, coords, uid);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -790,7 +793,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
}
|
||||
}
|
||||
|
||||
private void DoAttack(IEntity player, GridCoordinates coordinates)
|
||||
private void DoAttack(IEntity player, GridCoordinates coordinates, bool wideAttack, EntityUid target = default)
|
||||
{
|
||||
// Verify player is on the same map as the entity he clicked on
|
||||
if (_mapManager.GetGrid(coordinates.GridID).ParentMapId != player.Transform.MapID)
|
||||
@@ -800,12 +803,13 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ActionBlockerSystem.CanAttack(player))
|
||||
if (!ActionBlockerSystem.CanAttack(player) ||
|
||||
(!wideAttack && !InRangeUnobstructed(player.Transform.MapPosition, coordinates.ToMap(_mapManager), ignoreInsideBlocker:true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var eventArgs = new AttackEventArgs(player, coordinates);
|
||||
var eventArgs = new AttackEventArgs(player, coordinates, wideAttack, target);
|
||||
|
||||
// Verify player has a hand, and find what object he is currently holding in his active hand
|
||||
if (player.TryGetComponent<IHandsComponent>(out var hands))
|
||||
@@ -814,22 +818,20 @@ namespace Content.Server.GameObjects.EntitySystems.Click
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
var attacked = false;
|
||||
foreach (var attackComponent in item.GetAllComponents<IAttack>())
|
||||
{
|
||||
attackComponent.Attack(eventArgs);
|
||||
attacked = true;
|
||||
}
|
||||
if (attacked)
|
||||
{
|
||||
return;
|
||||
if(wideAttack ? attackComponent.WideAttack(eventArgs) : attackComponent.ClickAttack(eventArgs))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var attackComponent in player.GetAllComponents<IAttack>())
|
||||
{
|
||||
attackComponent.Attack(eventArgs);
|
||||
if (wideAttack)
|
||||
attackComponent.WideAttack(eventArgs);
|
||||
else
|
||||
attackComponent.ClickAttack(eventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user