mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
ScriptEngine refactoring
This commit is contained in:
@@ -13,19 +13,16 @@ abstract class SharpType : RefCounter
|
||||
protected String _namespace ~ delete _;
|
||||
protected String _className ~ delete _;
|
||||
protected String _fullName ~ delete _;
|
||||
protected ScriptFieldType _scriptType;
|
||||
|
||||
public StringView Namespace => _namespace;
|
||||
public StringView ClassName => _className;
|
||||
public StringView FullName => _fullName;
|
||||
public ScriptFieldType ScriptType => _scriptType;
|
||||
|
||||
public this(StringView classNamespace, StringView className, ScriptFieldType scriptType)
|
||||
public this(StringView classNamespace, StringView className)
|
||||
{
|
||||
_namespace = new String(classNamespace);
|
||||
_className = new String(className);
|
||||
_fullName = new $"{_namespace}.{_className}";
|
||||
_scriptType = scriptType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,36 +30,21 @@ class SharpClass : SharpType
|
||||
{
|
||||
protected internal MonoClass* _monoClass;
|
||||
|
||||
public this(StringView classNamespace, StringView className, MonoImage* image, ScriptFieldType fieldType = .Class) :
|
||||
base(classNamespace, className, fieldType)
|
||||
public this(StringView classNamespace, StringView className, MonoImage* image) :
|
||||
base(classNamespace, className)
|
||||
{
|
||||
_monoClass = Mono.mono_class_from_name(image, _namespace, _className);
|
||||
|
||||
Log.EngineLogger.AssertDebug(_monoClass != null);
|
||||
}
|
||||
|
||||
internal this(MonoClass* monoClass, ScriptFieldType fieldType = .Class) :
|
||||
base(StringView(Mono.mono_class_get_namespace(monoClass)), StringView(Mono.mono_class_get_name(monoClass)), fieldType)
|
||||
internal this(MonoClass* monoClass) :
|
||||
base(StringView(Mono.mono_class_get_namespace(monoClass)), StringView(Mono.mono_class_get_name(monoClass)))
|
||||
{
|
||||
_monoClass = monoClass;
|
||||
|
||||
Log.EngineLogger.AssertDebug(_monoClass != null);
|
||||
}
|
||||
|
||||
internal MonoType* GetMonoType()
|
||||
{
|
||||
return Mono.mono_class_get_type(_monoClass);
|
||||
}
|
||||
|
||||
internal bool IsType(MonoType* type)
|
||||
{
|
||||
return GetMonoType() == type;
|
||||
}
|
||||
|
||||
internal bool IsSubclass(MonoClass* @class)
|
||||
{
|
||||
return Mono.mono_class_is_subclass_of(_monoClass, @class, false);
|
||||
}
|
||||
}
|
||||
|
||||
class ScriptClass : SharpClass
|
||||
@@ -88,8 +70,8 @@ class ScriptClass : SharpClass
|
||||
public bool RunInEditMode => _runInEditMode;
|
||||
|
||||
[AllowAppend]
|
||||
public this(StringView classNamespace, StringView className, MonoImage* image, ScriptFieldType scriptFieldType = .Class) :
|
||||
base(classNamespace, className, image, scriptFieldType)
|
||||
public this(StringView classNamespace, StringView className, MonoImage* image) :
|
||||
base(classNamespace, className, image)
|
||||
{
|
||||
_constructor = FindConstructor();
|
||||
_onCreate = (OnCreateMethod)GetMethodThunk("OnCreate");
|
||||
|
||||
@@ -585,15 +585,12 @@ static class ScriptEngine
|
||||
if (scriptClass == null)
|
||||
return;
|
||||
|
||||
let monoType = scriptClass.GetMonoType();
|
||||
let monoReflectionType = Mono.mono_type_get_object(s_AppDomain, monoType);
|
||||
|
||||
let entityId = entity.UUID;
|
||||
|
||||
#unwarn
|
||||
void*[2] args = .(&entityId, monoReflectionType);
|
||||
void*[1] args = .(&entityId);
|
||||
|
||||
let method = Classes.EntityEditor.GetMethod("ShowDefaultEntityEditor", 2);
|
||||
let method = Classes.EntityEditor.GetMethod("ShowDefaultEntityEditor", 1);
|
||||
|
||||
Classes.EntityEditor.Invoke(method, null, &args);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using GlitchyEngine.Core;
|
||||
using GlitchyEngine.Math;
|
||||
|
||||
namespace GlitchyEngine.Scripting;
|
||||
|
||||
enum ScriptFieldType
|
||||
{
|
||||
case None;
|
||||
|
||||
case Class;
|
||||
case Struct;
|
||||
|
||||
case Entity;
|
||||
case Component;
|
||||
}
|
||||
Reference in New Issue
Block a user