Exemplo n.º 1
0
        public static void TryModifyHeadGearLocRef(Rot4 rot, ref Vector3 loc, ApparelGraphicRecord apparelRecord)
        {
            var extension = apparelRecord.sourceApparel.def.GetModExtension <ApparelDrawPosExtension>();

            if (extension?.headgearDrawSettings != null)
            {
                loc = extension.headgearDrawSettings.GetDrawPosOffset(rot, loc);
            }
        }
 private static bool ShouldHideFacepaint(bool hidden, ApparelGraphicRecord graphicRecord)
 {
     // Check if apparel covers any parts that should hide beards
     if (!hidden)
     {
         return(false); // graphicRecord.sourceApparel.def.apparel.bodyPartGroups.Any(g => BodyPartGroupDefExtension.Get(g).hideBeardIfCovered);
     }
     return(hidden);
 }
Exemplo n.º 3
0
        public static void TryModifyMeshRef(Pawn pawn, ref Mesh mesh, ApparelGraphicRecord apparelRecord)
        {
            var extension = apparelRecord.sourceApparel.def.GetModExtension <ApparelDrawPosExtension>();

            if (extension?.headgearDrawSettings != null)
            {
                mesh = extension.headgearDrawSettings.TryGetNewMesh(mesh, pawn);
            }
        }
Exemplo n.º 4
0
        public static void ModifyShellLoc(Rot4 rot, ref Vector3 loc, ApparelGraphicRecord apparelRecord)
        {
            oldVector = loc;
            var extension = apparelRecord.sourceApparel.def.GetModExtension <ApparelDrawPosExtension>();

            if (extension?.shellPosDrawSettings != null)
            {
                loc = extension.shellPosDrawSettings.GetDrawPosOffset(rot, loc);
            }
        }
Exemplo n.º 5
0
        public static void ModifyPackMesh(Pawn pawn, ref Mesh mesh, ApparelGraphicRecord apparelRecord)
        {
            oldMesh = mesh;
            var extension = apparelRecord.sourceApparel.def.GetModExtension <ApparelDrawPosExtension>();

            if (extension?.packPosDrawSettings != null)
            {
                mesh = extension.packPosDrawSettings.TryGetNewMesh(mesh, pawn);
            }
        }
Exemplo n.º 6
0
 public static bool Prefix(ref Apparel apparel, ref BodyTypeDef bodyType, ref ApparelGraphicRecord rec, ref bool __3, ref bool __result)
 {
     if (Patch_ApparelGraphicRecordGetter_TryGetGraphicApparel_Transpiler.IsUnifiedApparel(apparel))
     {
         __3      = true;
         __result = true;
         return(false);
     }
     return(true);
 }
        public static void Postfix(Apparel apparel, BodyTypeDef bodyType, ref ApparelGraphicRecord rec)
        {
            if (apparel.def.apparel.wornGraphicPath.NullOrEmpty())
            {
                return;
            }
            CompAdvancedGraphic comp    = apparel.TryGetComp <CompAdvancedGraphic>();
            CompQuality         quality = apparel.TryGetComp <CompQuality>();
            CompArt             art     = apparel.TryGetComp <CompArt>();
            bool adv = comp != null;

            if (adv)
            {
                if (comp._graphic == null || comp._graphic.path.NullOrEmpty())
                {
                    bool flag = apparel.DefaultGraphic as Graphic_RandomRotated != null;
                    if (flag)
                    {
                        //	Log.Message(apparel.LabelShortCap + " as Graphic_RandomRotated");
                        Traverse traverse = Traverse.Create(apparel.DefaultGraphic);
                        Graphic_AdvancedSingle subGraphic = AG_Thing_get_DefaultGraphic_CompAdvancedGraphic_Patch.subgraphic.GetValue(apparel.DefaultGraphic) as Graphic_AdvancedSingle;
                        if (subGraphic != null)
                        {
                            //	Log.Message(apparel.LabelShortCap + " as Graphic_AdvancedSingle");
                            comp._graphic = subGraphic.SubGraphicFor(apparel);
                        }
                    }
                    else
                    {
                        comp._graphic = apparel.DefaultGraphic;
                        return;
                    }
                }
                string path   = apparel.def.apparel.wornGraphicPath;
                Shader shader = ShaderDatabase.Cutout;
                if (apparel.def.apparel.useWornGraphicMask)
                {
                    shader = ShaderDatabase.CutoutComplex;
                }
                if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead || apparel.def.apparel.wornGraphicPath == BaseContent.PlaceholderImagePath)
                {
                    path = comp._graphic.path;
                }
                else
                {
                    path = comp._graphic.path + "_" + bodyType.defName;
                }
                Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColorTwo);
                rec = new ApparelGraphicRecord(graphic, apparel);
            }
            if (apparel.DrawColorTwo != Color.white)
            {
                rec.graphic = rec.graphic.GetColoredVersion(rec.graphic.Shader, apparel.DrawColor, apparel.DrawColorTwo);
            }
        }
 private void DrawApparelOnTooluser(PawnRenderer renderer, Vector3 drawLoc, Rot4 bodyFacing, Quaternion quat)
 {
     for (int k = 0; k < renderer.graphics.apparelGraphics.Count; k++)
     {
         ApparelGraphicRecord apparelGraphicRecord = renderer.graphics.apparelGraphics[k];
         Mesh     mesh      = renderer.graphics.nakedGraphic.MeshAt(bodyFacing);
         Material material2 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null);
         material2 = renderer.graphics.flasher.GetDamagedMat(material2);
         GenDraw.DrawMeshNowOrLater(mesh, drawLoc, quat, material2, false);
     }
 }
Exemplo n.º 9
0
            private static Material GetMaterial(PawnRenderer renderer, Pawn pawn, ApparelGraphicRecord record, Rot4 bodyFacing, PawnRenderFlags flags)
            {
                Material mat = record.graphic.MatAt(bodyFacing);

                if (flags.FlagSet(PawnRenderFlags.Cache))
                {
                    return(mat);
                }

                return((Material)mOverrideMaterialIfNeeded.Invoke(renderer, new object[] { mat, pawn, flags.FlagSet(PawnRenderFlags.Portrait) }));
            }
Exemplo n.º 10
0
 public void ResolveApparelGraphics()
 {
     this.ClearCache();
     this.apparelGraphics.Clear();
     foreach (Apparel item2 in this.pawn.apparel.WornApparelInDrawOrder)
     {
         ApparelGraphicRecord item = default(ApparelGraphicRecord);
         if (ApparelGraphicRecordGetter.TryGetGraphicApparel(item2, this.pawn.story.bodyType, out item))
         {
             this.apparelGraphics.Add(item);
         }
     }
 }
