Exemple #1
0
 public bool AllowRenderingFor(TerrainDef terrain)
 {
     return(DebugViewSettings.drawTerrainWater || !terrain.HasTag("Water"));
 }
Exemple #2
0
        public override void Regenerate()
        {
            base.ClearSubMeshes(MeshParts.All);
            TerrainGrid terrainGrid = base.Map.terrainGrid;
            CellRect    cellRect    = base.section.CellRect;

            TerrainDef[]         array   = new TerrainDef[8];
            HashSet <TerrainDef> hashSet = new HashSet <TerrainDef>();

            bool[] array2 = new bool[8];
            foreach (IntVec3 item in cellRect)
            {
                IntVec3 current = item;
                hashSet.Clear();
                TerrainDef   terrainDef = terrainGrid.TerrainAt(current);
                LayerSubMesh subMesh    = base.GetSubMesh(this.GetMaterialFor(terrainDef));
                if (subMesh != null && this.AllowRenderingFor(terrainDef))
                {
                    int count = subMesh.verts.Count;
                    subMesh.verts.Add(new Vector3((float)current.x, 0f, (float)current.z));
                    subMesh.verts.Add(new Vector3((float)current.x, 0f, (float)(current.z + 1)));
                    subMesh.verts.Add(new Vector3((float)(current.x + 1), 0f, (float)(current.z + 1)));
                    subMesh.verts.Add(new Vector3((float)(current.x + 1), 0f, (float)current.z));
                    subMesh.colors.Add(SectionLayer_Terrain.ColorWhite);
                    subMesh.colors.Add(SectionLayer_Terrain.ColorWhite);
                    subMesh.colors.Add(SectionLayer_Terrain.ColorWhite);
                    subMesh.colors.Add(SectionLayer_Terrain.ColorWhite);
                    subMesh.tris.Add(count);
                    subMesh.tris.Add(count + 1);
                    subMesh.tris.Add(count + 2);
                    subMesh.tris.Add(count);
                    subMesh.tris.Add(count + 2);
                    subMesh.tris.Add(count + 3);
                }
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c = current + GenAdj.AdjacentCellsAroundBottom[i];
                    if (!c.InBounds(base.Map))
                    {
                        array[i] = terrainDef;
                    }
                    else
                    {
                        TerrainDef terrainDef2 = terrainGrid.TerrainAt(c);
                        Thing      edifice     = c.GetEdifice(base.Map);
                        if (edifice != null && edifice.def.coversFloor)
                        {
                            terrainDef2 = TerrainDefOf.Underwall;
                        }
                        array[i] = terrainDef2;
                        if (terrainDef2 != terrainDef && terrainDef2.edgeType != 0 && terrainDef2.renderPrecedence >= terrainDef.renderPrecedence && !hashSet.Contains(terrainDef2))
                        {
                            hashSet.Add(terrainDef2);
                        }
                    }
                }
                foreach (TerrainDef item2 in hashSet)
                {
                    LayerSubMesh subMesh2 = base.GetSubMesh(this.GetMaterialFor(item2));
                    if (subMesh2 != null && this.AllowRenderingFor(item2))
                    {
                        int count = subMesh2.verts.Count;
                        subMesh2.verts.Add(new Vector3((float)((float)current.x + 0.5), 0f, (float)current.z));
                        subMesh2.verts.Add(new Vector3((float)current.x, 0f, (float)current.z));
                        subMesh2.verts.Add(new Vector3((float)current.x, 0f, (float)((float)current.z + 0.5)));
                        subMesh2.verts.Add(new Vector3((float)current.x, 0f, (float)(current.z + 1)));
                        subMesh2.verts.Add(new Vector3((float)((float)current.x + 0.5), 0f, (float)(current.z + 1)));
                        subMesh2.verts.Add(new Vector3((float)(current.x + 1), 0f, (float)(current.z + 1)));
                        subMesh2.verts.Add(new Vector3((float)(current.x + 1), 0f, (float)((float)current.z + 0.5)));
                        subMesh2.verts.Add(new Vector3((float)(current.x + 1), 0f, (float)current.z));
                        subMesh2.verts.Add(new Vector3((float)((float)current.x + 0.5), 0f, (float)((float)current.z + 0.5)));
                        for (int j = 0; j < 8; j++)
                        {
                            array2[j] = false;
                        }
                        for (int k = 0; k < 8; k++)
                        {
                            if (k % 2 == 0)
                            {
                                if (array[k] == item2)
                                {
                                    array2[(k - 1 + 8) % 8] = true;
                                    array2[k]           = true;
                                    array2[(k + 1) % 8] = true;
                                }
                            }
                            else if (array[k] == item2)
                            {
                                array2[k] = true;
                            }
                        }
                        for (int l = 0; l < 8; l++)
                        {
                            if (array2[l])
                            {
                                subMesh2.colors.Add(SectionLayer_Terrain.ColorWhite);
                            }
                            else
                            {
                                subMesh2.colors.Add(SectionLayer_Terrain.ColorClear);
                            }
                        }
                        subMesh2.colors.Add(SectionLayer_Terrain.ColorClear);
                        for (int m = 0; m < 8; m++)
                        {
                            subMesh2.tris.Add(count + m);
                            subMesh2.tris.Add(count + (m + 1) % 8);
                            subMesh2.tris.Add(count + 8);
                        }
                    }
                }
            }
            base.FinalizeMesh(MeshParts.All);
        }
