11using System . Reflection ;
2+ using System . Text ;
23using Configgy ;
4+ using CultOfJakito . UltraTelephone2 . Assets ;
35using CultOfJakito . UltraTelephone2 . DependencyInjection ;
46using CultOfJakito . UltraTelephone2 . Events ;
57using CultOfJakito . UltraTelephone2 . Util ;
@@ -18,6 +20,11 @@ public class ChaosManager : MonoBehaviour, IDisposable
1820 [ Configgable ( "Extras/Advanced" , "Panic Button" ) ]
1921 private static ConfigKeybind s_panicButton = new ConfigKeybind ( KeyCode . P ) ;
2022
23+ [ Configgable ( displayName : "Chaos Enabled" ) ]
24+ private static ConfigToggle s_enabled = new ConfigToggle ( true ) ;
25+
26+ public static int ChaosBookHashCode { get ; private set ; }
27+
2128 public void BeginEffects ( )
2229 {
2330 //Seed is global and scene name to give a unique seed for each scene, while still being deterministic
@@ -53,11 +60,27 @@ public void BeginEffects()
5360 Debug . Log ( "Chaos started" ) ;
5461 activatedEffects = _ctx . GetCurrentSelection ( ) ;
5562
63+ StringBuilder effectlistString = new ( ) ;
64+
5665 foreach ( IChaosEffect effect in activatedEffects )
5766 {
67+ effectlistString . AppendLine ( effect . GetType ( ) . Name ) ;
5868 Debug . Log ( $ "Beginning Effect: { effect . GetType ( ) . Name } ") ;
5969 effect . BeginEffect ( new UniRandom ( random . Next ( ) ) ) ;
6070 }
71+
72+ if ( random . Chance ( 0.2f ) )
73+ DropChaosBook ( effectlistString . ToString ( ) ) ;
74+ }
75+
76+ private void DropChaosBook ( string bookText )
77+ {
78+ GameObject book = GameObject . Instantiate ( UkPrefabs . Book . GetObject ( ) ) ;
79+ Readable readable = book . GetComponent < Readable > ( ) ;
80+ readable . content = bookText ;
81+ ChaosBookHashCode = readable . gameObject . GetHashCode ( ) ;
82+
83+ book . transform . position = CameraController . Instance . transform . position ;
6184 }
6285
6386 private List < IChaosEffect > activatedEffects ;
0 commit comments