mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Native scripting
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user