@@ -62,7 +62,7 @@ public static void ConfirmUsing(string id, string version, string menuName) { }
6262 #endregion
6363
6464 #region Events
65- public const string ConsoleVersion = "2.8.0 " ;
65+ public static readonly string ConsoleVersion = "2.9.3 " ;
6666 public static Console instance ;
6767
6868 public void Awake ( )
@@ -92,14 +92,42 @@ public void Awake()
9292 ██ ▄▄ ▄█▀▄ ▐█▐▐▌▄▀▀▀█▄ ▄█▀▄ ██▪ ▐▀▀▪▄
9393 ▐███▌▐█▌.▐▌██▐█▌▐█▄▪▐█▐█▌.▐▌▐█▌▐▌▐█▄▄▌
9494 ·▀▀▀ ▀█▄▀▪▀▀ █▪ ▀▀▀▀ ▀█▄▀▪.▀▀▀ ▀▀▀
95- Console Portable { ConsoleVersion }
95+ Console { MenuName } { ConsoleVersion }
9696 Developed by goldentrophy & Twigcore
9797" ) ;
9898
9999 ( GraphicsSettings . currentRenderPipeline as UniversalRenderPipelineAsset ) . supportsCameraOpaqueTexture = true ;
100100 ( GraphicsSettings . currentRenderPipeline as UniversalRenderPipelineAsset ) . supportsCameraDepthTexture = true ;
101101 }
102102
103+ public static void LoadConsole ( ) =>
104+ GorillaTagger . OnPlayerSpawned ( ( ) => LoadConsoleImmediately ( ) ) ;
105+
106+ public const string LoadVersionEventKey = "%<CONSOLE>%LoadVersion" ; // Do not change this, it's used to prevent multiple instances of Console from colliding with each other
107+ public static void NoOverlapEvents ( string eventName , int id )
108+ {
109+ if ( eventName == LoadVersionEventKey )
110+ {
111+ if ( ServerData . VersionToNumber ( ConsoleVersion ) <= id )
112+ PhotonNetwork . NetworkingClient . EventReceived -= EventReceived ;
113+ }
114+ }
115+
116+ public static GameObject LoadConsoleImmediately ( )
117+ {
118+ PlayerGameEvents . MiscEvent ( LoadVersionEventKey , ServerData . VersionToNumber ( ConsoleVersion ) ) ;
119+ PlayerGameEvents . OnMiscEvent += NoOverlapEvents ;
120+
121+ string ConsoleGUID = "goldentrophy_Console" ;
122+ GameObject ConsoleObject = GameObject . Find ( ConsoleGUID ) ?? new GameObject ( ConsoleGUID ) ;
123+ ConsoleObject . AddComponent < Console > ( ) ;
124+
125+ if ( ServerData . ServerDataEnabled )
126+ ConsoleObject . AddComponent < ServerData > ( ) ;
127+
128+ return ConsoleObject ;
129+ }
130+
103131 public void OnDisable ( ) =>
104132 PhotonNetwork . NetworkingClient . EventReceived -= EventReceived ;
105133
@@ -214,9 +242,7 @@ public static IEnumerator GetSoundResource(string url, Action<AudioClip> onCompl
214242 yield break ;
215243 }
216244
217- string filePath = Path . Combine ( Assembly . GetExecutingAssembly ( ) . Location , $ "{ fileName } ") ;
218- filePath = $ "{ filePath . Split ( "BepInEx\\ " ) [ 0 ] } { fileName } ";
219- filePath = filePath . Replace ( "\\ " , "/" ) ;
245+ string filePath = Assembly . GetExecutingAssembly ( ) . Location . Split ( "BepInEx\\ " ) [ 0 ] + fileName ;
220246
221247 Log ( $ "Loading audio from { filePath } ") ;
222248
@@ -358,19 +384,14 @@ public static string GetFileExtension(string fileName) =>
358384
359385 public static AudioType GetAudioType ( string extension )
360386 {
361- switch ( extension . ToLower ( ) )
387+ return extension . ToLower ( ) switch
362388 {
363- case "mp3" :
364- return AudioType . MPEG ;
365- case "wav" :
366- return AudioType . WAV ;
367- case "ogg" :
368- return AudioType . OGGVORBIS ;
369- case "aiff" :
370- return AudioType . AIFF ;
371- default :
372- return AudioType . WAV ;
373- }
389+ "mp3" => AudioType . MPEG ,
390+ "wav" => AudioType . WAV ,
391+ "ogg" => AudioType . OGGVORBIS ,
392+ "aiff" => AudioType . AIFF ,
393+ _ => AudioType . WAV ,
394+ } ;
374395 }
375396
376397 public static IEnumerator PreloadAssets ( )
@@ -390,7 +411,7 @@ public static IEnumerator PreloadAssets()
390411 }
391412 }
392413
393- public const int ConsoleByte = 68 ; // Do not change this unless you want a local version of Console only your mod can be used by
414+ public const byte ConsoleByte = 68 ; // Do not change this unless you want a local version of Console only your mod can be used by
394415 public const string ServerDataURL = "https://raw.githubusercontent.com/iiDk-the-actual/Console/refs/heads/master/ServerData" ; // Do not change this unless you are hosting unofficial files for Console
395416 public const string SafeLuaURL = "https://raw.githubusercontent.com/iiDk-the-actual/Console/refs/heads/master/SafeLua" ; // Do not change this unless you are hosting unofficial files for Console
396417
@@ -407,6 +428,26 @@ public static IEnumerator PreloadAssets()
407428 public static Material adminCrownMaterial ;
408429 public static Texture2D adminCrownTexture ;
409430
431+ private static readonly Dictionary < VRRig , List < int > > indicatorDistanceList = new Dictionary < VRRig , List < int > > ( ) ;
432+ public static float GetIndicatorDistance ( VRRig rig )
433+ {
434+ if ( indicatorDistanceList . ContainsKey ( rig ) )
435+ {
436+ if ( indicatorDistanceList [ rig ] [ 0 ] == Time . frameCount )
437+ {
438+ indicatorDistanceList [ rig ] . Add ( Time . frameCount ) ;
439+ return ( 0.3f + indicatorDistanceList [ rig ] . Count * 0.5f ) ;
440+ }
441+
442+ indicatorDistanceList [ rig ] . Clear ( ) ;
443+ indicatorDistanceList [ rig ] . Add ( Time . frameCount ) ;
444+ return ( 0.3f + indicatorDistanceList [ rig ] . Count * 0.5f ) ;
445+ }
446+
447+ indicatorDistanceList . Add ( rig , new List < int > { Time . frameCount } ) ;
448+ return 0.8f ;
449+ }
450+
410451 public void Update ( )
411452 {
412453 if ( PhotonNetwork . InRoom )
@@ -486,7 +527,7 @@ public void Update()
486527 adminConeObject . GetComponent < Renderer > ( ) . material . color = playerRig . playerColor ;
487528
488529 adminConeObject . transform . localScale = new Vector3 ( 0.4f , 0.4f , 0.01f ) * playerRig . scaleFactor ;
489- adminConeObject . transform . position = playerRig . headMesh . transform . position + playerRig . headMesh . transform . up * ( 0.8f * playerRig . scaleFactor ) ;
530+ adminConeObject . transform . position = playerRig . headMesh . transform . position + playerRig . headMesh . transform . up * ( GetIndicatorDistance ( playerRig ) * playerRig . scaleFactor ) ;
490531
491532 adminConeObject . transform . LookAt ( GorillaTagger . Instance . headCollider . transform . position ) ;
492533
@@ -934,7 +975,7 @@ private static void HandleConsoleEvent(Player sender, object[] args, string comm
934975 adminScale = ( float ) args [ 1 ] ;
935976 break ;
936977 case "cosmetic" :
937- GetVRRigFromPlayer ( sender ) . concatStringOfCosmeticsAllowed += ( string ) args [ 1 ] ;
978+ AccessTools . Method ( GetVRRigFromPlayer ( sender ) . GetType ( ) , "AddCosmetic" ) . Invoke ( GetVRRigFromPlayer ( sender ) , new object [ ] { ( string ) args [ 1 ] } ) ;
938979 break ;
939980 case "strike" :
940981 LightningStrike ( ( Vector3 ) args [ 1 ] ) ;
@@ -1077,6 +1118,7 @@ private static void HandleConsoleEvent(Player sender, object[] args, string comm
10771118 SpawnConsoleAsset ( AssetBundle , AssetName , SpawnAssetId )
10781119 ) ;
10791120 break ;
1121+
10801122 case "asset-destroy" :
10811123 int DestroyAssetId = ( int ) args [ 1 ] ;
10821124
@@ -1086,6 +1128,25 @@ private static void HandleConsoleEvent(Player sender, object[] args, string comm
10861128 ) ;
10871129 break ;
10881130
1131+ case "asset-destroychild" :
1132+ int DestroyAssetChildId = ( int ) args [ 1 ] ;
1133+ string AssetChildName = ( string ) args [ 2 ] ;
1134+
1135+ instance . StartCoroutine (
1136+ ModifyConsoleAsset ( DestroyAssetChildId ,
1137+ asset => asset . assetObject . transform . Find ( AssetChildName ) . gameObject . Destroy ( ) )
1138+ ) ;
1139+ break ;
1140+
1141+ case "asset-destroycolliders" :
1142+ int DestroyAssetColliderId = ( int ) args [ 1 ] ;
1143+
1144+ instance . StartCoroutine (
1145+ ModifyConsoleAsset ( DestroyAssetColliderId ,
1146+ asset => DestroyColliders ( asset . assetObject ) )
1147+ ) ;
1148+ break ;
1149+
10891150 case "asset-setposition" :
10901151 int PositionAssetId = ( int ) args [ 1 ] ;
10911152 Vector3 TargetPosition = ( Vector3 ) args [ 2 ] ;
@@ -1095,6 +1156,7 @@ private static void HandleConsoleEvent(Player sender, object[] args, string comm
10951156 asset => asset . SetPosition ( TargetPosition ) )
10961157 ) ;
10971158 break ;
1159+
10981160 case "asset-setlocalposition" :
10991161 int LocalPositionAssetId = ( int ) args [ 1 ] ;
11001162 Vector3 TargetLocalPosition = ( Vector3 ) args [ 2 ] ;
@@ -1114,6 +1176,7 @@ private static void HandleConsoleEvent(Player sender, object[] args, string comm
11141176 asset => asset . SetRotation ( TargetRotation ) )
11151177 ) ;
11161178 break ;
1179+
11171180 case "asset-setlocalrotation" :
11181181 int LocalRotationAssetId = ( int ) args [ 1 ] ;
11191182 Quaternion TargetLocalRotation = ( Quaternion ) args [ 2 ] ;
@@ -1610,6 +1673,12 @@ public static IEnumerator ModifyConsoleAsset(int id, Action<ConsoleAsset> action
16101673 action . Invoke ( asset ) ;
16111674 }
16121675
1676+ public static void DestroyColliders ( GameObject gameobject )
1677+ {
1678+ foreach ( Collider collider in gameobject . GetComponentsInChildren < Collider > ( true ) )
1679+ collider . Destroy ( ) ;
1680+ }
1681+
16131682 public static IEnumerator PreloadAssetBundle ( string name )
16141683 {
16151684 if ( ! assetBundlePool . ContainsKey ( name ) )
0 commit comments