Exemple #3
0
 public virtual Material GetMaterialFor(TerrainDef terrain)
 {
     return(terrain.DrawMatSingle);
 }
Exemple #4
0
 public override Material GetMaterialFor(TerrainDef terrain)
 {
     return(terrain.waterDepthMaterial);
 }
            internal ushort <> m__0(IntVec3 c)
            {
                TerrainDef terrainDef = this.grid[this.$this.map.cellIndices.CellToIndex(c)];

                return((terrainDef == null) ? 0 : terrainDef.shortHash);
            }
Exemple #6
0
        public void MouseoverReadoutOnGUI()
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (Find.MainTabsRoot.OpenTab != null)
            {
                return;
            }
            GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
            Text.Font = GameFont.Small;
            GUI.color = new Color(1f, 1f, 1f, 0.8f);
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.VisibleMap))
            {
                return;
            }
            float num = 0f;
            Rect  rect;

            if (c.Fogged(Find.VisibleMap))
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, "Undiscovered".Translate());
                GUI.color = Color.white;
                return;
            }
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            int num2 = Mathf.RoundToInt(Find.VisibleMap.glowGrid.GameGlowAt(c, false) * 100f);

            Widgets.Label(rect, this.glowStrings[num2]);
            num += 19f;
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            TerrainDef terrain = c.GetTerrain(Find.VisibleMap);

            if (terrain != this.cachedTerrain)
            {
                string str = ((double)terrain.fertility <= 0.0001) ? string.Empty : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent());
                this.cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)terrain.pathCost)
                }) + str + ")"));
                this.cachedTerrain = terrain;
            }
            Widgets.Label(rect, this.cachedTerrainString);
            num += 19f;
            Zone zone = c.GetZone(Find.VisibleMap);

            if (zone != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                string label = zone.label;
                Widgets.Label(rect, label);
                num += 19f;
            }
            float depth = Find.VisibleMap.snowGrid.GetDepth(c);

            if (depth > 0.03f)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))
                }) + ")";
                Widgets.Label(rect, label2);
                num += 19f;
            }
            List <Thing> thingList = c.GetThingList(Find.VisibleMap);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing = thingList[i];
                if (thing.def.category != ThingCategory.Mote)
                {
                    rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                    string labelMouseover = thing.LabelMouseover;
                    Widgets.Label(rect, labelMouseover);
                    num += 19f;
                }
            }
            RoofDef roof = c.GetRoof(Find.VisibleMap);

            if (roof != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, roof.LabelCap);
                num += 19f;
            }
            GUI.color = Color.white;
        }
