Beispiel #1
0
        protected void DrawHighlightFieldRadiusAroundTarget(LocalTargetInfo target)
        {
            bool  needLOSToCenter;
            float num = HighlightFieldRadiusAroundTarget(out needLOSToCenter);

            if (!(num > 0.2f) || !TryFindShootLineFromTo(caster.Position, target, out var resultingLine))
            {
                return;
            }
            if (needLOSToCenter)
            {
                GenExplosion.RenderPredictedAreaOfEffect(resultingLine.Dest, num);
                return;
            }
            GenDraw.DrawFieldEdges((from x in GenRadial.RadialCellsAround(resultingLine.Dest, num, useCenter: true)
                                    where x.InBounds(Find.CurrentMap)
                                    select x).ToList());
        }
Beispiel #2
0
 public virtual void DrawExtraSelectionOverlays()
 {
     if (def.specialDisplayRadius > 0.1f)
     {
         GenDraw.DrawRadiusRing(Position, def.specialDisplayRadius);
     }
     if (def.drawPlaceWorkersWhileSelected && def.PlaceWorkers != null)
     {
         for (int i = 0; i < def.PlaceWorkers.Count; i++)
         {
             def.PlaceWorkers[i].DrawGhost(def, Position, Rotation, Color.white, this);
         }
     }
     if (def.hasInteractionCell)
     {
         GenDraw.DrawInteractionCell(def, Position, rotationInt);
     }
 }
Beispiel #3
0
 public virtual void DrawExtraSelectionOverlays()
 {
     if (this.def.specialDisplayRadius > 0.10000000149011612)
     {
         GenDraw.DrawRadiusRing(this.Position, this.def.specialDisplayRadius);
     }
     if (this.def.drawPlaceWorkersWhileSelected && this.def.PlaceWorkers != null)
     {
         for (int i = 0; i < this.def.PlaceWorkers.Count; i++)
         {
             this.def.PlaceWorkers[i].DrawGhost(this.def, this.Position, this.Rotation);
         }
     }
     if (this.def.hasInteractionCell)
     {
         GenDraw.DrawInteractionCell(this.def, this.Position, this.rotationInt);
     }
 }
Beispiel #4
0
 public static void DrawWorldRadiusRing(int center, int radius)
 {
     if (radius < 0)
     {
         return;
     }
     if (GenDraw.cachedEdgeTilesForCenter != center || GenDraw.cachedEdgeTilesForRadius != radius || GenDraw.cachedEdgeTilesForWorldSeed != Find.World.info.Seed)
     {
         GenDraw.cachedEdgeTilesForCenter    = center;
         GenDraw.cachedEdgeTilesForRadius    = radius;
         GenDraw.cachedEdgeTilesForWorldSeed = Find.World.info.Seed;
         GenDraw.cachedEdgeTiles.Clear();
         Find.WorldFloodFiller.FloodFill(center, (int tile) => true, delegate(int tile, int dist)
         {
             if (dist > radius + 1)
             {
                 return(true);
             }
             if (dist == radius + 1)
             {
                 GenDraw.cachedEdgeTiles.Add(tile);
             }
             return(false);
         }, 2147483647, null);
         WorldGrid worldGrid = Find.WorldGrid;
         Vector3   c         = worldGrid.GetTileCenter(center);
         Vector3   n         = c.normalized;
         GenDraw.cachedEdgeTiles.Sort(delegate(int a, int b)
         {
             float num = Vector3.Dot(n, Vector3.Cross(worldGrid.GetTileCenter(a) - c, worldGrid.GetTileCenter(b) - c));
             if (Mathf.Abs(num) < 0.0001f)
             {
                 return(0);
             }
             if (num < 0f)
             {
                 return(-1);
             }
             return(1);
         });
     }
     GenDraw.DrawWorldLineStrip(GenDraw.cachedEdgeTiles, GenDraw.OneSidedWorldLineMatWhite, 5f);
 }
