diff --git a/Common/Languages/English/Keyed/Dialog_StatsReport.xml b/Common/Languages/English/Keyed/Dialog_StatsReport.xml
new file mode 100644
index 0000000..53837f8
--- /dev/null
+++ b/Common/Languages/English/Keyed/Dialog_StatsReport.xml
@@ -0,0 +1,9 @@
+
+
+
+
+ queen in proximity
+ queen absent
+ multiple queens present
+
+
\ No newline at end of file
diff --git a/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_MultipleQueens.cs b/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_MultipleQueens.cs
index 1e66488..22f0ba1 100644
--- a/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_MultipleQueens.cs
+++ b/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_MultipleQueens.cs
@@ -21,6 +21,9 @@ namespace RJW_Genes
{
if (req.Pawn == null || !req.Pawn.Spawned)
return false;
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(req.Pawn))
+ return false;
if (GeneUtility.HasGeneNullCheck(req.Pawn, GeneDefOf.rjw_genes_zealous_loyalty))
{
diff --git a/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_QueenCloseBy.cs b/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_QueenCloseBy.cs
index 4e3bdff..e604b54 100644
--- a/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_QueenCloseBy.cs
+++ b/Source/Genes/Hive/Genes/ConditionalStatAffecters/ConditionalStatAffecter_QueenCloseBy.cs
@@ -26,6 +26,9 @@ namespace RJW_Genes
{
if (req.Pawn == null || !req.Pawn.Spawned)
return false;
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(req.Pawn))
+ return false;
// Case A: Check for Loyal Pawns if their One Queen is nearby
if (GeneUtility.HasGeneNullCheck(req.Pawn, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 1)
diff --git a/Source/Genes/Hive/Helpers/HiveUtility.cs b/Source/Genes/Hive/Helpers/HiveUtility.cs
index 707957e..e90a0cf 100644
--- a/Source/Genes/Hive/Helpers/HiveUtility.cs
+++ b/Source/Genes/Hive/Helpers/HiveUtility.cs
@@ -10,6 +10,13 @@ namespace RJW_Genes
{
internal class HiveUtility
{
+
+ ///
+ /// Checks for existance of the RJW-Gene `queen`, if the pawn is spawned and if the pawn has reached adulthood.
+ /// Despite the naming, a Queen can also be male.
+ ///
+ /// The pawn that could be an Adult Queen
+ /// Whether the pawn is an adult queen.
public static bool IsAdultQueen(Pawn pawn)
{
@@ -24,16 +31,41 @@ namespace RJW_Genes
return false;
}
- public static int QueensOnMap()
- {
- List playersPawns = Find.CurrentMap.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer);
- return playersPawns.Count(pawn => pawn.Spawned && IsAdultQueen(pawn));
- }
+ public static int QueensOnMap() => GetQueensOnMap().Count;
+ ///
+ /// Checks for all pawns on the Players Home Map if they are an adult queen.
+ /// Adultness is determined by Base-Game Logic, Queen is determined by the rjw_genes_queen GeneDefOf (Not Xenotype).
+ ///
+ /// A list of queens on the players HomeMap
public static List GetQueensOnMap()
{
- List playersPawns = Find.CurrentMap.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer);
- return playersPawns.FindAll(pawn => pawn.Spawned && IsAdultQueen(pawn));
+ Map map = Find.Maps.Where(mapCandidate => mapCandidate.IsPlayerHome).First();
+
+ if (map != null)
+ {
+ List playersPawns = map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer);
+ return playersPawns.FindAll(pawn => pawn.Spawned && IsAdultQueen(pawn));
+ }
+ // Fallback: Something is wrong with Map
+ return new List();
+ }
+
+ ///
+ /// Checks if the pawn is on the players home map.
+ ///
+ /// Reason is that drones should only be punished for absence of queen if they are on the map and there is no queen.
+ /// If they are on a mission, transport-pod etc. they should not get boni or mali.
+ ///
+ /// The pawn for which to check map-presence.
+ /// True if the pawn is on the home-map, False otherwise.
+ public static bool PawnIsOnHomeMap(Pawn pawn)
+ {
+ Map homeMap = Find.Maps.Where(mapCandidate => mapCandidate.IsPlayerHome).First();
+ return
+ homeMap != null && pawn != null
+ && pawn.Spawned
+ && pawn.Map == homeMap;
}
}
}
diff --git a/Source/Genes/Hive/Thoughts/ThoughtWorker_QueenPresent_Social.cs b/Source/Genes/Hive/Thoughts/ThoughtWorker_QueenPresent_Social.cs
index fd3d1e6..e6b9ea8 100644
--- a/Source/Genes/Hive/Thoughts/ThoughtWorker_QueenPresent_Social.cs
+++ b/Source/Genes/Hive/Thoughts/ThoughtWorker_QueenPresent_Social.cs
@@ -23,9 +23,11 @@ namespace RJW_Genes
// Only check if they are spawned
if (!p.Spawned || !other.Spawned)
- {
return (ThoughtState)false;
- }
+
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(p))
+ return (ThoughtState)false;
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 1)
{
diff --git a/Source/Genes/Hive/Thoughts/ThoughtWorker_RivalQueen_Social.cs b/Source/Genes/Hive/Thoughts/ThoughtWorker_RivalQueen_Social.cs
index 21d116a..24b1b79 100644
--- a/Source/Genes/Hive/Thoughts/ThoughtWorker_RivalQueen_Social.cs
+++ b/Source/Genes/Hive/Thoughts/ThoughtWorker_RivalQueen_Social.cs
@@ -19,6 +19,9 @@ namespace RJW_Genes
if (!RelationsUtility.PawnsKnowEachOther(p, other))
return (ThoughtState)false;
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(p))
+ return (ThoughtState)false;
// Only check if they are spawned
if (!p.Spawned || !other.Spawned)
diff --git a/Source/Genes/Hive/Thoughts/Thoughtworker_QueenAbsent_Mood.cs b/Source/Genes/Hive/Thoughts/Thoughtworker_QueenAbsent_Mood.cs
index 7693c1d..502b013 100644
--- a/Source/Genes/Hive/Thoughts/Thoughtworker_QueenAbsent_Mood.cs
+++ b/Source/Genes/Hive/Thoughts/Thoughtworker_QueenAbsent_Mood.cs
@@ -20,6 +20,9 @@ namespace RJW_Genes
// Queens cannot have loyalty thoughts
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_queen))
return (ThoughtState)false;
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(p))
+ return (ThoughtState)false;
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 0)
{
diff --git a/Source/Genes/Hive/Thoughts/Thoughtworker_QueenPresent_Mood.cs b/Source/Genes/Hive/Thoughts/Thoughtworker_QueenPresent_Mood.cs
index 8ee3401..e6003be 100644
--- a/Source/Genes/Hive/Thoughts/Thoughtworker_QueenPresent_Mood.cs
+++ b/Source/Genes/Hive/Thoughts/Thoughtworker_QueenPresent_Mood.cs
@@ -20,6 +20,9 @@ namespace RJW_Genes
// Queens cannot have loyalty thoughts
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_queen))
return (ThoughtState)false;
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(p))
+ return (ThoughtState)false;
if (GeneUtility.HasGeneNullCheck(p, GeneDefOf.rjw_genes_zealous_loyalty) && HiveUtility.QueensOnMap() == 1)
{
diff --git a/Source/Genes/Hive/Thoughts/Thoughtworker_RivalQueen_Mood.cs b/Source/Genes/Hive/Thoughts/Thoughtworker_RivalQueen_Mood.cs
index 19ba88e..fbcdb2b 100644
--- a/Source/Genes/Hive/Thoughts/Thoughtworker_RivalQueen_Mood.cs
+++ b/Source/Genes/Hive/Thoughts/Thoughtworker_RivalQueen_Mood.cs
@@ -16,6 +16,9 @@ namespace RJW_Genes
{
if (p == null || !p.Spawned)
return (ThoughtState) false;
+ // If the pawn is not on Map (e.g. caravan), no mali
+ if (!HiveUtility.PawnIsOnHomeMap(p))
+ return (ThoughtState)false;
if (HiveUtility.IsAdultQueen(p) && HiveUtility.QueensOnMap() >= 2)
{