コード例 #1
0
        public static void SwapChunk(this ClipmapCell clipmapCell, ClipmapChunk nullableClipmapChunk)
        {
            if (clipmapCell.IsVisible())
            {
                if (nullableClipmapChunk)
                {
                    Logger.Debug($"{clipmapCell}: Showing new chunk");
                    nullableClipmapChunk.Show();
                }
            }

            var oldClipmapChunk = clipmapCell.chunk;

            if (oldClipmapChunk)
            {
#if BelowZero
                if (!clipmapCell.streamer.host.terrainPoolManager.meshPoolingEnabled)
                {
                    MeshBuilder.DestroyMeshes(oldClipmapChunk);
                }
                clipmapCell.ReturnChunkToPool(oldClipmapChunk);
#else
                MeshBuilder.DestroyMeshes(oldClipmapChunk);
                if (oldClipmapChunk.gameObject)
                {
                    UnityEngine.Object.Destroy(oldClipmapChunk.gameObject);
                }
#endif
            }

            clipmapCell.chunk = nullableClipmapChunk;
        }
コード例 #2
0
        static void Prefix(out ClipmapChunk __state, ClipmapChunk ___chunk)
        {
            var oldChunk = ___chunk;

            __state = oldChunk;

            if (oldChunk && oldChunk.gameObject)
            {
                UnityEngine.Object.Destroy(oldChunk.gameObject);
            }
        }
コード例 #3
0
        public static IEnumerator RebuildLayersAsync(this ClipmapCell clipmapCell, MeshBuilder meshBuilder)
        {
            Logger.Debug($"{clipmapCell}: Begin");

            ClipmapChunk nullableClipmapChunk = null;

            if (clipmapCell.streamer != null && clipmapCell.streamer.host != null)
            {
                var host = clipmapCell.level.streamer.host;
                nullableClipmapChunk = meshBuilder.DoFinalizePart(host.chunkRoot, host.terrainPoolManager);
                clipmapCell.streamer.meshBuilderPool.Return(meshBuilder);

                yield return(clipmapCell.ActivateChunkAndCollider(nullableClipmapChunk));
            }
            clipmapCell.level.OnEndBuildLayers(clipmapCell, nullableClipmapChunk);

            Logger.Debug($"{clipmapCell}: End");

            yield break;
        }
コード例 #4
0
        public static void RebuildLayers(this ClipmapCell clipmapCell, MeshBuilder meshBuilder, out ClipmapChunk clipmapChunk)
        {
            Logger.Debug($"{clipmapCell}: Begin");

            var host = clipmapCell.level.streamer.host;

            clipmapChunk = meshBuilder.DoFinalizePart(host.chunkRoot, host.chunkPrefab, host.chunkLayerPrefab);

            clipmapCell.level.streamer.meshBuilderPool.Return(meshBuilder);

            Logger.Debug($"{clipmapCell}: End");
        }
コード例 #5
0
        public static void OnEndBuildLayers(this ClipmapLevel clipmapLevel, ClipmapCell clipmapCell, ClipmapChunk nullableClipmapChunk)
        {
            nullableClipmapChunks[clipmapLevel.id][clipmapCell.id] = nullableClipmapChunk;

            remainingCellCount[clipmapLevel.id]--;
            Logger.Debug($"Decrementing remainingCellCount to {remainingCellCount[clipmapLevel.id]}");

            if (remainingCellCount[clipmapLevel.id] <= 0)
            {
                clipmapLevel.SwapChunks(nullableClipmapChunks[clipmapLevel.id]);
                nullableClipmapChunks[clipmapLevel.id].Clear();

                if (remainingCellCount.All((levelCountPair) => levelCountPair.Value <= 0))
                {
                    isMeshesRebuilding = false;
                    Logger.Debug($"{clipmapLevel}: Mesh building finished with 'remainingCellCount' of {remainingCellCount[clipmapLevel.id]}");

                    if (rebuildingMessage != null)
                    {
                        ErrorMessageExtensions.SetMessageTimeEnd(rebuildingMessage, Time.time);
                        ErrorMessageExtensions.pendingMessageToRemove = rebuildingMessage;
                        rebuildingMessage = null;
                    }
                }
            }
            else if (rebuildingMessage != null)
            {
                var oldTimeEnd  = ErrorMessageExtensions.GetMessageTimeEnd(rebuildingMessage);
                var timeFadeOut = ErrorMessageExtensions.GetTimeFadeOut();
                if (oldTimeEnd - timeFadeOut < Time.time)
                {
                    rebuildingMessage = ErrorMessageExtensions.AddReturnMessage(rebuildingTerrainMsg);
                }
            }
        }