Pawn Group Utility - SmArtKar/AthenaFramework GitHub Wiki
PawnGroupUtility
is a static class that contains multiple utility functions for all your pawn management needs
Following four functions allow you to get dictionaries with pawns and distances or just lists of pawns around a certain point/pawn with a specified search radius. checkDowned
and checkDead
include downed and dead pawns in results respectively
Dictionary<Pawn, float> GetNearbyAlliesWithDistances(IntVec3 cell, Map map, Faction faction, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
Dictionary<Pawn, float> GetNearbyAlliesWithDistances(Pawn pawn, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
List<Pawn> GetNearbyAllies(Pawn pawn, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
List<Pawn> GetNearbyAllies(IntVec3 cell, Map map, Faction faction, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
These four functions do the same but for hostile pawns instead
Dictionary<Pawn, float> GetNearbyHostilesWithDistances(IntVec3 cell, Map map, Faction faction, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
Dictionary<Pawn, float> GetNearbyHostilesWithDistances(Pawn pawn, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
List<Pawn> GetNearbyHostiles(Pawn pawn, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
List<Pawn> GetNearbyHostiles(IntVec3 cell, Map map, Faction faction, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
These four do the same but with no regard about the pawn's faction
Dictionary<Pawn, float> GetNearbyPawnsWithDistances(IntVec3 cell, Map map, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
Dictionary<Pawn, float> GetNearbyPawnsWithDistances(Pawn pawn, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
List<Pawn> GetNearbyPawns(Pawn pawn, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
List<Pawn> GetNearbyPawns(IntVec3 cell, Map map, float maxDistance, bool checkDowned = false, bool checkDead = false) { }
These six functions return a bool value instead and simply check if there's a required amount of pawns in range. Due to that they're more performance friendly and should be used in cases when pawns themselves and their exact amount don't matter
bool AlliedPawnsNearbyThreshold(IntVec3 cell, Map map, Faction faction, float maxDistance, int alliesAmount, bool checkDowned = false, bool checkDead = false) { }
bool AlliedPawnsNearbyThreshold(Pawn pawn, float maxDistance, int alliesAmount, bool checkDowned = false, bool checkDead = false) { }
bool HostilePawnsNearbyThreshold(IntVec3 cell, Map map, Faction faction, float maxDistance, int hostilesAmount, bool checkDowned = false, bool checkDead = false) { }
bool HostilePawnsNearbyThreshold(Pawn pawn, float maxDistance, int hostilesAmount, bool checkDowned = false, bool checkDead = false) { }
bool PawnsNearbyThreshold(IntVec3 cell, Map map, float maxDistance, int pawnAmount, bool checkDowned = false, bool checkDead = false) { }
bool PawnsNearbyThreshold(Pawn pawn, float maxDistance, int pawnAmount, bool checkDowned = false, bool checkDead = false) { }
List<PawnGroupup> GroupPawns(List<Pawn> pawnList, float groupDistance)
groups pawns up into clusters. Pawns are considered to be in a group as long as distance between them is equal or less than groupDistance
. If a pawn could be assigned to multiple groups then they're merged together. It returns a list of PawnGroupup
objects which contain List<Pawn> members
and IntVec3 groupCenter
with group center being an average of it's members' coordinates