static void Postfix(Pawn ___pawn, ref PawnGraphicSet __instance) { Pawn pawn = ___pawn; StatDef moveStat = pawn.BestTerrainMoveStat(); if (!(moveStat == null || moveStat == StatDefOf.MoveSpeed)) { TerrainMovementPawnKindGraphics graphicsExt = pawn.LoadTerrainMovementPawnKindGraphicsExtension(moveStat); if (graphicsExt != null) { // Resolve the graphics classes the first time they are reached if (graphicsExt.bodyGraphicData != null && graphicsExt.bodyGraphicData.graphicClass == null) { graphicsExt.bodyGraphicData.graphicClass = typeof(Graphic_Multi); } if (graphicsExt.femaleGraphicData != null && graphicsExt.femaleGraphicData.graphicClass == null) { graphicsExt.femaleGraphicData.graphicClass = typeof(Graphic_Multi); } // Pick the graphic geing used if (pawn.gender != Gender.Female || graphicsExt.femaleGraphicData == null) { __instance.nakedGraphic = graphicsExt.bodyGraphicData.Graphic; } else { __instance.nakedGraphic = graphicsExt.femaleGraphicData.Graphic; } } } }
public static int CalculateGraphicsHash(this PawnGraphicSet graphicsSet, TerrainMovementPawnKindGraphics graphicsExt, Rot4 facing, RotDrawMode bodyCondition) { int num = facing.AsInt + 1000 * (int)bodyCondition; if (graphicsExt != null) { num += graphicsExt.pawnSpeedStat.GetHashCode(); } return(num); }
public static TerrainMovementPawnKindGraphics LoadTerrainMovementPawnKindGraphicsExtension(this Pawn pawn, StatDef moveStat) { if (moveStat != null && pawn.ageTracker.CurLifeStage.modExtensions != null) { foreach (DefModExtension ext in pawn.ageTracker.CurLifeStage.modExtensions) { TerrainMovementPawnKindGraphics graphicsExt = TerrainMovementPawnKindGraphicsExtension(ext); if (graphicsExt != null && graphicsExt.StatAffectedGraphic(moveStat)) { return(graphicsExt); } } } return(null); }
public static bool HasTerrainMovementPawnKindGraphicsExtension(this Pawn pawn) { if (pawn.ageTracker.CurLifeStage.modExtensions != null) { foreach (DefModExtension ext in pawn.ageTracker.CurLifeStage.modExtensions) { TerrainMovementPawnKindGraphics graphicsExt = TerrainMovementPawnKindGraphicsExtension(ext); if (graphicsExt != null) { return(true); } } } return(false); }
static bool Prefix(Pawn ___pawn, ref bool __result, ref PawnGraphicSet __instance, ref int ___cachedMatsBodyBaseHash) { Pawn pawn = ___pawn; if (!pawn.HasTerrainMovementPawnKindGraphicsExtension()) { return(true); } StatDef moveStat = StatDefOf.MoveSpeed; if (!pawn.Dead) { moveStat = pawn.BestTerrainMoveStat(); } TerrainMovementPawnKindGraphics graphicsExt = pawn.LoadTerrainMovementPawnKindGraphicsExtension(moveStat); __result = __instance.CalculateGraphicsHash(graphicsExt, pawn.Rotation, pawn.CurRotDrawMode()) == ___cachedMatsBodyBaseHash; return(false); }