public class CampaignUtils extends Object
LocationAPI
the
specified token is located in.The Misc class provided by vanilla for a large number of useful utility methods.
Modifier and Type | Class and Description |
---|---|
static class |
CampaignUtils.IncludeRep
Controls what
RepLevel s will be accepted by methods that check
reputation relative to the RepLevel passed in. |
Modifier and Type | Method and Description |
---|---|
static FleetMemberAPI |
addShipToFleet(String wingOrVariantId,
FleetMemberType type,
CampaignFleetAPI fleet)
Adds a fully crewed, fully combat ready ship to the designated fleet.
|
static boolean |
areAtRep(SectorEntityToken token1,
SectorEntityToken token2,
CampaignUtils.IncludeRep include,
RepLevel rep)
Checks if two campaign objects have a specific reputation with each
other.
|
static boolean |
areSameFaction(SectorEntityToken token1,
SectorEntityToken token2)
Checks if two campaign objects are owned by the same faction.
|
static <T extends SectorEntityToken> |
getEntitiesFromFaction(LocationAPI location,
String entityTag,
FactionAPI faction)
Find all entities with a specific tag and faction within a location.
|
static <T extends SectorEntityToken> |
getEntitiesWithRep(SectorEntityToken token,
String entityTag,
CampaignUtils.IncludeRep include,
RepLevel rep)
Find all entities with a specific tag and reputation with a
SectorEntityToken in that token's location, excluding itself. |
static List<CampaignFleetAPI> |
getHostileFleetsInSystem(SectorEntityToken token)
Find all hostile fleets towards a
SectorEntityToken present in
that token's location. |
static <T extends SectorEntityToken> |
getNearbyEntitiesFromFaction(SectorEntityToken token,
float range,
String entityTag,
FactionAPI faction)
Find entities with a specific tag and from a specific faction near a
SectorEntityToken , excluding itself. |
static <T extends SectorEntityToken> |
getNearbyEntitiesWithRep(SectorEntityToken token,
float range,
String entityTag,
CampaignUtils.IncludeRep include,
RepLevel rep)
Find nearby entities with a specific tag and reputation with a
SectorEntityToken , excluding itself. |
static <T extends SectorEntityToken> |
getNearbyEntitiesWithTag(SectorEntityToken token,
float range,
String entityTag)
Find entities with a specific tag near a
SectorEntityToken ,
excluding itself. |
static List<CampaignFleetAPI> |
getNearbyFleets(SectorEntityToken token,
float range)
Finds all visible fleets within a certain range around a
SectorEntityToken . |
static List<CampaignFleetAPI> |
getNearbyHostileFleets(SectorEntityToken token,
float range)
Finds all visible hostile fleets within a certain range around a
SectorEntityToken . |
static <T extends SectorEntityToken> |
getNearestEntityFromFaction(SectorEntityToken token,
String entityTag,
FactionAPI faction)
Find the closest entity with a specific tag and faction near a
SectorEntityToken , excluding itself. |
static <T extends SectorEntityToken> |
getNearestEntityWithRep(SectorEntityToken token,
String entityTag,
CampaignUtils.IncludeRep include,
RepLevel rep)
Find the closest entity with a specific tag and reputation with a
SectorEntityToken , excluding itself. |
static <T extends SectorEntityToken> |
getNearestEntityWithTag(SectorEntityToken token,
String entityTag)
Find the closest entity with a specifc tag to a
SectorEntityToken , excluding itself. |
static @Nullable CampaignFleetAPI |
getNearestHostileFleet(SectorEntityToken token)
Find the closest hostile fleet to a
SectorEntityToken . |
static float |
getRelation(SectorEntityToken token1,
SectorEntityToken token2)
Returns the faction relationship between two campaign objects.
|
static RepLevel |
getReputation(SectorEntityToken token1,
SectorEntityToken token2)
Returns the faction relationship between two campaign objects.
|
static boolean |
isPlayer(CampaignFleetAPI fleet)
Checks if a fleet is the player fleet.
|
static boolean |
isShipInFleet(String fleetMemberId,
CampaignFleetAPI fleet)
Checks if a fleet contains a specific ship in its roster.
|
static Vector2f |
toScreenCoordinates(Vector2f worldCoordinates)
Converts worldspace coordinates to screen coordinates.
|
static Vector2f |
toWorldCoordinates(Vector2f screenCoordinates)
Converts screenspace coordinates to world coordinates.
|
public static boolean isPlayer(CampaignFleetAPI fleet)
fleet
- The CampaignFleetAPI
to be checked.true
if fleet
is the player fleet, false
otherwise.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 float getRelation(SectorEntityToken token1, SectorEntityToken token2)
token1
- A SectorEntityToken
whose faction relationship will
be tested.token2
- The SectorEntityToken
to test relationship with.token1
and
token2
.public static RepLevel getReputation(SectorEntityToken token1, SectorEntityToken token2)
token1
- A SectorEntityToken
whose faction reputation will
be tested.token2
- The SectorEntityToken
to test reputation with.token1
and token2
.public static boolean areSameFaction(SectorEntityToken token1, SectorEntityToken token2)
token1
- The first SectorEntityToken
to check.token2
- The second SectorEntityToken
to check.true
if both tokens share a faction, false
otherwise.public static boolean areAtRep(SectorEntityToken token1, SectorEntityToken token2, CampaignUtils.IncludeRep include, RepLevel rep)
token1
- The first SectorEntityToken
to check.token2
- The second SectorEntityToken
to check.include
- What relative range of reputations to include.rep
- The base reputation level token1
and {token2} must
be at with each other for this to return true
,
modified by include
.true
if both tokens share a faction, false
otherwise.public static boolean isShipInFleet(String fleetMemberId, CampaignFleetAPI fleet)
CargoUtils.isShipInMothballed(java.lang.String,
com.fs.starfarer.api.campaign.CargoAPI)
for that.fleetMemberId
- The fleet member ID of the ship to check. This can
be retrieved with ShipAPI.getFleetMemberId()
or FleetMemberAPI.getId()
.fleet
- The fleet to check for the presence of this ship in.true
if fleet
contains a ship with this ID,
false
otherwise.public static FleetMemberAPI addShipToFleet(String wingOrVariantId, FleetMemberType type, CampaignFleetAPI fleet)
wingOrVariantId
- The wing or variant ID to create.type
- Whether to add a fighter wing or a ship.fleet
- The fleet to add this ship to.FleetMemberAPI
of the created ship.@Nullable public static @Nullable CampaignFleetAPI getNearestHostileFleet(SectorEntityToken token)
SectorEntityToken
.token
- The SectorEntityToken
to search around.CampaignFleetAPI
closest to token
, or null
if none are found.public static List<CampaignFleetAPI> getNearbyHostileFleets(SectorEntityToken token, float range)
SectorEntityToken
.token
- The entity to search around.range
- How far around token
to search.List
containing all fleets within range that are
hostile towards token
and can be seen by it.public static List<CampaignFleetAPI> getHostileFleetsInSystem(SectorEntityToken token)
SectorEntityToken
present in
that token's location.token
- The SectorEntityToken
to find enemies of.token
in the system that are actively
hostile.@Nullable public static <T extends SectorEntityToken> T getNearestEntityWithTag(SectorEntityToken token, String entityTag)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.entityTag
closest to token
, or null
if none are found.public static <T extends SectorEntityToken> List<T> getNearbyEntitiesWithTag(SectorEntityToken token, float range, String entityTag)
SectorEntityToken
,
excluding itself.token
- The SectorEntityToken
to search around.range
- How far around token
to search.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.entityTag
within range of
token
.@Nullable public static <T extends SectorEntityToken> T getNearestEntityFromFaction(SectorEntityToken token, String entityTag, FactionAPI faction)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.faction
- The faction ownership we are looking for.entityTag
closest to token
that is owned by faction
, or null
if none are found.public static <T extends SectorEntityToken> List<T> getNearbyEntitiesFromFaction(SectorEntityToken token, float range, String entityTag, FactionAPI faction)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.range
- How far around token
to search.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.faction
- What faction the entity must be owned by.entityTag
and faction
faction
within range of token
.public static <T extends SectorEntityToken> List<T> getEntitiesFromFaction(LocationAPI location, String entityTag, FactionAPI faction)
location
- The LocationAPI
to search in.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.faction
- What faction entities must belong to.faction
and with tag
entityTag
within location
.@Nullable public static <T extends SectorEntityToken> T getNearestEntityWithRep(SectorEntityToken token, String entityTag, CampaignUtils.IncludeRep include, RepLevel rep)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.include
- What range of RepLevel
s to accept, relative to
rep
.rep
- The base reputation to check against.entityTag
closest to token
within the reputation range specified by include
and
rep
, or null
if none are found.public static <T extends SectorEntityToken> List<T> getNearbyEntitiesWithRep(SectorEntityToken token, float range, String entityTag, CampaignUtils.IncludeRep include, RepLevel rep)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.range
- How far around token
to search.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.include
- What range of RepLevel
s to accept, relative to
rep
.rep
- The base reputation to check against.entityTag
within range of
token
.public static <T extends SectorEntityToken> List<T> getEntitiesWithRep(SectorEntityToken token, String entityTag, CampaignUtils.IncludeRep include, RepLevel rep)
SectorEntityToken
in that token's location, excluding itself.token
- The SectorEntityToken
to search around.entityTag
- The tag we should be searching for; for example:
Tags.STATION
or Tags.JUMP_POINT
.include
- What range of RepLevel
s to accept, relative to
rep
.rep
- The base reputation to check against.entityTag
within range of
token
.public static List<CampaignFleetAPI> getNearbyFleets(SectorEntityToken token, float range)
SectorEntityToken
.token
- The entity to search around.range
- How far around token
to search.List
containing all fleets within range that
token
can see, excluding itself if it is a
CampaignFleetAPI
.