Beispiel #5
0
 public void DrawRadiusRing(IntVec3 center)
 {
     if (Find.CurrentMap == null)
     {
         return;
     }
     if (!this.IsMeleeAttack)
     {
         float num = this.EffectiveMinRange(true);
         if (num > 0f && num < GenRadial.MaxRadialPatternRadius)
         {
             GenDraw.DrawRadiusRing(center, num);
         }
         if (this.range < (float)(Find.CurrentMap.Size.x + Find.CurrentMap.Size.z) && this.range < GenRadial.MaxRadialPatternRadius)
         {
             GenDraw.DrawRadiusRing(center, this.range);
         }
     }
 }
Beispiel #6
0
 public void DrawRadiusRing(IntVec3 center)
 {
     if (Find.CurrentMap != null && !IsMeleeAttack)
     {
         float num = EffectiveMinRange(allowAdjacentShot: true);
         if (num > 0f && num < GenRadial.MaxRadialPatternRadius)
         {
             GenDraw.DrawRadiusRing(center, num);
         }
         float   num2  = range;
         IntVec3 size  = Find.CurrentMap.Size;
         int     x     = size.x;
         IntVec3 size2 = Find.CurrentMap.Size;
         if (num2 < (float)(x + size2.z) && range < GenRadial.MaxRadialPatternRadius)
         {
             GenDraw.DrawRadiusRing(center, range);
         }
     }
 }
 public void LetterStackUpdate()
 {
     if (this.mouseoverLetterIndex >= 0 && this.mouseoverLetterIndex < this.letters.Count)
     {
         GlobalTargetInfo lookTarget = this.letters[this.mouseoverLetterIndex].lookTarget;
         if (lookTarget.IsValid && lookTarget.IsMapTarget && lookTarget.Map == Find.VisibleMap)
         {
             GenDraw.DrawArrowPointingAt(((TargetInfo)lookTarget).CenterVector3, false);
         }
     }
     this.mouseoverLetterIndex = -1;
     for (int num = this.letters.Count - 1; num >= 0; num--)
     {
         if (!this.letters[num].StillValid)
         {
             this.RemoveLetter(this.letters[num]);
         }
     }
 }
Beispiel #8
0
        public static void DrawRadiusRing(IntVec3 center, float radius)
        {
            if (radius > GenRadial.MaxRadialPatternRadius)
            {
                if (!GenDraw.maxRadiusMessaged)
                {
                    Log.Error("Cannot draw radius ring of radius " + radius + ": not enough squares in the precalculated list.");
                    GenDraw.maxRadiusMessaged = true;
                }
                return;
            }
            GenDraw.ringDrawCells.Clear();
            int num = GenRadial.NumCellsInRadius(radius);

            for (int i = 0; i < num; i++)
            {
                GenDraw.ringDrawCells.Add(center + GenRadial.RadialPattern[i]);
            }
            GenDraw.DrawFieldEdges(GenDraw.ringDrawCells);
        }
        public static void DrawCircleOutline(Vector3 center, float radius, Material material)
        {
            int     num    = Mathf.Clamp(Mathf.RoundToInt(24f * radius), 12, 48);
            float   num2   = 0f;
            float   num3   = 6.28318548f / (float)num;
            Vector3 vector = center;
            Vector3 a      = center;

            for (int i = 0; i < num + 2; i++)
            {
                if (i >= 2)
                {
                    GenDraw.DrawLineBetween(a, vector, material);
                }
                a         = vector;
                vector    = center;
                vector.x += Mathf.Cos(num2) * radius;
                vector.z += Mathf.Sin(num2) * radius;
                num2     += num3;
            }
        }
Beispiel #10
0
        public static void DrawLineBetween(Vector3 A, Vector3 B, SimpleColor color)
        {
            Material mat;

            switch (color)
            {
            case SimpleColor.White:
                mat = GenDraw.LineMatWhite;
                break;

            case SimpleColor.Red:
                mat = GenDraw.LineMatRed;
                break;

            case SimpleColor.Green:
                mat = GenDraw.LineMatGreen;
                break;

            case SimpleColor.Blue:
                mat = GenDraw.LineMatBlue;
                break;

            case SimpleColor.Magenta:
                mat = GenDraw.LineMatMagenta;
                break;

            case SimpleColor.Yellow:
                mat = GenDraw.LineMatYellow;
                break;

            case SimpleColor.Cyan:
                mat = GenDraw.LineMatCyan;
                break;

            default:
                mat = GenDraw.LineMatWhite;
                break;
            }
            GenDraw.DrawLineBetween(A, B, mat);
        }
