D:\ValheimDev\Dumps\Old\assembly_valheim\ZoneSystem.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\ZoneSystem.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using SoftReferenceableAssets; using SoftReferenceableAssets;
using UnityEngine; using UnityEngine;
   
public class ZoneSystem : MonoBehaviour public class ZoneSystem : MonoBehaviour
{ {
    public static ZoneSystem instance     public static ZoneSystem instance
    {     {
        get         get
        {         {
            return ZoneSystem.m_instance;             return ZoneSystem.m_instance;
        }         }
    }     }
   
.      private ZoneSystem()
      {
      }
   
    private void Awake()     private void Awake()
    {     {
        ZoneSystem.m_instance = this;         ZoneSystem.m_instance = this;
        this.m_terrainRayMask = LayerMask.GetMask(new string[] { "terrain" });         this.m_terrainRayMask = LayerMask.GetMask(new string[] { "terrain" });
        this.m_blockRayMask = LayerMask.GetMask(new string[] { "Default", "static_solid", "Default_small", "piece" });         this.m_blockRayMask = LayerMask.GetMask(new string[] { "Default", "static_solid", "Default_small", "piece" });
        this.m_solidRayMask = LayerMask.GetMask(new string[] { "Default", "static_solid", "Default_small", "piece", "terrain" });         this.m_solidRayMask = LayerMask.GetMask(new string[] { "Default", "static_solid", "Default_small", "piece", "terrain" });
        this.m_staticSolidRayMask = LayerMask.GetMask(new string[] { "static_solid", "terrain" });         this.m_staticSolidRayMask = LayerMask.GetMask(new string[] { "static_solid", "terrain" });
        foreach (GameObject gameObject in this.m_locationLists)         foreach (GameObject gameObject in this.m_locationLists)
        {         {
            UnityEngine.Object.Instantiate<GameObject>(gameObject);             UnityEngine.Object.Instantiate<GameObject>(gameObject);
        }         }
        ZLog.Log("Zonesystem Awake " + Time.frameCount.ToString());         ZLog.Log("Zonesystem Awake " + Time.frameCount.ToString());
    }     }
   
    private void Start()     private void Start()
    {     {
        ZLog.Log("Zonesystem Start " + Time.frameCount.ToString());         ZLog.Log("Zonesystem Start " + Time.frameCount.ToString());
        this.UpdateWorldRates();         this.UpdateWorldRates();
        this.SetupLocations();         this.SetupLocations();
        this.ValidateVegetation();         this.ValidateVegetation();
        ZRoutedRpc instance = ZRoutedRpc.instance;         ZRoutedRpc instance = ZRoutedRpc.instance;
        instance.m_onNewPeer = (Action<long>)Delegate.Combine(instance.m_onNewPeer, new Action<long>(this.OnNewPeer));         instance.m_onNewPeer = (Action<long>)Delegate.Combine(instance.m_onNewPeer, new Action<long>(this.OnNewPeer));
        if (ZNet.instance.IsServer())         if (ZNet.instance.IsServer())
        {         {
            ZRoutedRpc.instance.Register<string>("SetGlobalKey", new Action<long, string>(this.RPC_SetGlobalKey));             ZRoutedRpc.instance.Register<string>("SetGlobalKey", new Action<long, string>(this.RPC_SetGlobalKey));
            ZRoutedRpc.instance.Register<string>("RemoveGlobalKey", new Action<long, string>(this.RPC_RemoveGlobalKey));             ZRoutedRpc.instance.Register<string>("RemoveGlobalKey", new Action<long, string>(this.RPC_RemoveGlobalKey));
        }         }
        else         else
        {         {
            ZRoutedRpc.instance.Register<List<string>>("GlobalKeys", new Action<long, List<string>>(this.RPC_GlobalKeys));             ZRoutedRpc.instance.Register<List<string>>("GlobalKeys", new Action<long, List<string>>(this.RPC_GlobalKeys));
            ZRoutedRpc.instance.Register<ZPackage>("LocationIcons", new Action<long, ZPackage>(this.RPC_LocationIcons));             ZRoutedRpc.instance.Register<ZPackage>("LocationIcons", new Action<long, ZPackage>(this.RPC_LocationIcons));
        }         }
        this.m_startTime = (this.m_lastFixedTime = Time.fixedTime);         this.m_startTime = (this.m_lastFixedTime = Time.fixedTime);
    }     }
   
    public void GenerateLocationsIfNeeded()     public void GenerateLocationsIfNeeded()
    {     {
        if (!this.m_locationsGenerated)         if (!this.m_locationsGenerated)
        {         {
            this.GenerateLocations();             this.GenerateLocations();
        }         }
    }     }
   
    private void SendGlobalKeys(long peer)     private void SendGlobalKeys(long peer)
    {     {
        List<string> list = new List<string>(this.m_globalKeys);         List<string> list = new List<string>(this.m_globalKeys);
        ZRoutedRpc.instance.InvokeRoutedRPC(peer, "GlobalKeys", new object[] { list });         ZRoutedRpc.instance.InvokeRoutedRPC(peer, "GlobalKeys", new object[] { list });
        Player localPlayer = Player.m_localPlayer;         Player localPlayer = Player.m_localPlayer;
        if (localPlayer == null)         if (localPlayer == null)
        {         {
            return;             return;
        }         }
        localPlayer.UpdateEvents();         localPlayer.UpdateEvents();
    }     }
   
    private void RPC_GlobalKeys(long sender, List<string> keys)     private void RPC_GlobalKeys(long sender, List<string> keys)
    {     {
        ZLog.Log("client got keys " + keys.Count.ToString());         ZLog.Log("client got keys " + keys.Count.ToString());
        this.ClearGlobalKeys();         this.ClearGlobalKeys();
        foreach (string text in keys)         foreach (string text in keys)
        {         {
            this.GlobalKeyAdd(text, true);             this.GlobalKeyAdd(text, true);
        }         }
    }     }
   
    private void GlobalKeyAdd(string keyStr, bool canSaveToServerOptionKeys = true)     private void GlobalKeyAdd(string keyStr, bool canSaveToServerOptionKeys = true)
    {     {
        string text;         string text;
        GlobalKeys globalKeys;         GlobalKeys globalKeys;
        string keyValue = ZoneSystem.GetKeyValue(keyStr.ToLower(), out text, out globalKeys);         string keyValue = ZoneSystem.GetKeyValue(keyStr.ToLower(), out text, out globalKeys);
        bool flag = canSaveToServerOptionKeys && ZNet.World != null && globalKeys < GlobalKeys.NonServerOption;         bool flag = canSaveToServerOptionKeys && ZNet.World != null && globalKeys < GlobalKeys.NonServerOption;
        string text2;         string text2;
        if (this.m_globalKeysValues.TryGetValue(keyValue, out text2))         if (this.m_globalKeysValues.TryGetValue(keyValue, out text2))
        {         {
            string text3 = (keyValue + " " + text2).TrimEnd();             string text3 = (keyValue + " " + text2).TrimEnd();
            this.m_globalKeys.Remove(text3);             this.m_globalKeys.Remove(text3);
            if (flag)             if (flag)
            {             {
                ZNet.World.m_startingGlobalKeys.Remove(text3);                 ZNet.World.m_startingGlobalKeys.Remove(text3);
            }             }
        }         }
        string text4 = (keyValue + " " + text).TrimEnd();         string text4 = (keyValue + " " + text).TrimEnd();
        this.m_globalKeys.Add(text4);         this.m_globalKeys.Add(text4);
        this.m_globalKeysValues[keyValue] = text;         this.m_globalKeysValues[keyValue] = text;
        if (globalKeys != GlobalKeys.NonServerOption)         if (globalKeys != GlobalKeys.NonServerOption)
        {         {
            this.m_globalKeysEnums.Add(globalKeys);             this.m_globalKeysEnums.Add(globalKeys);
        }         }
        Game.instance.GetPlayerProfile().m_knownWorldKeys.IncrementOrSet(text4, 1f);         Game.instance.GetPlayerProfile().m_knownWorldKeys.IncrementOrSet(text4, 1f);
        if (flag)         if (flag)
        {         {
            ZNet.World.m_startingGlobalKeys.Add(keyStr.ToLower());             ZNet.World.m_startingGlobalKeys.Add(keyStr.ToLower());
        }         }
        this.UpdateWorldRates();         this.UpdateWorldRates();
    }     }
   
    private bool GlobalKeyRemove(string keyStr, bool canSaveToServerOptionKeys = true)     private bool GlobalKeyRemove(string keyStr, bool canSaveToServerOptionKeys = true)
    {     {
        string text;         string text;
        GlobalKeys globalKeys;         GlobalKeys globalKeys;
        string keyValue = ZoneSystem.GetKeyValue(keyStr, out text, out globalKeys);         string keyValue = ZoneSystem.GetKeyValue(keyStr, out text, out globalKeys);
        string text2;         string text2;
        if (this.m_globalKeysValues.TryGetValue(keyValue, out text2))         if (this.m_globalKeysValues.TryGetValue(keyValue, out text2))
        {         {
            string text3 = (keyValue + " " + text2).TrimEnd();             string text3 = (keyValue + " " + text2).TrimEnd();
            if (canSaveToServerOptionKeys && ZNet.World != null && globalKeys < GlobalKeys.NonServerOption)             if (canSaveToServerOptionKeys && ZNet.World != null && globalKeys < GlobalKeys.NonServerOption)
            {             {
                ZNet.World.m_startingGlobalKeys.Remove(text3);                 ZNet.World.m_startingGlobalKeys.Remove(text3);
            }             }
            this.m_globalKeys.Remove(text3);             this.m_globalKeys.Remove(text3);
            this.m_globalKeysValues.Remove(keyValue);             this.m_globalKeysValues.Remove(keyValue);
            if (globalKeys != GlobalKeys.NonServerOption)             if (globalKeys != GlobalKeys.NonServerOption)
            {             {
                this.m_globalKeysEnums.Remove(globalKeys);                 this.m_globalKeysEnums.Remove(globalKeys);
            }             }
            this.UpdateWorldRates();             this.UpdateWorldRates();
            return true;             return true;
        }         }
        return false;         return false;
    }     }
   
    public void UpdateWorldRates()     public void UpdateWorldRates()
    {     {
        Game.UpdateWorldRates(this.m_globalKeys, this.m_globalKeysValues);         Game.UpdateWorldRates(this.m_globalKeys, this.m_globalKeysValues);
    }     }
   
    public void Reset()     public void Reset()
    {     {
        this.ClearGlobalKeys();         this.ClearGlobalKeys();
        this.UpdateWorldRates();         this.UpdateWorldRates();
    }     }
   
    private void ClearGlobalKeys()     private void ClearGlobalKeys()
    {     {
        this.m_globalKeys.Clear();         this.m_globalKeys.Clear();
        this.m_globalKeysEnums.Clear();         this.m_globalKeysEnums.Clear();
        this.m_globalKeysValues.Clear();         this.m_globalKeysValues.Clear();
    }     }
   
    public static string GetKeyValue(string key, out string value, out GlobalKeys gk)     public static string GetKeyValue(string key, out string value, out GlobalKeys gk)
    {     {
        int num = key.IndexOf(' ');         int num = key.IndexOf(' ');
        value = "";         value = "";
        string text;         string text;
        if (num > 0)         if (num > 0)
        {         {
            value = key.Substring(num + 1);             value = key.Substring(num + 1);
            text = key.Substring(0, num).ToLower();             text = key.Substring(0, num).ToLower();
        }         }
        else         else
        {         {
            text = key.ToLower();             text = key.ToLower();
        }         }
        if (!Enum.TryParse<GlobalKeys>(text, true, out gk))         if (!Enum.TryParse<GlobalKeys>(text, true, out gk))
        {         {
            gk = GlobalKeys.NonServerOption;             gk = GlobalKeys.NonServerOption;
        }         }
        return text;         return text;
    }     }
   
    private void SendLocationIcons(long peer)     private void SendLocationIcons(long peer)
    {     {
        ZPackage zpackage = new ZPackage();         ZPackage zpackage = new ZPackage();
        this.tempIconList.Clear();         this.tempIconList.Clear();
        this.GetLocationIcons(this.tempIconList);         this.GetLocationIcons(this.tempIconList);
        zpackage.Write(this.tempIconList.Count);         zpackage.Write(this.tempIconList.Count);
        foreach (KeyValuePair<Vector3, string> keyValuePair in this.tempIconList)         foreach (KeyValuePair<Vector3, string> keyValuePair in this.tempIconList)
        {         {
            zpackage.Write(keyValuePair.Key);             zpackage.Write(keyValuePair.Key);
            zpackage.Write(keyValuePair.Value);             zpackage.Write(keyValuePair.Value);
        }         }
        ZRoutedRpc.instance.InvokeRoutedRPC(peer, "LocationIcons", new object[] { zpackage });         ZRoutedRpc.instance.InvokeRoutedRPC(peer, "LocationIcons", new object[] { zpackage });
    }     }
   
    private void RPC_LocationIcons(long sender, ZPackage pkg)     private void RPC_LocationIcons(long sender, ZPackage pkg)
    {     {
        ZLog.Log("client got location icons");         ZLog.Log("client got location icons");
        this.m_locationIcons.Clear();         this.m_locationIcons.Clear();
        int num = pkg.ReadInt();         int num = pkg.ReadInt();
        for (int i = 0; i < num; i++)         for (int i = 0; i < num; i++)
        {         {
            Vector3 vector = pkg.ReadVector3();             Vector3 vector = pkg.ReadVector3();
            string text = pkg.ReadString();             string text = pkg.ReadString();
            this.m_locationIcons[vector] = text;             this.m_locationIcons[vector] = text;
        }         }
        ZLog.Log("Icons:" + num.ToString());         ZLog.Log("Icons:" + num.ToString());
    }     }
   
    private void OnNewPeer(long peerID)     private void OnNewPeer(long peerID)
    {     {
        if (ZNet.instance.IsServer())         if (ZNet.instance.IsServer())
        {         {
            ZLog.Log("Server: New peer connected,sending global keys");             ZLog.Log("Server: New peer connected,sending global keys");
            this.SendGlobalKeys(peerID);             this.SendGlobalKeys(peerID);
            this.SendLocationIcons(peerID);             this.SendLocationIcons(peerID);
        }         }
    }     }
   
    private void SetupLocations()     private void SetupLocations()
    {     {
        List<LocationList> allLocationLists = LocationList.GetAllLocationLists();         List<LocationList> allLocationLists = LocationList.GetAllLocationLists();
        allLocationLists.Sort((LocationList a, LocationList b) => a.m_sortOrder.CompareTo(b.m_sortOrder));         allLocationLists.Sort((LocationList a, LocationList b) => a.m_sortOrder.CompareTo(b.m_sortOrder));
        foreach (LocationList locationList in allLocationLists)         foreach (LocationList locationList in allLocationLists)
        {         {
            this.m_locations.AddRange(locationList.m_locations);             this.m_locations.AddRange(locationList.m_locations);
            this.m_vegetation.AddRange(locationList.m_vegetation);             this.m_vegetation.AddRange(locationList.m_vegetation);
            foreach (EnvSetup envSetup in locationList.m_environments)             foreach (EnvSetup envSetup in locationList.m_environments)
            {             {
                EnvMan.instance.AppendEnvironment(envSetup);                 EnvMan.instance.AppendEnvironment(envSetup);
            }             }
            foreach (BiomeEnvSetup biomeEnvSetup in locationList.m_biomeEnvironments)             foreach (BiomeEnvSetup biomeEnvSetup in locationList.m_biomeEnvironments)
            {             {
                EnvMan.instance.AppendBiomeSetup(biomeEnvSetup);                 EnvMan.instance.AppendBiomeSetup(biomeEnvSetup);
            }             }
            ClutterSystem.instance.m_clutter.AddRange(locationList.m_clutter);             ClutterSystem.instance.m_clutter.AddRange(locationList.m_clutter);
            ZLog.Log(string.Format("Added {0} locations, {1} vegetations, {2} environments, {3} biome env-setups, {4} clutter  from ", new object[]             ZLog.Log(string.Format("Added {0} locations, {1} vegetations, {2} environments, {3} biome env-setups, {4} clutter  from ", new object[]
            {             {
                locationList.m_locations.Count,                 locationList.m_locations.Count,
                locationList.m_vegetation.Count,                 locationList.m_vegetation.Count,
                locationList.m_environments.Count,                 locationList.m_environments.Count,
                locationList.m_biomeEnvironments.Count,                 locationList.m_biomeEnvironments.Count,
                locationList.m_clutter.Count                 locationList.m_clutter.Count
            }) + locationList.gameObject.scene.name);             }) + locationList.gameObject.scene.name);
            RandEventSystem.instance.m_events.AddRange(locationList.m_events);             RandEventSystem.instance.m_events.AddRange(locationList.m_events);
        }         }
        foreach (ZoneSystem.ZoneLocation zoneLocation in this.m_locations)         foreach (ZoneSystem.ZoneLocation zoneLocation in this.m_locations)
        {         {
            if ((zoneLocation.m_enable || zoneLocation.m_prefab.IsValid) && Application.isPlaying)             if ((zoneLocation.m_enable || zoneLocation.m_prefab.IsValid) && Application.isPlaying)
            {             {
                zoneLocation.m_prefabName = zoneLocation.m_prefab.Name;                 zoneLocation.m_prefabName = zoneLocation.m_prefab.Name;
                int hash = zoneLocation.Hash;                 int hash = zoneLocation.Hash;
                if (!this.m_locationsByHash.ContainsKey(hash))                 if (!this.m_locationsByHash.ContainsKey(hash))
                {                 {
                    this.m_locationsByHash.Add(hash, zoneLocation);                     this.m_locationsByHash.Add(hash, zoneLocation);
                }                 }
            }             }
        }         }
        if (Settings.AssetMemoryUsagePolicy.HasFlag(AssetMemoryUsagePolicy.KeepAsynchronousLoadedBit))         if (Settings.AssetMemoryUsagePolicy.HasFlag(AssetMemoryUsagePolicy.KeepAsynchronousLoadedBit))
        {         {
            ReferenceHolder referenceHolder = base.gameObject.AddComponent<ReferenceHolder>();             ReferenceHolder referenceHolder = base.gameObject.AddComponent<ReferenceHolder>();
            foreach (ZoneSystem.ZoneLocation zoneLocation2 in this.m_locations)             foreach (ZoneSystem.ZoneLocation zoneLocation2 in this.m_locations)
            {             {
                if (zoneLocation2.m_enable)                 if (zoneLocation2.m_enable)
                {                 {
                    zoneLocation2.m_prefab.Load();                     zoneLocation2.m_prefab.Load();
                    referenceHolder.HoldReferenceTo(zoneLocation2.m_prefab);                     referenceHolder.HoldReferenceTo(zoneLocation2.m_prefab);
                    zoneLocation2.m_prefab.Release();                     zoneLocation2.m_prefab.Release();
                }                 }
            }             }
        }         }
    }     }
   
    public static void PrepareNetViews(GameObject root, List<ZNetView> views)     public static void PrepareNetViews(GameObject root, List<ZNetView> views)
    {     {
        views.Clear();         views.Clear();
        foreach (ZNetView znetView in root.GetComponentsInChildren<ZNetView>(true))         foreach (ZNetView znetView in root.GetComponentsInChildren<ZNetView>(true))
        {         {
.            if (Utils.IsEnabledInheirarcy(znetView.gameObject, root))             if (global::Utils.IsEnabledInheirarcy(znetView.gameObject, root))
            {             {
                views.Add(znetView);                 views.Add(znetView);
            }             }
        }         }
    }     }
   
    public static void PrepareRandomSpawns(GameObject root, List<RandomSpawn> randomSpawns)     public static void PrepareRandomSpawns(GameObject root, List<RandomSpawn> randomSpawns)
    {     {
        randomSpawns.Clear();         randomSpawns.Clear();
        foreach (RandomSpawn randomSpawn in root.GetComponentsInChildren<RandomSpawn>(true))         foreach (RandomSpawn randomSpawn in root.GetComponentsInChildren<RandomSpawn>(true))
        {         {
.            if (Utils.IsEnabledInheirarcy(randomSpawn.gameObject, root))             if (global::Utils.IsEnabledInheirarcy(randomSpawn.gameObject, root))
            {             {
                randomSpawns.Add(randomSpawn);                 randomSpawns.Add(randomSpawn);
                randomSpawn.Prepare();                 randomSpawn.Prepare();
            }             }
        }         }
    }     }
   
    private void OnDestroy()     private void OnDestroy()
    {     {
        this.ForceReleaseLoadedPrefabs();         this.ForceReleaseLoadedPrefabs();
        ZoneSystem.m_instance = null;         ZoneSystem.m_instance = null;
    }     }
   
    private void ValidateVegetation()     private void ValidateVegetation()
    {     {
        foreach (ZoneSystem.ZoneVegetation zoneVegetation in this.m_vegetation)         foreach (ZoneSystem.ZoneVegetation zoneVegetation in this.m_vegetation)
        {         {
            if (zoneVegetation.m_enable && zoneVegetation.m_prefab && zoneVegetation.m_prefab.GetComponent<ZNetView>() == null)             if (zoneVegetation.m_enable && zoneVegetation.m_prefab && zoneVegetation.m_prefab.GetComponent<ZNetView>() == null)
            {             {
                ZLog.LogError(string.Concat(new string[]                 ZLog.LogError(string.Concat(new string[]
                {                 {
                    "Vegetation ",                     "Vegetation ",
                    zoneVegetation.m_prefab.name,                     zoneVegetation.m_prefab.name,
                    " [ ",                     " [ ",
                    zoneVegetation.m_name,                     zoneVegetation.m_name,
                    "] is missing ZNetView"                      "] is missing ZNetView" 
                }));                 }));
            }             }
        }         }
    }     }
   
    public void PrepareSave()     public void PrepareSave()
    {     {
        this.m_tempGeneratedZonesSaveClone = new HashSet<Vector2i>(this.m_generatedZones);         this.m_tempGeneratedZonesSaveClone = new HashSet<Vector2i>(this.m_generatedZones);
        this.m_tempGlobalKeysSaveClone = new HashSet<string>(this.m_globalKeys);         this.m_tempGlobalKeysSaveClone = new HashSet<string>(this.m_globalKeys);
        this.m_tempLocationsSaveClone = new List<ZoneSystem.LocationInstance>(this.m_locationInstances.Values);         this.m_tempLocationsSaveClone = new List<ZoneSystem.LocationInstance>(this.m_locationInstances.Values);
        this.m_tempLocationsGeneratedSaveClone = this.m_locationsGenerated;         this.m_tempLocationsGeneratedSaveClone = this.m_locationsGenerated;
    }     }
   
    public void SaveASync(BinaryWriter writer)     public void SaveASync(BinaryWriter writer)
    {     {
        writer.Write(this.m_tempGeneratedZonesSaveClone.Count);         writer.Write(this.m_tempGeneratedZonesSaveClone.Count);
        foreach (Vector2i vector2i in this.m_tempGeneratedZonesSaveClone)         foreach (Vector2i vector2i in this.m_tempGeneratedZonesSaveClone)
        {         {
            writer.Write(vector2i.x);             writer.Write(vector2i.x);
            writer.Write(vector2i.y);             writer.Write(vector2i.y);
        }         }
        writer.Write(0);         writer.Write(0);
        writer.Write(this.m_locationVersion);         writer.Write(this.m_locationVersion);
        this.m_tempGlobalKeysSaveClone.RemoveWhere(delegate(string x)         this.m_tempGlobalKeysSaveClone.RemoveWhere(delegate(string x)
        {         {
            string text2;             string text2;
            GlobalKeys globalKeys;             GlobalKeys globalKeys;
            ZoneSystem.GetKeyValue(x, out text2, out globalKeys);             ZoneSystem.GetKeyValue(x, out text2, out globalKeys);
            return globalKeys < GlobalKeys.NonServerOption;             return globalKeys < GlobalKeys.NonServerOption;
        });         });
        writer.Write(this.m_tempGlobalKeysSaveClone.Count);         writer.Write(this.m_tempGlobalKeysSaveClone.Count);
        foreach (string text in this.m_tempGlobalKeysSaveClone)         foreach (string text in this.m_tempGlobalKeysSaveClone)
        {         {
            writer.Write(text);             writer.Write(text);
        }         }
        writer.Write(this.m_tempLocationsGeneratedSaveClone);         writer.Write(this.m_tempLocationsGeneratedSaveClone);
        writer.Write(this.m_tempLocationsSaveClone.Count);         writer.Write(this.m_tempLocationsSaveClone.Count);
        foreach (ZoneSystem.LocationInstance locationInstance in this.m_tempLocationsSaveClone)         foreach (ZoneSystem.LocationInstance locationInstance in this.m_tempLocationsSaveClone)
        {         {
            writer.Write(locationInstance.m_location.m_prefabName);             writer.Write(locationInstance.m_location.m_prefabName);
            writer.Write(locationInstance.m_position.x);             writer.Write(locationInstance.m_position.x);
            writer.Write(locationInstance.m_position.y);             writer.Write(locationInstance.m_position.y);
            writer.Write(locationInstance.m_position.z);             writer.Write(locationInstance.m_position.z);
            writer.Write(locationInstance.m_placed);             writer.Write(locationInstance.m_placed);
        }         }
        this.m_tempGeneratedZonesSaveClone.Clear();         this.m_tempGeneratedZonesSaveClone.Clear();
        this.m_tempGeneratedZonesSaveClone = null;         this.m_tempGeneratedZonesSaveClone = null;
        this.m_tempGlobalKeysSaveClone.Clear();         this.m_tempGlobalKeysSaveClone.Clear();
        this.m_tempGlobalKeysSaveClone = null;         this.m_tempGlobalKeysSaveClone = null;
        this.m_tempLocationsSaveClone.Clear();         this.m_tempLocationsSaveClone.Clear();
        this.m_tempLocationsSaveClone = null;         this.m_tempLocationsSaveClone = null;
    }     }
   
    public void Load(BinaryReader reader, int version)     public void Load(BinaryReader reader, int version)
    {     {
        this.m_generatedZones.Clear();         this.m_generatedZones.Clear();
        int num = reader.ReadInt32();         int num = reader.ReadInt32();
        for (int i = 0; i < num; i++)         for (int i = 0; i < num; i++)
        {         {
            Vector2i vector2i = default(Vector2i);             Vector2i vector2i = default(Vector2i);
            vector2i.x = reader.ReadInt32();             vector2i.x = reader.ReadInt32();
            vector2i.y = reader.ReadInt32();             vector2i.y = reader.ReadInt32();
            this.m_generatedZones.Add(vector2i);             this.m_generatedZones.Add(vector2i);
        }         }
        if (version >= 13)         if (version >= 13)
        {         {
            reader.ReadInt32();             reader.ReadInt32();
            int num2 = ((version >= 21) ? reader.ReadInt32() : 0);             int num2 = ((version >= 21) ? reader.ReadInt32() : 0);
            if (version >= 14)             if (version >= 14)
            {             {
                this.ClearGlobalKeys();                 this.ClearGlobalKeys();
                int num3 = reader.ReadInt32();                 int num3 = reader.ReadInt32();
                for (int j = 0; j < num3; j++)                 for (int j = 0; j < num3; j++)
                {                 {
                    string text = reader.ReadString();                     string text = reader.ReadString();
                    this.GlobalKeyAdd(text, true);                     this.GlobalKeyAdd(text, true);
                }                 }
            }             }
            if (version >= 18)             if (version >= 18)
            {             {
                if (version >= 20)                 if (version >= 20)
                {                 {
                    this.m_locationsGenerated = reader.ReadBoolean();                     this.m_locationsGenerated = reader.ReadBoolean();
                }                 }
                this.m_locationInstances.Clear();                 this.m_locationInstances.Clear();
                int num4 = reader.ReadInt32();                 int num4 = reader.ReadInt32();
                for (int k = 0; k < num4; k++)                 for (int k = 0; k < num4; k++)
                {                 {
                    string text2 = reader.ReadString();                     string text2 = reader.ReadString();
                    Vector3 zero = Vector3.zero;                     Vector3 zero = Vector3.zero;
                    zero.x = reader.ReadSingle();                     zero.x = reader.ReadSingle();
                    zero.y = reader.ReadSingle();                     zero.y = reader.ReadSingle();
                    zero.z = reader.ReadSingle();                     zero.z = reader.ReadSingle();
                    bool flag = false;                     bool flag = false;
                    if (version >= 19)                     if (version >= 19)
                    {                     {
                        flag = reader.ReadBoolean();                         flag = reader.ReadBoolean();
                    }                     }
                    ZoneSystem.ZoneLocation location = this.GetLocation(text2);                     ZoneSystem.ZoneLocation location = this.GetLocation(text2);
                    if (location != null)                     if (location != null)
                    {                     {
                        this.RegisterLocation(location, zero, flag);                         this.RegisterLocation(location, zero, flag);
                    }                     }
                    else                     else
                    {                     {
                        ZLog.DevLog("Failed to find location " + text2);                         ZLog.DevLog("Failed to find location " + text2);
                    }                     }
                }                 }
                ZLog.Log("Loaded " + num4.ToString() + " locations");                 ZLog.Log("Loaded " + num4.ToString() + " locations");
                if (num2 != this.m_locationVersion)                 if (num2 != this.m_locationVersion)
                {                 {
                    this.m_locationsGenerated = false;                     this.m_locationsGenerated = false;
                }                 }
            }             }
        }         }
    }     }
   
    private void Update()     private void Update()
    {     {
        this.m_lastFixedTime = Time.fixedTime;         this.m_lastFixedTime = Time.fixedTime;
        if (ZNet.GetConnectionStatus() != ZNet.ConnectionStatus.Connected)         if (ZNet.GetConnectionStatus() != ZNet.ConnectionStatus.Connected)
        {         {
            return;             return;
        }         }
        if (Terminal.m_showTests)         if (Terminal.m_showTests)
        {         {
            Terminal.m_testList["Time"] = Time.fixedTime.ToString("0.00") + " / " + this.TimeSinceStart().ToString("0.00");             Terminal.m_testList["Time"] = Time.fixedTime.ToString("0.00") + " / " + this.TimeSinceStart().ToString("0.00");
        }         }
        this.m_updateTimer += Time.deltaTime;         this.m_updateTimer += Time.deltaTime;
        if (this.m_updateTimer > 0.1f)         if (this.m_updateTimer > 0.1f)
        {         {
            this.m_updateTimer = 0f;             this.m_updateTimer = 0f;
            bool flag = this.CreateLocalZones(ZNet.instance.GetReferencePosition());             bool flag = this.CreateLocalZones(ZNet.instance.GetReferencePosition());
            this.UpdateTTL(0.1f);             this.UpdateTTL(0.1f);
            if (ZNet.instance.IsServer() && !flag)             if (ZNet.instance.IsServer() && !flag)
            {             {
                this.CreateGhostZones(ZNet.instance.GetReferencePosition());                 this.CreateGhostZones(ZNet.instance.GetReferencePosition());
                foreach (ZNetPeer znetPeer in ZNet.instance.GetPeers())                 foreach (ZNetPeer znetPeer in ZNet.instance.GetPeers())
                {                 {
                    this.CreateGhostZones(znetPeer.GetRefPos());                     this.CreateGhostZones(znetPeer.GetRefPos());
                }                 }
            }             }
            this.UpdatePrefabLifetimes();             this.UpdatePrefabLifetimes();
        }         }
    }     }
   
    private void UpdatePrefabLifetimes()     private void UpdatePrefabLifetimes()
    {     {
        for (int i = 0; i < this.m_locationPrefabs.Count; i++)         for (int i = 0; i < this.m_locationPrefabs.Count; i++)
        {         {
            this.m_locationPrefabs[i].m_iterationLifetime--;             this.m_locationPrefabs[i].m_iterationLifetime--;
            if (this.m_locationPrefabs[i].m_iterationLifetime <= 0)             if (this.m_locationPrefabs[i].m_iterationLifetime <= 0)
            {             {
                this.m_tempLocationPrefabsToRelease.Add(i);                 this.m_tempLocationPrefabsToRelease.Add(i);
            }             }
        }         }
        for (int j = this.m_tempLocationPrefabsToRelease.Count - 1; j >= 0; j--)         for (int j = this.m_tempLocationPrefabsToRelease.Count - 1; j >= 0; j--)
        {         {
            int num = this.m_tempLocationPrefabsToRelease[j];             int num = this.m_tempLocationPrefabsToRelease[j];
            this.m_locationPrefabs[num].Release();             this.m_locationPrefabs[num].Release();
            this.m_locationPrefabs.RemoveAt(num);             this.m_locationPrefabs.RemoveAt(num);
        }         }
        this.m_tempLocationPrefabsToRelease.Clear();         this.m_tempLocationPrefabsToRelease.Clear();
    }     }
   
    private void ForceReleaseLoadedPrefabs()     private void ForceReleaseLoadedPrefabs()
    {     {
        foreach (ZoneSystem.LocationPrefabLoadData locationPrefabLoadData in this.m_locationPrefabs)         foreach (ZoneSystem.LocationPrefabLoadData locationPrefabLoadData in this.m_locationPrefabs)
        {         {
            locationPrefabLoadData.Release();             locationPrefabLoadData.Release();
        }         }
        this.m_locationPrefabs.Clear();         this.m_locationPrefabs.Clear();
    }     }
   
    private bool CreateGhostZones(Vector3 refPoint)     private bool CreateGhostZones(Vector3 refPoint)
    {     {
        Vector2i zone = this.GetZone(refPoint);         Vector2i zone = this.GetZone(refPoint);
        GameObject gameObject;         GameObject gameObject;
        if (!this.IsZoneGenerated(zone) && this.SpawnZone(zone, ZoneSystem.SpawnMode.Ghost, out gameObject))         if (!this.IsZoneGenerated(zone) && this.SpawnZone(zone, ZoneSystem.SpawnMode.Ghost, out gameObject))
        {         {
            return true;             return true;
        }         }
        int num = this.m_activeArea + this.m_activeDistantArea;         int num = this.m_activeArea + this.m_activeDistantArea;
        for (int i = zone.y - num; i <= zone.y + num; i++)         for (int i = zone.y - num; i <= zone.y + num; i++)
        {         {
            for (int j = zone.x - num; j <= zone.x + num; j++)             for (int j = zone.x - num; j <= zone.x + num; j++)
            {             {
                Vector2i vector2i = new Vector2i(j, i);                 Vector2i vector2i = new Vector2i(j, i);
                GameObject gameObject2;                 GameObject gameObject2;
                if (!this.IsZoneGenerated(vector2i) && this.SpawnZone(vector2i, ZoneSystem.SpawnMode.Ghost, out gameObject2))                 if (!this.IsZoneGenerated(vector2i) && this.SpawnZone(vector2i, ZoneSystem.SpawnMode.Ghost, out gameObject2))
                {                 {
                    return true;                     return true;
                }                 }
            }             }
        }         }
        return false;         return false;
    }     }
   
    private bool CreateLocalZones(Vector3 refPoint)     private bool CreateLocalZones(Vector3 refPoint)
    {     {
        Vector2i zone = this.GetZone(refPoint);         Vector2i zone = this.GetZone(refPoint);
        if (this.PokeLocalZone(zone))         if (this.PokeLocalZone(zone))
        {         {
            return true;             return true;
        }         }
        for (int i = zone.y - this.m_activeArea; i <= zone.y + this.m_activeArea; i++)         for (int i = zone.y - this.m_activeArea; i <= zone.y + this.m_activeArea; i++)
        {         {
            for (int j = zone.x - this.m_activeArea; j <= zone.x + this.m_activeArea; j++)             for (int j = zone.x - this.m_activeArea; j <= zone.x + this.m_activeArea; j++)
            {             {
                Vector2i vector2i = new Vector2i(j, i);                 Vector2i vector2i = new Vector2i(j, i);
                if (!(vector2i == zone) && this.PokeLocalZone(vector2i))                 if (!(vector2i == zone) && this.PokeLocalZone(vector2i))
                {                 {
                    return true;                     return true;
                }                 }
            }             }
        }         }
        return false;         return false;
    }     }
   
    private bool PokeLocalZone(Vector2i zoneID)     private bool PokeLocalZone(Vector2i zoneID)
    {     {
        ZoneSystem.ZoneData zoneData;         ZoneSystem.ZoneData zoneData;
        if (this.m_zones.TryGetValue(zoneID, out zoneData))         if (this.m_zones.TryGetValue(zoneID, out zoneData))
        {         {
            zoneData.m_ttl = 0f;             zoneData.m_ttl = 0f;
            return false;             return false;
        }         }
        ZoneSystem.SpawnMode spawnMode = ((ZNet.instance.IsServer() && !this.IsZoneGenerated(zoneID)) ? ZoneSystem.SpawnMode.Full : ZoneSystem.SpawnMode.Client);         ZoneSystem.SpawnMode spawnMode = ((ZNet.instance.IsServer() && !this.IsZoneGenerated(zoneID)) ? ZoneSystem.SpawnMode.Full : ZoneSystem.SpawnMode.Client);
        GameObject gameObject;         GameObject gameObject;
        if (this.SpawnZone(zoneID, spawnMode, out gameObject))         if (this.SpawnZone(zoneID, spawnMode, out gameObject))
        {         {
            ZoneSystem.ZoneData zoneData2 = new ZoneSystem.ZoneData();             ZoneSystem.ZoneData zoneData2 = new ZoneSystem.ZoneData();
            zoneData2.m_root = gameObject;             zoneData2.m_root = gameObject;
            this.m_zones.Add(zoneID, zoneData2);             this.m_zones.Add(zoneID, zoneData2);
            return true;             return true;
        }         }
        return false;         return false;
    }     }
   
    public bool IsZoneLoaded(Vector3 point)     public bool IsZoneLoaded(Vector3 point)
    {     {
        Vector2i zone = this.GetZone(point);         Vector2i zone = this.GetZone(point);
        return this.IsZoneLoaded(zone);         return this.IsZoneLoaded(zone);
    }     }
   
    public bool IsZoneLoaded(Vector2i zoneID)     public bool IsZoneLoaded(Vector2i zoneID)
    {     {
        return this.m_zones.ContainsKey(zoneID) && !this.m_loadingObjectsInZones.ContainsKey(zoneID);         return this.m_zones.ContainsKey(zoneID) && !this.m_loadingObjectsInZones.ContainsKey(zoneID);
    }     }
   
    public bool IsActiveAreaLoaded()     public bool IsActiveAreaLoaded()
    {     {
        Vector2i zone = this.GetZone(ZNet.instance.GetReferencePosition());         Vector2i zone = this.GetZone(ZNet.instance.GetReferencePosition());
        for (int i = zone.y - this.m_activeArea; i <= zone.y + this.m_activeArea; i++)         for (int i = zone.y - this.m_activeArea; i <= zone.y + this.m_activeArea; i++)
        {         {
            for (int j = zone.x - this.m_activeArea; j <= zone.x + this.m_activeArea; j++)             for (int j = zone.x - this.m_activeArea; j <= zone.x + this.m_activeArea; j++)
            {             {
                if (!this.m_zones.ContainsKey(new Vector2i(j, i)))                 if (!this.m_zones.ContainsKey(new Vector2i(j, i)))
                {                 {
                    return false;                     return false;
                }                 }
            }             }
        }         }
        return true;         return true;
    }     }
   
    private bool SpawnZone(Vector2i zoneID, ZoneSystem.SpawnMode mode, out GameObject root)     private bool SpawnZone(Vector2i zoneID, ZoneSystem.SpawnMode mode, out GameObject root)
    {     {
        Vector3 zonePos = this.GetZonePos(zoneID);         Vector3 zonePos = this.GetZonePos(zoneID);
        Heightmap componentInChildren = this.m_zonePrefab.GetComponentInChildren<Heightmap>();         Heightmap componentInChildren = this.m_zonePrefab.GetComponentInChildren<Heightmap>();
        if (!HeightmapBuilder.instance.IsTerrainReady(zonePos, componentInChildren.m_width, componentInChildren.m_scale, componentInChildren.IsDistantLod, WorldGenerator.instance))         if (!HeightmapBuilder.instance.IsTerrainReady(zonePos, componentInChildren.m_width, componentInChildren.m_scale, componentInChildren.IsDistantLod, WorldGenerator.instance))
        {         {
            root = null;             root = null;
            return false;             return false;
        }         }
        ZoneSystem.LocationInstance locationInstance;         ZoneSystem.LocationInstance locationInstance;
        if (this.m_locationInstances.TryGetValue(zoneID, out locationInstance) && !locationInstance.m_placed && !this.PokeCanSpawnLocation(locationInstance.m_location, true))         if (this.m_locationInstances.TryGetValue(zoneID, out locationInstance) && !locationInstance.m_placed && !this.PokeCanSpawnLocation(locationInstance.m_location, true))
        {         {
            root = null;             root = null;
            return false;             return false;
        }         }
        root = UnityEngine.Object.Instantiate<GameObject>(this.m_zonePrefab, zonePos, Quaternion.identity);         root = UnityEngine.Object.Instantiate<GameObject>(this.m_zonePrefab, zonePos, Quaternion.identity);
        if ((mode == ZoneSystem.SpawnMode.Ghost || mode == ZoneSystem.SpawnMode.Full) && !this.IsZoneGenerated(zoneID))         if ((mode == ZoneSystem.SpawnMode.Ghost || mode == ZoneSystem.SpawnMode.Full) && !this.IsZoneGenerated(zoneID))
        {         {
            Heightmap componentInChildren2 = root.GetComponentInChildren<Heightmap>();             Heightmap componentInChildren2 = root.GetComponentInChildren<Heightmap>();
            this.m_tempClearAreas.Clear();             this.m_tempClearAreas.Clear();
            this.m_tempSpawnedObjects.Clear();             this.m_tempSpawnedObjects.Clear();
            this.PlaceLocations(zoneID, zonePos, root.transform, componentInChildren2, this.m_tempClearAreas, mode, this.m_tempSpawnedObjects);             this.PlaceLocations(zoneID, zonePos, root.transform, componentInChildren2, this.m_tempClearAreas, mode, this.m_tempSpawnedObjects);
            this.PlaceVegetation(zoneID, zonePos, root.transform, componentInChildren2, this.m_tempClearAreas, mode, this.m_tempSpawnedObjects);             this.PlaceVegetation(zoneID, zonePos, root.transform, componentInChildren2, this.m_tempClearAreas, mode, this.m_tempSpawnedObjects);
            this.PlaceZoneCtrl(zoneID, zonePos, mode, this.m_tempSpawnedObjects);             this.PlaceZoneCtrl(zoneID, zonePos, mode, this.m_tempSpawnedObjects);
            if (mode == ZoneSystem.SpawnMode.Ghost)             if (mode == ZoneSystem.SpawnMode.Ghost)
            {             {
                foreach (GameObject gameObject in this.m_tempSpawnedObjects)                 foreach (GameObject gameObject in this.m_tempSpawnedObjects)
                {                 {
                    UnityEngine.Object.Destroy(gameObject);                     UnityEngine.Object.Destroy(gameObject);
                }                 }
                this.m_tempSpawnedObjects.Clear();                 this.m_tempSpawnedObjects.Clear();
                UnityEngine.Object.Destroy(root);                 UnityEngine.Object.Destroy(root);
                root = null;                 root = null;
            }             }
            this.SetZoneGenerated(zoneID);             this.SetZoneGenerated(zoneID);
        }         }
        return true;         return true;
    }     }
   
    private void PlaceZoneCtrl(Vector2i zoneID, Vector3 zoneCenterPos, ZoneSystem.SpawnMode mode, List<GameObject> spawnedObjects)     private void PlaceZoneCtrl(Vector2i zoneID, Vector3 zoneCenterPos, ZoneSystem.SpawnMode mode, List<GameObject> spawnedObjects)
    {     {
        if (mode == ZoneSystem.SpawnMode.Full || mode == ZoneSystem.SpawnMode.Ghost)         if (mode == ZoneSystem.SpawnMode.Full || mode == ZoneSystem.SpawnMode.Ghost)
        {         {
            if (mode == ZoneSystem.SpawnMode.Ghost)             if (mode == ZoneSystem.SpawnMode.Ghost)
            {             {
                ZNetView.StartGhostInit();                 ZNetView.StartGhostInit();
            }             }
            GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_zoneCtrlPrefab, zoneCenterPos, Quaternion.identity);             GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_zoneCtrlPrefab, zoneCenterPos, Quaternion.identity);
            gameObject.GetComponent<ZNetView>();             gameObject.GetComponent<ZNetView>();
            if (mode == ZoneSystem.SpawnMode.Ghost)             if (mode == ZoneSystem.SpawnMode.Ghost)
            {             {
                spawnedObjects.Add(gameObject);                 spawnedObjects.Add(gameObject);
                ZNetView.FinishGhostInit();                 ZNetView.FinishGhostInit();
            }             }
        }         }
    }     }
   
    private Vector3 GetRandomPointInRadius(Vector3 center, float radius)     private Vector3 GetRandomPointInRadius(Vector3 center, float radius)
    {     {
        float num = UnityEngine.Random.value * 3.1415927f * 2f;         float num = UnityEngine.Random.value * 3.1415927f * 2f;
        float num2 = UnityEngine.Random.Range(0f, radius);         float num2 = UnityEngine.Random.Range(0f, radius);
        return center + new Vector3(Mathf.Sin(num) * num2, 0f, Mathf.Cos(num) * num2);         return center + new Vector3(Mathf.Sin(num) * num2, 0f, Mathf.Cos(num) * num2);
    }     }
   
    private void PlaceVegetation(Vector2i zoneID, Vector3 zoneCenterPos, Transform parent, Heightmap hmap, List<ZoneSystem.ClearArea> clearAreas, ZoneSystem.SpawnMode mode, List<GameObject> spawnedObjects)     private void PlaceVegetation(Vector2i zoneID, Vector3 zoneCenterPos, Transform parent, Heightmap hmap, List<ZoneSystem.ClearArea> clearAreas, ZoneSystem.SpawnMode mode, List<GameObject> spawnedObjects)
    {     {
        UnityEngine.Random.State state = UnityEngine.Random.state;         UnityEngine.Random.State state = UnityEngine.Random.state;
        int seed = WorldGenerator.instance.GetSeed();         int seed = WorldGenerator.instance.GetSeed();
        float num = this.m_zoneSize / 2f;         float num = this.m_zoneSize / 2f;
        int num2 = 1;         int num2 = 1;
        foreach (ZoneSystem.ZoneVegetation zoneVegetation in this.m_vegetation)         foreach (ZoneSystem.ZoneVegetation zoneVegetation in this.m_vegetation)
        {         {
            num2++;             num2++;
            if (zoneVegetation.m_enable && hmap.HaveBiome(zoneVegetation.m_biome))             if (zoneVegetation.m_enable && hmap.HaveBiome(zoneVegetation.m_biome))
            {             {
                UnityEngine.Random.InitState(seed + zoneID.x * 4271 + zoneID.y * 9187 + zoneVegetation.m_prefab.name.GetStableHashCode());                 UnityEngine.Random.InitState(seed + zoneID.x * 4271 + zoneID.y * 9187 + zoneVegetation.m_prefab.name.GetStableHashCode());
                int num3 = 1;                 int num3 = 1;
                if (zoneVegetation.m_max < 1f)                 if (zoneVegetation.m_max < 1f)
                {                 {
                    if (UnityEngine.Random.value > zoneVegetation.m_max)                     if (UnityEngine.Random.value > zoneVegetation.m_max)
                    {                     {
                        continue;                         continue;
                    }                     }
                }                 }
                else                 else
                {                 {
                    num3 = UnityEngine.Random.Range((int)zoneVegetation.m_min, (int)zoneVegetation.m_max + 1);                     num3 = UnityEngine.Random.Range((int)zoneVegetation.m_min, (int)zoneVegetation.m_max + 1);
                }                 }
                bool flag = zoneVegetation.m_prefab.GetComponent<ZNetView>() != null;                 bool flag = zoneVegetation.m_prefab.GetComponent<ZNetView>() != null;
                float num4 = Mathf.Cos(0.017453292f * zoneVegetation.m_maxTilt);                 float num4 = Mathf.Cos(0.017453292f * zoneVegetation.m_maxTilt);
                float num5 = Mathf.Cos(0.017453292f * zoneVegetation.m_minTilt);                 float num5 = Mathf.Cos(0.017453292f * zoneVegetation.m_minTilt);
                float num6 = num - zoneVegetation.m_groupRadius;                 float num6 = num - zoneVegetation.m_groupRadius;
.                  this.s_tempVeg.Clear();
                int num7 = (zoneVegetation.m_forcePlacement ? (num3 * 50) : num3);                 int num7 = (zoneVegetation.m_forcePlacement ? (num3 * 50) : num3);
                int num8 = 0;                 int num8 = 0;
                for (int i = 0; i < num7; i++)                 for (int i = 0; i < num7; i++)
                {                 {
                    Vector3 vector = new Vector3(UnityEngine.Random.Range(zoneCenterPos.x - num6, zoneCenterPos.x + num6), 0f, UnityEngine.Random.Range(zoneCenterPos.z - num6, zoneCenterPos.z + num6));                     Vector3 vector = new Vector3(UnityEngine.Random.Range(zoneCenterPos.x - num6, zoneCenterPos.x + num6), 0f, UnityEngine.Random.Range(zoneCenterPos.z - num6, zoneCenterPos.z + num6));
                    int num9 = UnityEngine.Random.Range(zoneVegetation.m_groupSizeMin, zoneVegetation.m_groupSizeMax + 1);                     int num9 = UnityEngine.Random.Range(zoneVegetation.m_groupSizeMin, zoneVegetation.m_groupSizeMax + 1);
                    bool flag2 = false;                     bool flag2 = false;
                    for (int j = 0; j < num9; j++)                     for (int j = 0; j < num9; j++)
                    {                     {
                        Vector3 vector2 = ((j == 0) ? vector : this.GetRandomPointInRadius(vector, zoneVegetation.m_groupRadius));                         Vector3 vector2 = ((j == 0) ? vector : this.GetRandomPointInRadius(vector, zoneVegetation.m_groupRadius));
                        float num10 = (float)UnityEngine.Random.Range(0, 360);                         float num10 = (float)UnityEngine.Random.Range(0, 360);
                        float num11 = UnityEngine.Random.Range(zoneVegetation.m_scaleMin, zoneVegetation.m_scaleMax);                         float num11 = UnityEngine.Random.Range(zoneVegetation.m_scaleMin, zoneVegetation.m_scaleMax);
                        float num12 = UnityEngine.Random.Range(-zoneVegetation.m_randTilt, zoneVegetation.m_randTilt);                         float num12 = UnityEngine.Random.Range(-zoneVegetation.m_randTilt, zoneVegetation.m_randTilt);
                        float num13 = UnityEngine.Random.Range(-zoneVegetation.m_randTilt, zoneVegetation.m_randTilt);                         float num13 = UnityEngine.Random.Range(-zoneVegetation.m_randTilt, zoneVegetation.m_randTilt);
                        if (!zoneVegetation.m_blockCheck || !this.IsBlocked(vector2))                         if (!zoneVegetation.m_blockCheck || !this.IsBlocked(vector2))
                        {                         {
                            Vector3 vector3;                             Vector3 vector3;
                            Heightmap.Biome biome;                             Heightmap.Biome biome;
                            Heightmap.BiomeArea biomeArea;                             Heightmap.BiomeArea biomeArea;
                            Heightmap heightmap;                             Heightmap heightmap;
                            this.GetGroundData(ref vector2, out vector3, out biome, out biomeArea, out heightmap);                             this.GetGroundData(ref vector2, out vector3, out biome, out biomeArea, out heightmap);
                            if ((zoneVegetation.m_biome & biome) != Heightmap.Biome.None && (zoneVegetation.m_biomeArea & biomeArea) != (Heightmap.BiomeArea)0)                             if ((zoneVegetation.m_biome & biome) != Heightmap.Biome.None && (zoneVegetation.m_biomeArea & biomeArea) != (Heightmap.BiomeArea)0)
                            {                             {
                                float num14;                                 float num14;
                                Vector3 vector4;                                 Vector3 vector4;
                                if (zoneVegetation.m_snapToStaticSolid && this.GetStaticSolidHeight(vector2, out num14, out vector4))                                 if (zoneVegetation.m_snapToStaticSolid && this.GetStaticSolidHeight(vector2, out num14, out vector4))
                                {                                 {
                                    vector2.y = num14;                                     vector2.y = num14;
                                    vector3 = vector4;                                     vector3 = vector4;
                                }                                 }
.                                float num15 = vector2.y - this.m_waterLevel;                                 float num15 = vector2.y - 30f;
                                if (num15 >= zoneVegetation.m_minAltitude && num15 <= zoneVegetation.m_maxAltitude)                                 if (num15 >= zoneVegetation.m_minAltitude && num15 <= zoneVegetation.m_maxAltitude)
                                {                                 {
                                    if (zoneVegetation.m_minVegetation != zoneVegetation.m_maxVegetation)                                     if (zoneVegetation.m_minVegetation != zoneVegetation.m_maxVegetation)
                                    {                                     {
                                        float vegetationMask = heightmap.GetVegetationMask(vector2);                                         float vegetationMask = heightmap.GetVegetationMask(vector2);
                                        if (vegetationMask > zoneVegetation.m_maxVegetation || vegetationMask < zoneVegetation.m_minVegetation)                                         if (vegetationMask > zoneVegetation.m_maxVegetation || vegetationMask < zoneVegetation.m_minVegetation)
                                        {                                         {
.                                            goto IL_4EF;                                             goto IL_60A;
                                        }                                         }
                                    }                                     }
                                    if (zoneVegetation.m_minOceanDepth != zoneVegetation.m_maxOceanDepth)                                     if (zoneVegetation.m_minOceanDepth != zoneVegetation.m_maxOceanDepth)
                                    {                                     {
                                        float oceanDepth = heightmap.GetOceanDepth(vector2);                                         float oceanDepth = heightmap.GetOceanDepth(vector2);
                                        if (oceanDepth < zoneVegetation.m_minOceanDepth || oceanDepth > zoneVegetation.m_maxOceanDepth)                                         if (oceanDepth < zoneVegetation.m_minOceanDepth || oceanDepth > zoneVegetation.m_maxOceanDepth)
                                        {                                         {
.                                            goto IL_4EF;                                             goto IL_60A;
                                        }                                         }
                                    }                                     }
                                    if (vector3.y >= num4 && vector3.y <= num5)                                     if (vector3.y >= num4 && vector3.y <= num5)
                                    {                                     {
                                        if (zoneVegetation.m_terrainDeltaRadius > 0f)                                         if (zoneVegetation.m_terrainDeltaRadius > 0f)
                                        {                                         {
                                            float num16;                                             float num16;
                                            Vector3 vector5;                                             Vector3 vector5;
                                            this.GetTerrainDelta(vector2, zoneVegetation.m_terrainDeltaRadius, out num16, out vector5);                                             this.GetTerrainDelta(vector2, zoneVegetation.m_terrainDeltaRadius, out num16, out vector5);
                                            if (num16 > zoneVegetation.m_maxTerrainDelta || num16 < zoneVegetation.m_minTerrainDelta)                                             if (num16 > zoneVegetation.m_maxTerrainDelta || num16 < zoneVegetation.m_minTerrainDelta)
                                            {                                             {
.                                                goto IL_4EF;                                                 goto IL_60A;
                                            }                                             }
                                        }                                         }
                                        if (zoneVegetation.m_inForest)                                         if (zoneVegetation.m_inForest)
                                        {                                         {
                                            float forestFactor = WorldGenerator.GetForestFactor(vector2);                                             float forestFactor = WorldGenerator.GetForestFactor(vector2);
                                            if (forestFactor < zoneVegetation.m_forestTresholdMin || forestFactor > zoneVegetation.m_forestTresholdMax)                                             if (forestFactor < zoneVegetation.m_forestTresholdMin || forestFactor > zoneVegetation.m_forestTresholdMax)
                                            {                                             {
.                                                goto IL_4EF;                                                 goto IL_60A;
                                              } 
                                          } 
                                          if (zoneVegetation.m_surroundCheckVegetation) 
                                          { 
                                              float num17 = 0f; 
                                              for (int k = 0; k < zoneVegetation.m_surroundCheckLayers; k++) 
                                              { 
                                                  float num18 = (float)(k + 1) / (float)zoneVegetation.m_surroundCheckLayers * zoneVegetation.m_surroundCheckDistance; 
                                                  for (int l = 0; l < 6; l++) 
                                                  { 
                                                      float num19 = (float)l / 6f * 3.1415927f * 2f; 
                                                      float vegetationMask2 = heightmap.GetVegetationMask(vector2 + new Vector3(Mathf.Sin(num19) * num18, 0f, Mathf.Cos(num19) * num18)); 
                                                      float num20 = (1f - num18) / (zoneVegetation.m_surroundCheckDistance * 2f); 
                                                      num17 += vegetationMask2 * num20; 
                                                  } 
                                              } 
                                              this.s_tempVeg.Add(num17); 
                                              if (this.s_tempVeg.Count < 10) 
                                              { 
                                                  goto IL_60A; 
                                              } 
                                              float num21 = this.s_tempVeg.Max(); 
                                              float num22 = this.s_tempVeg.Average(); 
                                              float num23 = num22 + (num21 - num22) * zoneVegetation.m_surroundBetterThanAverage; 
                                              if (num17 < num23) 
                                              { 
                                                  goto IL_60A; 
                                            }                                             }
                                        }                                         }
                                        if (!this.InsideClearArea(clearAreas, vector2))                                         if (!this.InsideClearArea(clearAreas, vector2))
                                        {                                         {
                                            if (zoneVegetation.m_snapToWater)                                             if (zoneVegetation.m_snapToWater)
                                            {                                             {
.                                                vector2.y = this.m_waterLevel;                                                 vector2.y = 30f;
                                            }                                             }
                                            vector2.y += zoneVegetation.m_groundOffset;                                             vector2.y += zoneVegetation.m_groundOffset;
                                            Quaternion quaternion = Quaternion.identity;                                             Quaternion quaternion = Quaternion.identity;
                                            if (zoneVegetation.m_chanceToUseGroundTilt > 0f && UnityEngine.Random.value <= zoneVegetation.m_chanceToUseGroundTilt)                                             if (zoneVegetation.m_chanceToUseGroundTilt > 0f && UnityEngine.Random.value <= zoneVegetation.m_chanceToUseGroundTilt)
                                            {                                             {
                                                Quaternion quaternion2 = Quaternion.Euler(0f, num10, 0f);                                                 Quaternion quaternion2 = Quaternion.Euler(0f, num10, 0f);
                                                quaternion = Quaternion.LookRotation(Vector3.Cross(vector3, quaternion2 * Vector3.forward), vector3);                                                 quaternion = Quaternion.LookRotation(Vector3.Cross(vector3, quaternion2 * Vector3.forward), vector3);
                                            }                                             }
                                            else                                             else
                                            {                                             {
                                                quaternion = Quaternion.Euler(num12, num10, num13);                                                 quaternion = Quaternion.Euler(num12, num10, num13);
                                            }                                             }
                                            if (flag)                                             if (flag)
                                            {                                             {
                                                if (mode == ZoneSystem.SpawnMode.Full || mode == ZoneSystem.SpawnMode.Ghost)                                                 if (mode == ZoneSystem.SpawnMode.Full || mode == ZoneSystem.SpawnMode.Ghost)
                                                {                                                 {
                                                    if (mode == ZoneSystem.SpawnMode.Ghost)                                                     if (mode == ZoneSystem.SpawnMode.Ghost)
                                                    {                                                     {
                                                        ZNetView.StartGhostInit();                                                         ZNetView.StartGhostInit();
                                                    }                                                     }
                                                    GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(zoneVegetation.m_prefab, vector2, quaternion);                                                     GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(zoneVegetation.m_prefab, vector2, quaternion);
                                                    ZNetView component = gameObject.GetComponent<ZNetView>();                                                     ZNetView component = gameObject.GetComponent<ZNetView>();
                                                    if (num11 != gameObject.transform.localScale.x)                                                     if (num11 != gameObject.transform.localScale.x)
                                                    {                                                     {
                                                        component.SetLocalScale(new Vector3(num11, num11, num11));                                                         component.SetLocalScale(new Vector3(num11, num11, num11));
                                                        foreach (Collider collider in gameObject.GetComponentsInChildren<Collider>())                                                         foreach (Collider collider in gameObject.GetComponentsInChildren<Collider>())
                                                        {                                                         {
                                                            collider.enabled = false;                                                             collider.enabled = false;
                                                            collider.enabled = true;                                                             collider.enabled = true;
                                                        }                                                         }
                                                    }                                                     }
                                                    if (mode == ZoneSystem.SpawnMode.Ghost)                                                     if (mode == ZoneSystem.SpawnMode.Ghost)
                                                    {                                                     {
                                                        spawnedObjects.Add(gameObject);                                                         spawnedObjects.Add(gameObject);
                                                        ZNetView.FinishGhostInit();                                                         ZNetView.FinishGhostInit();
                                                    }                                                     }
                                                }                                                 }
                                            }                                             }
                                            else                                             else
                                            {                                             {
                                                GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(zoneVegetation.m_prefab, vector2, quaternion);                                                 GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(zoneVegetation.m_prefab, vector2, quaternion);
                                                gameObject2.transform.localScale = new Vector3(num11, num11, num11);                                                 gameObject2.transform.localScale = new Vector3(num11, num11, num11);
                                                gameObject2.transform.SetParent(parent, true);                                                 gameObject2.transform.SetParent(parent, true);
                                            }                                             }
                                            flag2 = true;                                             flag2 = true;
                                        }                                         }
                                    }                                     }
                                }                                 }
                            }                             }
                        }                         }
.                        IL_4EF:;                         IL_60A:;
                    }                     }
                    if (flag2)                     if (flag2)
                    {                     {
                        num8++;                         num8++;
                    }                     }
                    if (num8 >= num3)                     if (num8 >= num3)
                    {                     {
                        break;                         break;
                    }                     }
                }                 }
            }             }
        }         }
        UnityEngine.Random.state = state;         UnityEngine.Random.state = state;
    }     }
   
    private bool InsideClearArea(List<ZoneSystem.ClearArea> areas, Vector3 point)     private bool InsideClearArea(List<ZoneSystem.ClearArea> areas, Vector3 point)
    {     {
        foreach (ZoneSystem.ClearArea clearArea in areas)         foreach (ZoneSystem.ClearArea clearArea in areas)
        {         {
            if (point.x > clearArea.m_center.x - clearArea.m_radius && point.x < clearArea.m_center.x + clearArea.m_radius && point.z > clearArea.m_center.z - clearArea.m_radius && point.z < clearArea.m_center.z + clearArea.m_radius)             if (point.x > clearArea.m_center.x - clearArea.m_radius && point.x < clearArea.m_center.x + clearArea.m_radius && point.z > clearArea.m_center.z - clearArea.m_radius && point.z < clearArea.m_center.z + clearArea.m_radius)
            {             {
                return true;                 return true;
            }             }
        }         }
        return false;         return false;
    }     }
   
    private ZoneSystem.ZoneLocation GetLocation(int hash)     private ZoneSystem.ZoneLocation GetLocation(int hash)
    {     {
        ZoneSystem.ZoneLocation zoneLocation;         ZoneSystem.ZoneLocation zoneLocation;
        if (this.m_locationsByHash.TryGetValue(hash, out zoneLocation))         if (this.m_locationsByHash.TryGetValue(hash, out zoneLocation))
        {         {
            return zoneLocation;             return zoneLocation;
        }         }
        return null;         return null;
    }     }
   
    private ZoneSystem.ZoneLocation GetLocation(string name)     private ZoneSystem.ZoneLocation GetLocation(string name)
    {     {
        foreach (ZoneSystem.ZoneLocation zoneLocation in this.m_locations)         foreach (ZoneSystem.ZoneLocation zoneLocation in this.m_locations)
        {         {
            if (zoneLocation.m_prefab.Name == name)             if (zoneLocation.m_prefab.Name == name)
            {             {
                return zoneLocation;                 return zoneLocation;
            }             }
        }         }
        return null;         return null;
    }     }
   
    private void ClearNonPlacedLocations()     private void ClearNonPlacedLocations()
    {     {
        Dictionary<Vector2i, ZoneSystem.LocationInstance> dictionary = new Dictionary<Vector2i, ZoneSystem.LocationInstance>();         Dictionary<Vector2i, ZoneSystem.LocationInstance> dictionary = new Dictionary<Vector2i, ZoneSystem.LocationInstance>();
        foreach (KeyValuePair<Vector2i, ZoneSystem.LocationInstance> keyValuePair in this.m_locationInstances)         foreach (KeyValuePair<Vector2i, ZoneSystem.LocationInstance> keyValuePair in this.m_locationInstances)
        {         {
            if (keyValuePair.Value.m_placed)             if (keyValuePair.Value.m_placed)
            {             {
                dictionary.Add(keyValuePair.Key, keyValuePair.Value);                 dictionary.Add(keyValuePair.Key, keyValuePair.Value);
            }             }
        }         }
        this.m_locationInstances = dictionary;         this.m_locationInstances = dictionary;
    }     }
   
    private void CheckLocationDuplicates()     private void CheckLocationDuplicates()
    {     {
        ZLog.Log("Checking for location duplicates");         ZLog.Log("Checking for location duplicates");
        Stopwatch stopwatch = new Stopwatch();         Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();         stopwatch.Start();
        for (int i = 0; i < this.m_locations.Count; i++)         for (int i = 0; i < this.m_locations.Count; i++)
        {         {
            ZoneSystem.ZoneLocation zoneLocation = this.m_locations[i];             ZoneSystem.ZoneLocation zoneLocation = this.m_locations[i];
            if (zoneLocation.m_enable)             if (zoneLocation.m_enable)
            {             {
                for (int j = i + 1; j < this.m_locations.Count; j++)                 for (int j = i + 1; j < this.m_locations.Count; j++)
                {                 {
                    ZoneSystem.ZoneLocation zoneLocation2 = this.m_locations[j];                     ZoneSystem.ZoneLocation zoneLocation2 = this.m_locations[j];
                    if (zoneLocation2.m_enable)                     if (zoneLocation2.m_enable)
                    {                     {
                        if (zoneLocation.m_prefab.Name == zoneLocation2.m_prefab.Name)                         if (zoneLocation.m_prefab.Name == zoneLocation2.m_prefab.Name)
                        {                         {
                            string text = "Two locations have the same location prefab name ";                             string text = "Two locations have the same location prefab name ";
                            SoftReference<GameObject> prefab = zoneLocation.m_prefab;                             SoftReference<GameObject> prefab = zoneLocation.m_prefab;
                            ZLog.LogWarning(text + prefab.ToString());                             ZLog.LogWarning(text + prefab.ToString());
                        }                         }
                        if (zoneLocation.m_prefab == zoneLocation2.m_prefab)                         if (zoneLocation.m_prefab == zoneLocation2.m_prefab)
                        {                         {
                            ZLog.LogWarning(string.Format("Locations {0} and {1} point to the same location prefab", zoneLocation.m_prefab, zoneLocation2.m_prefab));                             ZLog.LogWarning(string.Format("Locations {0} and {1} point to the same location prefab", zoneLocation.m_prefab, zoneLocation2.m_prefab));
                        }                         }
                    }                     }
                }                 }
            }             }
        }         }
        stopwatch.Stop();         stopwatch.Stop();
        ZLog.Log(string.Format("Location duplicate check took {0} ms", stopwatch.Elapsed.TotalMilliseconds));         ZLog.Log(string.Format("Location duplicate check took {0} ms", stopwatch.Elapsed.TotalMilliseconds));
    }     }
   
    public void GenerateLocations()     public void GenerateLocations()
    {     {
        if (!Application.isPlaying)         if (!Application.isPlaying)
        {         {
            ZLog.Log("Setting up locations");             ZLog.Log("Setting up locations");
            this.SetupLocations();             this.SetupLocations();
        }         }
        ZLog.Log("Generating locations");         ZLog.Log("Generating locations");
        DateTime now = DateTime.Now;         DateTime now = DateTime.Now;
        this.m_locationsGenerated = true;         this.m_locationsGenerated = true;
        UnityEngine.Random.State state = UnityEngine.Random.state;         UnityEngine.Random.State state = UnityEngine.Random.state;
        this.ClearNonPlacedLocations();         this.ClearNonPlacedLocations();
        foreach (ZoneSystem.ZoneLocation zoneLocation in this.m_locations.OrderByDescending((ZoneSystem.ZoneLocation a) => a.m_prioritized))         foreach (ZoneSystem.ZoneLocation zoneLocation in this.m_locations.OrderByDescending((ZoneSystem.ZoneLocation a) => a.m_prioritized))
        {         {
            if (zoneLocation.m_enable && zoneLocation.m_quantity != 0)             if (zoneLocation.m_enable && zoneLocation.m_quantity != 0)
            {             {
                this.GenerateLocations(zoneLocation);                 this.GenerateLocations(zoneLocation);
            }             }
        }         }
        UnityEngine.Random.state = state;         UnityEngine.Random.state = state;
        ZLog.Log(" Done generating locations, duration:" + (DateTime.Now - now).TotalMilliseconds.ToString() + " ms");         ZLog.Log(" Done generating locations, duration:" + (DateTime.Now - now).TotalMilliseconds.ToString() + " ms");
    }     }
   
    private int CountNrOfLocation(ZoneSystem.ZoneLocation location)     private int CountNrOfLocation(ZoneSystem.ZoneLocation location)
    {     {
        int num = 0;         int num = 0;
        using (Dictionary<Vector2i, ZoneSystem.LocationInstance>.ValueCollection.Enumerator enumerator = this.m_locationInstances.Values.GetEnumerator())         using (Dictionary<Vector2i, ZoneSystem.LocationInstance>.ValueCollection.Enumerator enumerator = this.m_locationInstances.Values.GetEnumerator())
        {         {
            while (enumerator.MoveNext())             while (enumerator.MoveNext())
            {             {
                if (enumerator.Current.m_location.m_prefab.Name == location.m_prefab.Name)                 if (enumerator.Current.m_location.m_prefab.Name == location.m_prefab.Name)
                {                 {
                    num++;                     num++;
                }                 }
            }             }
        }         }
        if (num > 0)         if (num > 0)
        {         {
            string text = "Old location found ";             string text = "Old location found ";
            SoftReference<GameObject> prefab = location.m_prefab;             SoftReference<GameObject> prefab = location.m_prefab;
            ZLog.Log(text + prefab.ToString() + " x " + num.ToString());             ZLog.Log(text + prefab.ToString() + " x " + num.ToString());
        }         }
        return num;         return num;
    }     }
   
    private void GenerateLocations(ZoneSystem.ZoneLocation location)     private void GenerateLocations(ZoneSystem.ZoneLocation location)
    {     {
        DateTime now = DateTime.Now;         DateTime now = DateTime.Now;
        UnityEngine.Random.InitState(WorldGenerator.instance.GetSeed() + location.m_prefab.Name.GetStableHashCode());         UnityEngine.Random.InitState(WorldGenerator.instance.GetSeed() + location.m_prefab.Name.GetStableHashCode());
        int num = 0;         int num = 0;
        int num2 = 0;         int num2 = 0;
        int num3 = 0;         int num3 = 0;
        int num4 = 0;         int num4 = 0;
        int num5 = 0;         int num5 = 0;
        int num6 = 0;         int num6 = 0;
        int num7 = 0;         int num7 = 0;
        int num8 = 0;         int num8 = 0;
.        float num9 = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius);         int num9 = 0; 
        int num10 = (location.m_prioritized ? 200000 : 100000);         int num10 = 0; 
        int num11 = 0;         float num11 = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius);
        int num12 = this.CountNrOfLocation(location);         int num12 = (location.m_prioritized ? 200000 : 100000);
        float num13 = 10000f;         int num13 = 0;
          int num14 = this.CountNrOfLocation(location);
          float num15 = 10000f;
        if (location.m_centerFirst)         if (location.m_centerFirst)
        {         {
.            num13 = location.m_minDistance;             num15 = location.m_minDistance;
        }         }
