@@ -7,49 +7,53 @@ namespace MCI
77{
88 public static class InstanceControl
99 {
10- public static Dictionary < int , ClientData > clients = new Dictionary < int , ClientData > ( ) ;
11- public static Dictionary < byte , int > PlayerIdClientId = new Dictionary < byte , int > ( ) ;
10+ public static Dictionary < int , ClientData > clients = new ( ) ;
11+
12+ public static Dictionary < byte , int > PlayerIdClientId = new ( ) ;
13+
1214 public const int MaxID = 100 ;
13- public static int availableId ( )
15+
16+ public static int AvailableId ( )
1417 {
1518 for ( int i = 2 ; i < MaxID ; i ++ )
16- if ( ! clients . ContainsKey ( i ) )
17- if ( PlayerControl . LocalPlayer . OwnerId != i ) return i ;
19+ {
20+ if ( ! clients . ContainsKey ( i ) && PlayerControl . LocalPlayer . OwnerId != i )
21+ return i ;
22+ }
1823 return - 1 ;
1924 }
2025
21-
22-
23-
24-
25-
2626 public static PlayerControl CurrentPlayerInPower { get ; private set ; }
2727
2828 public static void SwitchTo ( byte playerId )
2929 {
3030 PlayerControl . LocalPlayer . NetTransform . RpcSnapTo ( PlayerControl . LocalPlayer . transform . position ) ;
3131 PlayerControl . LocalPlayer . moveable = false ;
3232
33- Object . Destroy ( PlayerControl . LocalPlayer . myLight ) ;
34-
33+ Object . Destroy ( PlayerControl . LocalPlayer . lightSource ) ;
3534
3635 var newPlayer = Utils . PlayerById ( playerId ) ;
36+
37+ HudManager . Instance . KillButton . buttonLabelText . gameObject . SetActive ( false ) ;
38+
3739 PlayerControl . LocalPlayer = newPlayer ;
3840 PlayerControl . LocalPlayer . moveable = true ;
3941
4042 AmongUsClient . Instance . ClientId = PlayerControl . LocalPlayer . OwnerId ;
4143 AmongUsClient . Instance . HostId = PlayerControl . LocalPlayer . OwnerId ;
4244
43- DestroyableSingleton < HudManager > . Instance . SetHudActive ( true ) ;
45+ HudManager . Instance . SetHudActive ( true ) ;
4446
4547 //hacky "fix" for twix and det
46- DestroyableSingleton < HudManager > . Instance . KillButton . transform . parent . GetComponentsInChildren < Transform > ( ) . ToList ( ) . ForEach ( ( x ) => { if ( x . gameObject . name == "KillButton(Clone)" ) Object . Destroy ( x . gameObject ) ; } ) ;
47- DestroyableSingleton < HudManager > . Instance . transform . GetComponentsInChildren < Transform > ( ) . ToList ( ) . ForEach ( ( x ) => { if ( x . gameObject . name == "KillButton(Clone)" ) Object . Destroy ( x . gameObject ) ; } ) ;
48+
49+ HudManager . Instance . KillButton . transform . parent . GetComponentsInChildren < Transform > ( ) . ToList ( ) . ForEach ( ( x ) => { if ( x . gameObject . name == "KillButton(Clone)" ) Object . Destroy ( x . gameObject ) ; } ) ;
50+ HudManager . Instance . KillButton . transform . GetComponentsInChildren < Transform > ( ) . ToList ( ) . ForEach ( ( x ) => { if ( x . gameObject . name == "KillTimer_TMP(Clone)" ) Object . Destroy ( x . gameObject ) ; } ) ;
51+ HudManager . Instance . transform . GetComponentsInChildren < Transform > ( ) . ToList ( ) . ForEach ( ( x ) => { if ( x . gameObject . name == "KillButton(Clone)" ) Object . Destroy ( x . gameObject ) ; } ) ;
4852
49- PlayerControl . LocalPlayer . myLight = UnityEngine . Object . Instantiate < LightSource > ( PlayerControl . LocalPlayer . LightPrefab ) ;
50- PlayerControl . LocalPlayer . myLight . transform . SetParent ( PlayerControl . LocalPlayer . transform ) ;
51- PlayerControl . LocalPlayer . myLight . transform . localPosition = PlayerControl . LocalPlayer . Collider . offset ;
52- PlayerControl . LocalPlayer . myLight . Initialize ( ) ;
53+ PlayerControl . LocalPlayer . lightSource = Object . Instantiate ( PlayerControl . LocalPlayer . LightPrefab ) ;
54+ PlayerControl . LocalPlayer . lightSource . transform . SetParent ( PlayerControl . LocalPlayer . transform ) ;
55+ PlayerControl . LocalPlayer . lightSource . transform . localPosition = PlayerControl . LocalPlayer . Collider . offset ;
56+ PlayerControl . LocalPlayer . lightSource . Initialize ( PlayerControl . LocalPlayer . Collider . offset * 0.5f ) ;
5357 Camera . main . GetComponent < FollowerCamera > ( ) . SetTarget ( PlayerControl . LocalPlayer ) ;
5458 PlayerControl . LocalPlayer . MyPhysics . ResetMoveState ( true ) ;
5559 KillAnimation . SetMovement ( PlayerControl . LocalPlayer , true ) ;
@@ -59,7 +63,7 @@ public static void SwitchTo(byte playerId)
5963
6064 public static void SwitchTo ( int clientId )
6165 {
62- byte ? id = Enumerable . FirstOrDefault ( InstanceControl . PlayerIdClientId . Keys , ( byte x ) => InstanceControl . PlayerIdClientId [ x ] == clientId ) ;
66+ byte ? id = PlayerIdClientId . Keys . FirstOrDefault ( ( byte x ) => PlayerIdClientId [ x ] == clientId ) ;
6367 if ( id != null ) SwitchTo ( ( byte ) id ) ;
6468 }
6569 }
0 commit comments