mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Cleanup + Attach scripts
This commit is contained in:
@@ -291,13 +291,20 @@ namespace GlitchyEngine.World
|
||||
|
||||
struct DotNetScriptComponent : IDisposableComponent
|
||||
{
|
||||
public void* InstanceHandlePtr = null;
|
||||
public struct Instance : int {}
|
||||
|
||||
public Instance InstanceHandlePtr = 0;
|
||||
|
||||
private String TypeName = null;
|
||||
|
||||
typealias CreateInstanceDelegate = function void*(void* typeNamePtr, int32 typeNameLength, EcsEntity entity);
|
||||
typealias CreateInstanceDelegate = function Instance(void* typeNamePtr, int32 typeNameLength, EcsEntity entity);
|
||||
typealias InstanceDelegate = function void(Instance instance);
|
||||
|
||||
public static CreateInstanceDelegate DelCreateInstance;
|
||||
public static CreateInstanceDelegate CreateInstanceFn;
|
||||
public static InstanceDelegate UpdateInstanceFn;
|
||||
public static InstanceDelegate DestroyInstanceFn;
|
||||
|
||||
public const Self ss = Self();
|
||||
|
||||
public void Bind(StringView dotNetAssemblyQualifiedTypeName) mut
|
||||
{
|
||||
@@ -306,12 +313,17 @@ namespace GlitchyEngine.World
|
||||
|
||||
internal void CreateInstance(EcsEntity entity) mut
|
||||
{
|
||||
//IntPtr CreateInstance(IntPtr typeNamePtr, int typeNameLength, EcsEntity entity)
|
||||
InstanceHandlePtr = DelCreateInstance(TypeName.Ptr, (int32)TypeName.Length, entity);
|
||||
InstanceHandlePtr = CreateInstanceFn(TypeName.Ptr, (int32)TypeName.Length, entity);
|
||||
}
|
||||
|
||||
internal void UpdateInstance()
|
||||
{
|
||||
UpdateInstanceFn(InstanceHandlePtr);
|
||||
}
|
||||
|
||||
internal void DestroyInstance()
|
||||
{
|
||||
DestroyInstanceFn(InstanceHandlePtr);
|
||||
}
|
||||
|
||||
public void Dispose() mut
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace GlitchyEngine.World
|
||||
|
||||
cameraComponent.Camera.SetViewportSize(e.Scene.ViewportWidth, e.Scene.ViewportHeight);
|
||||
});
|
||||
|
||||
Entity dotNetEntity = CreateEntity("DotNet rocks!");
|
||||
dotNetEntity.AddComponent<SpriterRendererComponent>(.(Color(81, 43, 212)));
|
||||
var vv = dotNetEntity.AddComponent<DotNetScriptComponent>();
|
||||
vv.Bind("DotNetScriptingHelper.TestEntityScript, DotNetScriptingHelper");
|
||||
}
|
||||
|
||||
public ~this()
|
||||
@@ -52,7 +57,7 @@ namespace GlitchyEngine.World
|
||||
|
||||
for (var (entity, script) in _ecsWorld.Enumerate<DotNetScriptComponent>())
|
||||
{
|
||||
if (script.InstanceHandlePtr == null)
|
||||
if (script.InstanceHandlePtr == 0)
|
||||
{
|
||||
script.[Friend]CreateInstance(entity);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace GlitchyEngine.World
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(false, "Queried component is not registered for this world. This is invalid because the query would never return any results.");
|
||||
//Log.EngineLogger.AssertDebug(false, "Queried component is not registered for this world. This is invalid because the query would never return any results.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user