.        if (location.m_unique && num12 > 0)         if (location.m_unique && num14 > 0)
        {         {
            return;             return;
        }         }
.        int num14 = 0;         this.s_tempVeg.Clear(); 
        while (num14 < num10 && num12 < location.m_quantity)         int num16 = 0;
          while (num16 < num12 && num14 < location.m_quantity)
        {         {
.            Vector2i randomZone = this.GetRandomZone(num13);             Vector2i randomZone = this.GetRandomZone(num15);
            if (location.m_centerFirst)             if (location.m_centerFirst)
            {             {
.                num13 += 1f;                 num15 += 1f;
            }             }
            if (this.m_locationInstances.ContainsKey(randomZone))             if (this.m_locationInstances.ContainsKey(randomZone))
            {             {
                num++;                 num++;
            }             }
            else if (!this.IsZoneGenerated(randomZone))             else if (!this.IsZoneGenerated(randomZone))
            {             {
                Vector3 zonePos = this.GetZonePos(randomZone);                 Vector3 zonePos = this.GetZonePos(randomZone);
                Heightmap.BiomeArea biomeArea = WorldGenerator.instance.GetBiomeArea(zonePos);                 Heightmap.BiomeArea biomeArea = WorldGenerator.instance.GetBiomeArea(zonePos);
                if ((location.m_biomeArea & biomeArea) == (Heightmap.BiomeArea)0)                 if ((location.m_biomeArea & biomeArea) == (Heightmap.BiomeArea)0)
                {                 {
                    num4++;                     num4++;
                }                 }
                else                 else
                {                 {
                    for (int i = 0; i < 20; i++)                     for (int i = 0; i < 20; i++)
                    {                     {
.                        num11++;                         num13++;
                        Vector3 randomPointInZone = this.GetRandomPointInZone(randomZone, num9);                         Vector3 randomPointInZone = this.GetRandomPointInZone(randomZone, num11);
                        float magnitude = randomPointInZone.magnitude;                         float magnitude = randomPointInZone.magnitude;
                        if (location.m_minDistance != 0f && magnitude < location.m_minDistance)                         if (location.m_minDistance != 0f && magnitude < location.m_minDistance)
                        {                         {
                            num2++;                             num2++;
                        }                         }
                        else if (location.m_maxDistance != 0f && magnitude > location.m_maxDistance)                         else if (location.m_maxDistance != 0f && magnitude > location.m_maxDistance)
                        {                         {
                            num2++;                             num2++;
                        }                         }
                        else                         else
                        {                         {
                            Heightmap.Biome biome = WorldGenerator.instance.GetBiome(randomPointInZone);                             Heightmap.Biome biome = WorldGenerator.instance.GetBiome(randomPointInZone);
                            if ((location.m_biome & biome) == Heightmap.Biome.None)                             if ((location.m_biome & biome) == Heightmap.Biome.None)
                            {                             {
                                num3++;                                 num3++;
                            }                             }
                            else                             else
                            {                             {
.                                randomPointInZone.y = WorldGenerator.instance.GetHeight(randomPointInZone.x, randomPointInZone.z);                                 Color color; 
                                float num15 = (float)((double)randomPointInZone.y - (double)this.m_waterLevel);                                 randomPointInZone.y = WorldGenerator.instance.GetHeight(randomPointInZone.x, randomPointInZone.z, out color);
                                if (num15 < location.m_minAltitude || num15 > location.m_maxAltitude)                                 float num17 = (float)((double)randomPointInZone.y - 30.0);
                                  if (num17 < location.m_minAltitude || num17 > location.m_maxAltitude)
                                {                                 {
                                    num5++;                                     num5++;
                                }                                 }
                                else                                 else
                                {                                 {
                                    if (location.m_inForest)                                     if (location.m_inForest)
                                    {                                     {
                                        float forestFactor = WorldGenerator.GetForestFactor(randomPointInZone);                                         float forestFactor = WorldGenerator.GetForestFactor(randomPointInZone);
                                        if (forestFactor < location.m_forestTresholdMin || forestFactor > location.m_forestTresholdMax)                                         if (forestFactor < location.m_forestTresholdMin || forestFactor > location.m_forestTresholdMax)
                                        {                                         {
                                            num6++;                                             num6++;
.                                            goto IL_289;                                             goto IL_490;
                                        }                                         }
                                    }                                     }
.                                    float num16;                                     float num18;
                                    Vector3 vector;                                     Vector3 vector;
.                                    WorldGenerator.instance.GetTerrainDelta(randomPointInZone, location.m_exteriorRadius, out num16, out vector);                                     WorldGenerator.instance.GetTerrainDelta(randomPointInZone, location.m_exteriorRadius, out num18, out vector);
                                    if (num16 > location.m_maxTerrainDelta || num16 < location.m_minTerrainDelta)                                     if (num18 > location.m_maxTerrainDelta || num18 < location.m_minTerrainDelta)
                                      { 
                                          num9++; 
                                      } 
                                      else if (location.m_minDistanceFromSimilar > 0f && this.HaveLocationInRange(location.m_prefab.Name, location.m_group, randomPointInZone, location.m_minDistanceFromSimilar, false)) 
                                      { 
                                          num7++; 
                                      } 
                                      else if (location.m_maxDistanceFromSimilar > 0f && !this.HaveLocationInRange(location.m_prefabName, location.m_groupMax, randomPointInZone, location.m_maxDistanceFromSimilar, true)) 
                                    {                                     {
                                        num8++;                                         num8++;
                                    }                                     }
                                    else                                     else
                                    {                                     {
.                                        if (location.m_minDistanceFromSimilar <= 0f || !this.HaveLocationInRange(location.m_prefab.Name, location.m_group, randomPointInZone, location.m_minDistanceFromSimilar))                                          float a = color.a; 
                                          if (location.m_minimumVegetation > 0f && a <= location.m_minimumVegetation) 
                                        {                                         {
.                                            this.RegisterLocation(location, randomPointInZone, false);                                             num10++;
                                            num12++;                                          } 
                                            break;                                          else 
                                          { 
                                              if (location.m_maximumVegetation >= 1f || a < location.m_maximumVegetation) 
                                              { 
                                                  if (location.m_surroundCheckVegetation) 
                                                  { 
                                                      float num19 = 0f; 
                                                      for (int j = 0; j < location.m_surroundCheckLayers; j++) 
                                                      { 
                                                          float num20 = (float)(j + 1) / (float)location.m_surroundCheckLayers * location.m_surroundCheckDistance; 
                                                          for (int k = 0; k < 6; k++) 
                                                          { 
                                                              float num21 = (float)k / 6f * 3.1415927f * 2f; 
                                                              Vector3 vector2 = randomPointInZone + new Vector3(Mathf.Sin(num21) * num20, 0f, Mathf.Cos(num21) * num20); 
                                                              Color color2; 
                                                              WorldGenerator.instance.GetHeight(vector2.x, vector2.z, out color2); 
                                                              float num22 = (location.m_surroundCheckDistance - num20) / (location.m_surroundCheckDistance * 2f); 
                                                              num19 += color2.a * num22; 
                                                          } 
                                                      } 
                                                      this.s_tempVeg.Add(num19); 
                                                      if (this.s_tempVeg.Count < 10) 
                                                      { 
                                                          goto IL_490; 
                                                      } 
                                                      float num23 = this.s_tempVeg.Max(); 
                                                      float num24 = this.s_tempVeg.Average(); 
                                                      float num25 = num24 + (num23 - num24) * location.m_surroundBetterThanAverage; 
                                                      if (num19 < num25) 
                                                      { 
                                                          goto IL_490; 
                                                      } 
                                                      ZLog.DevLog(string.Format("Surround check passed with a value of {0}, cutoff was {1}, max: {2}, average: {3}.", new object[] { num19, num25, num23, num24 })); 
                                                  } 
                                                  this.RegisterLocation(location, randomPointInZone, false); 
                                                  num14++; 
                                                  break; 
                                              } 
                                              num10++; 
                                        }                                         }
.                                        num7++;  
                                    }                                     }
                                }                                 }
                            }                             }
                        }                         }
.                        IL_289:;                         IL_490:;
                    }                     }
                }                 }
            }             }
.            num14++;             num16++;
        }         }
