Basic Script reloading

+ ScriptComponent now saves script name instead of direct ScriptClass reference
+ Added ClearDictionaryAndDeleteKeys helper
+ Moved ScriptFieldType to separate file
+ _ScriptFieldMap now uses String as Key
This commit is contained in:
Simon Lübeß
2023-07-18 22:06:34 +02:00
parent e8505f6bdb
commit cd1562f372
10 changed files with 259 additions and 166 deletions
+2 -3
View File
@@ -93,11 +93,10 @@ namespace GlitchyEngine.World
Entity targetEntity = target.GetEntityByID(sourceEntity.UUID);
ScriptComponent* targetComponent = targetEntity.AddComponent<ScriptComponent>();
targetComponent.ScriptClass = sourceComponent.ScriptClass;
targetComponent.Instance = new ScriptInstance(sourceComponent.ScriptClass);
targetComponent.Instance..ReleaseRef();
targetComponent.ScriptClassName = sourceComponent.ScriptClassName;
// Initializes the created instance
// TODO: this returns false, if no script with ScriptClassName exists, we have to handle this case correctly I think.
ScriptEngine.InitializeInstance(targetEntity, targetComponent);
}