public static bool IsTerrainAllowed(this HediffComp_TrailLeaver comp, TerrainDef terrain) { if (terrain == null || comp.NullMap) { return(false); } if (!comp.HasTerrainRestriction) { return(true); } TerrainRestriction terrainRestriction = comp.TerrainRestriction; if (!terrainRestriction.allowedInWater && terrain.IsWater) { return(false); } if (terrainRestriction.HasRelevantSnowRestriction && !terrainRestriction.allowedSnowDepth.Includes(comp.MyMap.snowGrid.GetDepth(comp.Pawn.Position))) { return(false); } if (terrainRestriction.HasForbiddenTerrains && terrainRestriction.forbiddenTerrains.Contains(terrain)) { return(false); } return(true); }
public static void RecordMotePos(this HediffComp_TrailLeaver comp, Vector3 drawPos) { if (!comp.Props.dynamicRotation) { return; } comp.lastMotePos = drawPos; }
public static Vector3 GetBodyTypeOffset(this HediffComp_TrailLeaver comp) { if (comp.Pawn.story?.bodyType == null || !comp.Props.HasOffset) { return(comp.Props.defaultOffset); } BodyTypeOffset BTO = comp.Props.offSetPerBodyType.Where(b => b.bodyType == comp.Pawn.story.bodyType).FirstOrFallback(); return(BTO == null ? comp.Props.defaultOffset : BTO.offset); }
public static Vector3 GetFootPrintOffset(this HediffComp_TrailLeaver comp, Vector3 normalized) { if (!comp.Props.UsesFootPrints) { return(Vector3.zero); } float angle = comp.lastFootprintRight ? 90 : (-90); Vector3 b = normalized.RotatedBy(angle) * comp.Props.footprint.distanceBetweenFeet * Mathf.Sqrt(comp.Pawn.BodySize); comp.lastFootprintRight = !comp.lastFootprintRight; //if (comp.MyDebug)Log.Warning($"{comp.Props.footprint.offset} {b}"); return(comp.Props.footprint.offset + b); }
public static void ChangeMoteColor(this HediffComp_TrailLeaver comp, Mote mote) { if (!comp.Props.HasColorRange || mote == null) { return; } if (comp.lastColor == Color.black) { comp.lastColor = comp.Props.colorRange.colorA; } comp.lastColor = comp.Props.colorRange.RandomPickColor(comp.lastColor, comp.MyDebug); mote.instanceColor = comp.lastColor; }
public static float GetMoteRotation(this HediffComp_TrailLeaver comp, Vector3 drawPos, out Vector3 normalized) { normalized = Vector3.zero; if (!comp.Props.dynamicRotation && !comp.Props.UsesFootPrints) { return(0); } float dynaRot = comp.GetDynamicRotation(drawPos, out normalized); float rot = comp.Props.dynamicRotation ? dynaRot : 0; rot += comp.Props.HasRotationOffset ? comp.Props.rotationOffset : 0; //if (comp.MyDebug) Log.Warning("GetMoteRotation normalized" + normalized); return(rot % 360); }
public static bool IsPawnActivityCompatible(this HediffComp_TrailLeaver comp) { if (!comp.HasPawnRestriction) { return(true); } Restriction pawnRestriction = comp.PawnRestriction; if (pawnRestriction.HasPostureRestriction && !pawnRestriction.allowedPostures.Contains(comp.Pawn.GetPosture())) { return(false); } if (pawnRestriction.onlyWhenMoving && !comp.Pawn.pather.MovingNow) { return(false); } return(true); }
public static float GetDynamicRotation(this HediffComp_TrailLeaver comp, Vector3 drawPos, out Vector3 normalized) { normalized = (drawPos - comp.lastMotePos).normalized; return(normalized.AngleFlat()); }