.        if (num12 < location.m_quantity)         if (num14 < location.m_quantity)
        {         {
            ZLog.LogWarning(string.Concat(new string[]             ZLog.LogWarning(string.Concat(new string[]
            {             {
                "Failed to place all ",                 "Failed to place all ",
                location.m_prefab.Name,                 location.m_prefab.Name,
                ", placed ",                 ", placed ",
.                num12.ToString(),                 num14.ToString(),
                " out of ",                 " out of ",
                location.m_quantity.ToString()                 location.m_quantity.ToString()
            }));             }));
            ZLog.DevLog("errorLocationInZone " + num.ToString());             ZLog.DevLog("errorLocationInZone " + num.ToString());
            ZLog.DevLog("errorCenterDistance " + num2.ToString());             ZLog.DevLog("errorCenterDistance " + num2.ToString());
            ZLog.DevLog("errorBiome " + num3.ToString());             ZLog.DevLog("errorBiome " + num3.ToString());
            ZLog.DevLog("errorBiomeArea " + num4.ToString());             ZLog.DevLog("errorBiomeArea " + num4.ToString());
            ZLog.DevLog("errorAlt " + num5.ToString());             ZLog.DevLog("errorAlt " + num5.ToString());
            ZLog.DevLog("errorForest " + num6.ToString());             ZLog.DevLog("errorForest " + num6.ToString());
            ZLog.DevLog("errorSimilar " + num7.ToString());             ZLog.DevLog("errorSimilar " + num7.ToString());
.            ZLog.DevLog("errorTerrainDelta " + num8.ToString());             ZLog.DevLog("errorNotSimilar " + num8.ToString());
              ZLog.DevLog("errorTerrainDelta " + num9.ToString()); 
              ZLog.DevLog("errorVegetation " + num10.ToString()); 
        }         }
        DateTime.Now - now;         DateTime.Now - now;
    }     }
   
    private Vector2i GetRandomZone(float range)     private Vector2i GetRandomZone(float range)
    {     {
        int num = (int)range / (int)this.m_zoneSize;         int num = (int)range / (int)this.m_zoneSize;
        Vector2i vector2i;         Vector2i vector2i;
        do         do
        {         {
            vector2i = new Vector2i(UnityEngine.Random.Range(-num, num), UnityEngine.Random.Range(-num, num));             vector2i = new Vector2i(UnityEngine.Random.Range(-num, num), UnityEngine.Random.Range(-num, num));
        }         }
        while (this.GetZonePos(vector2i).magnitude >= 10000f);         while (this.GetZonePos(vector2i).magnitude >= 10000f);
        return vector2i;         return vector2i;
    }     }
   
    private Vector3 GetRandomPointInZone(Vector2i zone, float locationRadius)     private Vector3 GetRandomPointInZone(Vector2i zone, float locationRadius)
    {     {
        Vector3 zonePos = this.GetZonePos(zone);         Vector3 zonePos = this.GetZonePos(zone);
        float num = this.m_zoneSize / 2f;         float num = this.m_zoneSize / 2f;
        float num2 = UnityEngine.Random.Range(-num + locationRadius, num - locationRadius);         float num2 = UnityEngine.Random.Range(-num + locationRadius, num - locationRadius);
        float num3 = UnityEngine.Random.Range(-num + locationRadius, num - locationRadius);         float num3 = UnityEngine.Random.Range(-num + locationRadius, num - locationRadius);
        return zonePos + new Vector3(num2, 0f, num3);         return zonePos + new Vector3(num2, 0f, num3);
    }     }
   
    private Vector3 GetRandomPointInZone(float locationRadius)     private Vector3 GetRandomPointInZone(float locationRadius)
    {     {
        Vector3 vector = new Vector3(UnityEngine.Random.Range(-10000f, 10000f), 0f, UnityEngine.Random.Range(-10000f, 10000f));         Vector3 vector = new Vector3(UnityEngine.Random.Range(-10000f, 10000f), 0f, UnityEngine.Random.Range(-10000f, 10000f));
        Vector2i zone = this.GetZone(vector);         Vector2i zone = this.GetZone(vector);
        Vector3 zonePos = this.GetZonePos(zone);         Vector3 zonePos = this.GetZonePos(zone);
        float num = this.m_zoneSize / 2f;         float num = this.m_zoneSize / 2f;
        return new Vector3(UnityEngine.Random.Range(zonePos.x - num + locationRadius, zonePos.x + num - locationRadius), 0f, UnityEngine.Random.Range(zonePos.z - num + locationRadius, zonePos.z + num - locationRadius));         return new Vector3(UnityEngine.Random.Range(zonePos.x - num + locationRadius, zonePos.x + num - locationRadius), 0f, UnityEngine.Random.Range(zonePos.z - num + locationRadius, zonePos.z + num - locationRadius));
    }     }
   
    private void PlaceLocations(Vector2i zoneID, Vector3 zoneCenterPos, Transform parent, Heightmap hmap, List<ZoneSystem.ClearArea> clearAreas, ZoneSystem.SpawnMode mode, List<GameObject> spawnedObjects)     private void PlaceLocations(Vector2i zoneID, Vector3 zoneCenterPos, Transform parent, Heightmap hmap, List<ZoneSystem.ClearArea> clearAreas, ZoneSystem.SpawnMode mode, List<GameObject> spawnedObjects)
    {     {
        DateTime now = DateTime.Now;         DateTime now = DateTime.Now;
        ZoneSystem.LocationInstance locationInstance;         ZoneSystem.LocationInstance locationInstance;
        if (this.m_locationInstances.TryGetValue(zoneID, out locationInstance))         if (this.m_locationInstances.TryGetValue(zoneID, out locationInstance))
        {         {
            if (locationInstance.m_placed)             if (locationInstance.m_placed)
            {             {
                return;                 return;
            }             }
            Vector3 position = locationInstance.m_position;             Vector3 position = locationInstance.m_position;
            Vector3 vector;             Vector3 vector;
            Heightmap.Biome biome;             Heightmap.Biome biome;
            Heightmap.BiomeArea biomeArea;             Heightmap.BiomeArea biomeArea;
            Heightmap heightmap;             Heightmap heightmap;
            this.GetGroundData(ref position, out vector, out biome, out biomeArea, out heightmap);             this.GetGroundData(ref position, out vector, out biome, out biomeArea, out heightmap);
            if (locationInstance.m_location.m_snapToWater)             if (locationInstance.m_location.m_snapToWater)
            {             {
.                position.y = this.m_waterLevel;                 position.y = 30f;
            }             }
            if (locationInstance.m_location.m_clearArea)             if (locationInstance.m_location.m_clearArea)
            {             {
                ZoneSystem.ClearArea clearArea = new ZoneSystem.ClearArea(position, locationInstance.m_location.m_exteriorRadius);                 ZoneSystem.ClearArea clearArea = new ZoneSystem.ClearArea(position, locationInstance.m_location.m_exteriorRadius);
                clearAreas.Add(clearArea);                 clearAreas.Add(clearArea);
            }             }
            Quaternion quaternion = Quaternion.identity;             Quaternion quaternion = Quaternion.identity;
            if (locationInstance.m_location.m_slopeRotation)             if (locationInstance.m_location.m_slopeRotation)
            {             {
                float num;                 float num;
                Vector3 vector2;                 Vector3 vector2;
                this.GetTerrainDelta(position, locationInstance.m_location.m_exteriorRadius, out num, out vector2);                 this.GetTerrainDelta(position, locationInstance.m_location.m_exteriorRadius, out num, out vector2);
                Vector3 vector3 = new Vector3(vector2.x, 0f, vector2.z);                 Vector3 vector3 = new Vector3(vector2.x, 0f, vector2.z);
                vector3.Normalize();                 vector3.Normalize();
                quaternion = Quaternion.LookRotation(vector3);                 quaternion = Quaternion.LookRotation(vector3);
                Vector3 eulerAngles = quaternion.eulerAngles;                 Vector3 eulerAngles = quaternion.eulerAngles;
                eulerAngles.y = Mathf.Round(eulerAngles.y / 22.5f) * 22.5f;                 eulerAngles.y = Mathf.Round(eulerAngles.y / 22.5f) * 22.5f;
                quaternion.eulerAngles = eulerAngles;                 quaternion.eulerAngles = eulerAngles;
            }             }
            else if (locationInstance.m_location.m_randomRotation)             else if (locationInstance.m_location.m_randomRotation)
            {             {
                quaternion = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 16) * 22.5f, 0f);                 quaternion = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 16) * 22.5f, 0f);
            }             }
            int num2 = WorldGenerator.instance.GetSeed() + zoneID.x * 4271 + zoneID.y * 9187;             int num2 = WorldGenerator.instance.GetSeed() + zoneID.x * 4271 + zoneID.y * 9187;
            this.SpawnLocation(locationInstance.m_location, num2, position, quaternion, mode, spawnedObjects);             this.SpawnLocation(locationInstance.m_location, num2, position, quaternion, mode, spawnedObjects);
            locationInstance.m_placed = true;             locationInstance.m_placed = true;
            this.m_locationInstances[zoneID] = locationInstance;             this.m_locationInstances[zoneID] = locationInstance;
            TimeSpan timeSpan = DateTime.Now - now;             TimeSpan timeSpan = DateTime.Now - now;
            string[] array = new string[5];             string[] array = new string[5];
            array[0] = "Placed locations in zone ";             array[0] = "Placed locations in zone ";
            int num3 = 1;             int num3 = 1;
            Vector2i vector2i = zoneID;             Vector2i vector2i = zoneID;
            array[num3] = vector2i.ToString();             array[num3] = vector2i.ToString();
            array[2] = "  duration ";             array[2] = "  duration ";
            array[3] = timeSpan.TotalMilliseconds.ToString();             array[3] = timeSpan.TotalMilliseconds.ToString();
            array[4] = " ms";             array[4] = " ms";
            ZLog.Log(string.Concat(array));             ZLog.Log(string.Concat(array));
            if (locationInstance.m_location.m_unique)             if (locationInstance.m_location.m_unique)
            {             {
                this.RemoveUnplacedLocations(locationInstance.m_location);                 this.RemoveUnplacedLocations(locationInstance.m_location);
            }             }
            if (locationInstance.m_location.m_iconPlaced)             if (locationInstance.m_location.m_iconPlaced)
            {             {
                this.SendLocationIcons(ZRoutedRpc.Everybody);                 this.SendLocationIcons(ZRoutedRpc.Everybody);
            }             }
        }         }
    }     }
   
    private void RemoveUnplacedLocations(ZoneSystem.ZoneLocation location)     private void RemoveUnplacedLocations(ZoneSystem.ZoneLocation location)
    {     {
        List<Vector2i> list = new List<Vector2i>();         List<Vector2i> list = new List<Vector2i>();
        foreach (KeyValuePair<Vector2i, ZoneSystem.LocationInstance> keyValuePair in this.m_locationInstances)         foreach (KeyValuePair<Vector2i, ZoneSystem.LocationInstance> keyValuePair in this.m_locationInstances)
        {         {
            if (keyValuePair.Value.m_location == location && !keyValuePair.Value.m_placed)             if (keyValuePair.Value.m_location == location && !keyValuePair.Value.m_placed)
            {             {
                list.Add(keyValuePair.Key);                 list.Add(keyValuePair.Key);
            }             }
        }         }
        foreach (Vector2i vector2i in list)         foreach (Vector2i vector2i in list)
        {         {
            this.m_locationInstances.Remove(vector2i);             this.m_locationInstances.Remove(vector2i);
        }         }
        ZLog.DevLog("Removed " + list.Count.ToString() + " unplaced locations of type " + location.m_prefab.Name);         ZLog.DevLog("Removed " + list.Count.ToString() + " unplaced locations of type " + location.m_prefab.Name);
    }     }
   
    public bool TestSpawnLocation(string name, Vector3 pos, bool disableSave = true)     public bool TestSpawnLocation(string name, Vector3 pos, bool disableSave = true)
    {     {
        if (!ZNet.instance.IsServer())         if (!ZNet.instance.IsServer())
        {         {
            return false;             return false;
        }         }
        ZoneSystem.ZoneLocation location = this.GetLocation(name);         ZoneSystem.ZoneLocation location = this.GetLocation(name);
        if (location == null)         if (location == null)
        {         {
            ZLog.Log("Missing location:" + name);             ZLog.Log("Missing location:" + name);
            global::Console.instance.Print("Missing location:" + name);             global::Console.instance.Print("Missing location:" + name);
            return false;             return false;
        }         }
        if (!location.m_prefab.IsValid)         if (!location.m_prefab.IsValid)
        {         {
            ZLog.Log("Missing prefab in location:" + name);             ZLog.Log("Missing prefab in location:" + name);
            global::Console.instance.Print("Missing location:" + name);             global::Console.instance.Print("Missing location:" + name);
            return false;             return false;
        }         }
        float num = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius);         float num = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius);
        Vector2i zone = this.GetZone(pos);         Vector2i zone = this.GetZone(pos);
        Vector3 zonePos = this.GetZonePos(zone);         Vector3 zonePos = this.GetZonePos(zone);
        pos.x = Mathf.Clamp(pos.x, zonePos.x - this.m_zoneSize / 2f + num, zonePos.x + this.m_zoneSize / 2f - num);         pos.x = Mathf.Clamp(pos.x, zonePos.x - this.m_zoneSize / 2f + num, zonePos.x + this.m_zoneSize / 2f - num);
        pos.z = Mathf.Clamp(pos.z, zonePos.z - this.m_zoneSize / 2f + num, zonePos.z + this.m_zoneSize / 2f - num);         pos.z = Mathf.Clamp(pos.z, zonePos.z - this.m_zoneSize / 2f + num, zonePos.z + this.m_zoneSize / 2f - num);
        string[] array = new string[6];         string[] array = new string[6];
        array[0] = "radius ";         array[0] = "radius ";
        array[1] = num.ToString();         array[1] = num.ToString();
        array[2] = "  ";         array[2] = "  ";
        int num2 = 3;         int num2 = 3;
        Vector3 vector = zonePos;         Vector3 vector = zonePos;
        array[num2] = vector.ToString();         array[num2] = vector.ToString();
        array[4] = " ";         array[4] = " ";
        int num3 = 5;         int num3 = 5;
        vector = pos;         vector = pos;
        array[num3] = vector.ToString();         array[num3] = vector.ToString();
        ZLog.Log(string.Concat(array));         ZLog.Log(string.Concat(array));
        MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "Location spawned, " + (disableSave ? "world saving DISABLED until restart" : "CAUTION! world saving is ENABLED, use normal location command to disable it!"), 0, null);         MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "Location spawned, " + (disableSave ? "world saving DISABLED until restart" : "CAUTION! world saving is ENABLED, use normal location command to disable it!"), 0, null);
        this.m_didZoneTest = disableSave;         this.m_didZoneTest = disableSave;
        float num4 = (float)UnityEngine.Random.Range(0, 16) * 22.5f;         float num4 = (float)UnityEngine.Random.Range(0, 16) * 22.5f;
        List<GameObject> list = new List<GameObject>();         List<GameObject> list = new List<GameObject>();
        this.SpawnLocation(location, UnityEngine.Random.Range(0, 99999), pos, Quaternion.Euler(0f, num4, 0f), ZoneSystem.SpawnMode.Full, list);         this.SpawnLocation(location, UnityEngine.Random.Range(0, 99999), pos, Quaternion.Euler(0f, num4, 0f), ZoneSystem.SpawnMode.Full, list);
        return true;         return true;
    }     }
   
    private bool PokeCanSpawnLocation(ZoneSystem.ZoneLocation location, bool isFirstSpawn)     private bool PokeCanSpawnLocation(ZoneSystem.ZoneLocation location, bool isFirstSpawn)
    {     {
        ZoneSystem.LocationPrefabLoadData locationPrefabLoadData = null;         ZoneSystem.LocationPrefabLoadData locationPrefabLoadData = null;
        for (int i = 0; i < this.m_locationPrefabs.Count; i++)         for (int i = 0; i < this.m_locationPrefabs.Count; i++)
        {         {
            if (this.m_locationPrefabs[i].PrefabAssetID == location.m_prefab.m_assetID)             if (this.m_locationPrefabs[i].PrefabAssetID == location.m_prefab.m_assetID)
            {             {
                locationPrefabLoadData = this.m_locationPrefabs[i];                 locationPrefabLoadData = this.m_locationPrefabs[i];
                break;                 break;
            }             }
        }         }
        if (locationPrefabLoadData == null)         if (locationPrefabLoadData == null)
        {         {
            locationPrefabLoadData = new ZoneSystem.LocationPrefabLoadData(location.m_prefab, isFirstSpawn);             locationPrefabLoadData = new ZoneSystem.LocationPrefabLoadData(location.m_prefab, isFirstSpawn);
            this.m_locationPrefabs.Add(locationPrefabLoadData);             this.m_locationPrefabs.Add(locationPrefabLoadData);
        }         }
        locationPrefabLoadData.m_iterationLifetime = this.GetLocationPrefabLifetime();         locationPrefabLoadData.m_iterationLifetime = this.GetLocationPrefabLifetime();
        return locationPrefabLoadData.IsLoaded;         return locationPrefabLoadData.IsLoaded;
    }     }
   
    public int GetLocationPrefabLifetime()     public int GetLocationPrefabLifetime()
    {     {
        int num = 2 * (this.m_activeArea + this.m_activeDistantArea) + 1;         int num = 2 * (this.m_activeArea + this.m_activeDistantArea) + 1;
        int num2 = num * num;         int num2 = num * num;
        int num3 = (ZNet.instance.IsServer() ? (ZNet.instance.GetPeers().Count + 1) : 1);         int num3 = (ZNet.instance.IsServer() ? (ZNet.instance.GetPeers().Count + 1) : 1);
        return num2 * num3;         return num2 * num3;
    }     }
   
    public bool ShouldDelayProxyLocationSpawning(int hash)     public bool ShouldDelayProxyLocationSpawning(int hash)
    {     {
        ZoneSystem.ZoneLocation location = this.GetLocation(hash);         ZoneSystem.ZoneLocation location = this.GetLocation(hash);
        if (location == null)         if (location == null)
        {         {
            ZLog.LogWarning("Missing location:" + hash.ToString());             ZLog.LogWarning("Missing location:" + hash.ToString());
            return false;             return false;
        }         }
        return !this.PokeCanSpawnLocation(location, false);         return !this.PokeCanSpawnLocation(location, false);
    }     }
   
    public GameObject SpawnProxyLocation(int hash, int seed, Vector3 pos, Quaternion rot)     public GameObject SpawnProxyLocation(int hash, int seed, Vector3 pos, Quaternion rot)
    {     {
        ZoneSystem.ZoneLocation location = this.GetLocation(hash);         ZoneSystem.ZoneLocation location = this.GetLocation(hash);
        if (location == null)         if (location == null)
        {         {
            ZLog.LogWarning("Missing location:" + hash.ToString());             ZLog.LogWarning("Missing location:" + hash.ToString());
            return null;             return null;
        }         }
        List<GameObject> list = new List<GameObject>();         List<GameObject> list = new List<GameObject>();
        return this.SpawnLocation(location, seed, pos, rot, ZoneSystem.SpawnMode.Client, list);         return this.SpawnLocation(location, seed, pos, rot, ZoneSystem.SpawnMode.Client, list);
    }     }
   
    private GameObject SpawnLocation(ZoneSystem.ZoneLocation location, int seed, Vector3 pos, Quaternion rot, ZoneSystem.SpawnMode mode, List<GameObject> spawnedGhostObjects)     private GameObject SpawnLocation(ZoneSystem.ZoneLocation location, int seed, Vector3 pos, Quaternion rot, ZoneSystem.SpawnMode mode, List<GameObject> spawnedGhostObjects)
    {     {
        location.m_prefab.Load();         location.m_prefab.Load();
.        ZNetView[] enabledComponentsInChildren = Utils.GetEnabledComponentsInChildren<ZNetView>(location.m_prefab.Asset);         ZNetView[] enabledComponentsInChildren = global::Utils.GetEnabledComponentsInChildren<ZNetView>(location.m_prefab.Asset);
        RandomSpawn[] enabledComponentsInChildren2 = Utils.GetEnabledComponentsInChildren<RandomSpawn>(location.m_prefab.Asset);         RandomSpawn[] enabledComponentsInChildren2 = global::Utils.GetEnabledComponentsInChildren<RandomSpawn>(location.m_prefab.Asset);
        for (int i = 0; i < enabledComponentsInChildren2.Length; i++)         for (int i = 0; i < enabledComponentsInChildren2.Length; i++)
        {         {
            enabledComponentsInChildren2[i].Prepare();             enabledComponentsInChildren2[i].Prepare();
        }         }
        Location component = location.m_prefab.Asset.GetComponent<Location>();         Location component = location.m_prefab.Asset.GetComponent<Location>();
        Vector3 vector = Vector3.zero;         Vector3 vector = Vector3.zero;
        Vector3 vector2 = Vector3.zero;         Vector3 vector2 = Vector3.zero;
        if (component.m_interiorTransform && component.m_generator)         if (component.m_interiorTransform && component.m_generator)
        {         {
            vector = component.m_interiorTransform.localPosition;             vector = component.m_interiorTransform.localPosition;
            vector2 = component.m_generator.transform.localPosition;             vector2 = component.m_generator.transform.localPosition;
        }         }
        Vector3 position = location.m_prefab.Asset.transform.position;         Vector3 position = location.m_prefab.Asset.transform.position;
        Quaternion rotation = location.m_prefab.Asset.transform.rotation;         Quaternion rotation = location.m_prefab.Asset.transform.rotation;
        location.m_prefab.Asset.transform.position = Vector3.zero;         location.m_prefab.Asset.transform.position = Vector3.zero;
        location.m_prefab.Asset.transform.rotation = Quaternion.identity;         location.m_prefab.Asset.transform.rotation = Quaternion.identity;
        UnityEngine.Random.InitState(seed);         UnityEngine.Random.InitState(seed);
        bool flag = component && component.m_useCustomInteriorTransform && component.m_interiorTransform && component.m_generator;         bool flag = component && component.m_useCustomInteriorTransform && component.m_interiorTransform && component.m_generator;
        Vector3 vector3 = Vector3.zero;         Vector3 vector3 = Vector3.zero;
        Vector3 vector4 = Vector3.zero;         Vector3 vector4 = Vector3.zero;
        Quaternion quaternion = Quaternion.identity;         Quaternion quaternion = Quaternion.identity;
        if (flag)         if (flag)
        {         {
            vector3 = component.m_generator.transform.localPosition;             vector3 = component.m_generator.transform.localPosition;
            vector4 = component.m_interiorTransform.localPosition;             vector4 = component.m_interiorTransform.localPosition;
            quaternion = component.m_interiorTransform.localRotation;             quaternion = component.m_interiorTransform.localRotation;
            Vector2i zone = this.GetZone(pos);             Vector2i zone = this.GetZone(pos);
            Vector3 zonePos = this.GetZonePos(zone);             Vector3 zonePos = this.GetZonePos(zone);
            component.m_generator.transform.localPosition = Vector3.zero;             component.m_generator.transform.localPosition = Vector3.zero;
            Vector3 vector5 = zonePos + vector + vector2 - pos;             Vector3 vector5 = zonePos + vector + vector2 - pos;
            Vector3 vector6 = (Matrix4x4.Rotate(Quaternion.Inverse(rot)) * Matrix4x4.Translate(vector5)).GetColumn(3);             Vector3 vector6 = (Matrix4x4.Rotate(Quaternion.Inverse(rot)) * Matrix4x4.Translate(vector5)).GetColumn(3);
            vector6.y = component.m_interiorTransform.localPosition.y;             vector6.y = component.m_interiorTransform.localPosition.y;
            component.m_interiorTransform.localPosition = vector6;             component.m_interiorTransform.localPosition = vector6;
            component.m_interiorTransform.localRotation = Quaternion.Inverse(rot);             component.m_interiorTransform.localRotation = Quaternion.Inverse(rot);
        }         }
        if (component && component.m_generator && component.m_useCustomInteriorTransform != component.m_generator.m_useCustomInteriorTransform)         if (component && component.m_generator && component.m_useCustomInteriorTransform != component.m_generator.m_useCustomInteriorTransform)
        {         {
            ZLog.LogWarning(component.name + " & " + component.m_generator.name + " don't have matching m_useCustomInteriorTransform()! If one has it the other should as well!");             ZLog.LogWarning(component.name + " & " + component.m_generator.name + " don't have matching m_useCustomInteriorTransform()! If one has it the other should as well!");
        }         }
        GameObject gameObject = null;         GameObject gameObject = null;
        if (mode == ZoneSystem.SpawnMode.Full || mode == ZoneSystem.SpawnMode.Ghost)         if (mode == ZoneSystem.SpawnMode.Full || mode == ZoneSystem.SpawnMode.Ghost)
        {         {
            UnityEngine.Random.InitState(seed);             UnityEngine.Random.InitState(seed);
.            RandomSpawn[] array = enabledComponentsInChildren2;              foreach (RandomSpawn randomSpawn in enabledComponentsInChildren2)
            for (int j = 0; j < array.Length; j++)  
            {             {
.                array[j].Randomize(component, null);                 Vector3 position2 = randomSpawn.gameObject.transform.position; 
                  Vector3 vector7 = pos + rot * position2; 
                  randomSpawn.Randomize(vector7, component, null);
            }             }
            WearNTear.m_randomInitialDamage = component.m_applyRandomDamage;             WearNTear.m_randomInitialDamage = component.m_applyRandomDamage;
            foreach (ZNetView znetView in enabledComponentsInChildren)             foreach (ZNetView znetView in enabledComponentsInChildren)
            {             {
                if (znetView.gameObject.activeSelf)                 if (znetView.gameObject.activeSelf)
                {                 {
.                    Vector3 position2 = znetView.gameObject.transform.position;                     Vector3 position3 = znetView.gameObject.transform.position;
                    Vector3 vector7 = pos + rot * position2;                     Vector3 vector8 = pos + rot * position3;
                    Quaternion rotation2 = znetView.gameObject.transform.rotation;                     Quaternion rotation2 = znetView.gameObject.transform.rotation;
                    Quaternion quaternion2 = rot * rotation2;                     Quaternion quaternion2 = rot * rotation2;
                    if (mode == ZoneSystem.SpawnMode.Ghost)                     if (mode == ZoneSystem.SpawnMode.Ghost)
                    {                     {
                        ZNetView.StartGhostInit();                         ZNetView.StartGhostInit();
                    }                     }
.                    GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(znetView.gameObject, vector7, quaternion2);                     GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(znetView.gameObject, vector8, quaternion2);
                    gameObject2.GetComponent<ZNetView>().HoldReferenceTo(location.m_prefab);                     gameObject2.HoldReferenceTo(location.m_prefab);
                    DungeonGenerator component2 = gameObject2.GetComponent<DungeonGenerator>();                     DungeonGenerator component2 = gameObject2.GetComponent<DungeonGenerator>();
                    if (component2)                     if (component2)
                    {                     {
                        if (flag)                         if (flag)
                        {                         {
                            component2.m_originalPosition = vector2;                             component2.m_originalPosition = vector2;
                        }                         }
                        component2.Generate(mode);                         component2.Generate(mode);
                    }                     }
                    if (mode == ZoneSystem.SpawnMode.Ghost)                     if (mode == ZoneSystem.SpawnMode.Ghost)
                    {                     {
                        spawnedGhostObjects.Add(gameObject2);                         spawnedGhostObjects.Add(gameObject2);
                        ZNetView.FinishGhostInit();                         ZNetView.FinishGhostInit();
                    }                     }
                }                 }
            }             }
            WearNTear.m_randomInitialDamage = false;             WearNTear.m_randomInitialDamage = false;
.            array = enabledComponentsInChildren2;             RandomSpawn[] array = enabledComponentsInChildren2;
            for (int j = 0; j < array.Length; j++)             for (int j = 0; j < array.Length; j++)
            {             {
                array[j].Reset();                 array[j].Reset();
            }             }
            ZNetView[] array2 = enabledComponentsInChildren;             ZNetView[] array2 = enabledComponentsInChildren;
            for (int j = 0; j < array2.Length; j++)             for (int j = 0; j < array2.Length; j++)
            {             {
                array2[j].gameObject.SetActive(true);                 array2[j].gameObject.SetActive(true);
            }             }
            location.m_prefab.Asset.transform.position = position;             location.m_prefab.Asset.transform.position = position;
            location.m_prefab.Asset.transform.rotation = rotation;             location.m_prefab.Asset.transform.rotation = rotation;
            if (flag)             if (flag)
            {             {
                component.m_generator.transform.localPosition = vector3;                 component.m_generator.transform.localPosition = vector3;
                component.m_interiorTransform.localPosition = vector4;                 component.m_interiorTransform.localPosition = vector4;
                component.m_interiorTransform.localRotation = quaternion;                 component.m_interiorTransform.localRotation = quaternion;
            }             }
            this.CreateLocationProxy(location, seed, pos, rot, mode, spawnedGhostObjects);             this.CreateLocationProxy(location, seed, pos, rot, mode, spawnedGhostObjects);
        }         }
        else         else
        {         {
            UnityEngine.Random.InitState(seed);             UnityEngine.Random.InitState(seed);
.            RandomSpawn[] array = enabledComponentsInChildren2;              foreach (RandomSpawn randomSpawn2 in enabledComponentsInChildren2)
            for (int j = 0; j < array.Length; j++)  
            {             {
.                array[j].Randomize(component, null);                 Vector3 position4 = randomSpawn2.gameObject.transform.position; 
                  Vector3 vector9 = pos + rot * position4; 
                  randomSpawn2.Randomize(vector9, component, null);
            }             }
            ZNetView[] array2 = enabledComponentsInChildren;             ZNetView[] array2 = enabledComponentsInChildren;
            for (int j = 0; j < array2.Length; j++)             for (int j = 0; j < array2.Length; j++)
            {             {
                array2[j].gameObject.SetActive(false);                 array2[j].gameObject.SetActive(false);
            }             }
.            gameObject = UnityEngine.Object.Instantiate<GameObject>(location.m_prefab.Asset, pos, rot);             gameObject = SoftReferenceableAssets.Utils.Instantiate(location.m_prefab, pos, rot);
            ReferenceHolder referenceHolder = gameObject.GetComponent<ReferenceHolder>();   
            if (referenceHolder == null)   
            {   
                referenceHolder = gameObject.AddComponent<ReferenceHolder>();   
            }   
            if (referenceHolder != null)   
            {   
                referenceHolder.HoldReferenceTo(location.m_prefab);   
            }   
            else   
            {   
                ZLog.LogError("Failed to get or add reference holder!");   
            }   
            gameObject.SetActive(true);             gameObject.SetActive(true);
.            array = enabledComponentsInChildren2;             RandomSpawn[] array = enabledComponentsInChildren2;
            for (int j = 0; j < array.Length; j++)             for (int j = 0; j < array.Length; j++)
            {             {
                array[j].Reset();                 array[j].Reset();
            }             }
            array2 = enabledComponentsInChildren;             array2 = enabledComponentsInChildren;
            for (int j = 0; j < array2.Length; j++)             for (int j = 0; j < array2.Length; j++)
            {             {
                array2[j].gameObject.SetActive(true);                 array2[j].gameObject.SetActive(true);
            }             }
            location.m_prefab.Asset.transform.position = position;             location.m_prefab.Asset.transform.position = position;
            location.m_prefab.Asset.transform.rotation = rotation;             location.m_prefab.Asset.transform.rotation = rotation;
            if (flag)             if (flag)
            {             {
                component.m_generator.transform.localPosition = vector3;                 component.m_generator.transform.localPosition = vector3;
                component.m_interiorTransform.localPosition = vector4;                 component.m_interiorTransform.localPosition = vector4;
                component.m_interiorTransform.localRotation = quaternion;                 component.m_interiorTransform.localRotation = quaternion;
            }             }
        }         }
        location.m_prefab.Release();         location.m_prefab.Release();
        SnapToGround.SnappAll();         SnapToGround.SnappAll();
        return gameObject;         return gameObject;
    }     }
   
    private void CreateLocationProxy(ZoneSystem.ZoneLocation location, int seed, Vector3 pos, Quaternion rotation, ZoneSystem.SpawnMode mode, List<GameObject> spawnedGhostObjects)     private void CreateLocationProxy(ZoneSystem.ZoneLocation location, int seed, Vector3 pos, Quaternion rotation, ZoneSystem.SpawnMode mode, List<GameObject> spawnedGhostObjects)
    {     {
        if (mode == ZoneSystem.SpawnMode.Ghost)         if (mode == ZoneSystem.SpawnMode.Ghost)
        {         {
            ZNetView.StartGhostInit();             ZNetView.StartGhostInit();
        }         }
        GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_locationProxyPrefab, pos, rotation);         GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_locationProxyPrefab, pos, rotation);
        LocationProxy component = gameObject.GetComponent<LocationProxy>();         LocationProxy component = gameObject.GetComponent<LocationProxy>();
        bool flag = mode == ZoneSystem.SpawnMode.Full;         bool flag = mode == ZoneSystem.SpawnMode.Full;
        component.SetLocation(location.m_prefab.Name, seed, flag);         component.SetLocation(location.m_prefab.Name, seed, flag);
        if (mode == ZoneSystem.SpawnMode.Ghost)         if (mode == ZoneSystem.SpawnMode.Ghost)
        {         {
            spawnedGhostObjects.Add(gameObject);             spawnedGhostObjects.Add(gameObject);
            ZNetView.FinishGhostInit();             ZNetView.FinishGhostInit();
        }         }
    }     }
   
    private void RegisterLocation(ZoneSystem.ZoneLocation location, Vector3 pos, bool generated)     private void RegisterLocation(ZoneSystem.ZoneLocation location, Vector3 pos, bool generated)
    {     {
        ZoneSystem.LocationInstance locationInstance = default(ZoneSystem.LocationInstance);         ZoneSystem.LocationInstance locationInstance = default(ZoneSystem.LocationInstance);
        locationInstance.m_location = location;         locationInstance.m_location = location;
        locationInstance.m_position = pos;         locationInstance.m_position = pos;
        locationInstance.m_placed = generated;         locationInstance.m_placed = generated;
        Vector2i zone = this.GetZone(pos);         Vector2i zone = this.GetZone(pos);
        if (this.m_locationInstances.ContainsKey(zone))         if (this.m_locationInstances.ContainsKey(zone))
        {         {
            string text = "Location already exist in zone ";             string text = "Location already exist in zone ";
            Vector2i vector2i = zone;             Vector2i vector2i = zone;
            ZLog.LogWarning(text + vector2i.ToString());             ZLog.LogWarning(text + vector2i.ToString());
            return;             return;
        }         }
        this.m_locationInstances.Add(zone, locationInstance);         this.m_locationInstances.Add(zone, locationInstance);
    }     }
   
