示例#1
0
    public void StartUp(VoxelMap map, WorldScriptableObject worldObject)
    {
        voxelMesh     = FindObjectOfType <VoxelMesh>();
        terrainNoise  = FindObjectOfType <TerrainNoise>();
        terrainMap    = FindObjectOfType <TerrainMap>();
        chunkCollider = FindObjectOfType <ChunkCollider>();

        recycleableChunks     = map.recycleableChunks;
        regionResolution      = map.regionResolution;
        chunkResolution       = map.chunkResolution;
        voxelResolution       = map.voxelResolution;
        viewDistance          = map.viewDistance;
        chunks                = map.chunks;
        existingChunks        = map.existingChunks;
        useVoxelReferences    = map.useVoxelReferences;
        colliderRadius        = map.colliderRadius;
        useColliders          = map.useColliders;
        player                = map.player;
        chunkSaveLoadManager  = map.chunkSaveLoadManager;
        worldScriptableObject = worldObject;

        playerRb = player.GetComponent <Rigidbody2D>();

        terrainNoise.seed = worldScriptableObject.seed;
        terrainNoise.Startup(voxelResolution, chunkResolution);
        voxelMesh.Startup(voxelResolution, chunkResolution, viewDistance, useColliders, colliderRadius);

        InvokeRepeating(nameof(UpdateMap), 0.0f, terrainMap.updateInterval);
    }