public class CombatUtils extends Object
Global.getCombatEngine() != null
). If you wish to check fog of war
visibility you should use the methods in AIUtils
.The Misc class provided by vanilla for a large number of useful utility methods.
Modifier and Type | Method and Description |
---|---|
static void |
applyForce(CombatEntityAPI entity,
float direction,
float force)
Apply force to an object.
|
static void |
applyForce(CombatEntityAPI entity,
Vector2f direction,
float force)
Apply force to an object.
|
static void |
centerViewport(Vector2f newCenter)
Recenters the viewport at a specific point.
|
static List<CombatEntityAPI> |
getAsteroidsWithinRange(Vector2f location,
float range)
Returns all asteroids in range of a given location.
|
static List<CombatEntityAPI> |
getEntitiesWithinRange(Vector2f location,
float range)
Returns all entities in range of a given location.
|
static @Nullable FleetMemberAPI |
getFleetMember(ShipAPI ship)
Find a
ShipAPI 's corresponding FleetMemberAPI . |
static List<MissileAPI> |
getMissilesWithinRange(Vector2f location,
float range)
Returns all missiles in range of a given location.
|
static List<BattleObjectiveAPI> |
getObjectivesWithinRange(Vector2f location,
float range)
Returns all objectives in range of a given location.
|
static List<DamagingProjectileAPI> |
getProjectilesWithinRange(Vector2f location,
float range)
Returns all projectiles in range of a given location, excluding missiles.
|
static List<ShipAPI> |
getShipsWithinRange(Vector2f location,
float range)
Returns all ships in range of a given location, excluding the shuttle
pod.
|
static boolean |
isVisibleToSide(CombatEntityAPI entity,
int side)
Checks if a
CombatEntityAPI is visible to a side of battle. |
static ShipAPI |
spawnShipOrWingDirectly(String variantId,
FleetMemberType type,
FleetSide side,
float combatReadiness,
Vector2f location,
float facing)
Spawns a ship directly onto the battle map, bypassing the fleet reserves.
|
static Vector2f |
toScreenCoordinates(Vector2f worldCoordinates)
Converts worldspace coordinates to screen coordinates.
|
static Vector2f |
toWorldCoordinates(Vector2f screenCoordinates)
Converts screenspace coordinates to world coordinates.
|
@Nullable public static @Nullable FleetMemberAPI getFleetMember(ShipAPI ship)
ShipAPI
's corresponding FleetMemberAPI
. Due to the
way the game keeps tracks of ship ownership, this will be extremely slow
when used with hulks.ship
- The ShipAPI
whose corresponding
FleetMemberAPI
we are trying to find.FleetMemberAPI
that represents this ShipAPI
in the campaign, or null
if no match is found.public static boolean isVisibleToSide(CombatEntityAPI entity, int side)
CombatEntityAPI
is visible to a side of battle.
Note1: Allied and neutral entities are always visible.
Note2: All AIUtils
methods already filter by visibility, so use
of this method is not necessary on their results.entity
- The CombatEntityAPI
to check visibility of.side
- The side whose fog of war will be tested.true
if entity
is visible to side
,
false
otherwise.public static List<DamagingProjectileAPI> getProjectilesWithinRange(Vector2f location, float range)
location
- The location to search around.range
- How far around location
to search.List
of DamagingProjectileAPI
s within range of
location
.public static List<MissileAPI> getMissilesWithinRange(Vector2f location, float range)
location
- The location to search around.range
- How far around location
to search.List
of MissileAPI
s within range of
location
.public static List<ShipAPI> getShipsWithinRange(Vector2f location, float range)
public static List<CombatEntityAPI> getAsteroidsWithinRange(Vector2f location, float range)
location
- The location to search around.range
- How far around location
to search.List
of asteroids within range of location
.public static List<BattleObjectiveAPI> getObjectivesWithinRange(Vector2f location, float range)
location
- The location to search around.range
- How far around location
to search.List
of BattleObjectiveAPI
s within range of
location
.public static List<CombatEntityAPI> getEntitiesWithinRange(Vector2f location, float range)
location
- The location to search around.range
- How far around location
to search.List
of CombatEntityAPI
s within range of location
.public static ShipAPI spawnShipOrWingDirectly(String variantId, FleetMemberType type, FleetSide side, float combatReadiness, Vector2f location, float facing)
variantId
- The ID of the ship variant to spawn.type
- Whether this is a ship or a fighter wing.side
- What side of the battle this ship should fight on.combatReadiness
- The CR the ship should start with.location
- The location on the battle map the ship should
spawn at.facing
- The initial facing of the ship on the battle map.ShipAPI
that was spawned by this method.public static void centerViewport(Vector2f newCenter)
newCenter
- The new center point of the ViewportAPI
.public static Vector2f toWorldCoordinates(Vector2f screenCoordinates)
screenCoordinates
- The screenspace coordinates to convert.screenCoordinates
converted to world coordinates.public static Vector2f toScreenCoordinates(Vector2f worldCoordinates)
worldCoordinates
- The worldspace coordinates to convert.worldCoordinates
converted to screen coordinates.public static void applyForce(CombatEntityAPI entity, Vector2f direction, float force)
Force is multiplied by 100 to avoid requiring ridiculous force amounts.
entity
- The CombatEntityAPI
to apply the force to.direction
- The directional vector of the force (this will
automatically be normalized).force
- How much force to apply. Unit is how much it takes
to modify a 100 weight object's velocity by 1 su/sec.public static void applyForce(CombatEntityAPI entity, float direction, float force)
Force is multiplied by 100 to avoid requiring ridiculous force amounts.
entity
- The CombatEntityAPI
to apply the force to.direction
- The angle the force will be applied towards.force
- How much force to apply. Unit is how much it takes
to modify a 100 weight object's velocity by 1 su/sec.