Package mindustry.entities
Class Units
java.lang.Object
mindustry.entities.Units
Utility class for unit and team interactions.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
static boolean
anyEntities
(float x, float y, float size) static boolean
anyEntities
(float x, float y, float width, float height) static boolean
anyEntities
(float x, float y, float width, float height, boolean ground) static boolean
anyEntities
(float x, float y, float width, float height, Boolf<mindustry.gen.Unit> check) static boolean
anyEntities
(Tile tile) Returns whether there are any entities on this tile.static boolean
anyEntities
(Tile tile, boolean ground) Returns whether there are any entities on this tile.static mindustry.gen.Unit
bestEnemy
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate, Units.Sortf sort) Returns the closest enemy of this team using a custom comparison function.static mindustry.gen.Teamc
bestTarget
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> unitPred, Boolf<mindustry.gen.Building> tilePred, Units.Sortf sort) Returns the closest target enemy.static boolean
static boolean
canInteract
(mindustry.gen.Player player, mindustry.gen.Building tile) static mindustry.gen.Unit
Returns the closest ally of this team in a range.static mindustry.gen.Unit
closest
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate, Units.Sortf sort) Returns the closest ally of this team in a range.static mindustry.gen.Unit
Returns the closest ally of this team.static mindustry.gen.Building
closestBuilding
(Team team, float wx, float wy, float range, Boolf<mindustry.gen.Building> pred) static mindustry.gen.Unit
closestEnemy
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate) Returns the closest enemy of this team.static mindustry.gen.Unit
closestOverlap
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate) Returns the closest ally of this team.static mindustry.gen.Teamc
closestTarget
(Team team, float x, float y, float range) Returns the closest target enemy.static mindustry.gen.Teamc
closestTarget
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> unitPred) Returns the closest target enemy.static mindustry.gen.Teamc
closestTarget
(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> unitPred, Boolf<mindustry.gen.Building> tilePred) Returns the closest target enemy.static int
static int
static mindustry.gen.Building
findAllyTile
(Team team, float x, float y, float range, Boolf<mindustry.gen.Building> pred) Returns the nearest ally tile in a range.static mindustry.gen.Building
findDamagedTile
(Team team, float x, float y) Returns the nearest damaged tile.static mindustry.gen.Building
findEnemyTile
(Team team, float x, float y, float range, Boolf<mindustry.gen.Building> pred) Returns the nearest enemy tile in a range.static int
static String
getStringCap
(Team team) static boolean
invalidateTarget
(mindustry.gen.Posc target, Team team, float x, float y) static boolean
invalidateTarget
(mindustry.gen.Posc target, Team team, float x, float y, float range) Validates a target.static boolean
invalidateTarget
(mindustry.gen.Teamc target, mindustry.gen.Unit targeter, float range) static void
Iterates over all units in a rectangle.static void
Iterates over all units in a rectangle.static void
Iterates over all units in a rectangle.static void
Iterates over all units in a circle around this position.static void
nearbyBuildings
(float x, float y, float range, Cons<mindustry.gen.Building> cons) Iterates through all buildings in a range.static void
nearbyEnemies
(Team team, float x, float y, float width, float height, Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team.static void
nearbyEnemies
(Team team, float x, float y, float radius, Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team.static void
nearbyEnemies
(Team team, Rect rect, Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team.static boolean
static void
unitCapDeath
(mindustry.gen.Unit unit) static void
unitDeath
(int uid) static void
unitDespawn
(mindustry.gen.Unit unit) static void
unitDestroy
(int uid) static void
unitEnvDeath
(mindustry.gen.Unit unit)
-
Constructor Details
-
Units
public Units()
-
-
Method Details
-
unitCapDeath
public static void unitCapDeath(mindustry.gen.Unit unit) -
unitEnvDeath
public static void unitEnvDeath(mindustry.gen.Unit unit) -
unitDeath
public static void unitDeath(int uid) -
unitDestroy
public static void unitDestroy(int uid) -
unitDespawn
public static void unitDespawn(mindustry.gen.Unit unit) -
canCreate
- Returns:
- whether a new instance of a unit of this team can be created.
-
getCap
-
getStringCap
- Returns:
- unit cap as a string, substituting the infinity symbol instead of MAX_VALUE
-
canInteract
public static boolean canInteract(mindustry.gen.Player player, mindustry.gen.Building tile) - Returns:
- whether this player can interact with a specific tile. if either of these are null, returns true.
-
invalidateTarget
public static boolean invalidateTarget(mindustry.gen.Posc target, Team team, float x, float y, float range) Validates a target.- Parameters:
target
- The target to validateteam
- The team of the thing doing tha targetingx
- The X position of the thing doing the targetingy
- The Y position of the thing doing the targetingrange
- The maximum distance from the target X/Y the targeter can be for it to be valid- Returns:
- whether the target is invalid
-
invalidateTarget
-
invalidateTarget
public static boolean invalidateTarget(mindustry.gen.Teamc target, mindustry.gen.Unit targeter, float range) -
anyEntities
Returns whether there are any entities on this tile. -
anyEntities
Returns whether there are any entities on this tile. -
anyEntities
public static boolean anyEntities(float x, float y, float size) -
anyEntities
public static boolean anyEntities(float x, float y, float width, float height) -
anyEntities
public static boolean anyEntities(float x, float y, float width, float height, boolean ground) -
anyEntities
public static boolean anyEntities(float x, float y, float width, float height, Boolf<mindustry.gen.Unit> check) -
findDamagedTile
Returns the nearest damaged tile. -
findAllyTile
public static mindustry.gen.Building findAllyTile(Team team, float x, float y, float range, Boolf<mindustry.gen.Building> pred) Returns the nearest ally tile in a range. -
findEnemyTile
public static mindustry.gen.Building findEnemyTile(Team team, float x, float y, float range, Boolf<mindustry.gen.Building> pred) Returns the nearest enemy tile in a range. -
closestBuilding
@Nullable public static mindustry.gen.Building closestBuilding(Team team, float wx, float wy, float range, Boolf<mindustry.gen.Building> pred) - Returns:
- the closest building of the provided team that matches the predicate.
-
nearbyBuildings
public static void nearbyBuildings(float x, float y, float range, Cons<mindustry.gen.Building> cons) Iterates through all buildings in a range. -
closestTarget
Returns the closest target enemy. First, units are checked, then tile entities. -
closestTarget
public static mindustry.gen.Teamc closestTarget(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> unitPred) Returns the closest target enemy. First, units are checked, then tile entities. -
closestTarget
public static mindustry.gen.Teamc closestTarget(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> unitPred, Boolf<mindustry.gen.Building> tilePred) Returns the closest target enemy. First, units are checked, then tile entities. -
bestTarget
public static mindustry.gen.Teamc bestTarget(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> unitPred, Boolf<mindustry.gen.Building> tilePred, Units.Sortf sort) Returns the closest target enemy. First, units are checked, then buildings. -
closestEnemy
public static mindustry.gen.Unit closestEnemy(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate) Returns the closest enemy of this team. Filter by predicate. -
bestEnemy
public static mindustry.gen.Unit bestEnemy(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate, Units.Sortf sort) Returns the closest enemy of this team using a custom comparison function. Filter by predicate. -
closest
public static mindustry.gen.Unit closest(Team team, float x, float y, Boolf<mindustry.gen.Unit> predicate) Returns the closest ally of this team. Filter by predicate. No range. -
closest
public static mindustry.gen.Unit closest(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate) Returns the closest ally of this team in a range. Filter by predicate. -
closest
public static mindustry.gen.Unit closest(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate, Units.Sortf sort) Returns the closest ally of this team in a range. Filter by predicate. -
closestOverlap
public static mindustry.gen.Unit closestOverlap(Team team, float x, float y, float range, Boolf<mindustry.gen.Unit> predicate) Returns the closest ally of this team. Filter by predicate. Unlike the closest() function, this only guarantees that unit hitboxes overlap the range. -
count
- Returns:
- whether any units exist in this square (centered)
-
count
public static int count(float x, float y, float width, float height, Boolf<mindustry.gen.Unit> filter) - Returns:
- whether any units exist in this rectangle
-
any
public static boolean any(float x, float y, float width, float height, Boolf<mindustry.gen.Unit> filter) - Returns:
- whether any units exist in this rectangle
-
nearby
public static void nearby(@Nullable Team team, float x, float y, float width, float height, Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle. -
nearby
public static void nearby(@Nullable Team team, float x, float y, float radius, Cons<mindustry.gen.Unit> cons) Iterates over all units in a circle around this position. -
nearby
public static void nearby(float x, float y, float width, float height, Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle. -
nearby
Iterates over all units in a rectangle. -
nearbyEnemies
public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team. -
nearbyEnemies
public static void nearbyEnemies(Team team, float x, float y, float radius, Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team. -
nearbyEnemies
Iterates over all units that are enemies of this team. -
nearEnemy
- Returns:
- whether there is an enemy in this rectangle.
-