Exemplo n.º 11
0
            private static void DrawHeadApparel(PawnRenderer renderer, Pawn pawn, Vector3 rootLoc, Vector3 headLoc, Vector3 headOffset, Rot4 bodyFacing, Quaternion quaternion, PawnRenderFlags flags, Rot4 headFacing, ref bool hideHair)
            {
                if (flags.FlagSet(PawnRenderFlags.Portrait) && Prefs.HatsOnlyOnMap)
                {
                    return;
                }
                if (!flags.FlagSet(PawnRenderFlags.Headgear))
                {
                    return;
                }
                List <ApparelGraphicRecord> apparelGraphics = renderer.graphics.apparelGraphics;

                // This will limit us to only 32 layers of headgear
                float interval = YOffsetIntervalClothes / 32;

                Vector3 customScale = Vec2ToVec3(GetHeadCustomSize(pawn.def));
                Vector3 headwearPos = headLoc + Vec2ToVec3(GetHeadCustomOffset(pawn.def));

                Mesh mesh = GetHeadMesh(flags, pawn, headFacing, renderer.graphics) ?? renderer.graphics.HairMeshSet.MeshAt(bodyFacing);

                for (int i = 0; i < apparelGraphics.Count; i++)
                {
                    ApparelGraphicRecord apparelRecord = apparelGraphics[i];
                    if (apparelRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead && !apparelRecord.sourceApparel.def.apparel.hatRenderedFrontOfFace)
                    {
                        hideHair = apparelRecord.sourceApparel?.def?.GetModExtension <ApperalRenderingExtension>()?.HideHair ?? true;
                    }
                    else if (apparelRecord.sourceApparel.def.apparel.LastLayer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false)
                    {
                        Material apparelMat = GetMaterial(renderer, pawn, apparelRecord, bodyFacing, flags);

                        if (apparelRecord.sourceApparel.def.apparel.hatRenderedFrontOfFace)
                        {
                            Matrix4x4 matrix  = new Matrix4x4();
                            Vector3   maskLoc = rootLoc + headOffset;
                            maskLoc.y += !(bodyFacing == north) ? YOffsetPostHead : YOffsetBehind;
                            matrix.SetTRS(maskLoc, quaternion, customScale);
                            GenDraw.DrawMeshNowOrLater(mesh, matrix, apparelMat, flags.FlagSet(PawnRenderFlags.DrawNow));
                        }
                        else
                        {
                            Matrix4x4 matrix = new Matrix4x4();
                            hideHair       = apparelRecord.sourceApparel?.def?.GetModExtension <ApperalRenderingExtension>()?.HideHair ?? true;
                            headwearPos.y += interval;
                            matrix.SetTRS(headwearPos, quaternion, customScale);
                            GenDraw.DrawMeshNowOrLater(mesh, matrix, apparelMat, flags.FlagSet(PawnRenderFlags.DrawNow));
                        }
                    }
                }
            }
        public static void Postfix(ref PawnGraphicSet __instance)
        {
            Pawn pawn = __instance.pawn;

            if (!pawn.RaceProps.Humanlike)
            {
                return;
            }
            if (__instance.apparelGraphics.NullOrEmpty())
            {
                return;
            }
            __instance.apparelGraphics.OrderBy(x => x.sourceApparel.def.apparel.LastLayer.drawOrder);

            List <ApparelGraphicRecord> graphics = new List <ApparelGraphicRecord>();

            List <ApparelGraphicRecord> bodyGraphics     = new List <ApparelGraphicRecord>();
            List <ApparelGraphicRecord> shellGraphics    = new List <ApparelGraphicRecord>();
            List <ApparelGraphicRecord> overheadGraphics = new List <ApparelGraphicRecord>();

            /*
             * List<ApparelGraphicRecord> bodyGraphics = __instance.apparelGraphics.FindAll(x => x.sourceApparel.def.apparel.LastLayer != ApparelLayerDefOf.Shell && x.sourceApparel.def.apparel.LastLayer != ApparelLayerDefOf.Overhead).ToList();
             * List<ApparelGraphicRecord> shellGraphics = __instance.apparelGraphics.FindAll(x => x.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell).OrderBy(x => x.sourceApparel.def.apparel.layers[Math.Max(x.sourceApparel.def.apparel.layers.Count - 2, 0)].drawOrder).ToList();
             * List<ApparelGraphicRecord> overheadGraphics = __instance.apparelGraphics.FindAll(x => x.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead).OrderBy(x => x.sourceApparel.def.apparel.layers[Math.Max(x.sourceApparel.def.apparel.layers.Count - 2, 0)].drawOrder).ToList();
             */
            for (int i = 0; i < __instance.apparelGraphics.Count; i++)
            {
                ApparelGraphicRecord record = __instance.apparelGraphics[i];
                if (record.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead)
                {
                    overheadGraphics.Add(record);
                    continue;
                }
                if (record.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell)
                {
                    shellGraphics.Add(record);
                    continue;
                }
                bodyGraphics.Add(record);
            }
            overheadGraphics.OrderBy(x => x.sourceApparel.def.apparel.layers[Math.Max(x.sourceApparel.def.apparel.layers.Count - 2, 0)].drawOrder);
            shellGraphics.OrderBy(x => x.sourceApparel.def.apparel.layers[Math.Max(x.sourceApparel.def.apparel.layers.Count - 2, 0)].drawOrder);
            bodyGraphics.OrderBy(x => x.sourceApparel.def.apparel.layers[Math.Max(x.sourceApparel.def.apparel.layers.Count - 2, 0)].drawOrder);
            graphics.AddRange(bodyGraphics);
            graphics.AddRange(shellGraphics);
            graphics.AddRange(overheadGraphics);
            __instance.apparelGraphics = graphics;
        }
Exemplo n.º 13
0
        public static bool TryGetApparelDetails(Apparel curr, Graphic detailgraphic, out ApparelGraphicRecord recDetail)
        {
            //          Log.Message("Trying to get GraphicRecord");
            Apparel temp1 = new Apparel();

            if (curr.def.apparel.LastLayer == ApparelLayer.Overhead)
            {
                temp1.def = FactionColorsDefOf.Overlay_Headgear;
            }
            else
            {
                temp1.def = FactionColorsDefOf.Overlay_Body;
            }
            //           Log.Message("GraphicRecord of DEF: "+ temp1.def.ToString());
            recDetail = new ApparelGraphicRecord(detailgraphic, temp1);
            return(true);
        }
Exemplo n.º 14
0
        public List <Material> MatsBodyBaseAt(Rot4 facing, RotDrawMode bodyCondition = RotDrawMode.Fresh)
        {
            int num = facing.AsInt + 1000 * (int)bodyCondition;

            if (num != this.cachedMatsBodyBaseHash)
            {
                this.cachedMatsBodyBase.Clear();
                this.cachedMatsBodyBaseHash = num;
                switch (bodyCondition)
                {
                case RotDrawMode.Fresh:
                    this.cachedMatsBodyBase.Add(this.nakedGraphic.MatAt(facing, null));
                    break;

                default:
                    if (this.dessicatedGraphic == null)
                    {
                        goto case RotDrawMode.Rotting;
                    }
                    if (bodyCondition == RotDrawMode.Dessicated)
                    {
                        this.cachedMatsBodyBase.Add(this.dessicatedGraphic.MatAt(facing, null));
                    }
                    break;

                case RotDrawMode.Rotting:
                    this.cachedMatsBodyBase.Add(this.rottingGraphic.MatAt(facing, null));
                    break;
                }
                for (int i = 0; i < this.apparelGraphics.Count; i++)
                {
                    ApparelGraphicRecord apparelGraphicRecord = this.apparelGraphics[i];
                    if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer != ApparelLayer.Shell)
                    {
                        ApparelGraphicRecord apparelGraphicRecord2 = this.apparelGraphics[i];
                        if (apparelGraphicRecord2.sourceApparel.def.apparel.LastLayer != ApparelLayer.Overhead)
                        {
                            List <Material>      list = this.cachedMatsBodyBase;
                            ApparelGraphicRecord apparelGraphicRecord3 = this.apparelGraphics[i];
                            list.Add(apparelGraphicRecord3.graphic.MatAt(facing, null));
                        }
                    }
                }
            }
            return(this.cachedMatsBodyBase);
        }
