ScriptEngine work and cleanup

This commit is contained in:
Simon Lübeß
2025-07-18 12:40:44 +02:00
parent 271286fb7e
commit 28311165ad
22 changed files with 204 additions and 1031 deletions
+4 -15
View File
@@ -372,10 +372,6 @@ struct EngineFunctions
static class ScriptGlue
{
/*private static Dictionary<MonoType*, function void(Entity entityId)> s_AddComponentMethods = new .() ~ delete _;
private static Dictionary<MonoType*, function bool(Entity entityId)> s_HasComponentMethods = new .() ~ delete _;
private static Dictionary<MonoType*, function void(Entity entityId)> s_RemoveComponentMethods = new .() ~ delete _;*/
/* Adding this attribute to a method will log method entry and returned Result<T> errors */
[AttributeUsage(.Method)]
struct RegisterMethodAttribute : Attribute, IOnMethodInit
@@ -408,9 +404,6 @@ static class ScriptGlue
public static Event<delegate void()> OnRegisterNativeCalls ~ _.Dispose();
/*private function void SetEngineFunctions(EngineFunctions* engineFunctions);
private static SetEngineFunctions _setEngineFunctions;*/
private function void SetEngineFunctions(EngineFunctions* engineFunctions);
private static SetEngineFunctions _setEngineFunctions;
@@ -423,17 +416,13 @@ static class ScriptGlue
RegisterCalls();
//RegisterMathFunctions();
RegisterManagedComponents();
}
public static void RegisterManagedComponents()
{
Debug.Profiler.ProfileFunction!();
/*s_AddComponentMethods.Clear();
s_HasComponentMethods.Clear();
s_RemoveComponentMethods.Clear();*/
RegisterComponent<TransformComponent>();
RegisterComponent<Rigidbody2DComponent>();
RegisterComponent<CameraComponent>();
@@ -459,12 +448,10 @@ static class ScriptGlue
private static void RegisterComponent<T>() where T : struct, new
{
Log.EngineLogger.Error("ScriptGlue::RegisterComponent not updated yet.");
String fullComponentTypeName = scope String();
typeof(T).GetFullName(fullComponentTypeName);
CoreClrHelper.RegisterComponent(fullComponentTypeName,
CoreClrHelper.RegisterComponent(fullComponentTypeName..EnsureNullTerminator(),
addComponent: (entityId) => {
Entity entity = GetEntitySafe(entityId);
entity.AddComponent<T>();
@@ -1550,6 +1537,8 @@ static class ScriptGlue
Log.EngineLogger.AssertDebug(context != null);
Log.EngineLogger.Trace(StringView(fieldName));
context.AddField(StringView(fieldName), type, valueObject, StringView(fullTypeName));
}