Exemple #7
0
 public void MouseoverReadoutOnGUI()
 {
     if (Event.current.type == EventType.Repaint && Find.MainTabsRoot.OpenTab == null)
     {
         GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
         Text.Font = GameFont.Small;
         GUI.color = new Color(1f, 1f, 1f, 0.8f);
         IntVec3 c = UI.MouseCell();
         if (c.InBounds(Find.CurrentMap))
         {
             float num  = 0f;
             Rect  rect = default(Rect);
             if (c.Fogged(Find.CurrentMap))
             {
                 Vector2 botLeft  = BotLeft;
                 float   x        = botLeft.x;
                 float   num2     = (float)UI.screenHeight;
                 Vector2 botLeft2 = BotLeft;
                 rect = new Rect(x, num2 - botLeft2.y - num, 999f, 999f);
                 Widgets.Label(rect, "Undiscovered".Translate());
                 GUI.color = Color.white;
             }
             else
             {
                 Vector2 botLeft3 = BotLeft;
                 float   x2       = botLeft3.x;
                 float   num3     = (float)UI.screenHeight;
                 Vector2 botLeft4 = BotLeft;
                 rect = new Rect(x2, num3 - botLeft4.y - num, 999f, 999f);
                 int num4 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);
                 Widgets.Label(rect, glowStrings[num4]);
                 num += 19f;
                 Vector2 botLeft5 = BotLeft;
                 float   x3       = botLeft5.x;
                 float   num5     = (float)UI.screenHeight;
                 Vector2 botLeft6 = BotLeft;
                 rect = new Rect(x3, num5 - botLeft6.y - num, 999f, 999f);
                 TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                 if (terrain != cachedTerrain)
                 {
                     string str = (!((double)terrain.fertility > 0.0001)) ? string.Empty : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent());
                     cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(SpeedPercentString((float)terrain.pathCost)) + str + ")"));
                     cachedTerrain       = terrain;
                 }
                 Widgets.Label(rect, cachedTerrainString);
                 num += 19f;
                 Zone zone = c.GetZone(Find.CurrentMap);
                 if (zone != null)
                 {
                     Vector2 botLeft7 = BotLeft;
                     float   x4       = botLeft7.x;
                     float   num6     = (float)UI.screenHeight;
                     Vector2 botLeft8 = BotLeft;
                     rect = new Rect(x4, num6 - botLeft8.y - num, 999f, 999f);
                     string label = zone.label;
                     Widgets.Label(rect, label);
                     num += 19f;
                 }
                 float depth = Find.CurrentMap.snowGrid.GetDepth(c);
                 if (depth > 0.03f)
                 {
                     Vector2 botLeft9  = BotLeft;
                     float   x5        = botLeft9.x;
                     float   num7      = (float)UI.screenHeight;
                     Vector2 botLeft10 = BotLeft;
                     rect = new Rect(x5, num7 - botLeft10.y - num, 999f, 999f);
                     SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                     string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))) + ")";
                     Widgets.Label(rect, label2);
                     num += 19f;
                 }
                 List <Thing> thingList = c.GetThingList(Find.CurrentMap);
                 for (int i = 0; i < thingList.Count; i++)
                 {
                     Thing thing = thingList[i];
                     if (thing.def.category != ThingCategory.Mote)
                     {
                         Vector2 botLeft11 = BotLeft;
                         float   x6        = botLeft11.x;
                         float   num8      = (float)UI.screenHeight;
                         Vector2 botLeft12 = BotLeft;
                         rect = new Rect(x6, num8 - botLeft12.y - num, 999f, 999f);
                         string labelMouseover = thing.LabelMouseover;
                         Widgets.Label(rect, labelMouseover);
                         num += 19f;
                     }
                 }
                 RoofDef roof = c.GetRoof(Find.CurrentMap);
                 if (roof != null)
                 {
                     Vector2 botLeft13 = BotLeft;
                     float   x7        = botLeft13.x;
                     float   num9      = (float)UI.screenHeight;
                     Vector2 botLeft14 = BotLeft;
                     rect = new Rect(x7, num9 - botLeft14.y - num, 999f, 999f);
                     Widgets.Label(rect, roof.LabelCap);
                     num += 19f;
                 }
                 GUI.color = Color.white;
             }
         }
     }
 }