Beispiel #11
0
 public static void DrawWorldLineStrip(List <int> edgeTiles, Material material, float widthFactor)
 {
     if (edgeTiles.Count >= 3)
     {
         WorldGrid worldGrid = Find.WorldGrid;
         float     d         = 0.05f;
         for (int i = 0; i < edgeTiles.Count; i++)
         {
             int index = (i != 0) ? (i - 1) : (edgeTiles.Count - 1);
             int num   = edgeTiles[index];
             int num2  = edgeTiles[i];
             if (worldGrid.IsNeighbor(num, num2))
             {
                 Vector3 a      = worldGrid.GetTileCenter(num);
                 Vector3 vector = worldGrid.GetTileCenter(num2);
                 a      += a.normalized * d;
                 vector += vector.normalized * d;
                 GenDraw.DrawWorldLineBetween(a, vector, material, widthFactor);
             }
         }
     }
 }
Beispiel #12
0
 public static void DrawLineBetween(Vector3 A, Vector3 B)
 {
     GenDraw.DrawLineBetween(A, B, GenDraw.LineMatWhite);
 }
Beispiel #13
0
 public static void DrawLineBetween(Vector3 A, Vector3 B, float layer)
 {
     GenDraw.DrawLineBetween(A + Vector3.up * layer, B + Vector3.up * layer, GenDraw.LineMatWhite);
 }
Beispiel #14
0
 public static void DrawNoBuildEdgeLines()
 {
     GenDraw.DrawMapEdgeLines(10);
 }
Beispiel #15
0
 public static void DrawNoZoneEdgeLines()
 {
     GenDraw.DrawMapEdgeLines(5);
 }
