public class CampaignUtils
extends Object
LocationAPI
the
specified token is located in.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 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,
Class<T> entityType,
FactionAPI faction)
Find all entities of a specified type and faction within a location.
|
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,
Class<T> entityType,
FactionAPI faction)
Find entities of a specified type from a specific faction near a
SectorEntityToken . |
static <T extends SectorEntityToken> |
getNearbyEntitiesOfType(SectorEntityToken token,
float range,
Class<T> entityType)
Find nearby entities of a specified type to a
SectorEntityToken ,
excluding itself. |
static <T extends SectorEntityToken> |
getNearbyEntitiesWithRep(SectorEntityToken token,
float range,
Class<T> entityType,
CampaignUtils.IncludeRep include,
RepLevel rep)
Find nearby entities of a specified type and reputation with a
SectorEntityToken , excluding itself. |
static List<CampaignFleetAPI> |
getNearbyFleets(SectorEntityToken token,
float range)
Finds all fleets within a certain range around a
SectorEntityToken . |
static List<CampaignFleetAPI> |
getNearbyHostileFleets(SectorEntityToken token,
float range)
Finds all hostile fleets within a certain range around a
SectorEntityToken . |
static <T extends SectorEntityToken> |
getNearestEntityFromFaction(SectorEntityToken token,
Class<T> entityType,
FactionAPI faction)
Find the closest entity of a specified type and faction near a
SectorEntityToken , excluding itself. |
static <T extends SectorEntityToken> |
getNearestEntityOfType(SectorEntityToken token,
Class<T> entityType)
Find the closest entity of a specified type to a
SectorEntityToken , excluding itself. |
static <T extends SectorEntityToken> |
getNearestEntityWithRep(SectorEntityToken token,
Class<T> entityType,
CampaignUtils.IncludeRep include,
RepLevel rep)
Find the closest entity of a specified type and reputation with a
SectorEntityToken , excluding itself. |
static 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.
|
public static boolean isPlayer(CampaignFleetAPI fleet)
fleet
- The CampaignFleetAPI
to be checked.
true
if fleet
is the player fleet, false
otherwise.
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 CampaignFleetAPI getNearestHostileFleet(SectorEntityToken token)
SectorEntityToken
.token
- The SectorEntityToken
to search around.
CampaignFleetAPI
closest to token
.
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
.
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.
public static <T extends SectorEntityToken> T getNearestEntityOfType(SectorEntityToken token, Class<T> entityType)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.
type
closest to token
.
public static <T extends SectorEntityToken> List<T> getNearbyEntitiesOfType(SectorEntityToken token, float range, Class<T> entityType)
SectorEntityToken
,
excluding itself.token
- The SectorEntityToken
to search around.range
- How far around token
to search.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.
type
within range of token
.
public static <T extends SectorEntityToken> T getNearestEntityFromFaction(SectorEntityToken token, Class<T> entityType, FactionAPI faction)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.faction
- The faction ownership we are looking for.
type
closest to token
owned by
faction
.
public static <T extends SectorEntityToken> List<T> getNearbyEntitiesFromFaction(SectorEntityToken token, float range, Class<T> entityType, FactionAPI faction)
SectorEntityToken
.token
- The SectorEntityToken
to search around.range
- How far around token
to search.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.faction
- What faction the entity must be owned by.
type
and faction faction
within range of token
.
public static <T extends SectorEntityToken> List<T> getEntitiesFromFaction(LocationAPI location, Class<T> entityType, FactionAPI faction)
location
- The LocationAPI
to search in.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.faction
- What faction entities must belong to.
faction
and type type
within location
.
public static <T extends SectorEntityToken> T getNearestEntityWithRep(SectorEntityToken token, Class<T> entityType, CampaignUtils.IncludeRep include, RepLevel rep)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.include
- What range of RepLevel
s to accept, relative to
rep
.rep
- The base reputation to check against.
type
closest to token
within
the reputation range specified by include
and
rep
.
public static <T extends SectorEntityToken> List<T> getNearbyEntitiesWithRep(SectorEntityToken token, float range, Class<T> entityType, CampaignUtils.IncludeRep include, RepLevel rep)
SectorEntityToken
, excluding itself.token
- The SectorEntityToken
to search around.range
- How far around token
to search.entityType
- The class extending SectorEntityToken
we should
be searching for; for example: CampaignFleetAPI.class
or OrbitalStationAPI.class
.include
- What range of RepLevel
s to accept, relative to
rep
.rep
- The base reputation to check against.
type
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.