Fix DefaultLocalPlayerProfile and DefaultProfile conflicting, fix commands, bump IPC version, send Profile.OnUpdate for DefaultProfile and DefaultLocalPlayerProfile

This commit is contained in:
RisaDev
2024-10-19 23:06:48 +03:00
parent 93802e6115
commit 74cf737102
6 changed files with 39 additions and 40 deletions

View File

@@ -4,7 +4,7 @@ namespace CustomizePlus.Api;
public partial class CustomizePlusIpc
{
private readonly (int Breaking, int Feature) _apiVersion = (5, 1);
private readonly (int Breaking, int Feature) _apiVersion = (5, 2);
/// <summary>
/// When there are breaking changes the first number is bumped up and second one is reset.

View File

@@ -283,24 +283,12 @@ public partial class CustomizePlusIpc
else
(activeProfile, oldProfile) = ((Profile?, Profile?))arg3;
if (activeProfile != null)
{
if (activeProfile == _profileManager.DefaultProfile || activeProfile.ProfileType == ProfileType.Editor)
{
//ignore any changes while player is in editor or if player changes between default profiles
//also do not send event if there were no active profile before
if (activeProfile == oldProfile || oldProfile == null)
return;
//do not send event if we are entering editor
if (activeProfile != null && activeProfile.ProfileType == ProfileType.Editor)
return;
OnProfileUpdateInternal(localPlayerCharacter, null); //send empty profile when player enters editor or turns on default profile
return;
}
}
//do not send event if we are exiting editor or disabling default profile and don't have any active profile
if (oldProfile != null &&
(oldProfile == _profileManager.DefaultProfile || oldProfile.ProfileType == ProfileType.Editor) &&
activeProfile == null)
//do not send event if we are exiting editor
if (oldProfile != null && oldProfile.ProfileType == ProfileType.Editor)
return;
OnProfileUpdateInternal(localPlayerCharacter, activeProfile);
@@ -309,8 +297,9 @@ public partial class CustomizePlusIpc
if (type == ArmatureChanged.Type.Deleted)
{
//Do not send event if default or editor profile was used
if (armature.Profile == _profileManager.DefaultProfile || armature.Profile.ProfileType == ProfileType.Editor) //todo: never send if ProfileType != normal?
//Do not send event if editor profile was used
//todo: never send if ProfileType != normal?
if (armature.Profile.ProfileType == ProfileType.Editor)
return;
OnProfileUpdateInternal(localPlayerCharacter, null);