Package org.lazywizard.lazylib.combat
Class CombatUtils
Object
CombatUtils
Contains methods that deal with the battle map in general. These methods do
not respect fog of war, and assume that you are in combat
(
Global.getCombatEngine() != null). If you wish to check fog of war
visibility you should use the methods in AIUtils.- Since:
- 1.0
- Author:
- LazyWizard
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyForce(CombatEntityAPI entity, float direction, float force) Apply force to an object.static voidapplyForce(CombatEntityAPI entity, Vector2f direction, float force) Apply force to an object.static voidcenterViewport(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 FleetMemberAPIgetFleetMember(ShipAPI ship) Find aShipAPI's correspondingFleetMemberAPI.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.getShipsWithinRange(Vector2f location, float range) Returns all ships in range of a given location, excluding the shuttle pod.static booleanisVisibleToSide(CombatEntityAPI entity, int side) Checks if aCombatEntityAPIis visible to a side of battle.static ShipAPIspawnShipOrWingDirectly(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 Vector2ftoScreenCoordinates(Vector2f worldCoordinates) Converts worldspace coordinates to screen coordinates.static Vector2ftoWorldCoordinates(Vector2f screenCoordinates) Converts screenspace coordinates to world coordinates.
-
Method Details
-
getFleetMember
Find aShipAPI's correspondingFleetMemberAPI. Due to the way the game keeps tracks of ship ownership, this will be extremely slow when used with hulks.- Parameters:
ship- TheShipAPIwhose correspondingFleetMemberAPIwe are trying to find.- Returns:
- The
FleetMemberAPIthat represents thisShipAPIin the campaign, ornullif no match is found. - Since:
- 1.5
-
isVisibleToSide
Checks if aCombatEntityAPIis visible to a side of battle. Note1: Allied and neutral entities are always visible. Note2: AllAIUtilsmethods already filter by visibility, so use of this method is not necessary on their results.- Parameters:
entity- TheCombatEntityAPIto check visibility of.side- The side whose fog of war will be tested.- Returns:
trueifentityis visible toside,falseotherwise.- Since:
- 1.7
-
getProjectilesWithinRange
Returns all projectiles in range of a given location, excluding missiles.- Parameters:
location- The location to search around.range- How far aroundlocationto search.- Returns:
- A
ListofDamagingProjectileAPIs within range oflocation. - Since:
- 1.0
-
getMissilesWithinRange
Returns all missiles in range of a given location.- Parameters:
location- The location to search around.range- How far aroundlocationto search.- Returns:
- A
ListofMissileAPIs within range oflocation. - Since:
- 1.0
-
getShipsWithinRange
Returns all ships in range of a given location, excluding the shuttle pod. -
getAsteroidsWithinRange
Returns all asteroids in range of a given location.- Parameters:
location- The location to search around.range- How far aroundlocationto search.- Returns:
- A
Listof asteroids within range oflocation. - Since:
- 1.0
-
getObjectivesWithinRange
Returns all objectives in range of a given location.- Parameters:
location- The location to search around.range- How far aroundlocationto search.- Returns:
- A
ListofBattleObjectiveAPIs within range oflocation. - Since:
- 1.0
-
getEntitiesWithinRange
Returns all entities in range of a given location. This includes ships, projectiles, missiles, and asteroids.- Parameters:
location- The location to search around.range- How far aroundlocationto search.- Returns:
- A
ListofCombatEntityAPIs within range oflocation. - Since:
- 1.0
-
spawnShipOrWingDirectly
public 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. NOTE: this method will not work out of the box in the campaign (.6.2a) due to an after-battle crash in the default FleetEncounterContextPlugin caused by spawned ships not being registered with the fleet.- Parameters:
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.- Returns:
- The
ShipAPIthat was spawned by this method. - Since:
- 1.9
-
centerViewport
Recenters the viewport at a specific point.- Parameters:
newCenter- The new center point of theViewportAPI.- Since:
- 2.0
-
toWorldCoordinates
Converts screenspace coordinates to world coordinates.- Parameters:
screenCoordinates- The screenspace coordinates to convert.- Returns:
screenCoordinatesconverted to world coordinates.- Since:
- 2.3
-
toScreenCoordinates
Converts worldspace coordinates to screen coordinates.- Parameters:
worldCoordinates- The worldspace coordinates to convert.- Returns:
worldCoordinatesconverted to screen coordinates.- Since:
- 2.3
-
applyForce
Apply force to an object. Remember Newton's Second Law.Force is multiplied by 100 to avoid requiring ridiculous force amounts.
- Parameters:
entity- TheCombatEntityAPIto 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.- Since:
- 1.2
-
applyForce
Apply force to an object. Remember Newton's Second Law.Force is multiplied by 100 to avoid requiring ridiculous force amounts.
- Parameters:
entity- TheCombatEntityAPIto 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.- Since:
- 1.2
-