testing building some core systems

- serialization
- chunks
- parralelfor test
This commit is contained in:
max
2026-04-24 19:21:03 +02:00
parent 5eaf3547dc
commit fec2cd8d24
15 changed files with 999 additions and 98 deletions
@@ -0,0 +1,35 @@
using MoonTools.ECS;
using System;
namespace Nerfed.Runtime.Scene.Streaming;
/// <summary>
/// A centralized cleanup system for slowly destroying chunk entities to avoid frame stutters.
/// </summary>
public class ChunkTeardownSystem : MoonTools.ECS.System
{
private readonly Filter _unloadedFilter;
// Adjustable limit to prevent massive stutters when unloading chunks.
public int MaxEntitiesToDestroyPerFrame { get; set; } = 250;
public ChunkTeardownSystem(World world) : base(world)
{
_unloadedFilter = FilterBuilder
.Include<ChunkUnloadPendingTag>()
.Build();
}
public override void Update(TimeSpan delta)
{
int destroyed = 0;
foreach (var entity in _unloadedFilter.Entities)
{
if (destroyed >= MaxEntitiesToDestroyPerFrame) break;
Destroy(entity);
destroyed++;
}
}
}