1
+ using BepInEx . Configuration ;
1
2
using BepInEx . IL2CPP ;
2
3
using HarmonyLib ;
3
4
using Hazel ;
@@ -83,7 +84,7 @@ public static bool TryGetClient(this byte id, out ClientData client)
83
84
if ( client == null ) return false ;
84
85
return true ;
85
86
}
86
-
87
+
87
88
88
89
public static bool TryNamePlayer ( string name , out string playername , out PlayerControl pc )
89
90
{
@@ -124,7 +125,7 @@ public static bool TryGetPlayerName(int colorid, out string color)
124
125
125
126
public static string GetClientColor ( ClientData client ) =>
126
127
TryGetPlayerColor ( client . ColorId , out var color ) ? ColorToHex ( color ) : null ;
127
-
128
+
128
129
129
130
public static string ColorToHex ( Color32 color ) =>
130
131
color . r . ToString ( "X2" ) + color . g . ToString ( "X2" ) + color . b . ToString ( "X2" ) + color . a . ToString ( "X2" ) ;
@@ -139,7 +140,7 @@ public static void DMChat(ClientData client, string title, string text)
139
140
140
141
public static void StartRpc ( string value , uint targetid , RpcCalls rpccalls , int targetClientid = - 1 )
141
142
{
142
- var msg = AmongUsClient . Instance . StartRpcImmediately ( targetid , ( byte ) rpccalls , SendOption . None , targetClientid ) ;
143
+ var msg = AmongUsClient . Instance . StartRpcImmediately ( targetid , ( byte ) rpccalls , SendOption . Reliable , targetClientid ) ;
143
144
msg . Write ( value ) ;
144
145
AmongUsClient . Instance . FinishRpcImmediately ( msg ) ;
145
146
}
@@ -196,9 +197,16 @@ public static KeyCode GetKey()
196
197
return KeyCode . None ;
197
198
}
198
199
199
- public static void Destroy ( this GameObject ob )
200
+ public static GameObject Destroy ( this GameObject ob , float f = 0 )
201
+ {
202
+ UnityEngine . Object . Destroy ( ob , f ) ;
203
+ return ob ;
204
+ }
205
+
206
+ public static GameObject DontDestroyOnLoad ( this GameObject ob )
200
207
{
201
- UnityEngine . Object . Destroy ( ob ) ;
208
+ UnityEngine . Object . DontDestroyOnLoad ( ob ) ;
209
+ return ob ;
202
210
}
203
211
204
212
public static bool Contains ( this IEnumerable < string > list , string value , StringComparison stringcomparison )
@@ -323,7 +331,7 @@ public static class TextPlus
323
331
324
332
public static string SetColor ( ref string text , string color ) => text = text . SetColor ( color ) ;
325
333
326
- public static string SetColor ( this string text , string color ) => $ "<color=#{ color } >" + text + "</color>" ;
334
+ public static string SetColor ( this string text , string color ) => $ "<color=#{ color . TrimStart ( '#' ) } >" + text + "</color>" ;
327
335
328
336
public static string SetSize ( ref string text , float size ) => text = text . SetSize ( size ) ;
329
337
@@ -366,15 +374,76 @@ public static void RpcSendChat(string text)
366
374
{
367
375
if ( GameState . IsCanSendChat )
368
376
{
369
- HudManager . Instance . Chat . TimeSinceLastMessage = 0f ;
370
377
PlayerControl . LocalPlayer . RpcSendChat ( text ) ;
378
+ HudManager . Instance . Chat . TimeSinceLastMessage = 0f ;
371
379
}
372
380
}
373
381
374
382
public static string GetTranslation ( this StringNames name ) => DestroyableSingleton < TranslationController > . Instance . GetString ( name , new Il2CppReferenceArray < Il2CppSystem . Object > ( 0 ) ) ;
375
383
376
- public static char ComWord => main . ChangeComWord . Value ? '.' : '/' ;
384
+
385
+ public static char ComWord => main . ChangeComWord ? . Getbool ( ) is true ? '/' : '.' ;
377
386
}
387
+
388
+ public static class Overlay
389
+ {
390
+ public static SpriteRenderer CreateUnderlay ( ConfigEntry < float > x , ConfigEntry < float > y , string name )
391
+ {
392
+ HudManager hudManager = DestroyableSingleton < HudManager > . Instance ;
393
+
394
+ var underlay = UnityEngine . Object . Instantiate ( hudManager . FullScreen , hudManager . transform ) ;
395
+ underlay . transform . localPosition = new Vector3 ( x . Value , y . Value , - 900f ) ;
396
+ underlay . color = new Color ( 0.1f , 0.1f , 0.1f , 0.88f ) ;
397
+ underlay . name = name + "Underlay" ;
398
+ underlay . gameObject . SetActive ( true ) ;
399
+ underlay . enabled = true ;
400
+ return underlay ;
401
+ }
402
+
403
+ public static TMPro . TextMeshPro CreateText ( ConfigEntry < float > x , ConfigEntry < float > y , string name )
404
+ {
405
+ HudManager hudManager = DestroyableSingleton < HudManager > . Instance ;
406
+
407
+ var text = UnityEngine . Object . Instantiate ( hudManager . TaskText , hudManager . transform ) ;
408
+ text . fontSize = text . fontSizeMin = text . fontSizeMax = 1.75f ;
409
+ text . autoSizeTextContainer = false ;
410
+ text . enableWordWrapping = false ;
411
+ text . alignment = TMPro . TextAlignmentOptions . Center ;
412
+ text . transform . localPosition = new Vector3 ( x . Value , y . Value , - 900f ) ;
413
+ text . color = Palette . White ;
414
+ text . name = name + "text" ;
415
+ text . text = "0" ;
416
+ text . enabled = true ;
417
+ return text ;
418
+ }
419
+
420
+ public static Vector3 SettingPos ( ConfigEntry < float > x , ConfigEntry < float > y )
421
+ {
422
+ if ( Input . GetKey ( KeyCode . RightArrow ) )
423
+ {
424
+ x . Value += 0.05f ;
425
+ }
426
+ if ( Input . GetKey ( KeyCode . LeftArrow ) )
427
+ {
428
+ x . Value -= 0.05f ;
429
+ }
430
+ if ( Input . GetKey ( KeyCode . DownArrow ) )
431
+ {
432
+ y . Value -= 0.05f ;
433
+ }
434
+ if ( Input . GetKey ( KeyCode . UpArrow ) )
435
+ {
436
+ y . Value += 0.05f ;
437
+ }
438
+ if ( Input . GetMouseButton ( 1 ) )
439
+ {
440
+ x . Value = Helpers . ScreenToMousePositon . x ;
441
+ y . Value = Helpers . ScreenToMousePositon . y ;
442
+ }
443
+ return new Vector3 ( x . Value , y . Value , - 900f ) ;
444
+ }
445
+ }
446
+
378
447
public static class GameState
379
448
{
380
449
public static bool IsLobby => AmongUsClient . Instance ? . GameState is InnerNetClient . GameStates . Joined && ! IsFreePlay ;
@@ -388,7 +457,7 @@ public static class GameState
388
457
public static bool IsChatActive => HudManager . Instance ? . Chat ? . isActiveAndEnabled is true ;
389
458
public static bool IsCanSendChat => HudManager . Instance ? . Chat ? . TimeSinceLastMessage >= 3f ;
390
459
public static bool IsFocusChatArea => HudManager . Instance ? . Chat ? . TextArea ? . hasFocus is true ;
391
- public static bool IsCanKeyCommand => IsFocusChatArea && main . KeyCommand . Value ;
460
+ public static bool IsCanKeyCommand => IsFocusChatArea && main . KeyCommand . Getbool ( ) ;
392
461
public static bool IsCanMove => PlayerControl . LocalPlayer ? . CanMove is true ;
393
462
public static bool IsCountDown => GameStartManager . Instance ? . startState is GameStartManager . StartingStates . Countdown ;
394
463
public static bool IsDead => PlayerControl . LocalPlayer ? . Data ? . IsDead is true ;
0 commit comments