Beispiel #1
0
    // We don't want others changing the state,
    // so we'll ping the chunk to update it for itself
    public void UpdateState()
    {
        switch (_state)
        {
        case State.Generating:
            if (_chunkData.IsGenerated())
            {
                _state = State.Loaded;

                GenerateMesh();
            }
            break;
        }
    }
Beispiel #2
0
    /// <summary>
    /// Lets chunk know it can properly update its state.
    /// </summary>
    /// <remarks>We don't want others to change the state manually.</remarks>
    public void UpdateState()
    {
        switch (_state)
        {
        case State.Generating:
            if (_chunkData.IsGenerated())
            {
                _state = State.Loaded;

                // Attempt to get cardinal chunks
                // This isn't guaranteed to pass, but as these chunks
                // generate, they'll inform us of their existence

                /*_upChunk = World.GetChunk(_chunkPos + ChunkPos.up);
                 * if (_upChunk != null && !_upChunk.IsGenerated()) { _upChunk = null; }
                 * _downChunk = World.GetChunk(_chunkPos + ChunkPos.down);
                 * if (_downChunk != null && !_downChunk.IsGenerated()) { _downChunk = null; }
                 * _northChunk = World.GetChunk(_chunkPos + ChunkPos.north);
                 * if (_northChunk != null && !_northChunk.IsGenerated()) { _northChunk = null; }
                 * _southChunk = World.GetChunk(_chunkPos + ChunkPos.south);
                 * if (_southChunk != null && !_southChunk.IsGenerated()) { _southChunk = null; }
                 * _eastChunk = World.GetChunk(_chunkPos + ChunkPos.east);
                 * if (_eastChunk != null && !_eastChunk.IsGenerated()) { _eastChunk = null; }
                 * _westChunk = World.GetChunk(_chunkPos + ChunkPos.west);
                 * if (_westChunk != null && !_westChunk.IsGenerated()) { _westChunk = null; }
                 *
                 * // Let's now ping them like the baka we are
                 * if (_upChunk != null) { _upChunk.GetChunk().Ping(_chunkData, Atlas.Dir.Down); }
                 * if (_downChunk != null) { _downChunk.GetChunk().Ping(_chunkData, Atlas.Dir.Up); }
                 * if (_northChunk != null) { _northChunk.GetChunk().Ping(_chunkData, Atlas.Dir.South); }
                 * if (_southChunk != null) { _southChunk.GetChunk().Ping(_chunkData, Atlas.Dir.North); }
                 * if (_eastChunk != null) { _eastChunk.GetChunk().Ping(_chunkData, Atlas.Dir.West); }
                 * if (_westChunk != null) { _westChunk.GetChunk().Ping(_chunkData, Atlas.Dir.East); }*/

                GenerateMesh();
            }
            break;
        }
    }