Beispiel #16
0
        private void RenderPawnInternal(Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible)
        {
            if (!graphics.AllResolved)
            {
                graphics.ResolveAllGraphics();
            }
            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);
            Mesh       mesh       = null;

            if (renderBody)
            {
                Vector3 loc = rootLoc;
                loc.y += 9f / 980f;
                if (bodyDrawType == RotDrawMode.Dessicated && !pawn.RaceProps.Humanlike && graphics.dessicatedGraphic != null && !portrait)
                {
                    graphics.dessicatedGraphic.Draw(loc, bodyFacing, pawn, angle);
                }
                else
                {
                    mesh = ((!pawn.RaceProps.Humanlike) ? graphics.nakedGraphic.MeshAt(bodyFacing) : MeshPool.humanlikeBodySet.MeshAt(bodyFacing));
                    List <Material> list = graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType);
                    for (int i = 0; i < list.Count; i++)
                    {
                        Material mat = OverrideMaterialIfNeeded_NewTemp(list[i], pawn, portrait);
                        GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, mat, portrait);
                        loc.y += 3f / 980f;
                    }
                    if (bodyDrawType == RotDrawMode.Fresh)
                    {
                        Vector3 drawLoc = rootLoc;
                        drawLoc.y += 9f / 490f;
                        woundOverlays.RenderOverBody(drawLoc, mesh, quaternion, portrait);
                    }
                }
            }
            Vector3 vector = rootLoc;
            Vector3 a      = rootLoc;

            if (bodyFacing != Rot4.North)
            {
                a.y      += 6f / 245f;
                vector.y += 3f / 140f;
            }
            else
            {
                a.y      += 3f / 140f;
                vector.y += 6f / 245f;
            }
            Vector3 vector2 = rootLoc;

            vector2.y += ((bodyFacing == Rot4.South) ? (3f / 490f) : (27f / 980f));
            List <ApparelGraphicRecord> apparelGraphics = graphics.apparelGraphics;

            if (graphics.headGraphic != null)
            {
                Vector3  b        = quaternion * BaseHeadOffsetAt(headFacing);
                Material material = graphics.HeadMatAt_NewTemp(headFacing, bodyDrawType, headStump, portrait);
                if (material != null)
                {
                    GenDraw.DrawMeshNowOrLater(MeshPool.humanlikeHeadSet.MeshAt(headFacing), a + b, quaternion, material, portrait);
                }
                Vector3 loc2 = rootLoc + b;
                loc2.y += 3f / 98f;
                bool flag = false;
                if (!portrait || !Prefs.HatsOnlyOnMap)
                {
                    Mesh mesh2 = graphics.HairMeshSet.MeshAt(headFacing);
                    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 original = apparelGraphics[j].graphic.MatAt(bodyFacing);
                                original = OverrideMaterialIfNeeded_NewTemp(original, pawn, portrait);
                                GenDraw.DrawMeshNowOrLater(mesh2, loc2, quaternion, original, portrait);
                            }
                            else
                            {
                                Material original2 = apparelGraphics[j].graphic.MatAt(bodyFacing);
                                original2 = OverrideMaterialIfNeeded_NewTemp(original2, pawn, portrait);
                                Vector3 loc3 = rootLoc + b;
                                loc3.y += ((bodyFacing == Rot4.North) ? (3f / 980f) : (33f / 980f));
                                GenDraw.DrawMeshNowOrLater(mesh2, loc3, quaternion, original2, portrait);
                            }
                        }
                    }
                }
                if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump)
                {
                    GenDraw.DrawMeshNowOrLater(graphics.HairMeshSet.MeshAt(headFacing), mat: graphics.HairMatAt_NewTemp(headFacing, portrait), loc: loc2, quat: quaternion, drawNow: portrait);
                }
            }
            if (renderBody)
            {
                for (int k = 0; k < apparelGraphics.Count; k++)
                {
                    ApparelGraphicRecord apparelGraphicRecord = apparelGraphics[k];
                    if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell && !apparelGraphicRecord.sourceApparel.def.apparel.shellRenderedBehindHead)
                    {
                        Material original3 = apparelGraphicRecord.graphic.MatAt(bodyFacing);
                        original3 = OverrideMaterialIfNeeded_NewTemp(original3, pawn, portrait);
                        GenDraw.DrawMeshNowOrLater(mesh, vector, quaternion, original3, portrait);
                    }
                    if (RenderAsPack(apparelGraphicRecord.sourceApparel))
                    {
                        Material original4 = apparelGraphicRecord.graphic.MatAt(bodyFacing);
                        original4 = OverrideMaterialIfNeeded_NewTemp(original4, pawn, portrait);
                        if (apparelGraphicRecord.sourceApparel.def.apparel.wornGraphicData != null)
                        {
                            Vector2   vector3 = apparelGraphicRecord.sourceApparel.def.apparel.wornGraphicData.BeltOffsetAt(bodyFacing, pawn.story.bodyType);
                            Vector2   vector4 = apparelGraphicRecord.sourceApparel.def.apparel.wornGraphicData.BeltScaleAt(pawn.story.bodyType);
                            Matrix4x4 matrix  = Matrix4x4.Translate(vector2) * Matrix4x4.Rotate(quaternion) * Matrix4x4.Translate(new Vector3(vector3.x, 0f, vector3.y)) * Matrix4x4.Scale(new Vector3(vector4.x, 1f, vector4.y));
                            GenDraw.DrawMeshNowOrLater_NewTemp(mesh, matrix, original4, portrait);
                        }
                        else
                        {
                            GenDraw.DrawMeshNowOrLater(mesh, vector, quaternion, original4, portrait);
                        }
                    }
                }
            }
            if (!portrait && pawn.RaceProps.Animal && pawn.inventory != null && pawn.inventory.innerContainer.Count > 0 && graphics.packGraphic != null)
            {
                Graphics.DrawMesh(mesh, vector, quaternion, graphics.packGraphic.MatAt(bodyFacing), 0);
            }
            if (portrait)
            {
                return;
            }
            DrawEquipment(rootLoc);
            if (pawn.apparel != null)
            {
                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int l = 0; l < wornApparel.Count; l++)
                {
                    wornApparel[l].DrawWornExtras();
                }
            }
            Vector3 bodyLoc = rootLoc;

            bodyLoc.y += 39f / 980f;
            statusOverlays.RenderStatusOverlays(bodyLoc, quaternion, MeshPool.humanlikeHeadSet.MeshAt(headFacing));
        }