Exemplo n.º 15
0
        // Token: 0x06000003 RID: 3 RVA: 0x00002294 File Offset: 0x00000494
        internal static bool TryGetGraphicApparel(Apparel apparel, BodyTypeDef bodyType, out ApparelGraphicRecord rec)
        {
            var drawColor = apparel.DrawColor;
            var white     = Color.white;

            if (bodyType == null)
            {
                Log.Error("Getting apparel graphic with undefined body type.");
                bodyType = BodyTypeDefOf.Male;
            }

            bool result;

            if (apparel.def.apparel.wornGraphicPath.NullOrEmpty())
            {
                rec    = new ApparelGraphicRecord(null, null);
                result = false;
            }
            else
            {
                var shader = ShaderDatabase.Cutout;
                if (apparel.def.graphicData.shaderType == ShaderTypeDefOf.CutoutComplex)
                {
                    shader = ShaderDatabase.CutoutComplex;
                }

                string text;
                if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead)
                {
                    text = apparel.def.apparel.wornGraphicPath;
                }
                else
                {
                    text = apparel.def.apparel.wornGraphicPath + "_" + bodyType;
                }

                var graphic = GraphicDatabase.Get <Graphic_Multi>(text, shader, apparel.def.graphicData.drawSize,
                                                                  drawColor, white);
                rec    = new ApparelGraphicRecord(graphic, apparel);
                result = true;
            }

            return(result);
        }
        // Token: 0x06000003 RID: 3 RVA: 0x00002294 File Offset: 0x00000494
        internal static bool TryGetGraphicApparel(Apparel apparel, BodyTypeDef bodyType, out ApparelGraphicRecord rec)
        {
            Color drawColor = apparel.DrawColor;
            Color white     = Color.white;
            bool  flag      = bodyType == null;

            if (flag)
            {
                Log.Error("Getting apparel graphic with undefined body type.", false);
                bodyType = BodyTypeDefOf.Male;
            }
            bool flag2 = GenText.NullOrEmpty(apparel.def.apparel.wornGraphicPath);
            bool result;

            if (flag2)
            {
                rec    = new ApparelGraphicRecord(null, null);
                result = false;
            }
            else
            {
                Shader shader = ShaderDatabase.Cutout;
                bool   flag3  = apparel.def.graphicData.shaderType == ShaderTypeDefOf.CutoutComplex;
                if (flag3)
                {
                    shader = ShaderDatabase.CutoutComplex;
                }
                bool   flag4 = apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead;
                string text;
                if (flag4)
                {
                    text = apparel.def.apparel.wornGraphicPath;
                }
                else
                {
                    text = apparel.def.apparel.wornGraphicPath + "_" + bodyType.ToString();
                }
                Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(text, shader, apparel.def.graphicData.drawSize, drawColor, white);
                rec    = new ApparelGraphicRecord(graphic, apparel);
                result = true;
            }
            return(result);
        }
Exemplo n.º 17
0
        public static bool ReturnApparelDetails(Apparel curr, out ApparelGraphicRecord result)
        {
            ApparelDetailDrawer drawer;

            if ((drawer = curr.TryGetComp <ApparelDetailDrawer>()) != null)
            {
                //      Log.Message("Checking Available Details");
                if (drawer.HasDetail)
                {
                    //            Log.Message("Found Detail");
                    ApparelGraphicRecord recDetail;
                    if (ApparelDetailDrawer.TryGetApparelDetails(curr, drawer.DetailGraphic, out recDetail))
                    {
                        //              Log.Message("Gotten ApparelDetailRecord");
                        result = recDetail;
                        return(true);
                    }
                }
            }
            result = new ApparelGraphicRecord();
            return(false);
        }
Exemplo n.º 18
0
        public static bool TryGetGraphicApparelModded(Apparel apparel, BodyType bodyType, out ApparelGraphicRecord rec)
        {
            if (bodyType == BodyType.Undefined)
            {
                Log.Error("Getting apparel graphic with undefined body type.");
                bodyType = BodyType.Male;
            }
            if (apparel.def.apparel.wornGraphicPath.NullOrEmpty())
            {
                rec = new ApparelGraphicRecord(null, null);
                return(false);
            }
            string path;

            path = apparel.def.apparel.wornGraphicPath;
            CompFactionColor compF = apparel.TryGetComp <CompFactionColor>();

            if (compF != null)
            {
                if (compF.CProps.IsRandomMultiGraphic)
                {
                    path += "/" + compF.randomGraphicPath + "/" + compF.randomGraphicPath;
                }
            }

            if (apparel.def.apparel.LastLayer != ApparelLayer.Overhead)
            {
                path += "_" + bodyType.ToString();
            }

            Graphic graphic = new Graphic();

            graphic = GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColorTwo);
            //       Log.Message(apparel.DrawColor.ToString());
            //       Log.Message(apparel.DrawColorTwo.ToString());
            rec = new ApparelGraphicRecord(graphic, apparel);
            return(true);
        }
        public static bool TryGetAfflictionDrawer(Pawn pawn, Need_Soul soul, string patronName, BodyType bodyType, out ApparelGraphicRecord recBody, out ApparelGraphicRecord recHead, out ApparelGraphicRecord recHair)
        {
            if (bodyType == BodyType.Undefined)
            {
                Log.Error("Getting overlay graphic with undefined body type.");
                bodyType = BodyType.Male;
            }
            soul = pawn.needs.TryGetNeed <Need_Soul>();
            Graphic headgraphic    = AfflictionDrawerUtility.GetHeadGraphic(pawn, patronName);
            Graphic bodygraphic    = AfflictionDrawerUtility.GetBodyOverlay(pawn.story.BodyType, patronName);
            string  hairpath       = pawn.Drawer.renderer.graphics.hairGraphic.path;
            Graphic oldhairgraphic = GraphicDatabase.Get <Graphic_Multi>(hairpath, ShaderDatabase.Cutout, Vector2.one, pawn.story.hairColor);
            Apparel temp1          = new Apparel();
            Apparel temp2          = new Apparel();
            Apparel temp3          = new Apparel();

            temp1.def = CorruptionDefOfs.Overlay_Head;
            temp2.def = CorruptionDefOfs.Overlay_Hair;
            temp3.def = AfflictionDrawerUtility.GetOverlayDef(patronName);
            recHead   = new ApparelGraphicRecord(headgraphic, temp1);
            recHair   = new ApparelGraphicRecord(oldhairgraphic, temp2);
            recBody   = new ApparelGraphicRecord(bodygraphic, temp3);
            return(true);
        }