.    private bool HaveLocationInRange(string prefabName, string group, Vector3 p, float radius)     private bool HaveLocationInRange(string prefabName, string group, Vector3 p, float radius, bool maxGroup = false)
    {     {
        foreach (ZoneSystem.LocationInstance locationInstance in this.m_locationInstances.Values)         foreach (ZoneSystem.LocationInstance locationInstance in this.m_locationInstances.Values)
        {         {
.            if ((locationInstance.m_location.m_prefab.Name == prefabName || (group.Length > 0 && group == locationInstance.m_location.m_group)) && Vector3.Distance(locationInstance.m_position, p) < radius)             if ((locationInstance.m_location.m_prefab.Name == prefabName || (!maxGroup && group.Length > 0 && group == locationInstance.m_location.m_group) || (maxGroup && group.Length > 0 && group == locationInstance.m_location.m_groupMax)) && Vector3.Distance(locationInstance.m_position, p) < radius)
            {             {
                return true;                 return true;
            }             }
        }         }
        return false;         return false;
    }     }
   
    public bool GetLocationIcon(string name, out Vector3 pos)     public bool GetLocationIcon(string name, out Vector3 pos)
    {     {
        if (ZNet.instance.IsServer())         if (ZNet.instance.IsServer())
        {         {
            using (Dictionary<Vector2i, ZoneSystem.LocationInstance>.Enumerator enumerator = this.m_locationInstances.GetEnumerator())             using (Dictionary<Vector2i, ZoneSystem.LocationInstance>.Enumerator enumerator = this.m_locationInstances.GetEnumerator())
            {             {
                while (enumerator.MoveNext())                 while (enumerator.MoveNext())
                {                 {
                    KeyValuePair<Vector2i, ZoneSystem.LocationInstance> keyValuePair = enumerator.Current;                     KeyValuePair<Vector2i, ZoneSystem.LocationInstance> keyValuePair = enumerator.Current;
                    if ((keyValuePair.Value.m_location.m_iconAlways || (keyValuePair.Value.m_location.m_iconPlaced && keyValuePair.Value.m_placed)) && keyValuePair.Value.m_location.m_prefab.Name == name)                     if ((keyValuePair.Value.m_location.m_iconAlways || (keyValuePair.Value.m_location.m_iconPlaced && keyValuePair.Value.m_placed)) && keyValuePair.Value.m_location.m_prefab.Name == name)
                    {                     {
                        pos = keyValuePair.Value.m_position;                         pos = keyValuePair.Value.m_position;
                        return true;                         return true;
                    }                     }
                }                 }
                goto IL_F6;                 goto IL_F6;
            }             }
        }         }
        foreach (KeyValuePair<Vector3, string> keyValuePair2 in this.m_locationIcons)         foreach (KeyValuePair<Vector3, string> keyValuePair2 in this.m_locationIcons)
        {         {
            if (keyValuePair2.Value == name)             if (keyValuePair2.Value == name)
            {             {
                pos = keyValuePair2.Key;                 pos = keyValuePair2.Key;
                return true;                 return true;
            }             }
        }         }
        IL_F6:         IL_F6:
        pos = Vector3.zero;         pos = Vector3.zero;
        return false;         return false;
    }     }
   
    public void GetLocationIcons(Dictionary<Vector3, string> icons)     public void GetLocationIcons(Dictionary<Vector3, string> icons)
    {     {
        if (ZNet.instance.IsServer())         if (ZNet.instance.IsServer())
        {         {
            using (Dictionary<Vector2i, ZoneSystem.LocationInstance>.ValueCollection.Enumerator enumerator = this.m_locationInstances.Values.GetEnumerator())             using (Dictionary<Vector2i, ZoneSystem.LocationInstance>.ValueCollection.Enumerator enumerator = this.m_locationInstances.Values.GetEnumerator())
            {             {
                while (enumerator.MoveNext())                 while (enumerator.MoveNext())
                {                 {
                    ZoneSystem.LocationInstance locationInstance = enumerator.Current;                     ZoneSystem.LocationInstance locationInstance = enumerator.Current;
                    if (locationInstance.m_location.m_iconAlways || (locationInstance.m_location.m_iconPlaced && locationInstance.m_placed))                     if (locationInstance.m_location.m_iconAlways || (locationInstance.m_location.m_iconPlaced && locationInstance.m_placed))
                    {                     {
                        icons[locationInstance.m_position] = locationInstance.m_location.m_prefab.Name;                         icons[locationInstance.m_position] = locationInstance.m_location.m_prefab.Name;
                    }                     }
                }                 }
                return;                 return;
            }             }
        }         }
        foreach (KeyValuePair<Vector3, string> keyValuePair in this.m_locationIcons)         foreach (KeyValuePair<Vector3, string> keyValuePair in this.m_locationIcons)
        {         {
            icons.Add(keyValuePair.Key, keyValuePair.Value);             icons.Add(keyValuePair.Key, keyValuePair.Value);
        }         }
    }     }
   
    private void GetTerrainDelta(Vector3 center, float radius, out float delta, out Vector3 slopeDirection)     private void GetTerrainDelta(Vector3 center, float radius, out float delta, out Vector3 slopeDirection)
    {     {
        int num = 10;         int num = 10;
        float num2 = -999999f;         float num2 = -999999f;
        float num3 = 999999f;         float num3 = 999999f;
        Vector3 vector = center;         Vector3 vector = center;
        Vector3 vector2 = center;         Vector3 vector2 = center;
        for (int i = 0; i < num; i++)         for (int i = 0; i < num; i++)
        {         {
            Vector2 vector3 = UnityEngine.Random.insideUnitCircle * radius;             Vector2 vector3 = UnityEngine.Random.insideUnitCircle * radius;
            Vector3 vector4 = center + new Vector3(vector3.x, 0f, vector3.y);             Vector3 vector4 = center + new Vector3(vector3.x, 0f, vector3.y);
            float groundHeight = this.GetGroundHeight(vector4);             float groundHeight = this.GetGroundHeight(vector4);
            if (groundHeight < num3)             if (groundHeight < num3)
            {             {
                num3 = groundHeight;                 num3 = groundHeight;
                vector2 = vector4;                 vector2 = vector4;
            }             }
            if (groundHeight > num2)             if (groundHeight > num2)
            {             {
                num2 = groundHeight;                 num2 = groundHeight;
                vector = vector4;                 vector = vector4;
            }             }
        }         }
        delta = num2 - num3;         delta = num2 - num3;
        slopeDirection = Vector3.Normalize(vector2 - vector);         slopeDirection = Vector3.Normalize(vector2 - vector);
    }     }
   
    public bool IsBlocked(Vector3 p)     public bool IsBlocked(Vector3 p)
    {     {
        p.y += 2000f;         p.y += 2000f;
        return Physics.Raycast(p, Vector3.down, 10000f, this.m_blockRayMask);         return Physics.Raycast(p, Vector3.down, 10000f, this.m_blockRayMask);
    }     }
   
    public float GetAverageGroundHeight(Vector3 p, float radius)     public float GetAverageGroundHeight(Vector3 p, float radius)
    {     {
        Vector3 vector = p;         Vector3 vector = p;
        vector.y = 6000f;         vector.y = 6000f;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(vector, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))         if (Physics.Raycast(vector, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))
        {         {
            return raycastHit.point.y;             return raycastHit.point.y;
        }         }
        return p.y;         return p.y;
    }     }
   
    public float GetGroundHeight(Vector3 p)     public float GetGroundHeight(Vector3 p)
    {     {
        Vector3 vector = p;         Vector3 vector = p;
        vector.y = 6000f;         vector.y = 6000f;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(vector, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))         if (Physics.Raycast(vector, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))
        {         {
            return raycastHit.point.y;             return raycastHit.point.y;
        }         }
        return p.y;         return p.y;
    }     }
   
    public bool GetGroundHeight(Vector3 p, out float height)     public bool GetGroundHeight(Vector3 p, out float height)
    {     {
        p.y = 6000f;         p.y = 6000f;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(p, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))         if (Physics.Raycast(p, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))
        {         {
            height = raycastHit.point.y;             height = raycastHit.point.y;
            return true;             return true;
        }         }
        height = 0f;         height = 0f;
        return false;         return false;
    }     }
   
    public float GetSolidHeight(Vector3 p)     public float GetSolidHeight(Vector3 p)
    {     {
        Vector3 vector = p;         Vector3 vector = p;
        vector.y += 1000f;         vector.y += 1000f;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(vector, Vector3.down, out raycastHit, 2000f, this.m_solidRayMask))         if (Physics.Raycast(vector, Vector3.down, out raycastHit, 2000f, this.m_solidRayMask))
        {         {
            return raycastHit.point.y;             return raycastHit.point.y;
        }         }
        return p.y;         return p.y;
    }     }
   
    public bool GetSolidHeight(Vector3 p, out float height, int heightMargin = 1000)     public bool GetSolidHeight(Vector3 p, out float height, int heightMargin = 1000)
    {     {
        p.y += (float)heightMargin;         p.y += (float)heightMargin;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(p, Vector3.down, out raycastHit, 2000f, this.m_solidRayMask) && !raycastHit.collider.attachedRigidbody)         if (Physics.Raycast(p, Vector3.down, out raycastHit, 2000f, this.m_solidRayMask) && !raycastHit.collider.attachedRigidbody)
        {         {
            height = raycastHit.point.y;             height = raycastHit.point.y;
            return true;             return true;
        }         }
        height = 0f;         height = 0f;
        return false;         return false;
    }     }
   
    public bool GetSolidHeight(Vector3 p, float radius, out float height, Transform ignore)     public bool GetSolidHeight(Vector3 p, float radius, out float height, Transform ignore)
    {     {
        height = p.y - 1000f;         height = p.y - 1000f;
        p.y += 1000f;         p.y += 1000f;
        int num;         int num;
        if (radius <= 0f)         if (radius <= 0f)
        {         {
            num = Physics.RaycastNonAlloc(p, Vector3.down, this.rayHits, 2000f, this.m_solidRayMask);             num = Physics.RaycastNonAlloc(p, Vector3.down, this.rayHits, 2000f, this.m_solidRayMask);
        }         }
        else         else
        {         {
            num = Physics.SphereCastNonAlloc(p, radius, Vector3.down, this.rayHits, 2000f, this.m_solidRayMask);             num = Physics.SphereCastNonAlloc(p, radius, Vector3.down, this.rayHits, 2000f, this.m_solidRayMask);
        }         }
        bool flag = false;         bool flag = false;
        for (int i = 0; i < num; i++)         for (int i = 0; i < num; i++)
        {         {
            RaycastHit raycastHit = this.rayHits[i];             RaycastHit raycastHit = this.rayHits[i];
            Collider collider = raycastHit.collider;             Collider collider = raycastHit.collider;
.            if (!(collider.attachedRigidbody != null) && (!(ignore != null) || !Utils.IsParent(collider.transform, ignore)))             if (!(collider.attachedRigidbody != null) && (!(ignore != null) || !global::Utils.IsParent(collider.transform, ignore)))
            {             {
                if (raycastHit.point.y > height)                 if (raycastHit.point.y > height)
                {                 {
                    height = raycastHit.point.y;                     height = raycastHit.point.y;
                }                 }
                flag = true;                 flag = true;
            }             }
        }         }
        return flag;         return flag;
    }     }
   
    public bool GetSolidHeight(Vector3 p, out float height, out Vector3 normal)     public bool GetSolidHeight(Vector3 p, out float height, out Vector3 normal)
    {     {
        GameObject gameObject;         GameObject gameObject;
        return this.GetSolidHeight(p, out height, out normal, out gameObject);         return this.GetSolidHeight(p, out height, out normal, out gameObject);
    }     }
   
    public bool GetSolidHeight(Vector3 p, out float height, out Vector3 normal, out GameObject go)     public bool GetSolidHeight(Vector3 p, out float height, out Vector3 normal, out GameObject go)
    {     {
        p.y += 1000f;         p.y += 1000f;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(p, Vector3.down, out raycastHit, 2000f, this.m_solidRayMask) && !raycastHit.collider.attachedRigidbody)         if (Physics.Raycast(p, Vector3.down, out raycastHit, 2000f, this.m_solidRayMask) && !raycastHit.collider.attachedRigidbody)
        {         {
            height = raycastHit.point.y;             height = raycastHit.point.y;
            normal = raycastHit.normal;             normal = raycastHit.normal;
            go = raycastHit.collider.gameObject;             go = raycastHit.collider.gameObject;
            return true;             return true;
        }         }
        height = 0f;         height = 0f;
        normal = Vector3.zero;         normal = Vector3.zero;
        go = null;         go = null;
        return false;         return false;
    }     }
   
    public bool GetStaticSolidHeight(Vector3 p, out float height, out Vector3 normal)     public bool GetStaticSolidHeight(Vector3 p, out float height, out Vector3 normal)
    {     {
        p.y += 1000f;         p.y += 1000f;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(p, Vector3.down, out raycastHit, 2000f, this.m_staticSolidRayMask) && !raycastHit.collider.attachedRigidbody)         if (Physics.Raycast(p, Vector3.down, out raycastHit, 2000f, this.m_staticSolidRayMask) && !raycastHit.collider.attachedRigidbody)
        {         {
            height = raycastHit.point.y;             height = raycastHit.point.y;
            normal = raycastHit.normal;             normal = raycastHit.normal;
            return true;             return true;
        }         }
        height = 0f;         height = 0f;
        normal = Vector3.zero;         normal = Vector3.zero;
        return false;         return false;
    }     }
   
    public bool FindFloor(Vector3 p, out float height)     public bool FindFloor(Vector3 p, out float height)
    {     {
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(p + Vector3.up * 1f, Vector3.down, out raycastHit, 1000f, this.m_solidRayMask))         if (Physics.Raycast(p + Vector3.up * 1f, Vector3.down, out raycastHit, 1000f, this.m_solidRayMask))
        {         {
            height = raycastHit.point.y;             height = raycastHit.point.y;
            return true;             return true;
        }         }
        height = 0f;         height = 0f;
        return false;         return false;
    }     }
   
