コード例 #1
0
 public void OnShadersReloaded()
 {
     FreeMaterials();
     foreach (Element element in ElementLoader.elements)
     {
         if (element.IsSolid)
         {
             if ((UnityEngine.Object)element.substance.material == (UnityEngine.Object)null)
             {
                 DebugUtil.LogErrorArgs(element.name, "must have material associated with it in the substance table");
             }
             Material material = new Material(element.substance.material);
             InitOpaqueMaterial(material, element);
             Material material2 = new Material(material);
             InitAlphaMaterial(material2, element);
             Materials value = new Materials(material, material2);
             elementMaterials[element.id] = value;
         }
     }
     if (worldChunks != null)
     {
         for (int i = 0; i < dirtyChunks.GetLength(1); i++)
         {
             for (int j = 0; j < dirtyChunks.GetLength(0); j++)
             {
                 dirtyChunks[j, i] = true;
             }
         }
         WorldChunk[,] array = worldChunks;
         int length  = array.GetLength(0);
         int length2 = array.GetLength(1);
         for (int k = 0; k < length; k++)
         {
             for (int l = 0; l < length2; l++)
             {
                 WorldChunk worldChunk = array[k, l];
                 worldChunk.Clear();
                 worldChunk.Rebuild(biomeMasks, elementMaterials);
             }
         }
     }
 }
コード例 #2
0
 public void Render(Vector2I vis_min, Vector2I vis_max, bool forceVisibleRebuild = false)
 {
     if (base.enabled)
     {
         int      layer     = LayerMask.NameToLayer("World");
         Vector2I vector2I  = new Vector2I(vis_min.x / 16, vis_min.y / 16);
         Vector2I vector2I2 = new Vector2I((vis_max.x + 16 - 1) / 16, (vis_max.y + 16 - 1) / 16);
         for (int i = vector2I.y; i < vector2I2.y; i++)
         {
             for (int j = vector2I.x; j < vector2I2.x; j++)
             {
                 WorldChunk worldChunk = worldChunks[j, i];
                 if (dirtyChunks[j, i] || forceVisibleRebuild)
                 {
                     dirtyChunks[j, i] = false;
                     worldChunk.Rebuild(biomeMasks, elementMaterials);
                 }
                 worldChunk.Render(layer);
             }
         }
         RebuildDirtyChunks();
     }
 }