public void OnReset(object data = null)
 {
     lerpers                   = new TextureLerper[12];
     texturePagePool           = new TexturePagePool();
     textureBuffers            = new TextureBuffer[12];
     externallyUpdatedTextures = new Texture2D[12];
     for (int i = 0; i < 12; i++)
     {
         TextureProperties textureProperties = default(TextureProperties);
         textureProperties.textureFormat = TextureFormat.Alpha8;
         textureProperties.filterMode    = FilterMode.Bilinear;
         textureProperties.blend         = false;
         textureProperties.blendSpeed    = 1f;
         TextureProperties item = textureProperties;
         for (int j = 0; j < this.textureProperties.Length; j++)
         {
             if (i == (int)this.textureProperties[j].simProperty)
             {
                 item = this.textureProperties[j];
             }
         }
         Property property = (Property)i;
         item.name = property.ToString();
         if ((UnityEngine.Object)externallyUpdatedTextures[i] != (UnityEngine.Object)null)
         {
             UnityEngine.Object.Destroy(externallyUpdatedTextures[i]);
             externallyUpdatedTextures[i] = null;
         }
         Texture texture;
         if (item.updatedExternally)
         {
             externallyUpdatedTextures[i] = new Texture2D(Grid.WidthInCells, Grid.HeightInCells, TextureUtil.TextureFormatToGraphicsFormat(item.textureFormat), TextureCreationFlags.None);
             texture = externallyUpdatedTextures[i];
         }
         else
         {
             TextureBuffer[] array     = textureBuffers;
             int             num       = i;
             Property        property2 = (Property)i;
             array[num] = new TextureBuffer(property2.ToString(), Grid.WidthInCells, Grid.HeightInCells, item.textureFormat, item.filterMode, texturePagePool);
             texture    = textureBuffers[i].texture;
         }
         if (item.blend)
         {
             TextureLerper[] array2         = lerpers;
             int             num2           = i;
             Texture         target_texture = texture;
             Property        property3      = (Property)i;
             array2[num2]     = new TextureLerper(target_texture, property3.ToString(), texture.filterMode, item.textureFormat);
             lerpers[i].Speed = item.blendSpeed;
         }
         Shader.SetGlobalTexture(item.texturePropertyName = (texture.name = GetShaderPropertyName((Property)i)), texture);
         allTextureProperties.Add(item);
     }
 }
 private void OnShadersReloaded()
 {
     for (int i = 0; i < 12; i++)
     {
         TextureLerper textureLerper = lerpers[i];
         if (textureLerper != null)
         {
             TextureProperties textureProperties = allTextureProperties[i];
             Shader.SetGlobalTexture(textureProperties.texturePropertyName, textureLerper.Update());
         }
     }
 }
 private void LateUpdate()
 {
     if (Grid.IsInitialized())
     {
         Shader.SetGlobalVector(WorldSizeID, new Vector4((float)Grid.WidthInCells, (float)Grid.HeightInCells, 1f / (float)Grid.WidthInCells, 1f / (float)Grid.HeightInCells));
         Shader.SetGlobalVector(PropTexWsToCsID, new Vector4(0f, 0f, 1f, 1f));
         Shader.SetGlobalVector(PropTexCsToWsID, new Vector4(0f, 0f, 1f, 1f));
         Shader.SetGlobalFloat(TopBorderHeightID, (float)Grid.TopBorderHeight);
         GetVisibleCellRange(out int x, out int y, out int x2, out int y2);
         Shader.SetGlobalFloat(FogOfWarScaleID, FogOfWarScale);
         int num = NextPropertyIdx++ % allTextureProperties.Count;
         TextureProperties textureProperties = allTextureProperties[num];
         while (textureProperties.updateEveryFrame)
         {
             num = NextPropertyIdx++ % allTextureProperties.Count;
             textureProperties = allTextureProperties[num];
         }
         for (int i = 0; i < allTextureProperties.Count; i++)
         {
             TextureProperties p = allTextureProperties[i];
             if (num == i || p.updateEveryFrame || GameUtil.IsCapturingTimeLapse())
             {
                 UpdateProperty(ref p, x, y, x2, y2);
             }
         }
         for (int j = 0; j < 12; j++)
         {
             TextureLerper textureLerper = lerpers[j];
             if (textureLerper != null)
             {
                 if (Time.timeScale == 0f)
                 {
                     textureLerper.LongUpdate(Time.unscaledDeltaTime);
                 }
                 TextureProperties textureProperties2 = allTextureProperties[j];
                 Shader.SetGlobalTexture(textureProperties2.texturePropertyName, textureLerper.Update());
             }
         }
     }
 }