Exemplo n.º 20
0
        public static void Yautja_SpecificHatPatch(ref Apparel apparel, ref BodyTypeDef bodyType, ref ApparelGraphicRecord rec)
        {
            bool flag = bodyType == YautjaDefOf.RRYYautjaFemale || bodyType == YautjaDefOf.RRYYautjaMale;

            if (flag)
            {
                bool flag2 = apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead;
                if (flag2)
                {
                    string text  = apparel.def.apparel.wornGraphicPath + "_" + bodyType.defName;
                    bool   flag3 = ContentFinder <Texture2D> .Get(text + "_north", false) == null || ContentFinder <Texture2D> .Get(text + "_east", false) == null || ContentFinder <Texture2D> .Get(text + "_south", false) == null;

                    if (!flag3)
                    {
                        Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(text, ShaderDatabase.Cutout, apparel.def.graphicData.drawSize, apparel.DrawColor);
                        rec = new ApparelGraphicRecord(graphic, apparel);
                    }
                }
                else
                {
                    bool flag4 = !GenText.NullOrEmpty(apparel.def.apparel.wornGraphicPath);
                    if (flag4)
                    {
                        string text2 = apparel.def.apparel.wornGraphicPath + "_" + bodyType.defName;
                        bool   flag5 = ContentFinder <Texture2D> .Get(text2 + "_north", false) == null || ContentFinder <Texture2D> .Get(text2 + "_east", false) == null || ContentFinder <Texture2D> .Get(text2 + "_south", false) == null;

                        if (flag5)
                        {
                            text2 = apparel.def.apparel.wornGraphicPath + "_Female";
                            Graphic graphic2 = GraphicDatabase.Get <Graphic_Multi>(text2, ShaderDatabase.Cutout, apparel.def.graphicData.drawSize, apparel.DrawColor);
                            rec = new ApparelGraphicRecord(graphic2, apparel);
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        // Token: 0x0600007B RID: 123 RVA: 0x00004CC4 File Offset: 0x00002EC4
        private static bool TryGetGraphicApparel(Apparel apparel, Color color, BodyTypeDef bodyType, Shader shader, out ApparelGraphicRecord rec)
        {
            /*
             * if (bodyType == BodyTypeDefOf.)
             * {
             *  Log.Error("Getting apparel graphic with undefined body type.");
             *  bodyType = BodyType.Male;
             * }
             */
            if (apparel.def.apparel.wornGraphicPath.NullOrEmpty())
            {
                rec = new ApparelGraphicRecord(null, null);
                return(false);
            }
            string path;

            if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead)
            {
                path = apparel.def.apparel.wornGraphicPath;
            }
            else
            {
                path = apparel.def.apparel.wornGraphicPath + "_" + bodyType.ToString();
            }

            Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, apparel.def.graphicData.drawSize, color);

            if (graphic != null && graphic.MatEast != null && graphic.MatEast.mainTexture != null)
            {
                rec = new ApparelGraphicRecord(graphic, apparel);
                return(true);
            }

            rec = new ApparelGraphicRecord();
            return(false);
        }
Exemplo n.º 22
0
        public static bool _RenderPawnInternal(PawnRenderer __instance, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType = 0, bool portrait = false)
        {
            Log.Message("Calling");
            PawnRenderer renderer = __instance;

            if (!renderer.graphics.AllResolved)
            {
                renderer.graphics.ResolveAllGraphics();
            }
            Mesh mesh = null;
            Pawn pawn = (Pawn)HarmonyPatches.pawnInfo.GetValue(renderer);

            if (pawn is AlienPawn && (pawn as AlienPawn).bodySet == null)
            {
                (pawn as AlienPawn).UpdateSets();
            }

            Corruption.CompPsyker         compPsyker     = pawn.TryGetComp <CompPsyker>();
            List <HediffComp_DrawImplant> implantDrawers = HarmonyPatches.implantDrawers(pawn);
            string patronName = "Emperor";
            bool   drawChaos  = false;

            if (compPsyker != null)
            {
                patronName = compPsyker.patronName;
                //        Log.Message("GettingComp: " + patronName);
                if (patronName == "Khorne" || patronName == "Nurgle" || patronName == "Tzeentch" || patronName == "Undivided")
                {
                    //            Log.Message("drawChaos");
                    drawChaos = true;
                }
            }

            if (renderBody || (pawn.InBed() && pawn.ageTracker.CurLifeStageIndex <= 1))
            {
                if (pawn.RaceProps.Humanlike)
                {
                    if (pawn.ageTracker.CurLifeStageIndex == 2)
                    {
                        rootLoc.z -= 0.15f;
                    }
                    if (pawn.ageTracker.CurLifeStageIndex < 2 && pawn.InBed() && !portrait)
                    {
                        // Undo the offset for babies/toddlers in bed
                        Building_Bed building_bed = pawn.CurrentBed();
                        Vector3      offset       = new Vector3(0, 0, 0.5f).RotatedBy(building_bed.Rotation.AsAngle);
                        rootLoc -= offset;
                    }
                }
                Vector3 vector = rootLoc;
                vector.y += 0.005f;

                if (bodyDrawType == RotDrawMode.Dessicated && !pawn.RaceProps.Humanlike && renderer.graphics.dessicatedGraphic != null && !portrait)
                {
                    renderer.graphics.dessicatedGraphic.Draw(vector, bodyFacing, pawn);
                }
                else
                {
                    bool humanlike = pawn.RaceProps.Humanlike;
                    if (humanlike)
                    {
                        mesh = ((pawn is AlienPawn) ? (pawn as AlienPawn).bodySet : MeshPool.humanlikeBodySet).MeshAt(bodyFacing);
                    }
                    else
                    {
                        mesh = renderer.graphics.nakedGraphic.MeshAt(bodyFacing);
                    }

                    List <Material> list = renderer.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType);
                    for (int i = 0; i < list.Count; i++)
                    {
                        Material damagedMat = renderer.graphics.flasher.GetDamagedMat(list[i]);
                        if (pawn.ageTracker.CurLifeStageIndex == 2 && pawn.RaceProps.Humanlike)
                        {
                            damagedMat.mainTextureScale  = new Vector2(1, 1.3f);
                            damagedMat.mainTextureOffset = new Vector2(0, -0.2f);
                            if (bodyFacing == Rot4.West || bodyFacing == Rot4.East)
                            {
                                damagedMat.mainTextureOffset = new Vector2(-0.015f, -0.2f);
                            }
                        }

                        GenDraw.DrawMeshNowOrLater(mesh, vector, quat, damagedMat, portrait);
                        vector.y += 0.003f;
                        if (i == 0)
                        {
                            if (drawChaos)
                            {
                                Material markMat = (Corruption.AfflictionDrawerUtility.GetBodyOverlay(pawn.story.bodyType, patronName).MatAt(bodyFacing));
                                if (pawn.ageTracker.CurLifeStageIndex == 2 && pawn.RaceProps.Humanlike)
                                {
                                    markMat.mainTextureScale  = new Vector2(1, 1.3f);
                                    markMat.mainTextureOffset = new Vector2(0, -0.2f);
                                    if (bodyFacing == Rot4.West || bodyFacing == Rot4.East)
                                    {
                                        markMat.mainTextureOffset = new Vector2(-0.015f, -0.2f);
                                    }
                                }
                                GenDraw.DrawMeshNowOrLater(mesh, vector, quat, markMat, portrait);
                                vector.y += 0.003f;
                            }
                        }
                    }

                    if (bodyDrawType == 0)
                    {
                        Vector3 vector2 = rootLoc;
                        vector2.y += 0.02f;
                        ((PawnWoundDrawer)HarmonyPatches.woundInfo.GetValue(renderer)).RenderOverBody(vector2, mesh, quat, portrait);
                    }
                }
            }
            Vector3 vector3 = rootLoc;
            Vector3 vector4 = rootLoc;

            if (bodyFacing != Rot4.North)
            {
                vector4.y += 0.03f;
                vector3.y += 0.0249999985f;
            }
            else
            {
                vector4.y += 0.0249999985f;
                vector3.y += 0.03f;
            }

            if (renderer.graphics.headGraphic != null && pawn.ageTracker.CurLifeStageIndex >= 1)
            {
                Vector3  vector5  = quat * renderer.BaseHeadOffsetAt(headFacing);
                Mesh     mesh2    = ((pawn is AlienPawn) ? (pawn as AlienPawn).headSet : MeshPool.humanlikeHeadSet).MeshAt(headFacing);
                Material material = renderer.graphics.HeadMatAt(headFacing, bodyDrawType);
                GenDraw.DrawMeshNowOrLater(mesh2, vector4 + vector5, quat, material, portrait);

                if (drawChaos)
                {
                    Material headMarkMat = (AfflictionDrawerUtility.GetHeadGraphic(pawn, patronName).MatAt(bodyFacing));
                    vector5.y += 0.005f;
                    GenDraw.DrawMeshNowOrLater(mesh2, vector4 + vector5, quat, headMarkMat, portrait);
                }

                Vector3 vector6 = rootLoc + vector5;
                vector6.y += 0.035f;
                bool flag7 = false;
                if (pawn.ageTracker.CurLifeStageIndex >= 2)
                {
                    Mesh mesh3 = HarmonyPatches.HairMeshSet(pawn).MeshAt(headFacing);
                    List <ApparelGraphicRecord> apparelGraphics = renderer.graphics.apparelGraphics;
                    for (int j = 0; j < apparelGraphics.Count; j++)
                    {
                        if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead)
                        {
                            if ((!pawn.story.hairDef.hairTags.Contains("DrawUnderHat") && !pawn.story.hairDef.hairTags.Contains("Beard")) || pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.FullHead))
                            {
                                flag7 = true; // flag=true stops the hair from being drawn
                            }
                            Material material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
                            material2 = renderer.graphics.flasher.GetDamagedMat(material2);
                            if (pawn.ageTracker.CurLifeStageIndex == 2)
                            {
                                material2.mainTextureOffset    = new Vector2(0, 0.018f);
                                material2.mainTexture.wrapMode = TextureWrapMode.Clamp;
                            }
                            GenDraw.DrawMeshNowOrLater(mesh3, vector6, quat, material2, portrait);
                            Material detailMat;
                            if (ApparelDetailDrawer.GetDetailGraphic(pawn, apparelGraphics[j].sourceApparel, bodyFacing, out detailMat))
                            {
                                Vector3 vectorDet = vector6;
                                vectorDet.y += 0.005f;
                                GenDraw.DrawMeshNowOrLater(mesh3, vectorDet, quat, detailMat, portrait);
                            }
                        }
                    }
                }

                if (!flag7 && bodyDrawType != RotDrawMode.Dessicated)
                {
                    Mesh     mesh4     = HarmonyPatches.HairMeshSet(pawn).MeshAt(headFacing);
                    Material material3 = renderer.graphics.HairMatAt(headFacing);
                    // Hopefully stops graphic issues from modifying texture offset/scale
                    material3.mainTexture.wrapMode = TextureWrapMode.Clamp;

                    // Scale down the child hair to fit the head
                    if (pawn.ageTracker.CurLifeStageIndex <= 2)
                    {
                        material3.mainTextureScale  = new Vector2(1.13f, 1.13f);
                        material3.mainTextureOffset = new Vector2(-0.065f, -0.045f);
                    }
                    // Scale down the toddler hair to fit the head
                    if (pawn.ageTracker.CurLifeStageIndex == 1)
                    {
                        //	mat2.mainTextureScale = new Vector2 (1.25f, 1.25f);
                        material3.mainTextureOffset = new Vector2(-0.07f, 0.12f);
                    }
                    GenDraw.DrawMeshNowOrLater(mesh4, vector6, quat, material3, portrait);
                }
            }

            if (renderBody)
            {
                for (int k = 0; k < renderer.graphics.apparelGraphics.Count; k++)
                {
                    ApparelGraphicRecord apparelGraphicRecord = renderer.graphics.apparelGraphics[k];
                    if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell)
                    {
                        Material material4 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null);
                        material4 = renderer.graphics.flasher.GetDamagedMat(material4);
                        if (pawn.ageTracker.CurLifeStageIndex == 2)
                        {
                            material4.mainTextureScale  = new Vector2(1.00f, 1.22f);
                            material4.mainTextureOffset = new Vector2(0, -0.1f);
                        }

                        GenDraw.DrawMeshNowOrLater(mesh, vector3, quat, material4, portrait);
                    }
                    Material pauldronMat;
                    if (CompPauldronDrawer.ShouldDrawPauldron(pawn, renderer.graphics.apparelGraphics[k].sourceApparel, bodyFacing, out pauldronMat))
                    {
                        if (pawn.ageTracker.CurLifeStageIndex == 2)
                        {
                            pauldronMat.mainTextureScale  = new Vector2(1.00f, 1.22f);
                            pauldronMat.mainTextureOffset = new Vector2(0, -0.1f);
                        }
                        vector3.y += 0.005f;
                        GenDraw.DrawMeshNowOrLater(mesh, vector3, quat, pauldronMat, portrait);
                    }
                }

                if (!pawn.Dead)
                {
                    for (int l = 0; l < pawn.health.hediffSet.hediffs.Count; l++)
                    {
                        HediffComp_DrawImplant drawer;
                        if ((drawer = pawn.health.hediffSet.hediffs[l].TryGetComp <HediffComp_DrawImplant>()) != null)
                        {
                            if (drawer.implantDrawProps.implantDrawerType != ImplantDrawerType.Head)
                            {
                                vector3.y += 0.005f;
                                if (bodyFacing == Rot4.South && drawer.implantDrawProps.implantDrawerType == ImplantDrawerType.Backpack)
                                {
                                    vector3.y -= 0.3f;
                                }
                                Material implantMat = drawer.ImplantMaterial(pawn, bodyFacing);
                                GenDraw.DrawMeshNowOrLater(mesh, vector3, quat, implantMat, portrait);
                                vector3.y += 0.005f;
                            }
                        }
                    }
                }
            }

            if (!portrait && pawn.RaceProps.Animal && pawn.inventory != null && pawn.inventory.innerContainer.Count() > 0)
            {
                Graphics.DrawMesh(mesh, vector3, quat, renderer.graphics.packGraphic.MatAt(pawn.Rotation, null), 0);
            }
            if (!portrait)
            {
                HarmonyPatches.equipInfo.Invoke(renderer, new object[]
                {
                    rootLoc
                });
                if (pawn.apparel != null)
                {
                    List <Apparel> wornApparel = pawn.apparel.WornApparel;
                    for (int l = 0; l < wornApparel.Count; l++)
                    {
                        wornApparel[l].DrawWornExtras();
                    }
                }
                Vector3 vector7 = rootLoc;
                vector7.y += 0.0449999981f;
                ((PawnHeadOverlays)HarmonyPatches.statusInfo.GetValue(renderer)).RenderStatusOverlays(vector7, quat, ((pawn is AlienPawn) ? (pawn as AlienPawn).headSet : MeshPool.humanlikeHeadSet).MeshAt(headFacing));
            }
            return(false);
        }
