D:\ValheimDev\Dumps\Old\assembly_valheim\RandomSpawn.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\RandomSpawn.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
   
public class RandomSpawn : MonoBehaviour public class RandomSpawn : MonoBehaviour
{ {
.    public void Randomize(Location loc = null, DungeonGenerator dg = null)     public void Randomize(Vector3 pos, Location loc = null, DungeonGenerator dg = null)
    {     {
        bool flag = UnityEngine.Random.Range(0f, 100f) <= this.m_chanceToSpawn;         bool flag = UnityEngine.Random.Range(0f, 100f) <= this.m_chanceToSpawn;
        if (dg != null && this.m_dungeonRequireTheme != Room.Theme.None && !dg.m_themes.HasFlag(this.m_dungeonRequireTheme))         if (dg != null && this.m_dungeonRequireTheme != Room.Theme.None && !dg.m_themes.HasFlag(this.m_dungeonRequireTheme))
        {         {
            flag = false;             flag = false;
        }         }
        if (loc != null && this.m_requireBiome != Heightmap.Biome.None)         if (loc != null && this.m_requireBiome != Heightmap.Biome.None)
        {         {
            if (loc.m_biome == Heightmap.Biome.None)             if (loc.m_biome == Heightmap.Biome.None)
            {             {
.                loc.m_biome = WorldGenerator.instance.GetBiome(loc.transform.position);                 loc.m_biome = WorldGenerator.instance.GetBiome(pos);
            }             }
            if (!this.m_requireBiome.HasFlag(loc.m_biome))             if (!this.m_requireBiome.HasFlag(loc.m_biome))
            {             {
                flag = false;                 flag = false;
            }             }
        }         }
.          if (this.m_notInLava && ZoneSystem.instance && ZoneSystem.IsLavaPreHeightmap(pos, 0.6f))
          {
              flag = false;
          }
          if (pos.y < (float)this.m_minElevation || pos.y > (float)this.m_maxElevation)
          {
              flag = false;
          }
        this.SetSpawned(flag);         this.SetSpawned(flag);
    }     }
   
    public void Reset()     public void Reset()
    {     {
        this.SetSpawned(true);         this.SetSpawned(true);
    }     }
   
    private void SetSpawned(bool doSpawn)     private void SetSpawned(bool doSpawn)
    {     {
        if (!doSpawn)         if (!doSpawn)
        {         {
            base.gameObject.SetActive(false);             base.gameObject.SetActive(false);
            using (List<ZNetView>.Enumerator enumerator = this.m_childNetViews.GetEnumerator())             using (List<ZNetView>.Enumerator enumerator = this.m_childNetViews.GetEnumerator())
            {             {
                while (enumerator.MoveNext())                 while (enumerator.MoveNext())
                {                 {
                    ZNetView znetView = enumerator.Current;                     ZNetView znetView = enumerator.Current;
                    znetView.gameObject.SetActive(false);                     znetView.gameObject.SetActive(false);
                }                 }
                goto IL_62;                 goto IL_62;
            }             }
        }         }
        if (this.m_nview == null)         if (this.m_nview == null)
        {         {
            base.gameObject.SetActive(true);             base.gameObject.SetActive(true);
        }         }
        IL_62:         IL_62:
        if (this.m_OffObject != null)         if (this.m_OffObject != null)
        {         {
            this.m_OffObject.SetActive(!doSpawn);             this.m_OffObject.SetActive(!doSpawn);
        }         }
    }     }
   
    public void Prepare()     public void Prepare()
    {     {
        this.m_nview = base.GetComponent<ZNetView>();         this.m_nview = base.GetComponent<ZNetView>();
        this.m_childNetViews = new List<ZNetView>();         this.m_childNetViews = new List<ZNetView>();
        foreach (ZNetView znetView in base.gameObject.GetComponentsInChildren<ZNetView>(true))         foreach (ZNetView znetView in base.gameObject.GetComponentsInChildren<ZNetView>(true))
        {         {
            if (Utils.IsEnabledInheirarcy(znetView.gameObject, base.gameObject))             if (Utils.IsEnabledInheirarcy(znetView.gameObject, base.gameObject))
            {             {
                this.m_childNetViews.Add(znetView);                 this.m_childNetViews.Add(znetView);
            }             }
        }         }
    }     }
   
    public GameObject m_OffObject;     public GameObject m_OffObject;
   
    [Range(0f, 100f)]     [Range(0f, 100f)]
    public float m_chanceToSpawn = 50f;     public float m_chanceToSpawn = 50f;
   
    public Room.Theme m_dungeonRequireTheme;     public Room.Theme m_dungeonRequireTheme;
   
    public Heightmap.Biome m_requireBiome;     public Heightmap.Biome m_requireBiome;
.   
      public bool m_notInLava;
   
      [Header("Elevation span (water is 30)")]
      public int m_minElevation = -10000;
   
      public int m_maxElevation = 10000;
   
    private List<ZNetView> m_childNetViews;     private List<ZNetView> m_childNetViews;
   
    private ZNetView m_nview;     private ZNetView m_nview;
} }