Updated to latest Penumbra.GameData, updated ObjectManager
This commit is contained in:
@@ -20,6 +20,7 @@ using CustomizePlus.GameData.Services;
|
||||
using CustomizePlus.GameData.Extensions;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using System.Drawing;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
||||
namespace CustomizePlus.Armatures.Services;
|
||||
|
||||
@@ -33,7 +34,7 @@ public unsafe sealed class ArmatureManager : IDisposable
|
||||
private readonly Logger _logger;
|
||||
private readonly FrameworkManager _framework;
|
||||
private readonly ObjectManager _objectManager;
|
||||
private readonly ActorService _actorService;
|
||||
private readonly ActorManager _actorManager;
|
||||
private readonly ArmatureChanged _event;
|
||||
|
||||
public Dictionary<ActorIdentifier, Armature> Armatures { get; private set; } = new();
|
||||
@@ -47,7 +48,7 @@ public unsafe sealed class ArmatureManager : IDisposable
|
||||
Logger logger,
|
||||
FrameworkManager framework,
|
||||
ObjectManager objectManager,
|
||||
ActorService actorService,
|
||||
ActorManager actorManager,
|
||||
ArmatureChanged @event)
|
||||
{
|
||||
_profileManager = profileManager;
|
||||
@@ -58,7 +59,7 @@ public unsafe sealed class ArmatureManager : IDisposable
|
||||
_logger = logger;
|
||||
_framework = framework;
|
||||
_objectManager = objectManager;
|
||||
_actorService = actorService;
|
||||
_actorManager = actorManager;
|
||||
_event = @event;
|
||||
|
||||
_templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.ArmatureManager);
|
||||
@@ -92,7 +93,7 @@ public unsafe sealed class ArmatureManager : IDisposable
|
||||
/// </summary>
|
||||
public void OnGameObjectMove(Actor actor)
|
||||
{
|
||||
if (!actor.Identifier(_actorService.AwaitedService, out var identifier))
|
||||
if (!actor.Identifier(_actorManager, out var identifier))
|
||||
return;
|
||||
|
||||
if (Armatures.TryGetValue(identifier, out var armature) && armature.IsBuilt && armature.IsVisible)
|
||||
|
||||
@@ -28,16 +28,22 @@ using CustomizePlus.Game.Services.GPose;
|
||||
using CustomizePlus.Game.Services.GPose.ExternalTools;
|
||||
using CustomizePlus.GameData.Services;
|
||||
using CustomizePlus.Configuration.Services.Temporary;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData.Actors;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
using OtterGui;
|
||||
|
||||
namespace CustomizePlus.Core;
|
||||
|
||||
public static class ServiceManager
|
||||
public static class ServiceManagerBuilder
|
||||
{
|
||||
public static ServiceProvider CreateProvider(DalamudPluginInterface pi, Logger logger)
|
||||
public static ServiceManager CreateProvider(DalamudPluginInterface pi, Logger logger)
|
||||
{
|
||||
var services = new ServiceCollection()
|
||||
.AddSingleton(logger)
|
||||
.AddDalamud(pi)
|
||||
EventWrapperBase.ChangeLogger(logger);
|
||||
|
||||
var services = new ServiceManager(logger)
|
||||
.AddExistingService(logger)
|
||||
.AddCore()
|
||||
.AddEvents()
|
||||
.AddGPoseServices()
|
||||
@@ -49,16 +55,20 @@ public static class ServiceManager
|
||||
.AddGameServices()
|
||||
.AddConfigServices()
|
||||
.AddRestOfServices();
|
||||
return services.BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true });
|
||||
}
|
||||
|
||||
private static IServiceCollection AddDalamud(this IServiceCollection services, DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
new DalamudServices(pluginInterface).AddServices(services);
|
||||
DalamudServices.AddServices(services, pi);
|
||||
|
||||
services.AddIServices(typeof(EquipItem).Assembly);
|
||||
services.AddIServices(typeof(Plugin).Assembly);
|
||||
services.AddIServices(typeof(ObjectManager).Assembly);
|
||||
services.AddIServices(typeof(ImGuiUtil).Assembly);
|
||||
|
||||
services.CreateProvider();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddGPoseServices(this IServiceCollection services)
|
||||
private static ServiceManager AddGPoseServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<PosingModeDetectService>()
|
||||
@@ -67,14 +77,14 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddArmatureServices(this IServiceCollection services)
|
||||
private static ServiceManager AddArmatureServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<ArmatureManager>();
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddUI(this IServiceCollection services)
|
||||
private static ServiceManager AddUI(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<TemplateCombo>()
|
||||
@@ -107,7 +117,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddEvents(this IServiceCollection services)
|
||||
private static ServiceManager AddEvents(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<ProfileChanged>()
|
||||
@@ -118,7 +128,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddCore(this IServiceCollection services)
|
||||
private static ServiceManager AddCore(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<HookingService>()
|
||||
@@ -133,7 +143,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddRestOfServices(this IServiceCollection services) //temp
|
||||
private static ServiceManager AddRestOfServices(this ServiceManager services) //temp
|
||||
{
|
||||
services
|
||||
.AddSingleton<PoseFileBoneLoader>()
|
||||
@@ -142,7 +152,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddConfigServices(this IServiceCollection services)
|
||||
private static ServiceManager AddConfigServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<PluginConfiguration>()
|
||||
@@ -153,7 +163,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddGameServices(this IServiceCollection services)
|
||||
private static ServiceManager AddGameServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<GameObjectService>()
|
||||
@@ -162,7 +172,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddProfileServices(this IServiceCollection services)
|
||||
private static ServiceManager AddProfileServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<ProfileManager>()
|
||||
@@ -172,7 +182,7 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddTemplateServices(this IServiceCollection services)
|
||||
private static ServiceManager AddTemplateServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<TemplateManager>()
|
||||
@@ -182,12 +192,13 @@ public static class ServiceManager
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddGameDataServices(this IServiceCollection services)
|
||||
private static ServiceManager AddGameDataServices(this ServiceManager services)
|
||||
{
|
||||
services
|
||||
.AddSingleton<ActorManager>()
|
||||
.AddSingleton<CutsceneService>()
|
||||
.AddSingleton<GameEventManager>()
|
||||
.AddSingleton<ActorService>()
|
||||
.AddSingleton(p => new CutsceneResolver(idx => (short)p.GetRequiredService<CutsceneService>().GetParentIndex(idx)))
|
||||
.AddSingleton<ObjectManager>();
|
||||
|
||||
return services;
|
||||
@@ -4,90 +4,27 @@ using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OtterGui.Services;
|
||||
|
||||
namespace CustomizePlus.Core.Services;
|
||||
|
||||
public class DalamudServices
|
||||
{
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public DalamudPluginInterface PluginInterface { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public ISigScanner SigScanner { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
public IFramework Framework { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IObjectTable ObjectTable { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public ICommandManager CommandManager { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IChatGui ChatGui { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IClientState ClientState { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IGameGui GameGui { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
internal IGameInteropProvider Hooker { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IKeyState KeyState { get; private set; } = null!;
|
||||
|
||||
//GameData
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IDataManager DataManager { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public IPluginLog PluginLog { get; private set; } = null!;
|
||||
|
||||
/*[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public ICondition Condition { get; private set; } = null!;*/
|
||||
|
||||
[PluginService]
|
||||
[RequiredVersion("1.0")]
|
||||
public ITargetManager TargetManager { get; private set; } = null!;
|
||||
|
||||
public DalamudServices(DalamudPluginInterface pluginInterface)
|
||||
public static void AddServices(ServiceManager services, DalamudPluginInterface pi)
|
||||
{
|
||||
pluginInterface.Inject(this);
|
||||
}
|
||||
|
||||
public void AddServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddSingleton(PluginInterface)
|
||||
.AddSingleton(SigScanner)
|
||||
.AddSingleton(Framework)
|
||||
.AddSingleton(ObjectTable)
|
||||
.AddSingleton(CommandManager)
|
||||
.AddSingleton(ChatGui)
|
||||
.AddSingleton(ClientState)
|
||||
.AddSingleton(GameGui)
|
||||
.AddSingleton(Hooker)
|
||||
.AddSingleton(KeyState)
|
||||
.AddSingleton(this)
|
||||
.AddSingleton(PluginInterface.UiBuilder)
|
||||
.AddSingleton(DataManager)
|
||||
.AddSingleton(PluginLog)
|
||||
//.AddSingleton(Condition)
|
||||
.AddSingleton(TargetManager);
|
||||
services.AddExistingService(pi)
|
||||
.AddExistingService(pi.UiBuilder)
|
||||
.AddDalamudService<ISigScanner>(pi)
|
||||
.AddDalamudService<IFramework>(pi)
|
||||
.AddDalamudService<IObjectTable>(pi)
|
||||
.AddDalamudService<ICommandManager>(pi)
|
||||
.AddDalamudService<IChatGui>(pi)
|
||||
.AddDalamudService<IClientState>(pi)
|
||||
.AddDalamudService<IGameGui>(pi)
|
||||
.AddDalamudService<IGameInteropProvider>(pi)
|
||||
.AddDalamudService<IKeyState>(pi)
|
||||
.AddDalamudService<IDataManager>(pi)
|
||||
.AddDalamudService<IPluginLog>(pi)
|
||||
.AddDalamudService<ITargetManager>(pi);
|
||||
}
|
||||
}
|
||||
@@ -140,9 +140,17 @@ public class HookingService : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
var actor = (Actor)gameObjectPtr;
|
||||
if (actor.Valid)
|
||||
_armatureManager.OnGameObjectMove((Actor)gameObjectPtr);
|
||||
try
|
||||
{
|
||||
var actor = (Actor)gameObjectPtr;
|
||||
if (actor.Valid)
|
||||
_armatureManager.OnGameObjectMove((Actor)gameObjectPtr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error($"Exception in Customize+ movement hook: {ex}");
|
||||
_gameObjectMovementHook?.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -5,18 +5,19 @@ using CustomizePlus.Core.Data;
|
||||
using CustomizePlus.GameData.Data;
|
||||
using CustomizePlus.GameData.Services;
|
||||
using CustomizePlus.GameData.Extensions;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
||||
namespace CustomizePlus.Game.Services;
|
||||
|
||||
public class GameObjectService
|
||||
{
|
||||
private readonly ActorService _actorService;
|
||||
private readonly ActorManager _actorManager;
|
||||
private readonly IObjectTable _objectTable;
|
||||
private readonly ObjectManager _objectManager;
|
||||
|
||||
public GameObjectService(ActorService actorService, IObjectTable objectTable, ObjectManager objectManager)
|
||||
public GameObjectService(ActorManager actorManager, IObjectTable objectTable, ObjectManager objectManager)
|
||||
{
|
||||
_actorService = actorService;
|
||||
_actorManager = actorManager;
|
||||
_objectTable = objectTable;
|
||||
_objectManager = objectManager;
|
||||
}
|
||||
@@ -33,7 +34,7 @@ public class GameObjectService
|
||||
|
||||
public bool IsActorHasScalableRoot(Actor actor)
|
||||
{
|
||||
if (!actor.Identifier(_actorService.AwaitedService, out var identifier))
|
||||
if (!actor.Identifier(_actorManager, out var identifier))
|
||||
return false;
|
||||
|
||||
return !Constants.IsInObjectTableBusyNPCRange(actor.Index.Index)
|
||||
|
||||
@@ -8,6 +8,7 @@ using CustomizePlus.UI;
|
||||
using CustomizePlus.Core;
|
||||
using CustomizePlus.Api.Compatibility;
|
||||
using CustomizePlus.Configuration.Services.Temporary;
|
||||
using OtterGui.Services;
|
||||
|
||||
namespace CustomizePlus;
|
||||
|
||||
@@ -19,7 +20,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
public static readonly string Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
|
||||
#endif
|
||||
|
||||
private readonly ServiceProvider _services;
|
||||
private readonly ServiceManager _services;
|
||||
|
||||
public static readonly Logger Logger = new(); //for loggin in static classes/methods
|
||||
|
||||
@@ -27,18 +28,18 @@ public sealed class Plugin : IDalamudPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
_services = ServiceManager.CreateProvider(pluginInterface, Logger);
|
||||
_services = ServiceManagerBuilder.CreateProvider(pluginInterface, Logger);
|
||||
|
||||
//temporary
|
||||
var configMover = _services.GetRequiredService<FantasiaPlusConfigMover>();
|
||||
var configMover = _services.GetService<FantasiaPlusConfigMover>();
|
||||
configMover.MoveConfigsIfNeeded();
|
||||
|
||||
var v3ConfigFixer = _services.GetRequiredService<Version3ConfigFixer>();
|
||||
var v3ConfigFixer = _services.GetService<Version3ConfigFixer>();
|
||||
v3ConfigFixer.FixV3ConfigIfNeeded();
|
||||
|
||||
_services.GetRequiredService<CustomizePlusIpc>();
|
||||
_services.GetRequiredService<CPlusWindowSystem>();
|
||||
_services.GetRequiredService<CommandService>();
|
||||
_services.GetService<CustomizePlusIpc>();
|
||||
_services.GetService<CPlusWindowSystem>();
|
||||
_services.GetService<CommandService>();
|
||||
|
||||
Logger.Information($"Customize+ v{Version} [FantasiaPlus] started");
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ using CustomizePlus.GameData.Data;
|
||||
using CustomizePlus.GameData.Services;
|
||||
using CustomizePlus.GameData.Extensions;
|
||||
using CustomizePlus.Profiles.Enums;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
||||
namespace CustomizePlus.Profiles;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class ProfileManager : IDisposable
|
||||
private readonly SaveService _saveService;
|
||||
private readonly Logger _logger;
|
||||
private readonly PluginConfiguration _configuration;
|
||||
private readonly ActorService _actorService;
|
||||
private readonly ActorManager _actorManager;
|
||||
private readonly ProfileChanged _event;
|
||||
private readonly TemplateChanged _templateChangedEvent;
|
||||
private readonly ReloadEvent _reloadEvent;
|
||||
@@ -51,7 +52,7 @@ public class ProfileManager : IDisposable
|
||||
SaveService saveService,
|
||||
Logger logger,
|
||||
PluginConfiguration configuration,
|
||||
ActorService actorService,
|
||||
ActorManager actorManager,
|
||||
ProfileChanged @event,
|
||||
TemplateChanged templateChangedEvent,
|
||||
ReloadEvent reloadEvent,
|
||||
@@ -62,7 +63,7 @@ public class ProfileManager : IDisposable
|
||||
_saveService = saveService;
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_actorService = actorService;
|
||||
_actorManager = actorManager;
|
||||
_event = @event;
|
||||
_templateChangedEvent = templateChangedEvent;
|
||||
_templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.ProfileManager);
|
||||
@@ -375,7 +376,7 @@ public class ProfileManager : IDisposable
|
||||
|
||||
public void AddTemporaryProfile(Profile profile, Actor actor/*, Template template*/)
|
||||
{
|
||||
if (!actor.Identifier(_actorService.AwaitedService, out var identifier))
|
||||
if (!actor.Identifier(_actorManager, out var identifier))
|
||||
return;
|
||||
|
||||
profile.Enabled = true;
|
||||
@@ -413,7 +414,7 @@ public class ProfileManager : IDisposable
|
||||
|
||||
public void RemoveTemporaryProfile(Actor actor)
|
||||
{
|
||||
if (!actor.Identifier(_actorService.AwaitedService, out var identifier))
|
||||
if (!actor.Identifier(_actorManager, out var identifier))
|
||||
return;
|
||||
|
||||
var profile = Profiles.FirstOrDefault(x => x.TemporaryActor == identifier && x.IsTemporary);
|
||||
|
||||
@@ -10,6 +10,7 @@ using CustomizePlus.Profiles;
|
||||
using CustomizePlus.Configuration.Helpers;
|
||||
using CustomizePlus.Game.Services;
|
||||
using CustomizePlus.GameData.Services;
|
||||
using Penumbra.GameData.Actors;
|
||||
|
||||
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class IPCTestTab //: IDisposable
|
||||
private readonly PopupSystem _popupSystem;
|
||||
private readonly GameObjectService _gameObjectService;
|
||||
private readonly ObjectManager _objectManager;
|
||||
private readonly ActorService _actorService;
|
||||
private readonly ActorManager _actorManager;
|
||||
|
||||
private readonly ICallGateSubscriber<(int, int)>? _getApiVersion;
|
||||
private readonly ICallGateSubscriber<string, Character?, object>? _setCharacterProfile;
|
||||
@@ -41,14 +42,14 @@ public class IPCTestTab //: IDisposable
|
||||
PopupSystem popupSystem,
|
||||
ObjectManager objectManager,
|
||||
GameObjectService gameObjectService,
|
||||
ActorService actorService)
|
||||
ActorManager actorManager)
|
||||
{
|
||||
_objectTable = objectTable;
|
||||
_profileManager = profileManager;
|
||||
_popupSystem = popupSystem;
|
||||
_objectManager = objectManager;
|
||||
_gameObjectService = gameObjectService;
|
||||
_actorService = actorService;
|
||||
_actorManager = actorManager;
|
||||
|
||||
_popupSystem.RegisterPopup("ipc_v4_profile_remembered", "Current profile has been copied into memory");
|
||||
_popupSystem.RegisterPopup("ipc_get_profile_from_character_remembered", "GetProfileFromCharacter result has been copied into memory");
|
||||
@@ -96,7 +97,7 @@ public class IPCTestTab //: IDisposable
|
||||
if (actors.Count == 0)
|
||||
return;
|
||||
|
||||
if (!actors[0].Item2.Identifier(_actorService.AwaitedService, out var identifier))
|
||||
if (!actors[0].Item2.Identifier(_actorManager, out var identifier))
|
||||
return;
|
||||
|
||||
var profile = _profileManager.GetEnabledProfilesByActor(identifier).FirstOrDefault();
|
||||
|
||||
Reference in New Issue
Block a user