Exemplo n.º 23
0
        public static Vector3 OverShell(Vector3 original, Vector3 headPos, Vector3 hairPos, ApparelGraphicRecord apparelGraphicRecord, List <ApparelGraphicRecord> list, Rot4 bodyFacing)
        {
            Vector3 result     = original;
            Vector3 headoffset = (bodyFacing == Rot4.North ? hairPos : headPos) - original;
            List <ApparelGraphicRecord> shellList = list.FindAll(x => Main.LastLayerShellOrHigher(x.sourceApparel.def.apparel.LastLayer, ApparelLayerDefOf.Shell));
            int   shellInd = shellList.IndexOf(apparelGraphicRecord);
            float yspace   = headoffset.y / (shellList.Count + 1);

            if (bodyFacing == Rot4.North)
            {
                yspace = -yspace;
            }
            float increment = yspace * shellInd;

            result.y += increment;
            //    Log.Message("Shell apparelGraphic " + shellInd + ": " + apparelGraphicRecord.sourceApparel.LabelShortCap + " original: " + original.y + " headPos: " + headPos.y + " headoffset: " + headoffset.y + " Increment: " + increment + " yspace: " + yspace + " result: " + result.y);
            return(result);
        }
Exemplo n.º 24
0
 public static void MapValue(Material mat, ApparelGraphicRecord apparelGraphicRecord)
 {
     Patch_PawnRenderer_DrawPawnBody_Transpiler.mappedValues[mat] = apparelGraphicRecord;
 }
        // Token: 0x06000241 RID: 577 RVA: 0x000145E4 File Offset: 0x000127E4
        public override void DrawWornExtras()
        {
            if (base.Wearer == null || !base.Wearer.Spawned)
            {
                return;
            }
            Building_Bed building_Bed = base.Wearer.CurrentBed();

            if (building_Bed != null && !building_Bed.def.building.bed_showSleeperBody && !this.onHead)
            {
                return;
            }
            if (this.onHead)
            {
                Log.ErrorOnce("Adeptus Mechanicus :: Apparel_VisibleAccessory: The head drawing code is incomplete and the apparel '" + this.Label + "' will not be drawn.", (int)this.def.debugRandomId, false);
                return;
            }
            Rot4    rot    = default(Rot4);
            float   angle  = 0f;
            Vector3 vector = base.Wearer.Drawer.DrawPos;
            Rot4    rot2;

            if (base.Wearer.GetPosture() != PawnPosture.Standing)
            {
                rot2 = this.LayingFacing();
                if (building_Bed != null)
                {
                    rot        = building_Bed.Rotation;
                    rot.AsInt += 2;
                    angle      = rot.AsAngle;
                    AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 14);
                    vector.y = base.Wearer.Position.ToVector3ShiftedWithAltitude(altLayer).y;
                    vector  += rot.FacingCell.ToVector3() * -base.Wearer.Drawer.renderer.BaseHeadOffsetAt(Rot4.South).z;
                }
                else
                {
                    vector.y = base.Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.LayingPawn).y;
                    if (base.Wearer.Downed)
                    {
                        float?num = (((((base.Wearer.Drawer == null) ? null : base.Wearer.Drawer.renderer) == null) ? null : base.Wearer.Drawer.renderer.wiggler) == null) ? null : new float?(base.Wearer.Drawer.renderer.wiggler.downedAngle);
                        if (num != null)
                        {
                            angle = num.Value;
                        }
                    }
                    else
                    {
                        angle = rot2.FacingCell.AngleFlat;
                    }
                }
                vector.y += 0.005f;
            }
            else
            {
                rot2     = base.Wearer.Rotation;
                vector.y = base.Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.Pawn).y;
            }
            vector.y += this.GetAltitudeOffset(rot2);
            Graphic   graphic  = GraphicDatabase.Get <Graphic_Multi>(this.def.graphicData.texPath + "_" + ((base.Wearer == null) ? null : base.Wearer.story.bodyType.ToString()), ShaderDatabase.CutoutComplex, this.def.graphicData.drawSize, this.DrawColor);
            Material  material = new ApparelGraphicRecord(graphic, this).graphic.MatAt(rot2, null);
            Vector3   s        = new Vector3(1.5f, 1.5f, 1.5f);
            Matrix4x4 matrix   = default(Matrix4x4);

            matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
            //    Graphics.DrawMesh((rot2 == Rot4.West) ? MeshPool.plane10Flip : MeshPool.plane10, matrix, material, 0);

            CompPauldronDrawer comp = base.GetComp <CompPauldronDrawer>();

            if (comp != null)
            {
                //    comp.PostDraw_Pads(vector, rot2);
            }

            base.DrawWornExtras();
        }
