Add IPC for Adding and Removing characters from a profile
This commit is contained in:
@@ -4,7 +4,7 @@ namespace CustomizePlus.Api;
|
|||||||
|
|
||||||
public partial class CustomizePlusIpc
|
public partial class CustomizePlusIpc
|
||||||
{
|
{
|
||||||
private readonly (int Breaking, int Feature) _apiVersion = (6, 0);
|
private readonly (int Breaking, int Feature) _apiVersion = (6, 1);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When there are breaking changes the first number is bumped up and second one is reset.
|
/// When there are breaking changes the first number is bumped up and second one is reset.
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Penumbra.GameData.Enums;
|
|||||||
using CustomizePlus.Templates.Data;
|
using CustomizePlus.Templates.Data;
|
||||||
using CustomizePlus.Templates.Events;
|
using CustomizePlus.Templates.Events;
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
|
using Penumbra.String;
|
||||||
|
|
||||||
namespace CustomizePlus.Api;
|
namespace CustomizePlus.Api;
|
||||||
|
|
||||||
@@ -99,6 +100,70 @@ public partial class CustomizePlusIpc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a player character to a specified profile.
|
||||||
|
/// </summary>
|
||||||
|
[EzIPC("Profile.AddPlayerCharacter")]
|
||||||
|
private int AddPlayerCharacterToProfile(Guid uniqueId, string name, ushort worldId)
|
||||||
|
{
|
||||||
|
if (uniqueId == Guid.Empty)
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.ProfileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
var profile = this._profileManager.Profiles.FirstOrDefault(x => x.UniqueId == uniqueId && !x.IsTemporary);
|
||||||
|
if (profile == null)
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.ProfileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ByteString.FromString(name, out var byteString))
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.InvalidCharacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
var playerIdentifier = this._actorManager.CreatePlayer(byteString, worldId);
|
||||||
|
if (playerIdentifier == ActorIdentifier.Invalid)
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.InvalidCharacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._profileManager.AddCharacter(profile, playerIdentifier);
|
||||||
|
return (int)ErrorCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a player character to a specified profile.
|
||||||
|
/// </summary>
|
||||||
|
[EzIPC("Profile.RemovePlayerCharacter")]
|
||||||
|
private int RemovePlayerCharacterToProfile(Guid uniqueId, string name, ushort worldId)
|
||||||
|
{
|
||||||
|
if (uniqueId == Guid.Empty)
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.ProfileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
var profile = this._profileManager.Profiles.FirstOrDefault(x => x.UniqueId == uniqueId && !x.IsTemporary);
|
||||||
|
if (profile == null)
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.ProfileNotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ByteString.FromString(name, out var byteString))
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.InvalidCharacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
var playerIdentifier = this._actorManager.CreatePlayer(byteString, worldId);
|
||||||
|
if (playerIdentifier == ActorIdentifier.Invalid)
|
||||||
|
{
|
||||||
|
return (int)ErrorCode.InvalidCharacter;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._profileManager.DeleteCharacter(profile, playerIdentifier);
|
||||||
|
return (int)ErrorCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enable profile using its Unique ID. Does not work on temporary profiles.
|
/// Enable profile using its Unique ID. Does not work on temporary profiles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Dalamud.Plugin;
|
|||||||
using ECommonsLite.EzIpcManager;
|
using ECommonsLite.EzIpcManager;
|
||||||
using OtterGui.Log;
|
using OtterGui.Log;
|
||||||
using System;
|
using System;
|
||||||
|
using Penumbra.GameData.Actors;
|
||||||
|
|
||||||
namespace CustomizePlus.Api;
|
namespace CustomizePlus.Api;
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ public partial class CustomizePlusIpc : IDisposable
|
|||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
private readonly HookingService _hookingService;
|
private readonly HookingService _hookingService;
|
||||||
private readonly ProfileManager _profileManager;
|
private readonly ProfileManager _profileManager;
|
||||||
|
private readonly ActorManager _actorManager;
|
||||||
private readonly GameObjectService _gameObjectService;
|
private readonly GameObjectService _gameObjectService;
|
||||||
private readonly ProfileFileSystem _profileFileSystem;
|
private readonly ProfileFileSystem _profileFileSystem;
|
||||||
private readonly CutsceneService _cutsceneService;
|
private readonly CutsceneService _cutsceneService;
|
||||||
@@ -43,6 +45,7 @@ public partial class CustomizePlusIpc : IDisposable
|
|||||||
Logger logger,
|
Logger logger,
|
||||||
HookingService hookingService,
|
HookingService hookingService,
|
||||||
ProfileManager profileManager,
|
ProfileManager profileManager,
|
||||||
|
ActorManager actorManager,
|
||||||
GameObjectService gameObjectService,
|
GameObjectService gameObjectService,
|
||||||
ProfileFileSystem profileFileSystem,
|
ProfileFileSystem profileFileSystem,
|
||||||
CutsceneService cutsceneService,
|
CutsceneService cutsceneService,
|
||||||
@@ -53,6 +56,7 @@ public partial class CustomizePlusIpc : IDisposable
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_hookingService = hookingService;
|
_hookingService = hookingService;
|
||||||
_profileManager = profileManager;
|
_profileManager = profileManager;
|
||||||
|
_actorManager = actorManager;
|
||||||
_gameObjectService = gameObjectService;
|
_gameObjectService = gameObjectService;
|
||||||
_profileFileSystem = profileFileSystem;
|
_profileFileSystem = profileFileSystem;
|
||||||
_cutsceneService = cutsceneService;
|
_cutsceneService = cutsceneService;
|
||||||
|
|||||||
Reference in New Issue
Block a user