.      public float GetGroundOffset(Vector3 position)
      {
          Vector3 vector;
          Heightmap.Biome biome;
          Heightmap.BiomeArea biomeArea;
          Heightmap heightmap;
          this.GetGroundData(ref position, out vector, out biome, out biomeArea, out heightmap);
          if (heightmap)
          {
              return heightmap.GetHeightOffset(position);
          }
          return 0f;
      }
   
      public static bool IsLavaPreHeightmap(Vector3 position, float lavaValue = 0.6f)
      {
          if (WorldGenerator.instance.GetBiome(position.x, position.z, 0.02f, false) != Heightmap.Biome.AshLands)
          {
              return false;
          }
          Color color;
          WorldGenerator.instance.GetBiomeHeight(Heightmap.Biome.AshLands, position.x, position.z, out color, false);
          return color.a > lavaValue;
      }
   
      public bool IsLava(Vector3 position, bool defaultTrue = false)
      {
          Vector3 vector;
          Heightmap.Biome biome;
          Heightmap.BiomeArea biomeArea;
          Heightmap heightmap;
          this.GetGroundData(ref position, out vector, out biome, out biomeArea, out heightmap);
          if (!heightmap)
          {
              return defaultTrue;
          }
          return heightmap.IsLava(position, 0.6f);
      }
   
      public bool IsLava(ref Vector3 position, bool defaultTrue = false)
      {
          Vector3 vector;
          Heightmap.Biome biome;
          Heightmap.BiomeArea biomeArea;
          Heightmap heightmap;
          this.GetGroundData(ref position, out vector, out biome, out biomeArea, out heightmap);
          if (!heightmap)
          {
              return defaultTrue;
          }
          return heightmap.IsLava(position, 0.6f);
      }
   
    public void GetGroundData(ref Vector3 p, out Vector3 normal, out Heightmap.Biome biome, out Heightmap.BiomeArea biomeArea, out Heightmap hmap)     public void GetGroundData(ref Vector3 p, out Vector3 normal, out Heightmap.Biome biome, out Heightmap.BiomeArea biomeArea, out Heightmap hmap)
    {     {
        biome = Heightmap.Biome.None;         biome = Heightmap.Biome.None;
        biomeArea = Heightmap.BiomeArea.Everything;         biomeArea = Heightmap.BiomeArea.Everything;
        hmap = null;         hmap = null;
        RaycastHit raycastHit;         RaycastHit raycastHit;
        if (Physics.Raycast(p + Vector3.up * 5000f, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))         if (Physics.Raycast(p + Vector3.up * 5000f, Vector3.down, out raycastHit, 10000f, this.m_terrainRayMask))
        {         {
            p.y = raycastHit.point.y;             p.y = raycastHit.point.y;
            normal = raycastHit.normal;             normal = raycastHit.normal;
            Heightmap component = raycastHit.collider.GetComponent<Heightmap>();             Heightmap component = raycastHit.collider.GetComponent<Heightmap>();
            if (component)             if (component)
            {             {
.                biome = component.GetBiome(raycastHit.point);                 biome = component.GetBiome(raycastHit.point, 0.02f, false);
                biomeArea = component.GetBiomeArea();                 biomeArea = component.GetBiomeArea();
                hmap = component;                 hmap = component;
            }             }
            return;             return;
        }         }
        normal = Vector3.up;         normal = Vector3.up;
    }     }
   
    private void UpdateTTL(float dt)     private void UpdateTTL(float dt)
    {     {
        foreach (KeyValuePair<Vector2i, ZoneSystem.ZoneData> keyValuePair in this.m_zones)         foreach (KeyValuePair<Vector2i, ZoneSystem.ZoneData> keyValuePair in this.m_zones)
        {         {
            keyValuePair.Value.m_ttl += dt;             keyValuePair.Value.m_ttl += dt;
        }         }
        foreach (KeyValuePair<Vector2i, ZoneSystem.ZoneData> keyValuePair2 in this.m_zones)         foreach (KeyValuePair<Vector2i, ZoneSystem.ZoneData> keyValuePair2 in this.m_zones)
        {         {
            if (keyValuePair2.Value.m_ttl > this.m_zoneTTL && !ZNetScene.instance.HaveInstanceInSector(keyValuePair2.Key))             if (keyValuePair2.Value.m_ttl > this.m_zoneTTL && !ZNetScene.instance.HaveInstanceInSector(keyValuePair2.Key))
            {             {
                UnityEngine.Object.Destroy(keyValuePair2.Value.m_root);                 UnityEngine.Object.Destroy(keyValuePair2.Value.m_root);
                this.m_zones.Remove(keyValuePair2.Key);                 this.m_zones.Remove(keyValuePair2.Key);
                break;                 break;
            }             }
        }         }
    }     }
   
    public bool FindClosestLocation(string name, Vector3 point, out ZoneSystem.LocationInstance closest)     public bool FindClosestLocation(string name, Vector3 point, out ZoneSystem.LocationInstance closest)
    {     {
        float num = 999999f;         float num = 999999f;
        closest = default(ZoneSystem.LocationInstance);         closest = default(ZoneSystem.LocationInstance);
        bool flag = false;         bool flag = false;
        foreach (ZoneSystem.LocationInstance locationInstance in this.m_locationInstances.Values)         foreach (ZoneSystem.LocationInstance locationInstance in this.m_locationInstances.Values)
        {         {
            float num2 = Vector3.Distance(locationInstance.m_position, point);             float num2 = Vector3.Distance(locationInstance.m_position, point);
            if (locationInstance.m_location.m_prefab.Name == name && num2 < num)             if (locationInstance.m_location.m_prefab.Name == name && num2 < num)
            {             {
                num = num2;                 num = num2;
                closest = locationInstance;                 closest = locationInstance;
                flag = true;                 flag = true;
            }             }
        }         }
        return flag;         return flag;
    }     }
   
    public bool FindLocations(string name, ref List<ZoneSystem.LocationInstance> locations)     public bool FindLocations(string name, ref List<ZoneSystem.LocationInstance> locations)
    {     {
        locations.Clear();         locations.Clear();
        foreach (ZoneSystem.LocationInstance locationInstance in this.m_locationInstances.Values)         foreach (ZoneSystem.LocationInstance locationInstance in this.m_locationInstances.Values)
        {         {
            if (locationInstance.m_location.m_prefab.Name == name)             if (locationInstance.m_location.m_prefab.Name == name)
            {             {
                locations.Add(locationInstance);                 locations.Add(locationInstance);
            }             }
        }         }
        return locations.Count > 0;         return locations.Count > 0;
    }     }
   
    public Vector2i GetZone(Vector3 point)     public Vector2i GetZone(Vector3 point)
    {     {
        int num = Mathf.FloorToInt((float)(((double)point.x + (double)this.m_zoneSize / 2.0) / (double)this.m_zoneSize));         int num = Mathf.FloorToInt((float)(((double)point.x + (double)this.m_zoneSize / 2.0) / (double)this.m_zoneSize));
        int num2 = Mathf.FloorToInt((float)(((double)point.z + (double)this.m_zoneSize / 2.0) / (double)this.m_zoneSize));         int num2 = Mathf.FloorToInt((float)(((double)point.z + (double)this.m_zoneSize / 2.0) / (double)this.m_zoneSize));
        return new Vector2i(num, num2);         return new Vector2i(num, num2);
    }     }
   
    public Vector3 GetZonePos(Vector2i id)     public Vector3 GetZonePos(Vector2i id)
    {     {
        return new Vector3((float)((double)id.x * (double)this.m_zoneSize), 0f, (float)((double)id.y * (double)this.m_zoneSize));         return new Vector3((float)((double)id.x * (double)this.m_zoneSize), 0f, (float)((double)id.y * (double)this.m_zoneSize));
    }     }
   
    private void SetZoneGenerated(Vector2i zoneID)     private void SetZoneGenerated(Vector2i zoneID)
    {     {
        this.m_generatedZones.Add(zoneID);         this.m_generatedZones.Add(zoneID);
    }     }
   
    private bool IsZoneGenerated(Vector2i zoneID)     private bool IsZoneGenerated(Vector2i zoneID)
    {     {
        return this.m_generatedZones.Contains(zoneID);         return this.m_generatedZones.Contains(zoneID);
    }     }
   
    public bool IsZoneReadyForType(Vector2i zoneID, ZDO.ObjectType objectType)     public bool IsZoneReadyForType(Vector2i zoneID, ZDO.ObjectType objectType)
    {     {
        if (this.m_loadingObjectsInZones.Count <= 0)         if (this.m_loadingObjectsInZones.Count <= 0)
        {         {
            return true;             return true;
        }         }
        if (!this.m_loadingObjectsInZones.ContainsKey(zoneID))         if (!this.m_loadingObjectsInZones.ContainsKey(zoneID))
        {         {
            return true;             return true;
        }         }
        foreach (ZDO zdo in this.m_loadingObjectsInZones[zoneID])         foreach (ZDO zdo in this.m_loadingObjectsInZones[zoneID])
        {         {
            if (objectType < zdo.Type)             if (objectType < zdo.Type)
            {             {
                return false;                 return false;
            }             }
        }         }
        return true;         return true;
    }     }
   
    public void SetLoadingInZone(ZDO zdo)     public void SetLoadingInZone(ZDO zdo)
    {     {
        Vector2i sector = zdo.GetSector();         Vector2i sector = zdo.GetSector();
        if (this.m_loadingObjectsInZones.ContainsKey(sector))         if (this.m_loadingObjectsInZones.ContainsKey(sector))
        {         {
            this.m_loadingObjectsInZones[sector].Add(zdo);             this.m_loadingObjectsInZones[sector].Add(zdo);
            return;             return;
        }         }
        List<ZDO> list = new List<ZDO>();         List<ZDO> list = new List<ZDO>();
        list.Add(zdo);         list.Add(zdo);
        this.m_loadingObjectsInZones.Add(sector, list);         this.m_loadingObjectsInZones.Add(sector, list);
    }     }
   
    public void UnsetLoadingInZone(ZDO zdo)     public void UnsetLoadingInZone(ZDO zdo)
    {     {
        Vector2i sector = zdo.GetSector();         Vector2i sector = zdo.GetSector();
        this.m_loadingObjectsInZones[sector].Remove(zdo);         this.m_loadingObjectsInZones[sector].Remove(zdo);
        if (this.m_loadingObjectsInZones[sector].Count <= 0)         if (this.m_loadingObjectsInZones[sector].Count <= 0)
        {         {
            this.m_loadingObjectsInZones.Remove(sector);             this.m_loadingObjectsInZones.Remove(sector);
        }         }
    }     }
   
    public bool SkipSaving()     public bool SkipSaving()
    {     {
        return this.m_error || this.m_didZoneTest;         return this.m_error || this.m_didZoneTest;
    }     }
   
    public float TimeSinceStart()     public float TimeSinceStart()
    {     {
        return this.m_lastFixedTime - this.m_startTime;         return this.m_lastFixedTime - this.m_startTime;
    }     }
   
    public void ResetGlobalKeys()     public void ResetGlobalKeys()
    {     {
        this.ClearGlobalKeys();         this.ClearGlobalKeys();
        this.SetStartingGlobalKeys(false);         this.SetStartingGlobalKeys(false);
        this.SendGlobalKeys(ZRoutedRpc.Everybody);         this.SendGlobalKeys(ZRoutedRpc.Everybody);
    }     }
   
    public void ResetWorldKeys()     public void ResetWorldKeys()
    {     {
        for (int i = 0; i < 31; i++)         for (int i = 0; i < 31; i++)
        {         {
            GlobalKeys globalKeys = (GlobalKeys)i;             GlobalKeys globalKeys = (GlobalKeys)i;
            this.RemoveGlobalKey(globalKeys.ToString());             this.RemoveGlobalKey(globalKeys.ToString());
        }         }
    }     }
   
    public void SetStartingGlobalKeys(bool send = true)     public void SetStartingGlobalKeys(bool send = true)
    {     {
        for (int i = 0; i < 31; i++)         for (int i = 0; i < 31; i++)
        {         {
            GlobalKeys globalKeys = (GlobalKeys)i;             GlobalKeys globalKeys = (GlobalKeys)i;
            this.GlobalKeyRemove(globalKeys.ToString(), false);             this.GlobalKeyRemove(globalKeys.ToString(), false);
        }         }
        string text = null;         string text = null;
        this.m_tempKeys.Clear();         this.m_tempKeys.Clear();
        this.m_tempKeys.AddRange(ZNet.World.m_startingGlobalKeys);         this.m_tempKeys.AddRange(ZNet.World.m_startingGlobalKeys);
        foreach (string text2 in this.m_tempKeys)         foreach (string text2 in this.m_tempKeys)
        {         {
            string text3;             string text3;
            GlobalKeys globalKeys2;             GlobalKeys globalKeys2;
            ZoneSystem.GetKeyValue(text2.ToLower(), out text3, out globalKeys2);             ZoneSystem.GetKeyValue(text2.ToLower(), out text3, out globalKeys2);
            if (globalKeys2 == GlobalKeys.Preset)             if (globalKeys2 == GlobalKeys.Preset)
            {             {
                text = text3;                 text = text3;
            }             }
            this.GlobalKeyAdd(text2, false);             this.GlobalKeyAdd(text2, false);
        }         }
        if (text != null)         if (text != null)
        {         {
            ServerOptionsGUI.m_instance.SetPreset(ZNet.World, text);             ServerOptionsGUI.m_instance.SetPreset(ZNet.World, text);
        }         }
        if (send)         if (send)
        {         {
            this.SendGlobalKeys(ZRoutedRpc.Everybody);             this.SendGlobalKeys(ZRoutedRpc.Everybody);
        }         }
    }     }
   
    public void SetGlobalKey(GlobalKeys key, float value)     public void SetGlobalKey(GlobalKeys key, float value)
    {     {
        this.SetGlobalKey(string.Format("{0} {1}", key, value.ToString(CultureInfo.InvariantCulture)));         this.SetGlobalKey(string.Format("{0} {1}", key, value.ToString(CultureInfo.InvariantCulture)));
    }     }
   
    public void SetGlobalKey(GlobalKeys key)     public void SetGlobalKey(GlobalKeys key)
    {     {
        this.SetGlobalKey(key.ToString());         this.SetGlobalKey(key.ToString());
    }     }
   
    public void SetGlobalKey(string name)     public void SetGlobalKey(string name)
    {     {
        ZRoutedRpc.instance.InvokeRoutedRPC("SetGlobalKey", new object[] { name });         ZRoutedRpc.instance.InvokeRoutedRPC("SetGlobalKey", new object[] { name });
    }     }
   
    public bool GetGlobalKey(GlobalKeys key)     public bool GetGlobalKey(GlobalKeys key)
    {     {
        return this.m_globalKeysEnums.Contains(key);         return this.m_globalKeysEnums.Contains(key);
    }     }
   
    public bool GetGlobalKey(GlobalKeys key, out string value)     public bool GetGlobalKey(GlobalKeys key, out string value)
    {     {
        return this.m_globalKeysValues.TryGetValue(key.ToString().ToLower(), out value);         return this.m_globalKeysValues.TryGetValue(key.ToString().ToLower(), out value);
    }     }
   
    public bool GetGlobalKey(GlobalKeys key, out float value)     public bool GetGlobalKey(GlobalKeys key, out float value)
    {     {
        string text;         string text;
        if (this.m_globalKeysValues.TryGetValue(key.ToString().ToLower(), out text) && float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out value))         if (this.m_globalKeysValues.TryGetValue(key.ToString().ToLower(), out text) && float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
        {         {
            return true;             return true;
        }         }
        value = 0f;         value = 0f;
        return false;         return false;
    }     }
   
    public bool GetGlobalKey(string name)     public bool GetGlobalKey(string name)
    {     {
        string text;         string text;
        return this.GetGlobalKey(name, out text);         return this.GetGlobalKey(name, out text);
    }     }
   
    public bool GetGlobalKey(string name, out string value)     public bool GetGlobalKey(string name, out string value)
    {     {
        return this.m_globalKeysValues.TryGetValue(name.ToLower(), out value);         return this.m_globalKeysValues.TryGetValue(name.ToLower(), out value);
    }     }
   
    public bool GetGlobalKeyExact(string fullLine)     public bool GetGlobalKeyExact(string fullLine)
    {     {
        return this.m_globalKeys.Contains(fullLine);         return this.m_globalKeys.Contains(fullLine);
    }     }
   
    public bool CheckKey(string key, GameKeyType type = GameKeyType.Global, bool trueWhenKeySet = true)     public bool CheckKey(string key, GameKeyType type = GameKeyType.Global, bool trueWhenKeySet = true)
    {     {
        if (type == GameKeyType.Global)         if (type == GameKeyType.Global)
        {         {
            return ZoneSystem.instance.GetGlobalKey(key) == trueWhenKeySet;             return ZoneSystem.instance.GetGlobalKey(key) == trueWhenKeySet;
        }         }
        if (type != GameKeyType.Player)         if (type != GameKeyType.Player)
        {         {
            ZLog.LogError("Unknown GameKeyType type");             ZLog.LogError("Unknown GameKeyType type");
            return false;             return false;
        }         }
        return Player.m_localPlayer && Player.m_localPlayer.HaveUniqueKey(key) == trueWhenKeySet;         return Player.m_localPlayer && Player.m_localPlayer.HaveUniqueKey(key) == trueWhenKeySet;
    }     }
   
    private void RPC_SetGlobalKey(long sender, string name)     private void RPC_SetGlobalKey(long sender, string name)
    {     {
        if (this.m_globalKeys.Contains(name))         if (this.m_globalKeys.Contains(name))
        {         {
            return;             return;
        }         }
        this.GlobalKeyAdd(name, true);         this.GlobalKeyAdd(name, true);
        this.SendGlobalKeys(ZRoutedRpc.Everybody);         this.SendGlobalKeys(ZRoutedRpc.Everybody);
    }     }
   
    public void RemoveGlobalKey(GlobalKeys key)     public void RemoveGlobalKey(GlobalKeys key)
    {     {
        this.RemoveGlobalKey(key.ToString());         this.RemoveGlobalKey(key.ToString());
    }     }
   
    public void RemoveGlobalKey(string name)     public void RemoveGlobalKey(string name)
    {     {
        ZRoutedRpc.instance.InvokeRoutedRPC("RemoveGlobalKey", new object[] { name });         ZRoutedRpc.instance.InvokeRoutedRPC("RemoveGlobalKey", new object[] { name });
    }     }
   
    private void RPC_RemoveGlobalKey(long sender, string name)     private void RPC_RemoveGlobalKey(long sender, string name)
    {     {
        if (!this.GlobalKeyRemove(name, true))         if (!this.GlobalKeyRemove(name, true))
        {         {
            return;             return;
        }         }
        this.SendGlobalKeys(ZRoutedRpc.Everybody);         this.SendGlobalKeys(ZRoutedRpc.Everybody);
    }     }
   
    public List<string> GetGlobalKeys()     public List<string> GetGlobalKeys()
    {     {
        return new List<string>(this.m_globalKeys);         return new List<string>(this.m_globalKeys);
    }     }
   
    public Dictionary<Vector2i, ZoneSystem.LocationInstance>.ValueCollection GetLocationList()     public Dictionary<Vector2i, ZoneSystem.LocationInstance>.ValueCollection GetLocationList()
    {     {
        return this.m_locationInstances.Values;         return this.m_locationInstances.Values;
    }     }
   
    private Dictionary<Vector3, string> tempIconList = new Dictionary<Vector3, string>();     private Dictionary<Vector3, string> tempIconList = new Dictionary<Vector3, string>();
   
