mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 12:51:48 +00:00
No longer lose script instances (and type names) when reloading assemblies
This commit is contained in:
@@ -374,8 +374,6 @@ static class ScriptEngine
|
||||
if (script.Instance != null)
|
||||
script.Instance = null;
|
||||
|
||||
script.ScriptClassName = null;
|
||||
|
||||
DestroyInstance(entityId);
|
||||
}
|
||||
|
||||
@@ -455,26 +453,20 @@ static class ScriptEngine
|
||||
|
||||
LoadScriptAssemblies();
|
||||
|
||||
|
||||
if (retainScriptData)
|
||||
{
|
||||
if (Context != null)
|
||||
{
|
||||
Debug.Profiler.ProfileScope!("Initialize Instances");
|
||||
|
||||
// We need to create a new instance for every entity
|
||||
for (let (id, scriptInstance) in _entityScriptInstances)
|
||||
for (let (ecsEntity, scriptComponent) in Context.GetEntities<ScriptComponent>())
|
||||
{
|
||||
if (Context.GetEntityByID(id) case .Ok(let entity))
|
||||
{
|
||||
ScriptComponent* script = entity.GetComponent<ScriptComponent>();
|
||||
InitializeInstance(entity, script);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(false, "Entities script was just serialized but the entity doesn't exist anymore.");
|
||||
}
|
||||
InitializeInstance(Entity(ecsEntity, Context), scriptComponent);
|
||||
}
|
||||
}
|
||||
|
||||
if (retainScriptData)
|
||||
{
|
||||
contextSerializer.DeserializeScriptInstances();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user