Package mindustry.entities
Class Units
java.lang.Object
mindustry.entities.Units
Utility class for unit and team interactions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanany(float x, float y, float width, float height, arc.func.Boolf<mindustry.gen.Unit> filter) static booleananyEntities(float x, float y, float size) static booleananyEntities(float x, float y, float width, float height) static booleananyEntities(float x, float y, float width, float height, boolean ground) static booleananyEntities(float x, float y, float width, float height, arc.func.Boolf<mindustry.gen.Unit> check) Note that this checks the tile hitbox, not the standard hitbox.static booleananyEntities(Tile tile) Returns whether there are any entities on this tile.static booleananyEntities(Tile tile, boolean ground) Returns whether there are any entities on this tile.static mindustry.gen.UnitbestEnemy(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> predicate, Units.Sortf sort) Returns the closest enemy of this team using a custom comparison function.static mindustry.gen.TeamcbestTarget(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> unitPred, arc.func.Boolf<mindustry.gen.Building> tilePred, Units.Sortf sort) Returns the closest target enemy.static booleanstatic booleancanInteract(mindustry.gen.Player player, mindustry.gen.Building tile) static mindustry.gen.UnitReturns the closest ally of this team in a range.static mindustry.gen.Unitclosest(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> predicate, Units.Sortf sort) Returns the closest ally of this team in a range.static mindustry.gen.UnitReturns the closest ally of this team.static mindustry.gen.BuildingclosestBuilding(Team team, float wx, float wy, float range, arc.func.Boolf<mindustry.gen.Building> pred) static mindustry.gen.UnitclosestEnemy(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> predicate) Returns the closest enemy of this team.static mindustry.gen.UnitclosestOverlap(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> predicate) Returns the closest ally of this team.static mindustry.gen.TeamcclosestTarget(Team team, float x, float y, float range) Returns the closest target enemy.static mindustry.gen.TeamcclosestTarget(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> unitPred) Returns the closest target enemy.static mindustry.gen.TeamcclosestTarget(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Unit> unitPred, arc.func.Boolf<mindustry.gen.Building> tilePred) Returns the closest target enemy.static intcount(float x, float y, float width, float height, arc.func.Boolf<mindustry.gen.Unit> filter) static intcount(float x, float y, float size, arc.func.Boolf<mindustry.gen.Unit> filter) static mindustry.gen.BuildingfindAllyTile(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Building> pred) Returns the nearest ally tile in a range.static mindustry.gen.BuildingfindDamagedTile(Team team, float x, float y) Returns the nearest damaged tile.static mindustry.gen.BuildingfindEnemyTile(Team team, float x, float y, float range, arc.func.Boolf<mindustry.gen.Building> pred) Returns the nearest enemy tile in a range.static intstatic StringgetStringCap(Team team) static booleaninvalidateTarget(mindustry.gen.Posc target, Team team, float x, float y) static booleaninvalidateTarget(mindustry.gen.Posc target, Team team, float x, float y, float range) Validates a target.static booleaninvalidateTarget(mindustry.gen.Teamc target, mindustry.gen.Unit targeter, float range) static booleanisHittable(mindustry.gen.Posc target, boolean air, boolean ground) static voidnearby(float x, float y, float width, float height, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle.static voidnearby(arc.math.geom.Rect rect, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle.static voidnearby(Team team, float x, float y, float width, float height, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle.static voidIterates over all units in a circle around this position.static voidnearbyBuildings(float x, float y, float range, arc.func.Cons<mindustry.gen.Building> cons) Iterates through all buildings in a range.static booleannearbyCheck(float x, float y, float width, float height, arc.func.Boolf<mindustry.gen.Unit> cons) Iterates over all units in a rectangle.static voidnearbyEnemies(Team team, float x, float y, float width, float height, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team.static voidnearbyEnemies(Team team, float x, float y, float radius, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team.static voidnearbyEnemies(Team team, arc.math.geom.Rect rect, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team.static booleanstatic voidnotifyUnitSpawn(mindustry.gen.Unit unit) static voidunitCapDeath(mindustry.gen.Unit unit) static voidunitDeath(int uid) static voidunitDespawn(mindustry.gen.Unit unit) static voidunitDestroy(int uid) static voidunitEnvDeath(mindustry.gen.Unit unit) static voidunitSpawn(Units.UnitSyncContainer container)
-
Constructor Details
-
Units
public Units()
-
-
Method Details
-
notifyUnitSpawn
public static void notifyUnitSpawn(mindustry.gen.Unit unit) -
unitSpawn
-
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.
-
isHittable
public static boolean isHittable(@Nullable mindustry.gen.Posc target, boolean air, boolean ground) -
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, arc.func.Boolf<mindustry.gen.Unit> check) Note that this checks the tile hitbox, not the standard hitbox. -
findDamagedTile
Returns the nearest damaged tile. -
findAllyTile
public static mindustry.gen.Building findAllyTile(Team team, float x, float y, float range, arc.func.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, arc.func.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, arc.func.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, arc.func.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, arc.func.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, arc.func.Boolf<mindustry.gen.Unit> unitPred, arc.func.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, arc.func.Boolf<mindustry.gen.Unit> unitPred, arc.func.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, arc.func.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, arc.func.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, arc.func.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, arc.func.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, arc.func.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, arc.func.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
public static int count(float x, float y, float size, arc.func.Boolf<mindustry.gen.Unit> filter) - Returns:
- whether any units exist in this square (centered)
-
count
public static int count(float x, float y, float width, float height, arc.func.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, arc.func.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, arc.func.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, arc.func.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, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle. -
nearbyCheck
public static boolean nearbyCheck(float x, float y, float width, float height, arc.func.Boolf<mindustry.gen.Unit> cons) Iterates over all units in a rectangle.- Returns:
- whether a unit was found.
-
nearby
public static void nearby(arc.math.geom.Rect rect, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units in a rectangle. -
nearbyEnemies
public static void nearbyEnemies(Team team, float x, float y, float width, float height, arc.func.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, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team. -
nearbyEnemies
public static void nearbyEnemies(Team team, arc.math.geom.Rect rect, arc.func.Cons<mindustry.gen.Unit> cons) Iterates over all units that are enemies of this team. -
nearEnemy
- Returns:
- whether there is an enemy in this rectangle.
-