Native scripting

This commit is contained in:
Simon Lübeß
2022-03-03 01:39:04 +01:00
parent cbee9f59d8
commit e82f70ba02
5 changed files with 113 additions and 2 deletions
+29 -1
View File
@@ -115,7 +115,7 @@ namespace GlitchyEngine.World
struct CameraComponent
{
public SceneCamera Camera;
public bool Primary = true; // Todo: probably move into scene
public bool Primary = true; // Todo: probably move into scene
public bool FixedAspectRatio = false;
public this()
@@ -123,4 +123,32 @@ namespace GlitchyEngine.World
Camera = .();
}
}
struct NativeScriptComponent : IDisposableComponent
{
public ScriptableEntity Instance = null;
public function void (mut NativeScriptComponent this) Func;
public function ScriptableEntity () InstantiateFunction;
public function void (NativeScriptComponent* self) DestroyInstanceFunction;
public void Bind<T>() mut where T : ScriptableEntity
{
InstantiateFunction = () =>
{
return new T();
};
DestroyInstanceFunction = (self) =>
{
delete self.Instance;
};
}
public void Dispose() mut
{
DestroyInstanceFunction(&this);
}
}
}