-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnyRad3GlitchGenerator.cs
68 lines (57 loc) · 2.5 KB
/
AnyRad3GlitchGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Modding;
using UnityEngine;
using System;
using System.Reflection;
namespace AnyRad3GlitchGenerator {
public class AnyRad3GlitchGenerator: Mod, ITogglableMod {
public static AnyRad3GlitchGenerator instance;
private bool inPlatsPhase = false;
private bool glitched = false;
internal static FieldInfo portalPortalState;
internal static Type portalType;
public AnyRad3GlitchGenerator(): base ("AnyRad 3 Glitch Generator") => instance = this;
public override void Initialize() {
Log("Initializing...");
ModHooks.HeroUpdateHook += HeroUpdate;
On.PlayMakerFSM.OnEnable += OnFsmEnable;
On.CameraLockArea.Awake += CamLockAwake;
glitched = false;
Log("Initialized.");
Log("Mathy is a cool guy.");
}
public override string GetVersion() => GetType().Assembly.GetName().Version.ToString();
public void HeroUpdate() {
if (!glitched && inPlatsPhase) {
if (
GameObject.Find("Absolute Radiance") != null &&
GameObject.Find("Portal 1") != null &&
GameObject.Find("Portal 1").GetComponent<CircleCollider2D>() != null &&
GameObject.Find("Portal 1").GetComponent<CircleCollider2D>().bounds.extents.y == 3.16679f &&
GameObject.Find("Legs") != null &&
GameObject.Find("Abyss Pit").transform.position == new Vector3(61.77f, 30, 0)
) {
Modding.Logger.Log("Inducing platform phase glitch.");
GameObject.Find("Absolute Radiance").transform.position = GameObject.Find("Portal 1").transform.position + new Vector3(0.5f, -1, 0);
glitched = true;
}
}
}
public void OnFsmEnable(On.PlayMakerFSM.orig_OnEnable orig, PlayMakerFSM self) {
orig(self);
if (self.FsmName == "Control" && self.gameObject.name == "Absolute Radiance") {
glitched = false;
inPlatsPhase = false;
}
}
public void CamLockAwake(On.CameraLockArea.orig_Awake orig, CameraLockArea self) {
orig(self);
if (self.gameObject.name == "CamLock A2") {
Modding.Logger.Log(self.gameObject.name);
inPlatsPhase = true;
}
}
public void Unload() {
ModHooks.HeroUpdateHook -= HeroUpdate;
}
}
}