Shovel done
This commit is contained in:
parent
47a3ca3db2
commit
c1f9f61b0c
5 changed files with 18 additions and 6 deletions
|
|
@ -29,9 +29,18 @@ public partial class ShovelButton : TextureButton
|
|||
{
|
||||
if (@event.IsActionPressed("primary_action"))
|
||||
{
|
||||
if (_shovelCast.IsColliding() && (_shovelCast.GetCollider() as CollisionObject2D).GetParent() is RuntimePlantData plant)
|
||||
if (_shovelCast.IsColliding())
|
||||
{
|
||||
plant.Kill();
|
||||
var checkedPosition = (_shovelCast.GetCollider() as Node).GetParent<RuntimePlantData>().GlobalPosition;
|
||||
|
||||
for (int i = Utility.LayersCount-1; i >= 0; i--)
|
||||
{
|
||||
if (LevelController.Instance.Pools.EntityField[i].TryGetValue(checkedPosition, out var entity) && entity is RuntimePlantData plantData)
|
||||
{
|
||||
plantData.Kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ButtonPressed = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue