Exemple #1
0
 public void FreeResources()
 {
     UnityEngine.Object.DestroyImmediate(material);
     material  = null;
     atlasInfo = null;
     for (int i = 0; i < meshChunks.GetLength(0); i++)
     {
         for (int j = 0; j < meshChunks.GetLength(1); j++)
         {
             if ((UnityEngine.Object)meshChunks[i, j] != (UnityEngine.Object)null)
             {
                 UnityEngine.Object.DestroyImmediate(meshChunks[i, j]);
                 meshChunks[i, j] = null;
             }
         }
     }
     meshChunks      = null;
     decorRenderInfo = null;
     occupiedCells.Clear();
 }
Exemple #2
0
            public RenderInfo(BlockTileRenderer renderer, int queryLayer, int renderLayer, BuildingDef def, SimHashes element)
            {
                this.queryLayer  = queryLayer;
                this.renderLayer = renderLayer;
                rootPosition     = new Vector3(0f, 0f, Grid.GetLayerZ(def.SceneLayer));
                this.element     = element;
                material         = new Material(def.BlockTileMaterial);
                if (def.BlockTileIsTransparent)
                {
                    material.renderQueue = RenderQueues.Liquid;
                    decorZOffset         = Grid.GetLayerZ(Grid.SceneLayer.TileFront) - Grid.GetLayerZ(Grid.SceneLayer.Liquid) - 1f;
                }
                else if (def.SceneLayer == Grid.SceneLayer.TileMain)
                {
                    material.renderQueue = RenderQueues.BlockTiles;
                }
                material.DisableKeyword("ENABLE_SHINE");
                if (element != SimHashes.Void)
                {
                    material.SetTexture("_MainTex", def.BlockTileAtlas.texture);
                    material.name = def.BlockTileAtlas.name + "Mat";
                    if ((UnityEngine.Object)def.BlockTileShineAtlas != (UnityEngine.Object)null)
                    {
                        material.SetTexture("_SpecularTex", def.BlockTileShineAtlas.texture);
                        material.EnableKeyword("ENABLE_SHINE");
                    }
                }
                else
                {
                    material.SetTexture("_MainTex", def.BlockTilePlaceAtlas.texture);
                    material.name = def.BlockTilePlaceAtlas.name + "Mat";
                }
                int num  = Grid.WidthInCells / 16;
                int num2 = Grid.HeightInCells / 16;

                meshChunks  = new Mesh[num, num2];
                dirtyChunks = new bool[num, num2];
                for (int i = 0; i < num2; i++)
                {
                    for (int j = 0; j < num; j++)
                    {
                        dirtyChunks[j, i] = true;
                    }
                }
                BlockTileDecorInfo blockTileDecorInfo = (element != SimHashes.Void) ? def.DecorBlockTileInfo : def.DecorPlaceBlockTileInfo;

                if ((bool)blockTileDecorInfo)
                {
                    decorRenderInfo = new DecorRenderInfo(num, num2, queryLayer, def, blockTileDecorInfo);
                }
                string name       = def.BlockTileAtlas.items[0].name;
                int    length     = name.Length;
                int    num3       = length -= 4;
                int    num4       = num3 - 8;
                int    num5       = num4 - 1;
                int    startIndex = num5 - 8;

                atlasInfo = new AtlasInfo[def.BlockTileAtlas.items.Length];
                for (int k = 0; k < atlasInfo.Length; k++)
                {
                    TextureAtlas.Item item   = def.BlockTileAtlas.items[k];
                    string            value  = item.name.Substring(startIndex, 8);
                    string            value2 = item.name.Substring(num4, 8);
                    int requiredConnections  = Convert.ToInt32(value, 2);
                    int forbiddenConnections = Convert.ToInt32(value2, 2);
                    atlasInfo[k].requiredConnections  = (Bits)requiredConnections;
                    atlasInfo[k].forbiddenConnections = (Bits)forbiddenConnections;
                    atlasInfo[k].uvBox = item.uvBox;
                    atlasInfo[k].name  = item.name;
                }
                trimUVSize = new Vector2(0.03125f, 0.03125f);
            }