This commit is contained in:
RisaDev
2024-10-16 23:50:52 +03:00
parent d6975591fe
commit 497ab29de4
4 changed files with 31 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
using CustomizePlus.Configuration.Data.Version3;
using CustomizePlus.Core.Data;
using CustomizePlus.Game.Services;
using CustomizePlus.GameData.Extensions;
using CustomizePlus.Profiles.Data;
using CustomizePlus.Templates.Data;
@@ -17,14 +18,18 @@ namespace CustomizePlus.Api.Data;
/// </summary>
public class IPCCharacterProfile
{
/// <summary>
/// Used only for display purposes
/// </summary>
public string CharacterName { get; set; } = "Invalid";
public Dictionary<string, IPCBoneTransform> Bones { get; init; } = new();
public static IPCCharacterProfile FromFullProfile(Profile profile)
{
var ipcProfile = new IPCCharacterProfile
{
CharacterName = profile.Character.ToNameWithoutOwnerName(), //todo: proper update to v5
CharacterName = profile.Character.ToNameWithoutOwnerName(),
Bones = new Dictionary<string, IPCBoneTransform>()
};
@@ -48,8 +53,8 @@ public class IPCCharacterProfile
{
var fullProfile = new Profile
{
Name = $"{profile.CharacterName}'s IPC profile",
// CharacterName = profile.CharacterName, //todo: proper update to v5
Name = $"IPC profile for {profile.CharacterName}",
//Character should be set manually
CreationDate = DateTimeOffset.UtcNow,
ModifiedDate = DateTimeOffset.UtcNow,
Enabled = true,

View File

@@ -470,10 +470,27 @@ public unsafe sealed class ArmatureManager : IDisposable
if (type == ProfileChanged.Type.TemporaryProfileAdded)
{
if (!profile.Character.IsValid || !Armatures.ContainsKey(profile.Character)) //todo: any world support
if (!profile.Character.IsValid || !Armatures.ContainsKey(profile.Character)) //temporary profiles are never using AnyWorld identifiers so we should be fine here
return;
//todo: remove this later
/*Armature? armature = null;
foreach(var kvPair in Armatures)
{
//todo: check mount/companion
if(kvPair.Key.CompareIgnoringOwnership(profile.Character) &&
(kvPair.Key.Type != IdentifierType.Owned || kvPair.Key.IsOwnedByLocalPlayer()))
{
armature = kvPair.Value;
break;
}
}
if (armature == null)
return;*/
var armature = Armatures[profile.Character];
if (armature.Profile == profile)
return;

View File

@@ -342,14 +342,14 @@ public partial class ProfileManager : IDisposable
}
//warn: temporary profile system does not support any world identifiers
public void AddTemporaryProfile(Profile profile, Actor actor/*, Template template*/)
public void AddTemporaryProfile(Profile profile, Actor actor)
{
if (!actor.Identifier(_actorManager, out var identifier))
throw new ActorNotFoundException();
profile.Enabled = true;
profile.ProfileType = ProfileType.Temporary;
profile.Character = identifier;
profile.Character = identifier; //warn: identifier must not be AnyWorld or stuff will break!
var existingProfile = Profiles.FirstOrDefault(x => x.Character.CompareIgnoringOwnership(profile.Character) && x.IsTemporary);
if (existingProfile != null)
@@ -458,7 +458,7 @@ public partial class ProfileManager : IDisposable
return true;
var currentPlayer = _actorManager.GetCurrentPlayer();
return currentPlayer.IsValid && _actorManager.GetCurrentPlayer().CompareIgnoringOwnership(actorIdentifier);
return currentPlayer.IsValid && currentPlayer.CompareIgnoringOwnership(actorIdentifier);
}
if (actorIdentifier.Type == IdentifierType.Owned && !actorIdentifier.IsOwnedByLocalPlayer())

View File

@@ -2,6 +2,7 @@
using CustomizePlus.Core.Data;
using CustomizePlus.Game.Events;
using CustomizePlus.Game.Services;
using CustomizePlus.GameData.Extensions;
using CustomizePlus.Profiles;
using CustomizePlus.Profiles.Data;
using CustomizePlus.Profiles.Enums;
@@ -76,7 +77,7 @@ public class TemplateEditorManager : IDisposable
//todo: check with mounts/companions
var playerName = _gameObjectService.GetCurrentPlayerName();
return _gameObjectService.FindActorsByIdentifier(Character)
.Where(x => x.Item1.Type != Penumbra.GameData.Enums.IdentifierType.Owned || x.Item1.PlayerName.ToString() == playerName)
.Where(x => x.Item1.Type != Penumbra.GameData.Enums.IdentifierType.Owned || x.Item1.IsOwnedByLocalPlayer())
.Any();
}
}