Skip to content

Commit

Permalink
Fix completely black map
Browse files Browse the repository at this point in the history
  • Loading branch information
msuddaby committed Jun 5, 2023
1 parent df29201 commit 875a1c1
Show file tree
Hide file tree
Showing 2 changed files with 1,679 additions and 395 deletions.
10 changes: 7 additions & 3 deletions WebMap/WebMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
using HarmonyLib;
using static ZRoutedRpc;

namespace WebMap {
namespace WebMap
{
//This attribute is required, and lists metadata for your plugin.
//The GUID should be a unique ID for this plugin, which is human readable (as it is used in places like the config). I like to use the java package notation, which is "com.[your name here].[your plugin name here]"
//The name is the name of the plugin that's displayed on load, and the version number just specifies what version the plugin is.
Expand Down Expand Up @@ -54,7 +55,7 @@ public void Awake() {
try {
var fogTexture = new Texture2D(WebMapConfig.TEXTURE_SIZE, WebMapConfig.TEXTURE_SIZE);
var fogBytes = File.ReadAllBytes(fogImagePath);
fogTexture.LoadImage(fogBytes);
fogTexture.LoadImage(fogBytes, true);
mapDataServer.fogTexture = fogTexture;
} catch (Exception e) {
Debug.Log("WebMap: Failed to read fog image data from disk... Making new fog image..." + e.Message);
Expand All @@ -65,6 +66,7 @@ public void Awake() {
}
fogTexture.SetPixels32(fogColors);
var fogPngBytes = fogTexture.EncodeToPNG();


mapDataServer.fogTexture = fogTexture;
try {
Expand Down Expand Up @@ -235,6 +237,8 @@ static void Postfix(ZoneSystem __instance) {
}
Debug.Log("WebMap: BUILD MAP!");

var c = Color.black;

int num = WebMapConfig.TEXTURE_SIZE / 2;
float num2 = WebMapConfig.PIXEL_SIZE / 2f;
Color32[] colorArray = new Color32[WebMapConfig.TEXTURE_SIZE * WebMapConfig.TEXTURE_SIZE];
Expand All @@ -245,7 +249,7 @@ static void Postfix(ZoneSystem __instance) {
float wx = (float)(j - num) * WebMapConfig.PIXEL_SIZE + num2;
float wy = (float)(i - num) * WebMapConfig.PIXEL_SIZE + num2;
Heightmap.Biome biome = WorldGenerator.instance.GetBiome(wx, wy);
float biomeHeight = WorldGenerator.instance.GetBiomeHeight(biome, wx, wy);
float biomeHeight = WorldGenerator.instance.GetBiomeHeight(biome, wx, wy, out c);
colorArray[i * WebMapConfig.TEXTURE_SIZE + j] = GetPixelColor(biome);
treeMaskArray[i * WebMapConfig.TEXTURE_SIZE + j] = GetMaskColor(wx, wy, biomeHeight, biome);
heightArray[i * WebMapConfig.TEXTURE_SIZE + j] = biomeHeight;
Expand Down
Loading

0 comments on commit 875a1c1

Please sign in to comment.