Pull request #73: Fixed issue where farmer can be placed on a non-resource tile.
Merge in CGD/gather-and-defend from origin/bugfix/FarmerTileRestriction to main * commit '884d4a9ee6fb0bb68dccebb797b4617dc4cac1da': Fixed issue where farmer can be placed on a non-resource tile.
This commit is contained in:
commit
15782ad8c2
@ -18,6 +18,23 @@ public class ObjectPlaceholder : UnitPlaceholder
|
|||||||
&& LevelBoundCache.Contains(transform.position)
|
&& LevelBoundCache.Contains(transform.position)
|
||||||
&& ResourceManager.Instance.EnoughFor(Rock, Wood, Food)
|
&& ResourceManager.Instance.EnoughFor(Rock, Wood, Food)
|
||||||
&& (Prefab.GetComponent<Building>()
|
&& (Prefab.GetComponent<Building>()
|
||||||
|| ResourceManager.Instance.EnoughPopulationFor(defaultUnitCost));
|
|| ResourceManager.Instance.EnoughPopulationFor(defaultUnitCost))
|
||||||
|
&& IsFarmerAndAllowed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsFarmerAndAllowed()
|
||||||
|
{
|
||||||
|
Ally unit = Prefab.GetComponent<Ally>();
|
||||||
|
|
||||||
|
//Obtiens info correctement.
|
||||||
|
LevelTile pointedTile = LevelManager.Instance.Get<LevelTile>(obj => obj.Position.IsContainedIn(transform.position));
|
||||||
|
|
||||||
|
return unit is not Harvester || (unit is Harvester && IsAllowedTile(pointedTile));
|
||||||
|
//return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsAllowedTile(LevelTile pointedTile)
|
||||||
|
{
|
||||||
|
return pointedTile is ResourceTile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user