@@ -208,22 +208,52 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC
208
208
__instance . RpcRejectShapeshift ( ) ;
209
209
return false ;
210
210
}
211
+ var shapeshifter = __instance ;
212
+ var shapeshifting = shapeshifter . PlayerId != target . PlayerId ;
213
+ // 変身したとき一番近い人をマッドメイトにする処理
214
+ if ( shapeshifter . CanMakeMadmate ( ) && shapeshifting )
215
+ {
216
+ var sidekickable = shapeshifter . GetRoleClass ( ) as ISidekickable ;
217
+ var targetRole = sidekickable ? . SidekickTargetRole ?? CustomRoles . SKMadmate ;
218
+
219
+ Vector2 shapeshifterPosition = shapeshifter . transform . position ; //変身者の位置
220
+ Dictionary < PlayerControl , float > mpdistance = new ( ) ;
221
+ float dis ;
222
+ foreach ( var p in Main . AllAlivePlayerControls )
223
+ {
224
+ if ( p . Data . Role . Role != RoleTypes . Shapeshifter && ! p . Is ( CustomRoleTypes . Impostor ) && ! p . Is ( targetRole ) )
225
+ {
226
+ dis = Vector2 . Distance ( shapeshifterPosition , p . transform . position ) ;
227
+ mpdistance . Add ( p , dis ) ;
228
+ }
229
+ }
230
+ if ( mpdistance . Count != 0 )
231
+ {
232
+ var min = mpdistance . OrderBy ( c => c . Value ) . FirstOrDefault ( ) ; //一番値が小さい
233
+ PlayerControl targetm = min . Key ;
234
+ targetm . RpcSetCustomRole ( targetRole ) ;
235
+ Logger . Info ( $ "Make SKMadmate:{ targetm . name } ", "Shapeshift" ) ;
236
+ Main . SKMadmateNowCount ++ ;
237
+ Utils . MarkEveryoneDirtySettings ( ) ;
238
+ Utils . NotifyRoles ( ) ;
239
+ }
240
+ }
211
241
// 役職の処理
212
- var role = __instance . GetRoleClass ( ) ;
242
+ var role = shapeshifter . GetRoleClass ( ) ;
213
243
if ( role ? . OnCheckShapeshift ( target , ref shouldAnimate ) == false )
214
244
{
215
245
if ( role . CanDesyncShapeshift )
216
246
{
217
- __instance . RpcSpecificRejectShapeshift ( target , shouldAnimate ) ;
247
+ shapeshifter . RpcSpecificRejectShapeshift ( target , shouldAnimate ) ;
218
248
}
219
249
else
220
250
{
221
- __instance . RpcRejectShapeshift ( ) ;
251
+ shapeshifter . RpcRejectShapeshift ( ) ;
222
252
}
223
253
return false ;
224
254
}
225
255
226
- __instance . RpcShapeshift ( target , shouldAnimate ) ;
256
+ shapeshifter . RpcShapeshift ( target , shouldAnimate ) ;
227
257
return false ;
228
258
}
229
259
private static bool CheckInvalidShapeshifting ( PlayerControl instance , PlayerControl target , bool animate )
@@ -289,35 +319,6 @@ public static void Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC
289
319
290
320
if ( ! shapeshifting ) Camouflage . RpcSetSkin ( __instance ) ;
291
321
292
- // 変身したとき一番近い人をマッドメイトにする処理
293
- if ( shapeshifter . CanMakeMadmate ( ) && shapeshifting )
294
- {
295
- var sidekickable = shapeshifter . GetRoleClass ( ) as ISidekickable ;
296
- var targetRole = sidekickable ? . SidekickTargetRole ?? CustomRoles . SKMadmate ;
297
-
298
- Vector2 shapeshifterPosition = shapeshifter . transform . position ; //変身者の位置
299
- Dictionary < PlayerControl , float > mpdistance = new ( ) ;
300
- float dis ;
301
- foreach ( var p in Main . AllAlivePlayerControls )
302
- {
303
- if ( p . Data . Role . Role != RoleTypes . Shapeshifter && ! p . Is ( CustomRoleTypes . Impostor ) && ! p . Is ( targetRole ) )
304
- {
305
- dis = Vector2 . Distance ( shapeshifterPosition , p . transform . position ) ;
306
- mpdistance . Add ( p , dis ) ;
307
- }
308
- }
309
- if ( mpdistance . Count != 0 )
310
- {
311
- var min = mpdistance . OrderBy ( c => c . Value ) . FirstOrDefault ( ) ; //一番値が小さい
312
- PlayerControl targetm = min . Key ;
313
- targetm . RpcSetCustomRole ( targetRole ) ;
314
- Logger . Info ( $ "Make SKMadmate:{ targetm . name } ", "Shapeshift" ) ;
315
- Main . SKMadmateNowCount ++ ;
316
- Utils . MarkEveryoneDirtySettings ( ) ;
317
- Utils . NotifyRoles ( ) ;
318
- }
319
- }
320
-
321
322
//変身解除のタイミングがずれて名前が直せなかった時のために強制書き換え
322
323
if ( ! shapeshifting )
323
324
{
0 commit comments