Exemplo n.º 26
0
        private static void RenderPawnInternal(PawnRenderer __instance, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType = RotDrawMode.Fresh, bool portrait = false)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (!pawn.def.race.Humanlike)
            {
                return;
            }

            Corruption.CompPsyker         compPsyker     = pawn.TryGetComp <CompPsyker>();
            List <HediffComp_DrawImplant> implantDrawers = HarmonyPatches.implantDrawers(pawn);
            string patronName = "Emperor";
            bool   drawChaos  = false;

            if (compPsyker != null)
            {
                patronName = compPsyker.patronName;
                //        Log.Message("GettingComp: " + patronName);
                if (patronName == "Khorne" || patronName == "Nurgle" || patronName == "Tzeentch" || patronName == "Undivided")
                {
                    //            Log.Message("drawChaos");
                    drawChaos = true;
                }
            }

            if (!__instance.graphics.AllResolved)
            {
                __instance.graphics.ResolveAllGraphics();
            }
            Mesh mesh = null;

            if (renderBody)
            {
                Vector3 loc = rootLoc;
                loc.y += 0.005f;
                if (bodyDrawType == RotDrawMode.Dessicated && !pawn.RaceProps.Humanlike && __instance.graphics.dessicatedGraphic != null && !portrait)
                {
                    __instance.graphics.dessicatedGraphic.Draw(loc, bodyFacing, pawn);
                }
                else
                {
                    ThingDef_AlienRace alienDef = pawn.def as ThingDef_AlienRace;
                    if (alienDef != null)
                    {
                        Mesh mesh2;
                        if (bodyDrawType == RotDrawMode.Rotting)
                        {
                            if (__instance.graphics.dessicatedGraphic.ShouldDrawRotated)
                            {
                                mesh2 = MeshPool.GridPlane(portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.CustomPortraitDrawSize : alienDef.alienRace.generalSettings.alienPartGenerator.CustomDrawSize);
                            }
                            else
                            {
                                Vector2 size = portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.CustomPortraitDrawSize : alienDef.alienRace.generalSettings.alienPartGenerator.CustomDrawSize;
                                if (bodyFacing.IsHorizontal)
                                {
                                    size = size.Rotated();
                                }
                                if (bodyFacing == Rot4.West && (__instance.graphics.dessicatedGraphic.data == null || __instance.graphics.dessicatedGraphic.data.allowFlip))
                                {
                                    mesh = MeshPool.GridPlaneFlip(size);
                                }
                                mesh = MeshPool.GridPlane(size);
                            }
                        }
                        else
                        {
                            mesh = (portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.bodyPortraitSet.MeshAt(bodyFacing) : alienDef.alienRace.generalSettings.alienPartGenerator.bodySet.MeshAt(bodyFacing));
                        }
                    }
                    else
                    {
                        if (pawn.RaceProps.Humanlike)
                        {
                            mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing);
                        }
                        else
                        {
                            mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing);
                        }
                    }
                    List <Material> list = __instance.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType);
                    for (int i = 0; i < list.Count; i++)
                    {
                        //               Material damagedMat = __instance.graphics.flasher.GetDamagedMat(list[i]);
                        //               GenDraw.DrawMeshNowOrLater(mesh, loc, quat, damagedMat, portrait);
                        loc.y += 0.005f;
                        if (i == 0)
                        {
                            if (drawChaos)
                            {
                                Material markMat = (Corruption.AfflictionDrawerUtility.GetBodyOverlay(pawn.story.bodyType, patronName).MatAt(bodyFacing));
                                if (pawn.ageTracker.CurLifeStageIndex == 2 && pawn.RaceProps.Humanlike)
                                {
                                    markMat.mainTextureScale  = new Vector2(1, 1.3f);
                                    markMat.mainTextureOffset = new Vector2(0, -0.2f);
                                    if (bodyFacing == Rot4.West || bodyFacing == Rot4.East)
                                    {
                                        markMat.mainTextureOffset = new Vector2(-0.015f, -0.2f);
                                    }
                                }
                                GenDraw.DrawMeshNowOrLater(mesh, loc, quat, markMat, portrait);
                                loc.y += 0.005f;
                            }
                        }

                        if (bodyDrawType == RotDrawMode.Fresh)
                        {
                            Vector3 drawLoc = rootLoc;
                            drawLoc.y += 0.02f;
                            //                    Traverse.Create(__instance).Field("woundOverlays").GetValue<PawnWoundDrawer>().RenderOverBody(drawLoc, mesh, quat, portrait);
                        }
                    }
                }
                Vector3 vector = rootLoc;
                Vector3 a      = rootLoc;
                if (bodyFacing != Rot4.North)
                {
                    a.y      += 0.03f;
                    vector.y += 0.0249999985f;
                }
                else
                {
                    a.y      += 0.0249999985f;
                    vector.y += 0.03f;
                }
                if (__instance.graphics.headGraphic != null)
                {
                    Vector3  b     = quat * __instance.BaseHeadOffsetAt(headFacing);
                    Mesh     mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing);
                    Material mat   = __instance.graphics.HeadMatAt(headFacing, bodyDrawType);
                    //            GenDraw.DrawMeshNowOrLater(mesh2, a + b, quat, mat, portrait);
                    if (drawChaos)
                    {
                        Material headMarkMat = (AfflictionDrawerUtility.GetHeadGraphic(pawn, patronName).MatAt(bodyFacing));
                        //   vector.y += 0.005f;
                        GenDraw.DrawMeshNowOrLater(mesh2, a + b + new Vector3(0f, 0.004f, 0f), quat, headMarkMat, portrait);
                    }

                    Vector3 loc2 = rootLoc + b;
                    loc2.y += 0.035f;
                    bool flag  = false;
                    Mesh mesh3 = __instance.graphics.HairMeshSet.MeshAt(headFacing);
                    List <ApparelGraphicRecord> apparelGraphics = __instance.graphics.apparelGraphics;
                    for (int j = 0; j < apparelGraphics.Count; j++)
                    {
                        if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead)
                        {
                            flag = true;
                            Material material = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
                            material = __instance.graphics.flasher.GetDamagedMat(material);
                            //               GenDraw.DrawMeshNowOrLater(mesh3, loc2, quat, material, portrait);
                        }

                        if (!flag && bodyDrawType != RotDrawMode.Dessicated)
                        {
                            Mesh     mesh4 = __instance.graphics.HairMeshSet.MeshAt(headFacing);
                            Material mat2  = __instance.graphics.HairMatAt(headFacing);
                            //                   GenDraw.DrawMeshNowOrLater(mesh4, loc2, quat, mat2, portrait);
                        }
                    }
                    if (renderBody)
                    {
                        for (int k = 0; k < __instance.graphics.apparelGraphics.Count; k++)
                        {
                            Material pauldronMat;
                            if (CompPauldronDrawer.ShouldDrawPauldron(pawn, __instance.graphics.apparelGraphics[k].sourceApparel, bodyFacing, out pauldronMat))
                            {
                                if (pawn.ageTracker.CurLifeStageIndex == 2)
                                {
                                    pauldronMat.mainTextureScale  = new Vector2(1.00f, 1.22f);
                                    pauldronMat.mainTextureOffset = new Vector2(0, -0.1f);
                                }
                                vector.y += 0.035f;
                                GenDraw.DrawMeshNowOrLater(mesh, vector, quat, pauldronMat, portrait);
                            }
                            ApparelGraphicRecord apparelGraphicRecord = __instance.graphics.apparelGraphics[k];
                            if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell)
                            {
                                //           Material material2 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null);
                                //           material2 = __instance.graphics.flasher.GetDamagedMat(material2);
                                //           GenDraw.DrawMeshNowOrLater(mesh, vector, quat, material2, portrait);
                            }
                            if (!pawn.Dead)
                            {
                                for (int l = 0; l < pawn.health.hediffSet.hediffs.Count; l++)
                                {
                                    HediffComp_DrawImplant drawer;
                                    if ((drawer = pawn.health.hediffSet.hediffs[l].TryGetComp <HediffComp_DrawImplant>()) != null)
                                    {
                                        if (drawer.implantDrawProps.implantDrawerType != ImplantDrawerType.Head)
                                        {
                                            vector.y += 0.005f;
                                            if (bodyFacing == Rot4.South && drawer.implantDrawProps.implantDrawerType == ImplantDrawerType.Backpack)
                                            {
                                                vector.y -= 0.3f;
                                            }
                                            Material implantMat = drawer.ImplantMaterial(pawn, bodyFacing);
                                            GenDraw.DrawMeshNowOrLater(mesh, vector, quat, implantMat, portrait);
                                            vector.y += 0.005f;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
        private void RenderPawnInternal(Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump)
        {
            if (!this.graphics.AllResolved)
            {
                this.graphics.ResolveAllGraphics();
            }
            Mesh mesh = null;

            if (renderBody)
            {
                Vector3 loc = rootLoc;
                loc.y += 0.0078125f;
                if (bodyDrawType == RotDrawMode.Dessicated && !this.pawn.RaceProps.Humanlike && this.graphics.dessicatedGraphic != null && !portrait)
                {
                    this.graphics.dessicatedGraphic.Draw(loc, bodyFacing, this.pawn, 0f);
                }
                else
                {
                    if (this.pawn.RaceProps.Humanlike)
                    {
                        mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing);
                    }
                    else
                    {
                        mesh = this.graphics.nakedGraphic.MeshAt(bodyFacing);
                    }
                    List <Material> list = this.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType);
                    for (int i = 0; i < list.Count; i++)
                    {
                        Material damagedMat = this.graphics.flasher.GetDamagedMat(list[i]);
                        GenDraw.DrawMeshNowOrLater(mesh, loc, quat, damagedMat, portrait);
                        loc.y += 0.00390625f;
                    }
                    if (bodyDrawType == RotDrawMode.Fresh)
                    {
                        Vector3 drawLoc = rootLoc;
                        drawLoc.y += 0.01953125f;
                        this.woundOverlays.RenderOverBody(drawLoc, mesh, quat, portrait);
                    }
                }
            }
            Vector3 vector = rootLoc;
            Vector3 a      = rootLoc;

            if (bodyFacing != Rot4.North)
            {
                a.y      += 0.02734375f;
                vector.y += 0.0234375f;
            }
            else
            {
                a.y      += 0.0234375f;
                vector.y += 0.02734375f;
            }
            if (this.graphics.headGraphic != null)
            {
                Vector3  b        = quat * this.BaseHeadOffsetAt(headFacing);
                Material material = this.graphics.HeadMatAt(headFacing, bodyDrawType, headStump);
                if (material != null)
                {
                    Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing);
                    GenDraw.DrawMeshNowOrLater(mesh2, a + b, quat, material, portrait);
                }
                Vector3 loc2 = rootLoc + b;
                loc2.y += 0.03125f;
                bool flag = false;
                if (!portrait || !Prefs.HatsOnlyOnMap)
                {
                    Mesh mesh3 = this.graphics.HairMeshSet.MeshAt(headFacing);
                    List <ApparelGraphicRecord> apparelGraphics = this.graphics.apparelGraphics;
                    for (int j = 0; j < apparelGraphics.Count; j++)
                    {
                        if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead)
                        {
                            if (!apparelGraphics[j].sourceApparel.def.apparel.hatRenderedFrontOfFace)
                            {
                                flag = true;
                                Material material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
                                material2 = this.graphics.flasher.GetDamagedMat(material2);
                                GenDraw.DrawMeshNowOrLater(mesh3, loc2, quat, material2, portrait);
                            }
                            else
                            {
                                Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
                                material3 = this.graphics.flasher.GetDamagedMat(material3);
                                Vector3 loc3 = rootLoc + b;
                                loc3.y += ((!(bodyFacing == Rot4.North)) ? 0.03515625f : 0.00390625f);
                                GenDraw.DrawMeshNowOrLater(mesh3, loc3, quat, material3, portrait);
                            }
                        }
                    }
                }
                if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump)
                {
                    Mesh     mesh4 = this.graphics.HairMeshSet.MeshAt(headFacing);
                    Material mat   = this.graphics.HairMatAt(headFacing);
                    GenDraw.DrawMeshNowOrLater(mesh4, loc2, quat, mat, portrait);
                }
            }
            if (renderBody)
            {
                for (int k = 0; k < this.graphics.apparelGraphics.Count; k++)
                {
                    ApparelGraphicRecord apparelGraphicRecord = this.graphics.apparelGraphics[k];
                    if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell)
                    {
                        Material material4 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null);
                        material4 = this.graphics.flasher.GetDamagedMat(material4);
                        GenDraw.DrawMeshNowOrLater(mesh, vector, quat, material4, portrait);
                    }
                }
            }
            if (!portrait && this.pawn.RaceProps.Animal && this.pawn.inventory != null && this.pawn.inventory.innerContainer.Count > 0 && this.graphics.packGraphic != null)
            {
                Graphics.DrawMesh(mesh, vector, quat, this.graphics.packGraphic.MatAt(bodyFacing, null), 0);
            }
            if (!portrait)
            {
                this.DrawEquipment(rootLoc);
                if (this.pawn.apparel != null)
                {
                    List <Apparel> wornApparel = this.pawn.apparel.WornApparel;
                    for (int l = 0; l < wornApparel.Count; l++)
                    {
                        wornApparel[l].DrawWornExtras();
                    }
                }
                Vector3 bodyLoc = rootLoc;
                bodyLoc.y += 0.04296875f;
                this.statusOverlays.RenderStatusOverlays(bodyLoc, quat, MeshPool.humanlikeHeadSet.MeshAt(headFacing));
            }
        }
        public override void DrawWornExtras()
        {
            if (Wearer == null || !Wearer.Spawned)
            {
                return;
            }
            Building_Bed bed = Wearer.CurrentBed();

            if (bed != null && !bed.def.building.bed_showSleeperBody && !onHead)
            {
                return;
            }

            //Since I haven't a head apparel item to test the drawing code against for now we throw an error (ONCE) and exit.
            if (this.onHead)
            {
                Log.ErrorOnce(string.Concat("CombatExtended :: Apparel_VisibleAccessory: The head drawing code is incomplete and the apparel '",
                                            this.Label, "' will not be drawn."), this.def.debugRandomId);
                return;
            }

            // compute drawVec, angle and Rot4 vars
            Rot4    rotation;
            Rot4    bedRotation = new Rot4();
            float   angle       = 0;
            Vector3 drawVec     = Wearer.Drawer.DrawPos;

            if (Wearer.GetPosture() != PawnPosture.Standing)
            {
                rotation = LayingFacing();
                if (bed != null)
                {
                    bedRotation        = bed.Rotation;
                    bedRotation.AsInt += 2;
                    angle              = bedRotation.AsAngle;
                    AltitudeLayer altitude = (AltitudeLayer)((byte)Mathf.Max((int)bed.def.altitudeLayer, 14));
                    drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(altitude).y;
                    drawVec  += bedRotation.FacingCell.ToVector3() * (-Wearer.Drawer.renderer.BaseHeadOffsetAt(Rot4.South).z);
                }
                else
                {
                    drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.LayingPawn).y;
                    if (Wearer.Downed)      // Wearer.Spawned == false when Pawn.Dead == true.
                    {
                        float?newAngle = (((((Wearer.Drawer == null) ? null : Wearer.Drawer.renderer) == null) ? null : Wearer.Drawer.renderer.wiggler) == null) ? (float?)null : Wearer.Drawer.renderer.wiggler.downedAngle;
                        if (newAngle != null)
                        {
                            angle = newAngle.Value;
                        }
                    }
                    else
                    {
                        angle = rotation.FacingCell.AngleFlat;
                    }
                }
                drawVec.y += 0.005f;
            }
            else
            {
                rotation  = Wearer.Rotation;
                drawVec.y = Wearer.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.Pawn).y;
            }

            drawVec.y += GetAltitudeOffset(rotation);

            // Get the graphic path
            string  path    = def.graphicData.texPath + "_" + ((Wearer == null) ? null : Wearer.story.bodyType.ToString());
            Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, def.graphicData.drawSize, DrawColor);
            ApparelGraphicRecord apparelGraphic = new ApparelGraphicRecord(graphic, this);

            Material mat = apparelGraphic.graphic.MatAt(rotation);
            Vector3  s   = new Vector3(1.5f, 1.5f, 1.5f);

            //mat.shader = ShaderDatabase.CutoutComplex;
            //mat.color = DrawColor;
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(drawVec, Quaternion.AngleAxis(angle, Vector3.up), s);
            Graphics.DrawMesh(rotation == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);
        }
