@@ -70,40 +70,28 @@ internal static bool TryGetSceneProfile(CostumeScene scene, out Configuration.Sc
7070 return _config . TryGetSceneProfile ( scene , out profile ) ;
7171 }
7272
73- private static Configuration . Costume GetEffectiveCostume ( Maid maid , CostumeScene scene ) {
74- var hasMaidProfile = _config . TryGetMaidProfile ( maid , scene , out var profile ) ;
75-
76- if ( hasMaidProfile && profile . PreferredProfile == CostumeProfile . Personal && profile . HasCostume ) {
77- return profile . Costume ;
78- }
79-
73+ private static bool TryGetEffectiveCostume ( Maid maid , CostumeScene scene , out Configuration . Costume costume ) {
74+ var hasMaidProfile = _config . TryGetMaidProfile ( maid , scene , out var maidProfile ) ;
8075 var hasSceneProfile = _config . TryGetSceneProfile ( scene , out var sceneProfile ) ;
81- var tryScene = ! hasMaidProfile || ( profile . PreferredProfile == CostumeProfile . Personal && ! profile . HasCostume ) || profile . PreferredProfile == CostumeProfile . Shared ;
82- var hasSceneCostume = hasSceneProfile && sceneProfile . PreferredProfile == CostumeProfile . Shared && sceneProfile . HasCostume ;
83-
84- if ( ( ! ( hasMaidProfile && ! tryScene ) ) && hasSceneCostume ) {
85- return sceneProfile . Costume ;
86- }
87-
88- return CloneCostume ( maid ) ;
89- }
9076
91- internal static Configuration . Costume CloneCostume ( Configuration . Costume costume ) {
92- LogDebug ( $ "CloneCostume") ;
93- var newCostume = new Configuration . Costume ( ) ;
94- foreach ( var item in costume . Items ) {
95- newCostume . AddItem ( item . Slot , item . FileName , item . IsEnabled ) ;
77+ if ( hasMaidProfile ) {
78+ if ( maidProfile . PreferredProfile == CostumeProfile . Personal && maidProfile . HasCostume ) {
79+ costume = maidProfile . Costume ;
80+ return true ;
81+ }
82+ if ( maidProfile . PreferredProfile == CostumeProfile . Shared && hasSceneProfile && sceneProfile . HasCostume ) {
83+ costume = sceneProfile . Costume ;
84+ return true ;
85+ }
86+ } else if ( hasSceneProfile ) {
87+ if ( sceneProfile . PreferredProfile == CostumeProfile . Shared && sceneProfile . HasCostume ) {
88+ costume = sceneProfile . Costume ;
89+ return true ;
90+ }
9691 }
97- return newCostume ;
98- }
9992
100- internal static Configuration . Costume CloneCostume ( Maid maid ) {
101- var newCostume = new Configuration . Costume ( ) ;
102- foreach ( var mpn in CostumeEdit . AvailableMpn ) {
103- var prop = maid . GetProp ( mpn ) ;
104- newCostume . AddItem ( ( MPN ) prop . idx , prop . strFileName ) ;
105- }
106- return newCostume ;
93+ costume = null ;
94+ return false ;
10795 }
10896
10997 internal static CostumeProfile GetPreferredProfile ( Maid maid , CostumeScene scene ) {
@@ -139,11 +127,14 @@ internal static void LoadCostume(Maid maid, Configuration.Costume costume, bool
139127 }
140128
141129 private static void SetCostume ( Maid maid , CostumeScene scene ) {
130+ if ( ! TryGetEffectiveCostume ( maid , scene , out var costume ) ) {
131+ return ;
132+ }
133+
142134 LogDebug ( $ "Setting costume for { maid . name } ") ;
143135
144- var costume = GetEffectiveCostume ( maid , scene ) ;
145- if ( costume == null ) return ;
146136 GameMain . instance . StartCoroutine ( WaitMaidPropBusy ( maid , ( ) => {
137+ BackupCostume ( maid ) ;
147138 LoadCostume ( maid , costume ) ;
148139 maid . AllProcPropSeqStart ( ) ;
149140 } ) ) ;
@@ -235,7 +226,6 @@ private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
235226 for ( var i = 0 ; i < numMaids ; i ++ ) {
236227 var maid = GameMain . Instance . CharacterMgr . GetMaid ( i ) ;
237228 if ( maid != null && maid . body0 && ! _originalCostume . ContainsKey ( maid . status . guid ) ) {
238- BackupCostume ( maid ) ;
239229 SetCostume ( maid , costumeScene ) ;
240230 }
241231 }
@@ -274,7 +264,6 @@ private static void YotogiSubCharacterSelectManager_OnFinish(YotogiSubCharacterS
274264 // secondary yotogi maids are not yet loaded on sceneLoaded, so we fix them here
275265 foreach ( var maid in __instance . loaded_check_maid_ ) {
276266 if ( maid != null && ! _originalCostume . ContainsKey ( maid . status . guid ) ) {
277- BackupCostume ( maid ) ;
278267 SetCostume ( maid , CostumeScene . Yotogi ) ;
279268 }
280269 }
0 commit comments