Beispiel #17
0
 public void UpdateRotation()
 {
     if (!this.pawn.Destroyed && !this.pawn.jobs.HandlingFacing)
     {
         if (this.pawn.pather.Moving)
         {
             if (this.pawn.pather.curPath != null && this.pawn.pather.curPath.NodesLeftCount >= 1)
             {
                 this.FaceAdjacentCell(this.pawn.pather.nextCell);
             }
         }
         else
         {
             Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy;
             if (stance_Busy != null && stance_Busy.focusTarg.IsValid)
             {
                 if (stance_Busy.focusTarg.HasThing)
                 {
                     this.Face(stance_Busy.focusTarg.Thing.DrawPos);
                 }
                 else
                 {
                     this.FaceCell(stance_Busy.focusTarg.Cell);
                 }
             }
             else
             {
                 if (this.pawn.jobs.curJob != null)
                 {
                     LocalTargetInfo target = this.pawn.CurJob.GetTarget(this.pawn.jobs.curDriver.rotateToFace);
                     if (target.HasThing)
                     {
                         bool     flag     = false;
                         IntVec3  c        = default(IntVec3);
                         CellRect cellRect = target.Thing.OccupiedRect();
                         for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
                         {
                             for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                             {
                                 if (this.pawn.Position == new IntVec3(j, 0, i))
                                 {
                                     this.Face(target.Thing.DrawPos);
                                     return;
                                 }
                             }
                         }
                         for (int k = cellRect.minZ; k <= cellRect.maxZ; k++)
                         {
                             for (int l = cellRect.minX; l <= cellRect.maxX; l++)
                             {
                                 IntVec3 intVec = new IntVec3(l, 0, k);
                                 if (intVec.AdjacentToCardinal(this.pawn.Position))
                                 {
                                     this.FaceAdjacentCell(intVec);
                                     return;
                                 }
                                 if (intVec.AdjacentTo8Way(this.pawn.Position))
                                 {
                                     flag = true;
                                     c    = intVec;
                                 }
                             }
                         }
                         if (flag)
                         {
                             if (DebugViewSettings.drawPawnRotatorTarget)
                             {
                                 this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.6f, "jbthing", 50);
                                 GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), c.ToVector3Shifted());
                             }
                             this.FaceAdjacentCell(c);
                         }
                         else
                         {
                             this.Face(target.Thing.DrawPos);
                         }
                         return;
                     }
                     if (this.pawn.Position.AdjacentTo8Way(target.Cell))
                     {
                         if (DebugViewSettings.drawPawnRotatorTarget)
                         {
                             this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.2f, "jbloc", 50);
                             GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted());
                         }
                         this.FaceAdjacentCell(target.Cell);
                         return;
                     }
                     if (target.Cell.IsValid && target.Cell != this.pawn.Position)
                     {
                         this.Face(target.Cell.ToVector3());
                         return;
                     }
                 }
                 if (this.pawn.Drafted)
                 {
                     this.pawn.Rotation = Rot4.South;
                 }
             }
         }
     }
 }
 public void Draw()
 {
     GenDraw.DrawLineBetween(a, b, color);
 }
Beispiel #19
0
 public static void DrawLineBetween(Vector3 A, Vector3 B, SimpleColor color)
 {
     GenDraw.DrawLineBetween(A, B, GenDraw.GetLineMat(color));
 }
Beispiel #20
0
 public static void DrawCircleOutline(Vector3 center, float radius)
 {
     GenDraw.DrawCircleOutline(center, radius, GenDraw.LineMatWhite);
 }
Beispiel #21
0
 public static void DrawWorldLineBetween(Vector3 A, Vector3 B)
 {
     GenDraw.DrawWorldLineBetween(A, B, GenDraw.WorldLineMatWhite, 1f);
 }
