private void reloadGameplayDll() { twEngine.ClearAllGameplayData(); twEngine.updateActiveGameplayAssembly(); twEngine.ClearAllEngineState(); }
private void reloadGameplayDll() { //TODO: broke the persistance scope here, not sure whether it should be readded var persistentModels = TW.Data.Objects; //var persistentModels = TW.Data.Objects.Where(o => TW.Data.PersistentModelObjects.Contains(o)); MemoryStream mem = null; try { mem = TW.Data.ModelSerializer.SerializeToStream(persistentModels); File.WriteAllBytes("temp.txt", mem.ToArray()); } catch (Exception ex) { DI.Get <IErrorLogger>().Log(ex, "Serialize engine data"); } twEngine.ClearAllGameplayData(); twEngine.updateActiveGameplayAssembly(); try { if (mem != null) { var objects = deserializeData(mem); // The deserialized objects are added to TW.Data automatically //foreach (var obj in objects) // TW.Data.AddObject(obj); } } catch (Exception ex) { DI.Get <IErrorLogger>().Log(ex, "Deserialize engine data"); return; } twEngine.ClearAllEngineState(); }