Cleanup PawnExtensions
This commit is contained in:
parent
eab18ce2bb
commit
e9849712ca
|
@ -9,13 +9,17 @@ namespace RJWSexperience
|
||||||
{
|
{
|
||||||
public static bool IsIncest(this Pawn pawn, Pawn otherpawn)
|
public static bool IsIncest(this Pawn pawn, Pawn otherpawn)
|
||||||
{
|
{
|
||||||
if (otherpawn != null)
|
if (otherpawn == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
|
||||||
|
if (relations.EnumerableNullOrEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (PawnRelationDef relation in relations)
|
||||||
{
|
{
|
||||||
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
|
if (relation.incestOpinionOffset < 0)
|
||||||
if (!relations.EnumerableNullOrEmpty()) foreach (PawnRelationDef relation in relations)
|
return true;
|
||||||
{
|
|
||||||
if (relation.incestOpinionOffset < 0) return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,42 +27,40 @@ namespace RJWSexperience
|
||||||
public static float GetSexStat(this Pawn pawn)
|
public static float GetSexStat(this Pawn pawn)
|
||||||
{
|
{
|
||||||
if (xxx.is_human(pawn) && !pawn.Dead)
|
if (xxx.is_human(pawn) && !pawn.Dead)
|
||||||
{
|
|
||||||
return pawn.GetStatValue(xxx.sex_stat);
|
return pawn.GetStatValue(xxx.sex_stat);
|
||||||
}
|
return 1.0f;
|
||||||
else return 1.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T GetAdjacentBuilding<T>(this Pawn pawn) where T : Building
|
public static T GetAdjacentBuilding<T>(this Pawn pawn) where T : Building
|
||||||
{
|
{
|
||||||
if (pawn.Spawned)
|
if (!pawn.Spawned)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
EdificeGrid edifice = pawn.Map.edificeGrid;
|
||||||
|
if (edifice[pawn.Position] is T building)
|
||||||
|
return building;
|
||||||
|
foreach (IntVec3 pos in GenAdjFast.AdjacentCells8Way(pawn.Position))
|
||||||
{
|
{
|
||||||
EdificeGrid edifice = pawn.Map.edificeGrid;
|
if (edifice[pos] is T adjBuilding)
|
||||||
if (edifice[pawn.Position] is T) return (T)edifice[pawn.Position];
|
return adjBuilding;
|
||||||
IEnumerable<IntVec3> adjcells = GenAdjFast.AdjacentCells8Way(pawn.Position);
|
|
||||||
foreach (IntVec3 pos in adjcells)
|
|
||||||
{
|
|
||||||
if (edifice[pos] is T) return (T)edifice[pos];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<T> GetAdjacentBuildings<T>(this Pawn pawn) where T : Building
|
public static IEnumerable<T> GetAdjacentBuildings<T>(this Pawn pawn) where T : Building
|
||||||
{
|
{
|
||||||
// This Method was introduced to fill multiple CumBuckets around a single pawn.
|
|
||||||
var results = new List<T>();
|
var results = new List<T>();
|
||||||
if (pawn.Spawned)
|
|
||||||
|
if (!pawn.Spawned)
|
||||||
|
return results;
|
||||||
|
|
||||||
|
EdificeGrid edifice = pawn.Map.edificeGrid;
|
||||||
|
if (edifice[pawn.Position] is T building)
|
||||||
|
results.Add(building);
|
||||||
|
foreach (IntVec3 pos in GenAdjFast.AdjacentCells8Way(pawn.Position))
|
||||||
{
|
{
|
||||||
EdificeGrid edifice = pawn.Map.edificeGrid;
|
if (edifice[pos] is T adjBuilding)
|
||||||
if (edifice[pawn.Position] is T)
|
results.Add(adjBuilding);
|
||||||
results.Add((T)edifice[pawn.Position]);
|
|
||||||
IEnumerable<IntVec3> adjcells = GenAdjFast.AdjacentCells8Way(pawn.Position);
|
|
||||||
foreach (IntVec3 pos in adjcells)
|
|
||||||
{
|
|
||||||
if (edifice[pos] is T)
|
|
||||||
results.Add((T)edifice[pos]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue