Esempio n. 1
0
        public void DrawImplant()
        {// this.Pawn
            bool selected = Find.Selector.SelectedObjects.Contains(this.Pawn);
            HediffComp_DrawImplant comp = this;
            string  direction           = "";
            float   angle   = 0f;
            float   offset  = 0f;
            float   yvalue  = Pawn.Drawer.DrawPos.y;
            Vector3 drawPos = Pawn.Drawer.DrawPos;

            drawPos.y = Altitudes.AltitudeFor((AltitudeLayer)17);
            Vector3      s            = new Vector3(1.5f, 1.5f, 1.5f);
            PawnRenderer pawnRenderer = this.Pawn.Drawer.renderer;
            Rot4         rot          = LayingFacing();

            if (Pawn.CarriedBy != null)
            {
#if DEBUG
                if (selected)
                {
                    Log.Message(string.Format("{0} carried by {1} drawpos {2} modified to {3}", Pawn.Name, Pawn.CarriedBy.Name, drawPos, Pawn.CarriedBy.DrawPos));
                }
#endif
                drawPos.z = Pawn.CarriedBy.DrawPos.z;
                drawPos.x = Pawn.CarriedBy.DrawPos.x;
            }
            if (Pawn.InBed())
            {
                if (Pawn.CurrentBed().Rotation == Rot4.South)
                {
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman()));
                    }
#endif
                    drawPos -= pawnRenderer.BaseHeadOffsetAt(Rot4.South);
                }
                else if (Pawn.CurrentBed().Rotation == Rot4.North)
                {
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman()));
                    }
#endif
                    drawPos -= pawnRenderer.BaseHeadOffsetAt(Rot4.North);
                }
                else if (Pawn.CurrentBed().Rotation == Rot4.East)
                {
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman()));
                    }
#endif
                    drawPos.x += 0.3f;
                }
                else if (Pawn.CurrentBed().Rotation == Rot4.West)
                {
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("{0}", Pawn.CurrentBed().Rotation.ToStringHuman()));
                    }
#endif
                    drawPos.x -= 0.3f;
                }
                drawPos.y = yvalue;
#if DEBUG
                if (selected)
                {
                    Log.Message(string.Format("{0} in bed {1} drawpos modified to {2}", Pawn.Name, Pawn.InBed(), drawPos));
                }
#endif
            }
            if (offset < 0)
            {
                drawPos.y -= offset;
            }
            else
            {
                drawPos.y += offset;
            }
            if (Pawn.Downed)
            {
                angle = pawnRenderer.wiggler.downedAngle;
                if (Pawn.CarriedBy != null)
                {
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("{0} carried by {1} angle {2} modified to {3}", Pawn.Name, Pawn.CarriedBy.Name, angle, Pawn.CarriedBy.carryTracker.CarriedThing.Rotation.AsAngle));
                    }
#endif
                    angle = Pawn.CarriedBy.carryTracker.CarriedThing.Rotation.AsAngle;
                }
                if (Pawn.InBed())
                {
                    if (Pawn.CurrentBed().Rotation == Rot4.South)
                    {
                        angle = 0f;
                    }
                    else if (Pawn.CurrentBed().Rotation == Rot4.North)
                    {
                        angle = 180f;
                    }
                    else if (Pawn.CurrentBed().Rotation == Rot4.East)
                    {
                        angle = 270;
                    }
                    else if (Pawn.CurrentBed().Rotation == Rot4.West)
                    {
                        angle = 90;
                    }

                    // angle = Pawn.CurrentBed().Rotation.AsAngle;
                }
                if (Pawn.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
                {
                    s = new Vector3(2f, 1.5f, 2f);
                    if (rot.ToStringHuman() == "West" || rot == Rot4.West)
                    {
                        //drawPos.z -= 0.15f;
                        // drawPos.x += 0.25f;
                    }
                    else
                    {
                        //    drawPos.x += 0.25f;
                    }
                }
            }
