Пример #1
0
        void OnPlayModeStateChange(PlayModeStateChange state)
        {
            TerraConfig.Log("Killing worker threads before exiting play mode");

            // Destroy lingering worker thread
            if (state == PlayModeStateChange.ExitingPlayMode && Worker != null)
            {
                Worker.ForceStop();
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes fields to default values if they were null
        /// post serialization.
        /// </summary>
        void OnEnable()
        {
            _instance     = this;
            IsInitialized = true;

            if (Generator == null)
            {
                Generator = new GenerationData();
            }
            if (EditorState == null)
            {
                EditorState = new EditorStateData();
            }
            if (Placer == null)
            {
                Placer = new ObjectPlacer();
            }
            if (Worker == null)
            {
                Worker = new BackgroundWorker();
            }

            IsEditor = IsInEditMode;
        }
        /// <summary>
        /// Initializes fields to default values if they were null
        /// post serialization.
        /// </summary>
        void OnEnable()
        {
            _instance     = this;
            IsInitialized = true;

            if (Generator == null)
            {
                Generator = new GenerationData();
            }
            if (ShaderData == null)
            {
                ShaderData = new ShaderData();
            }
            if (BiomesData == null)
            {
                BiomesData = new List <BiomeData>();
            }
            if (Details == null)
            {
                Details = new List <DetailData>();
            }
            if (HeightMapData == null)
            {
                HeightMapData = new TileMapData {
                    Name = "Height Map"
                }
            }
            ;
            if (TemperatureMapData == null)
            {
                TemperatureMapData = new TileMapData {
                    Name = "Temperature Map", RampColor1 = Color.red, RampColor2 = Color.blue
                }
            }
            ;
            if (MoistureMapData == null)
            {
                MoistureMapData = new TileMapData {
                    Name = "Moisture Map", RampColor1 = Color.cyan, RampColor2 = Color.white
                }
            }
            ;
            if (Tessellation == null)
            {
                Tessellation = new TessellationData();
            }
            if (Grass == null)
            {
                Grass = new GrassData();
            }
            if (EditorState == null)
            {
                EditorState = new EditorStateData();
            }
        }

        void Start()
        {
            CreateMTD();

            if (Generator.GenerateOnStart)
            {
                Generate();
            }
        }

        void Update()
        {
            if (!IsInitialized)
            {
                return;
            }

            if (Application.isPlaying && Generator.Pool != null && Generator.GenerateOnStart)
            {
                //Generator.Pool.ResetQueue();
                Generator.Pool.Update();
            }
        }

        void Reset()
        {
            OnEnable();             //Initialize default values
        }