Construction Bugfixes (#1329)

* Added: CanReach property to AfterAttack events which signals if the attack was within reach.
Fixed: You cannot construct/deconstruct things out of reach.
Fixed: Construction entities now preserve transform rotation.
Fixed: No more exceptions about missing grids when constructing world entities.
Fixed: Used the proper intermediate sprite for intermediate entities.
Fixed: Issue with missing sprite layers on ghost.

* The alligator is greedy, he always eats the bigger number...

* Adds a check so that you cannot use tools on entities that are obstructed from view.
This commit is contained in:
Acruid
2020-07-10 16:52:07 -07:00
committed by GitHub
parent 89c111664a
commit b6b31b7294
4 changed files with 47 additions and 19 deletions

View File

@@ -286,7 +286,8 @@ namespace Content.Server.GameObjects.EntitySystems.Click
if (item != null)
{
// After attack: Check if we clicked on an empty location, if so the only interaction we can do is AfterInteract
InteractAfter(player, item, coordinates);
var distSqrt = (playerTransform.WorldPosition - coordinates.ToMapPos(_mapManager)).LengthSquared;
InteractAfter(player, item, coordinates, distSqrt <= InteractionRangeSquared);
}
return;
@@ -330,9 +331,9 @@ namespace Content.Server.GameObjects.EntitySystems.Click
/// <summary>
/// We didn't click on any entity, try doing an AfterInteract on the click location
/// </summary>
private void InteractAfter(IEntity user, IEntity weapon, GridCoordinates clickLocation)
private void InteractAfter(IEntity user, IEntity weapon, GridCoordinates clickLocation, bool canReach)
{
var message = new AfterInteractMessage(user, weapon, null, clickLocation);
var message = new AfterInteractMessage(user, weapon, null, clickLocation, canReach);
RaiseLocalEvent(message);
if (message.Handled)
{
@@ -340,7 +341,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
var afterInteracts = weapon.GetAllComponents<IAfterInteract>().ToList();
var afterInteractEventArgs = new AfterInteractEventArgs {User = user, ClickLocation = clickLocation};
var afterInteractEventArgs = new AfterInteractEventArgs {User = user, ClickLocation = clickLocation, CanReach = canReach};
foreach (var afterInteract in afterInteracts)
{
@@ -380,7 +381,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
}
var afterAtkMsg = new AfterInteractMessage(user, weapon, attacked, clickLocation);
var afterAtkMsg = new AfterInteractMessage(user, weapon, attacked, clickLocation, true);
RaiseLocalEvent(afterAtkMsg);
if (afterAtkMsg.Handled)
{
@@ -391,7 +392,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
var afterAttacks = weapon.GetAllComponents<IAfterInteract>().ToList();
var afterAttackEventArgs = new AfterInteractEventArgs
{
User = user, ClickLocation = clickLocation, Target = attacked
User = user, ClickLocation = clickLocation, Target = attacked, CanReach = true
};
foreach (var afterAttack in afterAttacks)
@@ -687,7 +688,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
}
}
var afterAtkMsg = new AfterInteractMessage(user, weapon, attacked, clickLocation);
var afterAtkMsg = new AfterInteractMessage(user, weapon, attacked, clickLocation, false);
RaiseLocalEvent(afterAtkMsg);
if (afterAtkMsg.Handled)
return;
@@ -695,7 +696,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click
var afterAttacks = weapon.GetAllComponents<IAfterInteract>().ToList();
var afterAttackEventArgs = new AfterInteractEventArgs
{
User = user, ClickLocation = clickLocation, Target = attacked
User = user, ClickLocation = clickLocation, Target = attacked, CanReach = false
};
//See if we have a ranged attack interaction