Beispiel #22
0
 public static void DrawCircleOutline(Vector3 center, float radius, SimpleColor color)
 {
     GenDraw.DrawCircleOutline(center, radius, GenDraw.GetLineMat(color));
 }
Beispiel #23
0
 public static void DrawWorldLineBetween(Vector3 A, Vector3 B, Material material)
 {
     GenDraw.DrawWorldLineBetween(A, B, material, 1f);
 }
Beispiel #24
0
 public static void RenderPredictedAreaOfEffect(IntVec3 loc, float radius)
 {
     GenDraw.DrawFieldEdges(DamageDefOf.Bomb.Worker.ExplosionCellsToHit(loc, Find.CurrentMap, radius).ToList <IntVec3>());
 }
Beispiel #25
0
 public static void DrawTargetingHightlight_Explosion(IntVec3 c, float Radius)
 {
     GenDraw.DrawRadiusRing(c, Radius);
 }
Beispiel #26
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));
            }
        }
Beispiel #27
0
 public static void DrawFieldEdges(List <IntVec3> cells)
 {
     GenDraw.DrawFieldEdges(cells, Color.white);
 }
Beispiel #28
0
 public void Draw()
 {
     GenDraw.DrawLineBetween(this.a, this.b, this.color);
 }
Beispiel #29
0
 public void FaceTarget(LocalTargetInfo target)
 {
     if (target.IsValid)
     {
         if (target.HasThing)
         {
             Thing thing = (!target.Thing.Spawned) ? ThingOwnerUtility.GetFirstSpawnedParentThing(target.Thing) : target.Thing;
             if (thing != null && thing.Spawned)
             {
                 bool     flag     = false;
                 IntVec3  c        = default(IntVec3);
                 CellRect cellRect = thing.OccupiedRect();
                 for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
                 {
                     for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                     {
                         if (pawn.Position == new IntVec3(j, 0, i))
                         {
                             Face(thing.DrawPos);
                             return;
                         }
                     }
                 }
                 for (int k = cellRect.minZ; k <= cellRect.maxZ; k++)
                 {
                     for (int l = cellRect.minX; l <= cellRect.maxX; l++)
                     {
                         IntVec3 intVec = new IntVec3(l, 0, k);
                         if (intVec.AdjacentToCardinal(pawn.Position))
                         {
                             FaceAdjacentCell(intVec);
                             return;
                         }
                         if (intVec.AdjacentTo8Way(pawn.Position))
                         {
                             flag = true;
                             c    = intVec;
                         }
                     }
                 }
                 if (flag)
                 {
                     if (DebugViewSettings.drawPawnRotatorTarget)
                     {
                         pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing");
                         GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted());
                     }
                     FaceAdjacentCell(c);
                 }
                 else
                 {
                     Face(thing.DrawPos);
                 }
             }
         }
         else if (pawn.Position.AdjacentTo8Way(target.Cell))
         {
             if (DebugViewSettings.drawPawnRotatorTarget)
             {
                 pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc");
                 GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted());
             }
             FaceAdjacentCell(target.Cell);
         }
         else if (target.Cell.IsValid && target.Cell != pawn.Position)
         {
             Face(target.Cell.ToVector3());
         }
     }
 }
Beispiel #30
0
        private void RenderPawnInternal(Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible)
        {
            if (!graphics.AllResolved)
            {
                graphics.ResolveAllGraphics();
            }
            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);
            Mesh       mesh       = null;

            if (renderBody)
            {
                Vector3 loc = rootLoc;
                loc.y += 0.007575758f;
                if (bodyDrawType == RotDrawMode.Dessicated && !pawn.RaceProps.Humanlike && graphics.dessicatedGraphic != null && !portrait)
                {
                    graphics.dessicatedGraphic.Draw(loc, bodyFacing, pawn, angle);
                }
                else
                {
                    mesh = ((!pawn.RaceProps.Humanlike) ? graphics.nakedGraphic.MeshAt(bodyFacing) : MeshPool.humanlikeBodySet.MeshAt(bodyFacing));
                    List <Material> list = graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType);
                    for (int i = 0; i < list.Count; i++)
                    {
                        Material mat = OverrideMaterialIfNeeded(list[i], pawn);
                        GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, mat, portrait);
                        loc.y += 0.003787879f;
                    }
                    if (bodyDrawType == RotDrawMode.Fresh)
                    {
                        Vector3 drawLoc = rootLoc;
                        drawLoc.y += 5f / 264f;
                        woundOverlays.RenderOverBody(drawLoc, mesh, quaternion, portrait);
                    }
                }
            }
            Vector3 vector = rootLoc;
            Vector3 a      = rootLoc;

            if (bodyFacing != Rot4.North)
            {
                a.y      += 7f / 264f;
                vector.y += 0.0227272734f;
            }
            else
            {
                a.y      += 0.0227272734f;
                vector.y += 7f / 264f;
            }
            if (graphics.headGraphic != null)
            {
                Vector3  b        = quaternion * BaseHeadOffsetAt(headFacing);
                Material material = graphics.HeadMatAt(headFacing, bodyDrawType, headStump);
                if (material != null)
                {
                    GenDraw.DrawMeshNowOrLater(MeshPool.humanlikeHeadSet.MeshAt(headFacing), a + b, quaternion, material, portrait);
                }
                Vector3 loc2 = rootLoc + b;
                loc2.y += 0.0303030312f;
                bool flag = false;
                if (!portrait || !Prefs.HatsOnlyOnMap)
                {
                    Mesh mesh2 = graphics.HairMeshSet.MeshAt(headFacing);
                    List <ApparelGraphicRecord> apparelGraphics = 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 original = apparelGraphics[j].graphic.MatAt(bodyFacing);
                                original = OverrideMaterialIfNeeded(original, pawn);
                                GenDraw.DrawMeshNowOrLater(mesh2, loc2, quaternion, original, portrait);
                            }
                            else
                            {
                                Material original2 = apparelGraphics[j].graphic.MatAt(bodyFacing);
                                original2 = OverrideMaterialIfNeeded(original2, pawn);
                                Vector3 loc3 = rootLoc + b;
                                loc3.y += ((bodyFacing == Rot4.North) ? 0.003787879f : (3f / 88f));
                                GenDraw.DrawMeshNowOrLater(mesh2, loc3, quaternion, original2, portrait);
                            }
                        }
                    }
                }
                if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump)
                {
                    GenDraw.DrawMeshNowOrLater(graphics.HairMeshSet.MeshAt(headFacing), mat: graphics.HairMatAt(headFacing), loc: loc2, quat: quaternion, drawNow: portrait);
                }
            }
            if (renderBody)
            {
                for (int k = 0; k < graphics.apparelGraphics.Count; k++)
                {
                    ApparelGraphicRecord apparelGraphicRecord = graphics.apparelGraphics[k];
                    if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell)
                    {
                        Material original3 = apparelGraphicRecord.graphic.MatAt(bodyFacing);
                        original3 = OverrideMaterialIfNeeded(original3, pawn);
                        GenDraw.DrawMeshNowOrLater(mesh, vector, quaternion, original3, portrait);
                    }
                }
            }
            if (!portrait && pawn.RaceProps.Animal && pawn.inventory != null && pawn.inventory.innerContainer.Count > 0 && graphics.packGraphic != null)
            {
                Graphics.DrawMesh(mesh, vector, quaternion, graphics.packGraphic.MatAt(bodyFacing), 0);
            }
            if (portrait)
            {
                return;
            }
            DrawEquipment(rootLoc);
            if (pawn.apparel != null)
            {
                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int l = 0; l < wornApparel.Count; l++)
                {
                    wornApparel[l].DrawWornExtras();
                }
            }
            Vector3 bodyLoc = rootLoc;

            bodyLoc.y += 0.0416666679f;
            statusOverlays.RenderStatusOverlays(bodyLoc, quaternion, MeshPool.humanlikeHeadSet.MeshAt(headFacing));
        }