public void UpdateFile(RefFilename filename, string text) { VariableStore.Instance.RemoveAllVariablesFromFile(filename); Instance.DeferedPostInitializationListNext.Clear(); ModCK3Library.ClearFile(filename); LoadingCK3Library = ModCK3Library; var c = GetContextFromDirectory(filename); try { var results = FileTokenizer.Instance.LoadText(text, filename, c); ModCK3Library.Add(results, c); } catch (Exception e) { } try { for (var i = 0; i < Instance.DeferedPostInitializationListNext.Count; i++) { var scriptObject = Instance.DeferedPostInitializationListNext[i]; scriptObject.Initialize(); } } catch (Exception e) { } try { LoadingCK3Library.RecalculateGroups(); do { Instance.DeferedPostInitializationList = Instance.DeferedPostInitializationListNext; Instance.DeferedPostInitializationListNext = new List <ScriptObject>(); for (var i = 0; i < Instance.DeferedPostInitializationList.Count; i++) { var scriptObject = Instance.DeferedPostInitializationList[i]; scriptObject.PostInitialize(null, null); } Instance.DeferedPostInitializationList.Clear(); } while (Instance.DeferedPostInitializationListNext.Count > 0); } catch (Exception e) { } ScriptObject.ClearCachedScriptedEffects(); }
public bool LoadCK3File(RefFilename filename, bool forceBase = false, bool forceReload = false) { var fromBase = filename.IsBase; LoadingCK3Library = fromBase ? BaseCK3Library : ModCK3Library; if (!forceReload) { if (fromBase) { if (BaseCK3Library.HasFile(filename)) { return(fromBase); } } else { if (ModCK3Library.HasFile(filename)) { return(fromBase); } } } else { LoadingCK3Library.ClearFile(filename); } // string directory = filename.Substring(0, Math.Max(filename.LastIndexOf("/"), 0)); var context = GetContextFromDirectory(filename); var results = FileTokenizer.Instance.LoadFile(filename, context, true); LoadingCK3Library.Add(results, context); PostInitialize(null); return(fromBase); }