Remove static ActorService.

This commit is contained in:
Ottermandias 2023-04-21 23:56:20 +02:00
parent be3c1c85aa
commit 2c55701cbf
4 changed files with 17 additions and 12 deletions

View file

@ -111,7 +111,7 @@ public class MetaCache : IDisposable, IEnumerable<KeyValuePair<MetaManipulation,
public bool RevertMod(MetaManipulation manip) public bool RevertMod(MetaManipulation manip)
{ {
var ret = _manipulations.Remove(manip); var ret = _manipulations.Remove(manip);
if (!Penumbra.CharacterUtility.Ready) if (!_manager.CharacterUtility.Ready)
return ret; return ret;
// Imc manipulations do not require character utility, // Imc manipulations do not require character utility,

View file

@ -30,10 +30,13 @@ public class ActiveCollections : ISavable, IDisposable
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
private readonly SaveService _saveService; private readonly SaveService _saveService;
private readonly ActiveCollectionData _data; private readonly ActiveCollectionData _data;
private readonly ActorService _actors;
public ActiveCollections(Configuration config, CollectionStorage storage, ActorService actors, CommunicatorService communicator, SaveService saveService, ActiveCollectionData data) public ActiveCollections(Configuration config, CollectionStorage storage, ActorService actors, CommunicatorService communicator,
SaveService saveService, ActiveCollectionData data)
{ {
_storage = storage; _storage = storage;
_actors = actors;
_communicator = communicator; _communicator = communicator;
_saveService = saveService; _saveService = saveService;
_data = data; _data = data;
@ -190,7 +193,9 @@ public class ActiveCollections : ISavable, IDisposable
else else
{ {
if (collection == null) if (collection == null)
{
RemoveSpecialCollection(collectionType); RemoveSpecialCollection(collectionType);
}
else else
{ {
CreateSpecialCollection(collectionType); CreateSpecialCollection(collectionType);
@ -207,8 +212,9 @@ public class ActiveCollections : ISavable, IDisposable
CollectionType.Default => Default, CollectionType.Default => Default,
CollectionType.Interface => Interface, CollectionType.Interface => Interface,
CollectionType.Current => Current, CollectionType.Current => Current,
CollectionType.Individual when individualIndex >= 0 && individualIndex < Individuals.Count => Individuals[individualIndex].Collection, CollectionType.Individual when individualIndex >= 0 && individualIndex < Individuals.Count => Individuals[individualIndex]
CollectionType.Individual => null, .Collection,
CollectionType.Individual => null,
_ when collectionType.IsSpecial() => SpecialCollections[(int)collectionType] ?? Default, _ when collectionType.IsSpecial() => SpecialCollections[(int)collectionType] ?? Default,
_ => null, _ => null,
}; };
@ -433,7 +439,7 @@ public class ActiveCollections : ISavable, IDisposable
{ {
case IdentifierType.Player when id.HomeWorld != ushort.MaxValue: case IdentifierType.Player when id.HomeWorld != ushort.MaxValue:
{ {
var global = ByType(CollectionType.Individual, Penumbra.Actors.CreatePlayer(id.PlayerName, ushort.MaxValue)); var global = ByType(CollectionType.Individual, _actors.AwaitedService.CreatePlayer(id.PlayerName, ushort.MaxValue));
return global?.Index == checkAssignment.Index return global?.Index == checkAssignment.Index
? "Assignment is redundant due to an identical Any-World assignment existing.\nYou can remove it." ? "Assignment is redundant due to an identical Any-World assignment existing.\nYou can remove it."
: string.Empty; : string.Empty;
@ -442,12 +448,12 @@ public class ActiveCollections : ISavable, IDisposable
if (id.HomeWorld != ushort.MaxValue) if (id.HomeWorld != ushort.MaxValue)
{ {
var global = ByType(CollectionType.Individual, var global = ByType(CollectionType.Individual,
Penumbra.Actors.CreateOwned(id.PlayerName, ushort.MaxValue, id.Kind, id.DataId)); _actors.AwaitedService.CreateOwned(id.PlayerName, ushort.MaxValue, id.Kind, id.DataId));
if (global?.Index == checkAssignment.Index) if (global?.Index == checkAssignment.Index)
return "Assignment is redundant due to an identical Any-World assignment existing.\nYou can remove it."; return "Assignment is redundant due to an identical Any-World assignment existing.\nYou can remove it.";
} }
var unowned = ByType(CollectionType.Individual, Penumbra.Actors.CreateNpc(id.Kind, id.DataId)); var unowned = ByType(CollectionType.Individual, _actors.AwaitedService.CreateNpc(id.Kind, id.DataId));
return unowned?.Index == checkAssignment.Index return unowned?.Index == checkAssignment.Index
? "Assignment is redundant due to an identical unowned NPC assignment existing.\nYou can remove it." ? "Assignment is redundant due to an identical unowned NPC assignment existing.\nYou can remove it."
: string.Empty; : string.Empty;

View file

@ -17,11 +17,13 @@ public class TempCollectionManager : IDisposable
private readonly CommunicatorService _communicator; private readonly CommunicatorService _communicator;
private readonly CollectionStorage _storage; private readonly CollectionStorage _storage;
private readonly ActorService _actors;
private readonly Dictionary<string, ModCollection> _customCollections = new(); private readonly Dictionary<string, ModCollection> _customCollections = new();
public TempCollectionManager(Configuration config, CommunicatorService communicator, ActorService actors, CollectionStorage storage) public TempCollectionManager(Configuration config, CommunicatorService communicator, ActorService actors, CollectionStorage storage)
{ {
_communicator = communicator; _communicator = communicator;
_actors = actors;
_storage = storage; _storage = storage;
Collections = new IndividualCollections(actors, config); Collections = new IndividualCollections(actors, config);
@ -97,7 +99,6 @@ public class TempCollectionManager : IDisposable
Penumbra.Log.Verbose($"Assigned temporary collection {collection.AnonymizedName} to {Collections.Last().DisplayName}."); Penumbra.Log.Verbose($"Assigned temporary collection {collection.AnonymizedName} to {Collections.Last().DisplayName}.");
_communicator.CollectionChange.Invoke(CollectionType.Temporary, null, collection, Collections.Last().DisplayName); _communicator.CollectionChange.Invoke(CollectionType.Temporary, null, collection, Collections.Last().DisplayName);
return true; return true;
} }
public bool AddIdentifier(string collectionName, params ActorIdentifier[] identifiers) public bool AddIdentifier(string collectionName, params ActorIdentifier[] identifiers)
@ -113,7 +114,7 @@ public class TempCollectionManager : IDisposable
if (!ByteString.FromString(characterName, out var byteString, false)) if (!ByteString.FromString(characterName, out var byteString, false))
return false; return false;
var identifier = Penumbra.Actors.CreatePlayer(byteString, worldId); var identifier = _actors.AwaitedService.CreatePlayer(byteString, worldId);
if (!identifier.IsValid) if (!identifier.IsValid)
return false; return false;
@ -125,7 +126,7 @@ public class TempCollectionManager : IDisposable
if (!ByteString.FromString(characterName, out var byteString, false)) if (!ByteString.FromString(characterName, out var byteString, false))
return false; return false;
var identifier = Penumbra.Actors.CreatePlayer(byteString, worldId); var identifier = _actors.AwaitedService.CreatePlayer(byteString, worldId);
return Collections.TryGetValue(identifier, out var collection) && RemoveTemporaryCollection(collection.Name); return Collections.TryGetValue(identifier, out var collection) && RemoveTemporaryCollection(collection.Name);
} }
} }

View file

@ -39,7 +39,6 @@ public class Penumbra : IDalamudPlugin
public static CharacterUtility CharacterUtility { get; private set; } = null!; public static CharacterUtility CharacterUtility { get; private set; } = null!;
public static CollectionManager CollectionManager { get; private set; } = null!; public static CollectionManager CollectionManager { get; private set; } = null!;
public static ActorManager Actors { get; private set; } = null!;
public readonly RedrawService RedrawService; public readonly RedrawService RedrawService;
public readonly ModFileSystem ModFileSystem; public readonly ModFileSystem ModFileSystem;
@ -68,7 +67,6 @@ public class Penumbra : IDalamudPlugin
_tmp.Services.GetRequiredService<BackupService>(); _tmp.Services.GetRequiredService<BackupService>();
_config = _tmp.Services.GetRequiredService<Configuration>(); _config = _tmp.Services.GetRequiredService<Configuration>();
CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>(); CharacterUtility = _tmp.Services.GetRequiredService<CharacterUtility>();
Actors = _tmp.Services.GetRequiredService<ActorService>().AwaitedService;
_tempMods = _tmp.Services.GetRequiredService<TempModManager>(); _tempMods = _tmp.Services.GetRequiredService<TempModManager>();
_residentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>(); _residentResources = _tmp.Services.GetRequiredService<ResidentResourceManager>();
_tmp.Services.GetRequiredService<ResourceManagerService>(); _tmp.Services.GetRequiredService<ResourceManagerService>();