#if DEBUG
            if (selected)
            {
                Log.Message(string.Format("{0}'s {1}, Rot:{2}, offset:{3}, x:{4}, z:{5}", Pawn.Label, this.parent.def.label, rot, offset, drawPos.x, drawPos.z));
                Log.Message(string.Format("Rot ToStringHuman:{1}, FacingCell:{2}, AsVector2:{3}, AsByte:{4}, AsAngle:{5}", rot, rot.ToStringHuman(), rot.FacingCell, rot.AsVector2, rot.AsByte, rot.AsAngle));
            }
#endif
            Material  matSingle = comp.ImplantMaterial(Pawn, rot);
            Matrix4x4 matrix    = default(Matrix4x4);
            matrix.SetTRS(drawPos, Quaternion.AngleAxis(angle, Vector3.up), s);
            Graphics.DrawMesh(rot == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, matSingle, 0);
        }
        static void DrawImplant(HediffComp_DrawImplant comp, PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump)
        {// this.Pawn
            Pawn    pawn     = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
            bool    selected = Find.Selector.SelectedObjects.Contains(pawn) && Prefs.DevMode;
            Rot4    rot      = bodyFacing;
            Vector3 vector3  = pawn.RaceProps.Humanlike ? __instance.BaseHeadOffsetAt(headFacing) : new Vector3();
            Vector3 s        = new Vector3(pawn.BodySize * 1.75f, pawn.BodySize * 1.75f, pawn.BodySize * 1.75f);

            GetAltitudeOffset(pawn, comp.parent, rot, out float X, out float Y, out float Z, out float DsX, out float DsZ, out float ang);
            vector3.x += X;
            vector3.y += Y;
            vector3.z += Z;
            angle     += ang;
            s.x        = DsX;
            s.z        = DsZ;
            if (pawn.RaceProps.Humanlike)
            {
                vector3.x += 0.01f;
                vector3.z += -0.35f;
            }

            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);
            Vector3    b          = quaternion * vector3;
            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;
            }

            /*
             * Material material = __instance.graphics.HeadMatAt(headFacing, bodyDrawType, headStump);
             * if (material != null)
             * {
             *  Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing);
             *  GenDraw.DrawMeshNowOrLater(mesh2, a + b, quaternion, material, portrait);
             * }
             */
            Vector3 loc2 = rootLoc + b;

            loc2.y += 0.03105f;
            bool flag = false;

            /*
             * if (!portrait || !Prefs.HatsOnlyOnMap)
             * {
             *  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 == ApparelLayerDefOf.Overhead)
             *      {
             *          if (!apparelGraphics[j].sourceApparel.def.apparel.hatRenderedFrontOfFace)
             *          {
             *              flag = true;
             *              Material material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
             *              material2 = __instance.graphics.flasher.GetDamagedMat(material2);
             *              GenDraw.DrawMeshNowOrLater(mesh3, loc2, quaternion, material2, portrait);
             *          }
             *          else
             *          {
             *              Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null);
             *              material3 = __instance.graphics.flasher.GetDamagedMat(material3);
             *              Vector3 loc3 = rootLoc + b;
             *              loc3.y += ((!(bodyFacing == Rot4.North)) ? 0.03515625f : 0.00390625f);
             *              GenDraw.DrawMeshNowOrLater(mesh3, loc3, quaternion, material3, portrait);
             *          }
             *      }
             *  }
             * }
             */
            if (!flag && bodyDrawType != RotDrawMode.Dessicated)
            {
#if DEBUG
                if (selected)
                {
                    //    Log.Message(string.Format("{0}'s rootLoc: {1}, angle: {2}, renderBody: {3}, bodyFacing: {4}, headFacing: {5}, bodyDrawType: {6}, portrait: {7}", pawn.Label, rootLoc, angle, renderBody, bodyFacing.ToStringHuman(), headFacing.ToStringHuman(), bodyDrawType, portrait));
                }
#endif
                if (!portrait)
                {
                    //    Mesh mesh4 = __instance.graphics.HairMeshSet.MeshAt(headFacing);
                    Material mat = comp.ImplantMaterial(pawn, pawn.RaceProps.Humanlike ? headFacing : bodyFacing);
                    //    GenDraw.DrawMeshNowOrLater(headFacing == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, loc2, quaternion, mat, true);
                    Matrix4x4 matrix = default(Matrix4x4);
                    matrix.SetTRS(loc2, quaternion, s);
                    Graphics.DrawMesh((pawn.RaceProps.Humanlike ? headFacing : bodyFacing) == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);
                    //    Graphics.DrawMesh((pawn.RaceProps.Humanlike ? headFacing : bodyFacing) == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0);
                }
            }

            /*
             * Material matSingle = comp.ImplantMaterial(pawn, rot);
             * Matrix4x4 matrix = default(Matrix4x4);
             * matrix.SetTRS(drawPos, Quaternion.AngleAxis(angle, Vector3.up), s);
             * Graphics.DrawMesh(rot == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, matSingle, 0);
             */
        }
