private static bool IsValidTarget(Unit requestor, UnitAction action, Cursor tile, int xPos, int zPos) { bool valid = true; if (tile.standingUnit && !action.CanTargetOwnTeam()) { valid = tile.standingUnit.playerIndex != action.Unit().playerIndex; } if (valid) { if (action.CanTargetSelf() || tile.xPos != xPos || tile.zPos != zPos) { if (action.NeedsLineOfSight()) { valid = Helpers.CanHitTarget(requestor.ProjectedHittable().position, tile); } } else { valid = false; } } Unit unit = Unit.Subject(); if (valid && unit != null) { foreach (Buff buff in unit.Buffs()) { valid = buff.CanTarget(tile); if (!valid) { break; } } ; } return(valid); }