add mono c# (using dotnet9.0 from https://github.com/dotnet/runtime), add ECS (entt), add some c# code, add fastNoise

This commit is contained in:
2025-12-08 23:38:22 +08:00
parent 39378bf23c
commit 3ffb4cc449
341 changed files with 11747 additions and 262 deletions

View File

@ -0,0 +1,61 @@
using System.Runtime.CompilerServices;
namespace Prism
{
public class Entity
{
public uint SceneID { get; private set; }
public uint EntityID { get; private set; }
~Entity()
{
Console.WriteLine("Destroyed Entity {0}:{1}", SceneID, EntityID);
}
public T CreateComponent<T>() where T : Component, new()
{
CreateComponent_Native(SceneID, EntityID, typeof(T));
T component = new T();
component.Entity = this;
return component;
}
public bool HasComponent<T>() where T : Component, new()
{
return HasComponent_Native(SceneID, EntityID, typeof(T));
}
public T GetComponent<T>() where T : Component, new()
{
if (HasComponent<T>())
{
T component = new T();
component.Entity = this;
return component;
}
return null;
}
public Mat4 GetTransform()
{
Mat4 mat4Instance;
GetTransform_Native(SceneID, EntityID, out mat4Instance);
return mat4Instance;
}
public void SetTransform(Mat4 transform)
{
SetTransform_Native(SceneID, EntityID, ref transform);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void CreateComponent_Native(uint sceneID, uint entityID, Type type);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool HasComponent_Native(uint sceneID, uint entityID, Type type);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void GetTransform_Native(uint sceneID, uint entityID, out Mat4 matrix);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void SetTransform_Native(uint sceneID, uint entityID, ref Mat4 matrix);
}
}