Esempio n. 3
0
        public void Draw()
        {
            HediffComp_DrawImplant comp = this.TryGetComp <HediffComp_DrawImplant>();
            string  direction           = "";
            float   angle   = 0f;
            float   offset  = 0f;
            Vector3 drawPos = pawn.Dead ? pawn.PositionHeld.ToVector3() : pawn.Drawer.DrawPos;

            drawPos.y = Altitudes.AltitudeFor((AltitudeLayer)17);
            Vector3      s            = new Vector3(1.5f, 1.5f, 1.5f);
            PawnRenderer pawnRenderer = this.pawn.Drawer.renderer;
            Rot4         rot          = LayingFacing();
            bool         selected     = Find.Selector.SingleSelectedThing == pawn;
            bool         flag3        = pawn.Rotation == Rot4.North;

            if (flag3)
            {
                //offset = NorthOffset;
                //    drawPos.x -= 0.1f;
                //    drawPos.z -= (0.2f);
                direction = "North";
            }
            else
            {
                bool flag4 = pawn.Rotation == Rot4.South;
                if (flag4)
                {
                    //offset = SouthOffset;
                    //    drawPos.x += 0.1f;
                    //    drawPos.z -= (0.2f);
                    direction = "South";
                }
                else
                {
                    bool flag5 = pawn.Rotation == Rot4.East;
                    if (flag5)
                    {
                        //offset = EastOffset;
                        //    drawPos.z -= (0.2f);
                        //    angle = 22.5f;
                        direction = "East";
                    }
                    else
                    {
                        bool flag6 = pawn.Rotation == Rot4.West;
                        if (flag6)
                        {
                            //offset = WestOffset;
                            //    drawPos.z -= (0.2f);
                            //    angle = 337.5f;
                            direction = "West";
                        }
                    }
                }
            }
            if (offset < 0)
            {
                drawPos.y -= offset;
            }
            else
            {
                drawPos.y += offset;
            }
            //Log.Message(string.Format("PauldronGraphic drawPos.y: {1}", PauldronGraphic.path, drawPos.y));
            angle = pawnRenderer.wiggler.downedAngle;
            //Material mat = apparelGraphic.graphic.MatAt(rotation);
            if (selected)
            {
                Log.Message(string.Format("{0}'s {1} CompPauldronDrawer, {2} offset: {3}, drawPos.y:{4}", pawn.Label, this.def.label, direction, offset, drawPos.y));
            }
            Material matSingle = comp.ImplantMaterial(pawn, rot); //.GetColoredVersion(ShaderDatabase.Cutout, this.mainColor, this.secondaryColor).MatAt(rotation);
            //    Log.Message(string.Format("PauldronGraphic this.mainColor:{0}, this.secondaryColor: {1}", this.mainColor, this.secondaryColor));
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(drawPos, Quaternion.AngleAxis(angle, Vector3.up), s);
            Graphics.DrawMesh(rot == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, matSingle, 0);
        }