mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Some fixes with coral
This commit is contained in:
@@ -43,12 +43,12 @@ namespace Nuake {
|
||||
return scene->GetEntity(entityName).GetHandle();
|
||||
}
|
||||
|
||||
Coral::ManagedObject* GetEntityScriptFromName(Coral::String entityName)
|
||||
void GetEntityScriptFromName(Coral::String entityName, Coral::ManagedObject* outInstance)
|
||||
{
|
||||
auto scene = Engine::GetCurrentScene();
|
||||
if (!scene->EntityExists(std::string(entityName)))
|
||||
{
|
||||
return nullptr; // Error code: entity not found.
|
||||
// Error code: entity not found.
|
||||
}
|
||||
|
||||
Entity entity = scene->GetEntity(entityName);
|
||||
@@ -57,9 +57,9 @@ namespace Nuake {
|
||||
if (scriptingEngine.HasEntityScriptInstance(entity))
|
||||
{
|
||||
auto instance = scriptingEngine.GetEntityScript(entity);
|
||||
return instance;
|
||||
outInstance->m_Handle = instance->m_Handle;
|
||||
outInstance->m_Type = instance->m_Type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Coral::ManagedObject* GetEntityScriptFromHandle(int entityHandle)
|
||||
|
||||
@@ -660,7 +660,7 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
entityToManagedObjects.emplace(entity.GetID(), classInstance);
|
||||
|
||||
|
||||
// Override with user values set in the editor.
|
||||
for (auto& exposedVarUserValue : component.ExposedVar)
|
||||
@@ -726,6 +726,8 @@ namespace Nuake
|
||||
classInstance.SetFieldValue(exposedVarUserValue.Name, exposedVarUserValue.Value);
|
||||
}
|
||||
}
|
||||
|
||||
entityToManagedObjects.emplace(entity.GetID(), std::move(classInstance));
|
||||
}
|
||||
|
||||
Coral::ManagedObject* ScriptingEngineNet::GetEntityScript(const Entity& entity)
|
||||
|
||||
@@ -7,16 +7,20 @@ namespace Nuake.Net
|
||||
public class Scene
|
||||
{
|
||||
internal static unsafe delegate*<NativeString, int> GetEntityIcall;
|
||||
internal static unsafe delegate*<NativeString, NativeInstance<Entity>> GetEntityScriptFromNameIcall;
|
||||
internal static unsafe delegate*<NativeString, NativeInstance<object>*, void> GetEntityScriptFromNameIcall;
|
||||
internal static unsafe delegate*<int, NativeInstance<Entity>> GetEntityScriptFromHandleIcall;
|
||||
internal static unsafe delegate*<NativeString, int> InstancePrefabIcall;
|
||||
|
||||
public static T? GetEntity<T>(string entityName) where T : class
|
||||
{
|
||||
NativeInstance<Entity> handle;
|
||||
unsafe { handle = GetEntityScriptFromNameIcall(entityName); }
|
||||
NativeInstance<object> handle;
|
||||
|
||||
Entity? entity = handle.Get();
|
||||
// This doesnt :(
|
||||
unsafe { GetEntityScriptFromNameIcall(entityName, &handle); }
|
||||
|
||||
|
||||
object? entity = handle.Get();
|
||||
Engine.Log("Fetched entityL: " + entity);
|
||||
if (entity != null && entity is T)
|
||||
{
|
||||
return entity as T;
|
||||
|
||||
Reference in New Issue
Block a user