Exemplo n.º 29
0
        private void RenderPawnInternal(Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait
                                        , bool headStump, bool invisible, int curLevel, int baseLevel)
        {
            if (!this.graphics.AllResolved)
            {
                this.graphics.ResolveAllGraphics();
            }

            float scaledSize = 1.5f * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale));

            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);
            Mesh       mesh       = null;

            if (renderBody)
            {
                Vector3 loc = rootLoc;
                loc.y += 0.007575758f;
                if (bodyDrawType == RotDrawMode.Dessicated && !this.pawn.RaceProps.Humanlike && this.graphics.dessicatedGraphic != null && !portrait)
                {
                    this.graphics.dessicatedGraphic.Draw(loc, bodyFacing, this.pawn, angle);
                }
                else
                {
                    if (this.pawn.RaceProps.Humanlike)
                    {
                        mesh = new GraphicMeshSet(scaledSize).MeshAt(bodyFacing);
                    }
                    else
                    {
                        Vector2 drawSize = this.graphics.nakedGraphic.drawSize;
                        drawSize.x *= 1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale);
                        drawSize.y *= 1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale);
                        var newGraphic = this.graphics.nakedGraphic.GetCopy(drawSize);
                        mesh = newGraphic.MeshAt(bodyFacing);
                    }
                    List <Material> list = this.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType);
                    for (int i = 0; i < list.Count; i++)
                    {
                        Material mat = this.OverrideMaterialIfNeeded(list[i], this.pawn);
                        GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, mat, portrait);
                        loc.y += 0.003787879f;
                    }
                    if (bodyDrawType == RotDrawMode.Fresh)
                    {
                        Vector3 drawLoc = rootLoc;
                        drawLoc.y += 0.0189393945f;
                        this.woundOverlays.RenderOverBody(drawLoc, mesh, quaternion, portrait);
                    }
                }
            }
            Vector3 vector = rootLoc;
            Vector3 a      = rootLoc;

            if (bodyFacing != Rot4.North)
            {
                a.y      += 0.0265151523f;
                vector.y += 0.0227272734f;
            }
            else
            {
                a.y      += 0.0227272734f;
                vector.y += 0.0265151523f;
            }
            if (this.graphics.headGraphic != null)
            {
                Vector3  b        = (quaternion * this.BaseHeadOffsetAt(headFacing)) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale));
                Material material = this.graphics.HeadMatAt(headFacing, bodyDrawType, headStump);
                if (material != null)
                {
                    GenDraw.DrawMeshNowOrLater(new GraphicMeshSet(scaledSize).MeshAt(headFacing), a + b, quaternion, material, portrait);
                }
                Vector3 loc2 = rootLoc + b;
                loc2.y += 0.0303030312f;
                bool flag = false;
                if (!portrait || !Prefs.HatsOnlyOnMap)
                {
                    Mesh mesh2 = new GraphicMeshSet(scaledSize).MeshAt(headFacing);
                    List <ApparelGraphicRecord> apparelGraphics = this.graphics.apparelGraphics;
                    for (int j = 0; j < apparelGraphics.Count; j++)
                    {
                        if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead)
                        {
                            if (!apparelGraphics[j].sourceApparel.def.apparel.hatRenderedFrontOfFace)
                            {
                                flag = true;
                                Material material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
                                material2 = this.OverrideMaterialIfNeeded(material2, this.pawn);
                                GenDraw.DrawMeshNowOrLater(mesh2, loc2, quaternion, material2, portrait);
                            }
                            else
                            {
                                Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
                                material3 = this.OverrideMaterialIfNeeded(material3, this.pawn);
                                Vector3 loc3 = rootLoc + b;
                                loc3.y += ((bodyFacing == Rot4.North) ? 0.003787879f : 0.03409091f);
                                GenDraw.DrawMeshNowOrLater(mesh2, loc3, quaternion, material3, portrait);
                            }
                        }
                    }
                }
                if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump)
                {
                    Mesh     mesh3 = new GraphicMeshSet(scaledSize).MeshAt(headFacing);
                    Material mat2  = this.graphics.HairMatAt(headFacing);
                    GenDraw.DrawMeshNowOrLater(mesh3, loc2, quaternion, mat2, portrait);
                }
            }
            if (renderBody)
            {
                for (int k = 0; k < this.graphics.apparelGraphics.Count; k++)
                {
                    ApparelGraphicRecord apparelGraphicRecord = this.graphics.apparelGraphics[k];
                    if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell)
                    {
                        Material material4 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null);
                        material4 = this.OverrideMaterialIfNeeded(material4, this.pawn);
                        GenDraw.DrawMeshNowOrLater(mesh, vector, quaternion, material4, portrait);
                    }
                }
            }
            if (!portrait && this.pawn.RaceProps.Animal && this.pawn.inventory != null && this.pawn.inventory.innerContainer.Count > 0 && this.graphics.packGraphic != null)
            {
                Graphics.DrawMesh(mesh, vector, quaternion, this.graphics.packGraphic.MatAt(bodyFacing, null), 0);
            }
            if (!portrait)
            {
                this.DrawEquipment(rootLoc, curLevel, baseLevel);
                if (this.pawn.apparel != null)
                {
                    List <Apparel> wornApparel = this.pawn.apparel.WornApparel;
                    for (int l = 0; l < wornApparel.Count; l++)
                    {
                        wornApparel[l].DrawWornExtras();
                    }
                }
                Vector3 bodyLoc = rootLoc;
                bodyLoc.y += 0.0416666679f;
                this.statusOverlays.RenderStatusOverlays(bodyLoc, quaternion, MeshPool.humanlikeHeadSet.MeshAt(headFacing));
            }
        }
Exemplo n.º 30
0
        public static bool TryGetGraphicApparelModded(Apparel apparel, BodyType bodyType, out ApparelGraphicRecord rec)
        {
            if (bodyType == BodyType.Undefined)
            {
                Log.Error("Getting apparel graphic with undefined body type.");
                bodyType = BodyType.Male;
            }
            if (apparel.def.apparel.wornGraphicPath.NullOrEmpty())
            {
                rec = new ApparelGraphicRecord(null, null);
                return(false);
            }
            string path;

            if (apparel.def.apparel.LastLayer == ApparelLayer.Overhead)
            {
                path = apparel.def.apparel.wornGraphicPath;
            }
            else
            {
                path = apparel.def.apparel.wornGraphicPath + "_" + bodyType.ToString();
            }

            Graphic graphic = new Graphic();

            graphic = GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.CutoutComplex, apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColorTwo);

            rec = new ApparelGraphicRecord(graphic, apparel);
            return(true);
        }