mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Modified parent-xenotype detection, should fix #37
This commit is contained in:
parent
d79ecb19e6
commit
b9a2466425
1 changed files with 18 additions and 15 deletions
|
@ -10,6 +10,11 @@ using Verse;
|
||||||
|
|
||||||
namespace RJW_Genes
|
namespace RJW_Genes
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// DevNote: Issue #37 came along because I checked for getMother() and getFather(), but it can happen that a pawn has two mothers.
|
||||||
|
/// They are called Mother if they have a ParentRelation and are female.
|
||||||
|
/// New behaviour iterates over all parents and returns the first queen/drone or null.
|
||||||
|
/// </summary>
|
||||||
public class HiveBirthLogic
|
public class HiveBirthLogic
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -100,13 +105,12 @@ namespace RJW_Genes
|
||||||
if (pawn == null)
|
if (pawn == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var motherXenotype = HiveUtility.TryGetDroneXenotype(pawn.GetMother());
|
List<DirectPawnRelation> parentRelations = pawn.relations.DirectRelations.FindAll(rel => rel.def.Equals(PawnRelationDefOf.Parent));
|
||||||
var fatherXenotype = HiveUtility.TryGetDroneXenotype(pawn.GetFather());
|
foreach (DirectPawnRelation parent in parentRelations)
|
||||||
|
{
|
||||||
if (motherXenotype != null)
|
XenotypeDef xenotype = HiveUtility.TryGetDroneXenotype(parent.otherPawn);
|
||||||
return motherXenotype;
|
if (xenotype != null) return xenotype;
|
||||||
if (fatherXenotype != null)
|
}
|
||||||
return fatherXenotype;
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +119,7 @@ namespace RJW_Genes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up if there is a Xenotype with Queen-Gene for the pawns parents.
|
/// Looks up if there is a Xenotype with Queen-Gene for the pawns parents.
|
||||||
/// This is to account that maybe father or mother are the queen (instead of hardcoding things for father).
|
/// This is to account that maybe father or mother are the queen (instead of hardcoding things for father).
|
||||||
/// If both are queens, the mothers is returned.
|
/// If both are queens, the first is returned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pawn">The pawn for whichs parent the xenotypes is looked up.</param>
|
/// <param name="pawn">The pawn for whichs parent the xenotypes is looked up.</param>
|
||||||
/// <returns>The Queen-Xenotype of a parent or null. If both are queens, mothers are preferred.</returns>
|
/// <returns>The Queen-Xenotype of a parent or null. If both are queens, mothers are preferred.</returns>
|
||||||
|
@ -124,13 +128,12 @@ namespace RJW_Genes
|
||||||
if (pawn == null)
|
if (pawn == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var motherXenotype = HiveUtility.TryGetQueenXenotype(pawn.GetMother());
|
List<DirectPawnRelation> parentRelations = pawn.relations.DirectRelations.FindAll(rel => rel.def.Equals(PawnRelationDefOf.Parent));
|
||||||
var fatherXenotype = HiveUtility.TryGetQueenXenotype(pawn.GetFather());
|
foreach (var parent in parentRelations)
|
||||||
|
{
|
||||||
if (motherXenotype != null)
|
XenotypeDef xenotype = HiveUtility.TryGetQueenXenotype(parent.otherPawn);
|
||||||
return motherXenotype;
|
if (xenotype != null) return xenotype;
|
||||||
if (fatherXenotype != null)
|
}
|
||||||
return fatherXenotype;
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue