From 497ab29de40e9e972a09d9d8cec514ed8a668dbd Mon Sep 17 00:00:00 2001
From: RisaDev <151885272+RisaDev@users.noreply.github.com>
Date: Wed, 16 Oct 2024 23:50:52 +0300
Subject: [PATCH] Cleanup
---
CustomizePlus/Api/Data/IPCCharacterProfile.cs | 11 ++++++++---
.../Armatures/Services/ArmatureManager.cs | 19 ++++++++++++++++++-
CustomizePlus/Profiles/ProfileManager.cs | 6 +++---
.../Templates/TemplateEditorManager.cs | 3 ++-
4 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/CustomizePlus/Api/Data/IPCCharacterProfile.cs b/CustomizePlus/Api/Data/IPCCharacterProfile.cs
index 262e8cc..b9a1988 100644
--- a/CustomizePlus/Api/Data/IPCCharacterProfile.cs
+++ b/CustomizePlus/Api/Data/IPCCharacterProfile.cs
@@ -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;
///
public class IPCCharacterProfile
{
+ ///
+ /// Used only for display purposes
+ ///
public string CharacterName { get; set; } = "Invalid";
+
public Dictionary 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()
};
@@ -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,
diff --git a/CustomizePlus/Armatures/Services/ArmatureManager.cs b/CustomizePlus/Armatures/Services/ArmatureManager.cs
index ac920ea..be87665 100644
--- a/CustomizePlus/Armatures/Services/ArmatureManager.cs
+++ b/CustomizePlus/Armatures/Services/ArmatureManager.cs
@@ -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;
diff --git a/CustomizePlus/Profiles/ProfileManager.cs b/CustomizePlus/Profiles/ProfileManager.cs
index adba325..3140ee4 100644
--- a/CustomizePlus/Profiles/ProfileManager.cs
+++ b/CustomizePlus/Profiles/ProfileManager.cs
@@ -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())
diff --git a/CustomizePlus/Templates/TemplateEditorManager.cs b/CustomizePlus/Templates/TemplateEditorManager.cs
index b586c23..1f9780c 100644
--- a/CustomizePlus/Templates/TemplateEditorManager.cs
+++ b/CustomizePlus/Templates/TemplateEditorManager.cs
@@ -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();
}
}