Character factories follow mod reloads
This commit is contained in:
1 parent
734169db3d
commit
3afa3a6a80
2 files changed
+14
-12
No files matched your search
@@ -56,12 +56,13 @@ namespace Cthangover.Core.Factories.Impls
|
||||
/// </summary>
|
||||
private Dictionary<string, ActionCharacterInfo> EnsureInfos()
|
||||
{
|
||||
if (_allInfos != null)
|
||||
return _allInfos;
|
||||
|
||||
// The resolver's dictionary identity is the data snapshot (see CharacterFactory.EnsureInfos).
|
||||
var infos = Entities.Collect<ActionCharacterInfo>();
|
||||
if (ModManager.Instance.IsInitialized)
|
||||
if (!ReferenceEquals(infos, _allInfos))
|
||||
{
|
||||
_allInfos = infos;
|
||||
_cache.Clear();
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,16 +64,17 @@ namespace Cthangover.Core.Factories.Impls
|
||||
/// </summary>
|
||||
private Dictionary<string, CharacterInfo> EnsureInfos()
|
||||
{
|
||||
if (_allInfos != null)
|
||||
return _allInfos;
|
||||
|
||||
GameLogger.Log("FACTORY", $"CharacterFactory.EnsureInfos: START, ModRegistry.IsInitialized={ModRegistry.Instance.IsInitialized}, mods count={ModRegistry.Instance.Mods?.Count ?? 0}", LogLevel.Debug);
|
||||
|
||||
// Entities.Collect is cached by the entity resolver until the next
|
||||
// mod reload, so its dictionary identity is the data snapshot: a new
|
||||
// one (reload, data edit, game switch with this mod kept) drops the
|
||||
// built templates instead of serving the previous mod set's data.
|
||||
var infos = Entities.Collect<CharacterInfo>();
|
||||
if (ModManager.Instance.IsInitialized)
|
||||
_allInfos = infos;
|
||||
if (ReferenceEquals(infos, _allInfos))
|
||||
return infos;
|
||||
|
||||
GameLogger.Log("FACTORY", $"CharacterFactory.EnsureInfos: END, loaded {infos?.Count ?? 0} infos", LogLevel.Debug);
|
||||
_allInfos = infos;
|
||||
_cache.Clear();
|
||||
GameLogger.Log("FACTORY", $"CharacterFactory.EnsureInfos: {infos?.Count ?? 0} infos (new data snapshot)", LogLevel.Debug);
|
||||
return infos;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user