.      private List<float> s_tempVeg = new List<float>();
   
    private RaycastHit[] rayHits = new RaycastHit[200];     private RaycastHit[] rayHits = new RaycastHit[200];
   
    private List<string> m_tempKeys = new List<string>();     private List<string> m_tempKeys = new List<string>();
   
    private static ZoneSystem m_instance;     private static ZoneSystem m_instance;
   
    [HideInInspector]     [HideInInspector]
    public List<Heightmap.Biome> m_biomeFolded = new List<Heightmap.Biome>();     public List<Heightmap.Biome> m_biomeFolded = new List<Heightmap.Biome>();
   
    [HideInInspector]     [HideInInspector]
    public List<Heightmap.Biome> m_vegetationFolded = new List<Heightmap.Biome>();     public List<Heightmap.Biome> m_vegetationFolded = new List<Heightmap.Biome>();
   
    [HideInInspector]     [HideInInspector]
    public List<Heightmap.Biome> m_locationFolded = new List<Heightmap.Biome>();     public List<Heightmap.Biome> m_locationFolded = new List<Heightmap.Biome>();
   
    [NonSerialized]     [NonSerialized]
    public bool m_drawLocations;     public bool m_drawLocations;
   
    [NonSerialized]     [NonSerialized]
    public string m_drawLocationsFilter = "";     public string m_drawLocationsFilter = "";
   
    [global::Tooltip("Zones to load around center sector")]     [global::Tooltip("Zones to load around center sector")]
    public int m_activeArea = 1;     public int m_activeArea = 1;
   
    public int m_activeDistantArea = 1;     public int m_activeDistantArea = 1;
   
    [global::Tooltip("Zone size, should match netscene sector size")]     [global::Tooltip("Zone size, should match netscene sector size")]
    public float m_zoneSize = 64f;     public float m_zoneSize = 64f;
   
    [global::Tooltip("Time before destroying inactive zone")]     [global::Tooltip("Time before destroying inactive zone")]
    public float m_zoneTTL = 4f;     public float m_zoneTTL = 4f;
   
    [global::Tooltip("Time before spawning active zone")]     [global::Tooltip("Time before spawning active zone")]
    public float m_zoneTTS = 4f;     public float m_zoneTTS = 4f;
   
    public GameObject m_zonePrefab;     public GameObject m_zonePrefab;
   
    public GameObject m_zoneCtrlPrefab;     public GameObject m_zoneCtrlPrefab;
   
    public GameObject m_locationProxyPrefab;     public GameObject m_locationProxyPrefab;
   
    public float m_waterLevel = 30f;     public float m_waterLevel = 30f;
   
