Skip to content

Commit f2b5871

Browse files
committed
Merge branch 'main' into Dev-Hydra
2 parents 7d368f0 + 2224b95 commit f2b5871

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/CultOfJakito.UltraTelephone2/Assets/UKPrefabs.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public static class UkPrefabs
2222
public static UKAsset<GameObject> MannequinEnemy { get; private set; } = new ("Assets/Prefabs/Enemies/Mannequin.prefab");
2323

2424
public static UKAsset<AudioClip> ThroatDrone { get; private set; } = new("Assets/Music/Drones/Throat Drone.ogg");
25+
26+
public static UKAsset<GameObject> Book { get; private set; } = new("Assets/Prefabs/Items/Book.prefab");
2527
}
2628

2729
public class UKAsset<T> where T : UnityEngine.Object

src/CultOfJakito.UltraTelephone2/Chaos/ChaosManager.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Reflection;
2+
using System.Text;
23
using Configgy;
4+
using CultOfJakito.UltraTelephone2.Assets;
35
using CultOfJakito.UltraTelephone2.DependencyInjection;
46
using CultOfJakito.UltraTelephone2.Events;
57
using 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;

src/CultOfJakito.UltraTelephone2/Chaos/Effects/CantRead.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ public override void BeginEffect(UniRandom random)
3333

3434

3535
[HarmonyPatch(typeof(ScanningStuff), nameof(ScanningStuff.ScanBook)), HarmonyPrefix]
36-
private static void OnScanBook(ScanningStuff __instance, ref string text)
36+
private static void OnScanBook(ScanningStuff __instance, ref string text, int instanceId)
3737
{
3838
if (!s_enabled.Value || !s_effectActive)
3939
return;
4040

41+
if (instanceId == ChaosManager.ChaosBookHashCode)
42+
return;
43+
4144
int option = s_rng.Next(0, 3);
4245

4346
//0 = Write console log to book

src/CultOfJakito.UltraTelephone2/Chaos/Effects/RealisticExplosions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void SoundReplacement(Explosion __instance)
4040

4141
AudioSource source = __instance.GetComponent<AudioSource>();
4242

43-
if(source != null)
43+
if(source != null && !source.loop)
4444
{
4545
source.dopplerLevel = 0;
4646
source.clip = Sound;

0 commit comments

Comments
 (0)