static void GetAltitudeOffset(Pawn pawn, Hediff hediff, Rot4 rotation, out float OffsetX, out float OffsetY, out float OffsetZ, out float DrawSizeX, out float DrawSizeZ, out float ang) { OffsetDefExtension myDef = null; if (!pawn.def.modExtensions.NullOrEmpty()) { if (pawn.def.HasModExtension <RRYautja.OffsetDefExtension>()) { List <DefModExtension> list = pawn.kindDef.race.modExtensions.Where((x) => x.GetType() == typeof(RRYautja.OffsetDefExtension)).ToList(); if (list.Any((x) => hediff.def.defName.Contains(((RRYautja.OffsetDefExtension)x).hediff.defName))) { myDef = (OffsetDefExtension)list.First((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName)) ?? null; } else { if (ThingDefOf.Human.modExtensions.Any((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName))) { myDef = (OffsetDefExtension)ThingDefOf.Human.modExtensions.First((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName)); } else { myDef = new OffsetDefExtension(); } } } } if (myDef == null) { if (!ThingDefOf.Human.modExtensions.NullOrEmpty()) { myDef = new OffsetDefExtension() { hediff = hediff.def }; } else if (ThingDefOf.Human.modExtensions.Any((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName))) { myDef = (OffsetDefExtension)ThingDefOf.Human.modExtensions.First((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName)) ?? new OffsetDefExtension() { hediff = hediff.def }; } else { myDef = new OffsetDefExtension() { hediff = hediff.def }; } } else { // Log.Message("else"); // myDef = new OffsetDefExtension() { hediff = hediff.def }; } if (myDef.hediff != null) { // Log.Message(string.Format("{0}'s drawdata for hediff {1} OffsetDefExtension.hediff {2}", pawn.LabelShortCap, hediff.LabelCap, myDef.hediff.label)); } if (pawn.RaceProps.Humanlike) { if (rotation == Rot4.North) { OffsetX = myDef.NorthXOffset; OffsetY = myDef.NorthYOffset; OffsetZ = myDef.NorthZOffset; DrawSizeX = myDef.NorthXDrawSize; DrawSizeZ = myDef.NorthZDrawSize; ang = myDef.NorthAngle; } else if (rotation == Rot4.West) { OffsetX = myDef.WestXOffset; OffsetY = myDef.WestYOffset; OffsetZ = myDef.WestZOffset; DrawSizeX = myDef.WestXDrawSize; DrawSizeZ = myDef.WestZDrawSize; ang = myDef.WestAngle; } else if (rotation == Rot4.East) { OffsetX = myDef.EastXOffset; OffsetY = myDef.EastYOffset; OffsetZ = myDef.EastZOffset; DrawSizeX = myDef.EastXDrawSize; DrawSizeZ = myDef.EastZDrawSize; ang = myDef.EastAngle; } else if (rotation == Rot4.South) { OffsetX = myDef.SouthXOffset; OffsetY = myDef.SouthYOffset; OffsetZ = myDef.SouthZOffset; DrawSizeX = myDef.SouthXDrawSize; DrawSizeZ = myDef.SouthZDrawSize; ang = myDef.SouthAngle; } else { OffsetX = 0f; OffsetY = 0f; OffsetZ = 0f; DrawSizeX = 1f; DrawSizeZ = 1f; ang = 0f; } if (myDef.ApplyBaseHeadOffset) { OffsetX = myDef.SouthXOffset + pawn.Drawer.renderer.BaseHeadOffsetAt(rotation).x; OffsetY = myDef.SouthYOffset + pawn.Drawer.renderer.BaseHeadOffsetAt(rotation).y; OffsetZ = myDef.SouthZOffset + pawn.Drawer.renderer.BaseHeadOffsetAt(rotation).z; } } else { if (rotation == Rot4.North) { OffsetX = myDef.NorthXOffset; OffsetY = myDef.NorthYOffset; OffsetZ = myDef.NorthZOffset; DrawSizeX = myDef.NorthXDrawSize; DrawSizeZ = myDef.NorthZDrawSize; ang = myDef.NorthAngle; } else if (rotation == Rot4.West) { OffsetX = myDef.WestXOffset; OffsetY = myDef.WestYOffset; OffsetZ = myDef.WestZOffset; DrawSizeX = myDef.WestXDrawSize; DrawSizeZ = myDef.WestZDrawSize; ang = myDef.WestAngle; } else if (rotation == Rot4.East) { OffsetX = myDef.EastXOffset; OffsetY = myDef.EastYOffset; OffsetZ = myDef.EastZOffset; DrawSizeX = myDef.EastXDrawSize; DrawSizeZ = myDef.EastZDrawSize; ang = myDef.EastAngle; } else if (rotation == Rot4.South) { OffsetX = myDef.SouthXOffset; OffsetY = myDef.SouthYOffset; OffsetZ = myDef.SouthZOffset; DrawSizeX = myDef.SouthXDrawSize; DrawSizeZ = myDef.SouthZDrawSize; ang = myDef.SouthAngle; } else { OffsetX = 0f; OffsetY = 0f; OffsetZ = 0f; DrawSizeX = 1f; DrawSizeZ = 1f; ang = 0f; } } }
static void GetAltitudeOffset(Pawn pawn, Hediff hediff, Rot4 rotation, out float OffsetX, out float OffsetY, out float OffsetZ, out float DrawSizeX, out float DrawSizeZ, out float ang) { OffsetDefExtension myDef = null; if (!pawn.def.modExtensions.NullOrEmpty()) { myDef = (OffsetDefExtension)pawn.kindDef.race.modExtensions.Find((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName)) ?? (OffsetDefExtension)ThingDefOf.Human.modExtensions.Find((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName)) ?? new OffsetDefExtension(); } else if (myDef == null) { myDef = (OffsetDefExtension)ThingDefOf.Human.modExtensions.Find((x) => hediff.def.defName.Contains(((OffsetDefExtension)x).hediff.defName)) ?? new OffsetDefExtension(); } else { myDef = new OffsetDefExtension() { hediff = hediff.def }; } if (myDef.hediff != null) { // Log.Message(string.Format("{0}'s drawdata for hediff {1} OffsetDefExtension.hediff {2}", pawn.LabelShortCap, hediff.LabelCap, myDef.hediff.label)); } string direction; if (pawn.RaceProps.Humanlike) { if (rotation == Rot4.North) { OffsetX = myDef.NorthXOffset; OffsetY = myDef.NorthYOffset; OffsetZ = myDef.NorthZOffset; DrawSizeX = myDef.NorthXDrawSize; DrawSizeZ = myDef.NorthZDrawSize; ang = myDef.NorthAngle; direction = "North"; } else if (rotation == Rot4.West) { OffsetX = myDef.WestXOffset; OffsetY = myDef.WestYOffset; OffsetZ = myDef.WestZOffset; DrawSizeX = myDef.WestXDrawSize; DrawSizeZ = myDef.WestZDrawSize; ang = myDef.WestAngle; direction = "West"; } else if (rotation == Rot4.East) { OffsetX = myDef.EastXOffset; OffsetY = myDef.EastYOffset; OffsetZ = myDef.EastZOffset; DrawSizeX = myDef.EastXDrawSize; DrawSizeZ = myDef.EastZDrawSize; ang = myDef.EastAngle; direction = "East"; } else if (rotation == Rot4.South) { OffsetX = myDef.SouthXOffset; OffsetY = myDef.SouthYOffset; OffsetZ = myDef.SouthZOffset; DrawSizeX = myDef.SouthXDrawSize; DrawSizeZ = myDef.SouthZDrawSize; ang = myDef.SouthAngle; direction = "South"; } else { OffsetX = 0f; OffsetY = 0f; OffsetZ = 0f; DrawSizeX = 1f; DrawSizeZ = 1f; ang = 0f; direction = "Unknown"; } if (myDef.ApplyBaseHeadOffset) { OffsetX = myDef.SouthXOffset + pawn.Drawer.renderer.BaseHeadOffsetAt(rotation).x; OffsetY = myDef.SouthYOffset + pawn.Drawer.renderer.BaseHeadOffsetAt(rotation).y; OffsetZ = myDef.SouthZOffset + pawn.Drawer.renderer.BaseHeadOffsetAt(rotation).z; } } else { if (rotation == Rot4.North) { OffsetX = myDef.NorthXOffset; OffsetY = myDef.NorthYOffset; OffsetZ = myDef.NorthZOffset; DrawSizeX = myDef.NorthXDrawSize; DrawSizeZ = myDef.NorthZDrawSize; ang = myDef.NorthAngle; direction = "North"; } else if (rotation == Rot4.West) { OffsetX = myDef.WestXOffset; OffsetY = myDef.WestYOffset; OffsetZ = myDef.WestZOffset; DrawSizeX = myDef.WestXDrawSize; DrawSizeZ = myDef.WestZDrawSize; ang = myDef.WestAngle; direction = "West"; } else if (rotation == Rot4.East) { OffsetX = myDef.EastXOffset; OffsetY = myDef.EastYOffset; OffsetZ = myDef.EastZOffset; DrawSizeX = myDef.EastXDrawSize; DrawSizeZ = myDef.EastZDrawSize; ang = myDef.EastAngle; direction = "East"; } else if (rotation == Rot4.South) { OffsetX = myDef.SouthXOffset; OffsetY = myDef.SouthYOffset; OffsetZ = myDef.SouthZOffset; DrawSizeX = myDef.SouthXDrawSize; DrawSizeZ = myDef.SouthZDrawSize; ang = myDef.SouthAngle; direction = "South"; } else { OffsetX = 0f; OffsetY = 0f; OffsetZ = 0f; DrawSizeX = 1f; DrawSizeZ = 1f; ang = 0f; direction = "Unknown"; } } }