.      public const float c_WaterLevel = 30f;
   
    [Header("Versions")]     [Header("Versions")]
    public int m_pgwVersion = 53;     public int m_pgwVersion = 53;
   
    public int m_locationVersion = 1;     public int m_locationVersion = 1;
   
    [Header("Generation data")]     [Header("Generation data")]
    public List<string> m_locationScenes = new List<string>();     public List<string> m_locationScenes = new List<string>();
   
    public List<GameObject> m_locationLists = new List<GameObject>();     public List<GameObject> m_locationLists = new List<GameObject>();
   
    public List<ZoneSystem.ZoneVegetation> m_vegetation = new List<ZoneSystem.ZoneVegetation>();     public List<ZoneSystem.ZoneVegetation> m_vegetation = new List<ZoneSystem.ZoneVegetation>();
   
    public List<ZoneSystem.ZoneLocation> m_locations = new List<ZoneSystem.ZoneLocation>();     public List<ZoneSystem.ZoneLocation> m_locations = new List<ZoneSystem.ZoneLocation>();
   
    private Dictionary<int, ZoneSystem.ZoneLocation> m_locationsByHash = new Dictionary<int, ZoneSystem.ZoneLocation>();     private Dictionary<int, ZoneSystem.ZoneLocation> m_locationsByHash = new Dictionary<int, ZoneSystem.ZoneLocation>();
   
    private bool m_error;     private bool m_error;
   
    public bool m_didZoneTest;     public bool m_didZoneTest;
   
    private int m_terrainRayMask;     private int m_terrainRayMask;
   
    private int m_blockRayMask;     private int m_blockRayMask;
   
    private int m_solidRayMask;     private int m_solidRayMask;
   
    private int m_staticSolidRayMask;     private int m_staticSolidRayMask;
   
    private float m_updateTimer;     private float m_updateTimer;
   
    private float m_startTime;     private float m_startTime;
   
    private float m_lastFixedTime;     private float m_lastFixedTime;
   
    private Dictionary<Vector2i, ZoneSystem.ZoneData> m_zones = new Dictionary<Vector2i, ZoneSystem.ZoneData>();     private Dictionary<Vector2i, ZoneSystem.ZoneData> m_zones = new Dictionary<Vector2i, ZoneSystem.ZoneData>();
   
    private HashSet<Vector2i> m_generatedZones = new HashSet<Vector2i>();     private HashSet<Vector2i> m_generatedZones = new HashSet<Vector2i>();
   
    private Dictionary<Vector2i, List<ZDO>> m_loadingObjectsInZones = new Dictionary<Vector2i, List<ZDO>>();     private Dictionary<Vector2i, List<ZDO>> m_loadingObjectsInZones = new Dictionary<Vector2i, List<ZDO>>();
   
    private bool m_locationsGenerated;     private bool m_locationsGenerated;
   
    [HideInInspector]     [HideInInspector]
    public Dictionary<Vector2i, ZoneSystem.LocationInstance> m_locationInstances = new Dictionary<Vector2i, ZoneSystem.LocationInstance>();     public Dictionary<Vector2i, ZoneSystem.LocationInstance> m_locationInstances = new Dictionary<Vector2i, ZoneSystem.LocationInstance>();
   
    private Dictionary<Vector3, string> m_locationIcons = new Dictionary<Vector3, string>();     private Dictionary<Vector3, string> m_locationIcons = new Dictionary<Vector3, string>();
   
    private HashSet<string> m_globalKeys = new HashSet<string>();     private HashSet<string> m_globalKeys = new HashSet<string>();
   
    public HashSet<GlobalKeys> m_globalKeysEnums = new HashSet<GlobalKeys>();     public HashSet<GlobalKeys> m_globalKeysEnums = new HashSet<GlobalKeys>();
   
    public Dictionary<string, string> m_globalKeysValues = new Dictionary<string, string>();     public Dictionary<string, string> m_globalKeysValues = new Dictionary<string, string>();
   
    private HashSet<Vector2i> m_tempGeneratedZonesSaveClone;     private HashSet<Vector2i> m_tempGeneratedZonesSaveClone;
   
    private HashSet<string> m_tempGlobalKeysSaveClone;     private HashSet<string> m_tempGlobalKeysSaveClone;
   
    private List<ZoneSystem.LocationInstance> m_tempLocationsSaveClone;     private List<ZoneSystem.LocationInstance> m_tempLocationsSaveClone;
   
    private bool m_tempLocationsGeneratedSaveClone;     private bool m_tempLocationsGeneratedSaveClone;
   
    private List<ZoneSystem.ClearArea> m_tempClearAreas = new List<ZoneSystem.ClearArea>();     private List<ZoneSystem.ClearArea> m_tempClearAreas = new List<ZoneSystem.ClearArea>();
   
    private List<GameObject> m_tempSpawnedObjects = new List<GameObject>();     private List<GameObject> m_tempSpawnedObjects = new List<GameObject>();
   
    private List<int> m_tempLocationPrefabsToRelease = new List<int>();     private List<int> m_tempLocationPrefabsToRelease = new List<int>();
   
    private List<ZoneSystem.LocationPrefabLoadData> m_locationPrefabs = new List<ZoneSystem.LocationPrefabLoadData>();     private List<ZoneSystem.LocationPrefabLoadData> m_locationPrefabs = new List<ZoneSystem.LocationPrefabLoadData>();
   
    private class ZoneData     private class ZoneData
    {     {
        public GameObject m_root;         public GameObject m_root;
   
        public float m_ttl;         public float m_ttl;
    }     }
   
    private class ClearArea     private class ClearArea
    {     {
        public ClearArea(Vector3 p, float r)         public ClearArea(Vector3 p, float r)
        {         {
            this.m_center = p;             this.m_center = p;
            this.m_radius = r;             this.m_radius = r;
        }         }
   
        public Vector3 m_center;         public Vector3 m_center;
   
        public float m_radius;         public float m_radius;
    }     }
   
    [Serializable]     [Serializable]
    public class ZoneVegetation     public class ZoneVegetation
    {     {
        public ZoneSystem.ZoneVegetation Clone()         public ZoneSystem.ZoneVegetation Clone()
        {         {
            return base.MemberwiseClone() as ZoneSystem.ZoneVegetation;             return base.MemberwiseClone() as ZoneSystem.ZoneVegetation;
        }         }
   
        public string m_name = "veg";         public string m_name = "veg";
   
        public GameObject m_prefab;         public GameObject m_prefab;
   
        public bool m_enable = true;         public bool m_enable = true;
   
        public float m_min;         public float m_min;
   
        public float m_max = 10f;         public float m_max = 10f;
   
        public bool m_forcePlacement;         public bool m_forcePlacement;
   
        public float m_scaleMin = 1f;         public float m_scaleMin = 1f;
   
        public float m_scaleMax = 1f;         public float m_scaleMax = 1f;
   
        public float m_randTilt;         public float m_randTilt;
   
        public float m_chanceToUseGroundTilt;         public float m_chanceToUseGroundTilt;
   
        [BitMask(typeof(Heightmap.Biome))]         [BitMask(typeof(Heightmap.Biome))]
        public Heightmap.Biome m_biome;         public Heightmap.Biome m_biome;
   
        [BitMask(typeof(Heightmap.BiomeArea))]         [BitMask(typeof(Heightmap.BiomeArea))]
        public Heightmap.BiomeArea m_biomeArea = Heightmap.BiomeArea.Everything;         public Heightmap.BiomeArea m_biomeArea = Heightmap.BiomeArea.Everything;
   
        public bool m_blockCheck = true;         public bool m_blockCheck = true;
   
        public bool m_snapToStaticSolid;         public bool m_snapToStaticSolid;
   
        public float m_minAltitude = -1000f;         public float m_minAltitude = -1000f;
   
        public float m_maxAltitude = 1000f;         public float m_maxAltitude = 1000f;
   
        public float m_minVegetation;         public float m_minVegetation;
   
        public float m_maxVegetation;         public float m_maxVegetation;
   
.          [Header("Samples points around and choses the highest vegetation")]
          [global::Tooltip("Samples points around the placement point and choses the point with most total vegetation value")]
          public bool m_surroundCheckVegetation;
   
          [global::Tooltip("How far to check surroundings")]
          public float m_surroundCheckDistance = 20f;
   
          [global::Tooltip("How many layers of circles to sample. (If distance is large you should have more layers)")]
          public int m_surroundCheckLayers = 2;
   
          [global::Tooltip("How much better than the average an accepted point will be. (Procentually between average and best)")]
          public float m_surroundBetterThanAverage;
   
          [Space(10f)]
        public float m_minOceanDepth;         public float m_minOceanDepth;
   
        public float m_maxOceanDepth;         public float m_maxOceanDepth;
   
        public float m_minTilt;         public float m_minTilt;
   
        public float m_maxTilt = 90f;         public float m_maxTilt = 90f;
   
        public float m_terrainDeltaRadius;         public float m_terrainDeltaRadius;
   
        public float m_maxTerrainDelta = 2f;         public float m_maxTerrainDelta = 2f;
   
        public float m_minTerrainDelta;         public float m_minTerrainDelta;
   
        public bool m_snapToWater;         public bool m_snapToWater;
   
        public float m_groundOffset;         public float m_groundOffset;
   
        public int m_groupSizeMin = 1;         public int m_groupSizeMin = 1;
   
        public int m_groupSizeMax = 1;         public int m_groupSizeMax = 1;
   
        public float m_groupRadius;         public float m_groupRadius;
   
        [Header("Forest fractal 0-1 inside forest")]         [Header("Forest fractal 0-1 inside forest")]
        public bool m_inForest;         public bool m_inForest;
   
        public float m_forestTresholdMin;         public float m_forestTresholdMin;
   
        public float m_forestTresholdMax = 1f;         public float m_forestTresholdMax = 1f;
   
        [HideInInspector]         [HideInInspector]
        public bool m_foldout;         public bool m_foldout;
    }     }
   
    [Serializable]     [Serializable]
    public class ZoneLocation     public class ZoneLocation
    {     {
        public ZoneSystem.ZoneLocation Clone()         public ZoneSystem.ZoneLocation Clone()
        {         {
            return base.MemberwiseClone() as ZoneSystem.ZoneLocation;             return base.MemberwiseClone() as ZoneSystem.ZoneLocation;
        }         }
   
        public int Hash         public int Hash
        {         {
            get             get
            {             {
                return this.m_prefab.Name.GetStableHashCode();                 return this.m_prefab.Name.GetStableHashCode();
            }             }
        }         }
   
.          public string m_name;
   
        public bool m_enable = true;         public bool m_enable = true;
   
        [HideInInspector]         [HideInInspector]
        public string m_prefabName;         public string m_prefabName;
   
        public SoftReference<GameObject> m_prefab;         public SoftReference<GameObject> m_prefab;
   
        [BitMask(typeof(Heightmap.Biome))]         [BitMask(typeof(Heightmap.Biome))]
        public Heightmap.Biome m_biome;         public Heightmap.Biome m_biome;
   
        [BitMask(typeof(Heightmap.BiomeArea))]         [BitMask(typeof(Heightmap.BiomeArea))]
        public Heightmap.BiomeArea m_biomeArea = Heightmap.BiomeArea.Everything;         public Heightmap.BiomeArea m_biomeArea = Heightmap.BiomeArea.Everything;
   
        public int m_quantity;         public int m_quantity;
   
        public bool m_prioritized;         public bool m_prioritized;
   
        public bool m_centerFirst;         public bool m_centerFirst;
   
        public bool m_unique;         public bool m_unique;
   
        public string m_group = "";         public string m_group = "";
   
        public float m_minDistanceFromSimilar;         public float m_minDistanceFromSimilar;
   
.          public string m_groupMax = "";
   
          public float m_maxDistanceFromSimilar;
   
        public bool m_iconAlways;         public bool m_iconAlways;
   
        public bool m_iconPlaced;         public bool m_iconPlaced;
   
        public bool m_randomRotation = true;         public bool m_randomRotation = true;
   
        public bool m_slopeRotation;         public bool m_slopeRotation;
   
        public bool m_snapToWater;         public bool m_snapToWater;
   
        public float m_interiorRadius;         public float m_interiorRadius;
   
        public float m_exteriorRadius;         public float m_exteriorRadius;
   
        public bool m_clearArea;         public bool m_clearArea;
   
        public float m_minTerrainDelta;         public float m_minTerrainDelta;
   
        public float m_maxTerrainDelta = 2f;         public float m_maxTerrainDelta = 2f;
   
.          public float m_minimumVegetation;
   
          public float m_maximumVegetation = 1f;
   
          [Header("Samples points around and choses the highest vegetation")]
          [global::Tooltip("Samples points around the placement point and choses the point with most total vegetation value")]
          public bool m_surroundCheckVegetation;
   
          [global::Tooltip("How far to check surroundings")]
          public float m_surroundCheckDistance = 20f;
   
          [global::Tooltip("How many layers of circles to sample. (If distance is large you should have more layers)")]
          public int m_surroundCheckLayers = 2;
   
          [global::Tooltip("How much better than the average an accepted point will be. (Procentually between average and best)")]
          public float m_surroundBetterThanAverage;
   
        [Header("Forest fractal 0-1 inside forest")]         [Header("Forest fractal 0-1 inside forest")]
        public bool m_inForest;         public bool m_inForest;
   
        public float m_forestTresholdMin;         public float m_forestTresholdMin;
   
        public float m_forestTresholdMax = 1f;         public float m_forestTresholdMax = 1f;
   
        [Space(10f)]         [Space(10f)]
        public float m_minDistance;         public float m_minDistance;
   
        public float m_maxDistance;         public float m_maxDistance;
   
        public float m_minAltitude = -1000f;         public float m_minAltitude = -1000f;
   
        public float m_maxAltitude = 1000f;         public float m_maxAltitude = 1000f;
   
        [HideInInspector]         [HideInInspector]
        public bool m_foldout;         public bool m_foldout;
    }     }
   
    public struct LocationInstance     public struct LocationInstance
    {     {
        public ZoneSystem.ZoneLocation m_location;         public ZoneSystem.ZoneLocation m_location;
   
        public Vector3 m_position;         public Vector3 m_position;
   
        public bool m_placed;         public bool m_placed;
    }     }
   
    private class LocationPrefabLoadData     private class LocationPrefabLoadData
    {     {
        public bool IsLoaded { get; private set; }         public bool IsLoaded { get; private set; }
   
        public AssetID PrefabAssetID         public AssetID PrefabAssetID
        {         {
            get             get
            {             {
                return this.m_prefab.m_assetID;                 return this.m_prefab.m_assetID;
            }             }
        }         }
   
        public LocationPrefabLoadData(SoftReference<GameObject> prefab, bool isFirstSpawn)         public LocationPrefabLoadData(SoftReference<GameObject> prefab, bool isFirstSpawn)
        {         {
            this.m_prefab = prefab;             this.m_prefab = prefab;
            this.m_isFirstSpawn = isFirstSpawn;             this.m_isFirstSpawn = isFirstSpawn;
            this.m_roomsToLoad = 0;             this.m_roomsToLoad = 0;
            this.m_prefab.LoadAsync(new LoadedHandler(this.OnPrefabLoaded));             this.m_prefab.LoadAsync(new LoadedHandler(this.OnPrefabLoaded));
        }         }
   
        public void Release()         public void Release()
        {         {
            if (!this.m_prefab.IsValid)             if (!this.m_prefab.IsValid)
            {             {
                return;                 return;
            }             }
            this.m_prefab.Release();             this.m_prefab.Release();
            this.m_prefab.m_assetID = default(AssetID);             this.m_prefab.m_assetID = default(AssetID);
            if (this.m_possibleRooms == null)             if (this.m_possibleRooms == null)
            {             {
                return;                 return;
            }             }
            for (int i = 0; i < this.m_possibleRooms.Length; i++)             for (int i = 0; i < this.m_possibleRooms.Length; i++)
            {             {
                this.m_possibleRooms[i].Release();                 this.m_possibleRooms[i].Release();
            }             }
            this.m_possibleRooms = null;             this.m_possibleRooms = null;
        }         }
   
        private void OnPrefabLoaded(LoadResult result)         private void OnPrefabLoaded(LoadResult result)
        {         {
            if (result != LoadResult.Succeeded)             if (result != LoadResult.Succeeded)
            {             {
                return;                 return;
            }             }
            if (!this.m_prefab.IsValid)             if (!this.m_prefab.IsValid)
            {             {
                return;                 return;
            }             }
            if (!this.m_isFirstSpawn)             if (!this.m_isFirstSpawn)
            {             {
                this.IsLoaded = true;                 this.IsLoaded = true;
                return;                 return;
            }             }
.            DungeonGenerator[] enabledComponentsInChildren = Utils.GetEnabledComponentsInChildren<DungeonGenerator>(this.m_prefab.Asset);             DungeonGenerator[] enabledComponentsInChildren = global::Utils.GetEnabledComponentsInChildren<DungeonGenerator>(this.m_prefab.Asset);
            if (enabledComponentsInChildren.Length == 0)             if (enabledComponentsInChildren.Length == 0)
            {             {
                this.IsLoaded = true;                 this.IsLoaded = true;
                return;                 return;
            }             }
            if (enabledComponentsInChildren.Length > 1)             if (enabledComponentsInChildren.Length > 1)
            {             {
                ZLog.LogWarning("Location " + this.m_prefab.Asset.name + " has more than one dungeon generator! The preloading code only works for one dungeon generator per location.");                 ZLog.LogWarning("Location " + this.m_prefab.Asset.name + " has more than one dungeon generator! The preloading code only works for one dungeon generator per location.");
            }             }
            this.m_possibleRooms = enabledComponentsInChildren[0].GetAvailableRoomPrefabs();             this.m_possibleRooms = enabledComponentsInChildren[0].GetAvailableRoomPrefabs();
            this.m_roomsToLoad = this.m_possibleRooms.Length;             this.m_roomsToLoad = this.m_possibleRooms.Length;
            for (int i = 0; i < this.m_possibleRooms.Length; i++)             for (int i = 0; i < this.m_possibleRooms.Length; i++)
            {             {
                this.m_possibleRooms[i].LoadAsync(new LoadedHandler(this.OnRoomLoaded));                 this.m_possibleRooms[i].LoadAsync(new LoadedHandler(this.OnRoomLoaded));
            }             }
        }         }
   
        private void OnRoomLoaded(LoadResult result)         private void OnRoomLoaded(LoadResult result)
        {         {
            if (result != LoadResult.Succeeded)             if (result != LoadResult.Succeeded)
            {             {
                return;                 return;
            }             }
            this.m_roomsToLoad--;             this.m_roomsToLoad--;
            if (this.m_possibleRooms == null)             if (this.m_possibleRooms == null)
            {             {
                return;                 return;
            }             }
            if (this.m_roomsToLoad > 0)             if (this.m_roomsToLoad > 0)
            {             {
                return;                 return;
            }             }
            this.IsLoaded = true;             this.IsLoaded = true;
        }         }
   
        private SoftReference<GameObject> m_prefab;         private SoftReference<GameObject> m_prefab;
   
        private SoftReference<GameObject>[] m_possibleRooms;         private SoftReference<GameObject>[] m_possibleRooms;
   
        private int m_roomsToLoad;         private int m_roomsToLoad;
   
        private bool m_isFirstSpawn;         private bool m_isFirstSpawn;
   
        public int m_iterationLifetime;         public int m_iterationLifetime;
    }     }
   
    public enum SpawnMode     public enum SpawnMode
    {     {
        Full,         Full,
        Client,         Client,
        Ghost         Ghost
    }     }
} }