Hopefully fix issue with missing caches.

This commit is contained in:
Ottermandias 2023-04-29 15:49:33 +02:00
parent c2933ba95c
commit 3d5765796e
4 changed files with 10 additions and 5 deletions

View file

@ -51,6 +51,7 @@ public class CollectionCacheManager : IDisposable
_communicator.ModSettingChanged.Subscribe(OnModSettingChange);
_communicator.CollectionInheritanceChanged.Subscribe(OnCollectionInheritanceChange);
CreateNecessaryCaches();
_active.Individuals.Loaded += CreateNecessaryCaches;
if (!MetaFileManager.CharacterUtility.Ready)
MetaFileManager.CharacterUtility.LoadingFinished += IncrementCounters;

View file

@ -47,6 +47,7 @@ public class ActiveCollections : ISavable, IDisposable
_communicator.CollectionChange.Subscribe(OnCollectionChange, -100);
LoadCollections();
UpdateCurrentCollectionInUse();
Individuals.Loaded += UpdateCurrentCollectionInUse;
}
public void Dispose()
@ -275,7 +276,7 @@ public class ActiveCollections : ISavable, IDisposable
jObj.WriteTo(j);
}
public void UpdateCurrentCollectionInUse()
private void UpdateCurrentCollectionInUse()
=> CurrentCollectionInUse = SpecialCollections
.OfType<ModCollection>()
.Prepend(Interface)

View file

@ -34,7 +34,7 @@ public partial class IndividualCollections
{
if (ReadJObjectInternal(obj, storage))
saver.ImmediateSave(parent);
parent.UpdateCurrentCollectionInUse();
Loaded?.Invoke();
_actorService.FinishedCreation -= Func;
}
_actorService.FinishedCreation += Func;

View file

@ -17,6 +17,8 @@ public sealed partial class IndividualCollections
private readonly List<(string DisplayName, IReadOnlyList<ActorIdentifier> Identifiers, ModCollection Collection)> _assignments = new();
private readonly Dictionary<ActorIdentifier, ModCollection> _individuals = new();
public event Action? Loaded;
public IReadOnlyList<(string DisplayName, IReadOnlyList<ActorIdentifier> Identifiers, ModCollection Collection)> Assignments
=> _assignments;
@ -95,7 +97,7 @@ public sealed partial class IndividualCollections
case IdentifierType.Owned:
if (!ByteString.FromString(name, out var ownerName))
return AddResult.Invalid;
identifiers = dataIds.Select(id => manager.CreateOwned(ownerName, homeWorld, kind, id)).ToArray();
break;
case IdentifierType.Npc:
@ -242,8 +244,9 @@ public sealed partial class IndividualCollections
IdentifierType.Retainer => $"{identifier.PlayerName} (Retainer)",
IdentifierType.Owned =>
$"{identifier.PlayerName} ({_actorService.AwaitedService.Data.ToWorldName(identifier.HomeWorld)})'s {_actorService.AwaitedService.Data.ToName(identifier.Kind, identifier.DataId)}",
IdentifierType.Npc => $"{_actorService.AwaitedService.Data.ToName(identifier.Kind, identifier.DataId)} ({identifier.Kind.ToName()})",
_ => string.Empty,
IdentifierType.Npc =>
$"{_actorService.AwaitedService.Data.ToName(identifier.Kind, identifier.DataId)} ({identifier.Kind.ToName()})",
_ => string.Empty,
};
}
}