riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
using System;
using Unity.Collections;
using Unity.Mathematics;
namespace DanieleMarotta.RiversongCodeShowcase
{
public class EntityIdMap : IDisposable
{
private NativeGrid<EntityIdMapValue> _data;
public EntityIdMap(int2 size)
{
_data = new NativeGrid<EntityIdMapValue>(size, Allocator.Persistent);
}
public void Dispose()
{
_data?.Dispose();
_data = null;
}
public void SetBuildingId(TileRect rect, int id)
{
foreach (var tile in TileRange.From(rect))
{
ref var value = ref _data.GetValueRW(tile);
value.BuildingId = id;
}
}
public void SetResourceNodeId(int2 tile, int id)
{
ref var value = ref _data.GetValueRW(tile);
value.ResourceNodeId = id;
}
public ref EntityIdMapValue GetValueRW(int2 tile)
{
return ref _data.GetValueRW(tile);
}
public NativeArray<EntityIdMapValue> GetNativeArray()
{
return _data.GetNativeArray();
}
}
}