-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
namespace GodSeekerPlus.Modules.QoL; | ||
|
||
[Category(nameof(QoL))] | ||
[ToggleableLevel(ToggleableLevel.ChangeScene)] | ||
[DefaultEnabled] | ||
internal sealed class P5Teleport : Module { | ||
private static readonly MethodInfo activateFsmStateActions = typeof(FsmState) | ||
.GetMethod( | ||
"ActivateActions", | ||
BindingFlags.Instance | BindingFlags.NonPublic | ||
); | ||
|
||
private protected override void Load() => | ||
USceneManager.activeSceneChanged += AddComponentToLever; | ||
|
||
private protected override void Unload() => | ||
USceneManager.activeSceneChanged -= AddComponentToLever; | ||
|
||
private void AddComponentToLever(Scene prev, Scene next) { | ||
if (next.name == "GG_Atrium") { | ||
next.GetGameObjectByName("gg_roof_door_pieces") | ||
.Child("GG_door_caps", "gg_roof_lever")! | ||
.AddComponent<TeleportOnDreamNail>(); | ||
} | ||
} | ||
|
||
private static IEnumerator Teleport() { | ||
#region Pre-teleport effects | ||
|
||
Ref.HC.RelinquishControl(); | ||
Fsm dreamNailFSM = Ref.HC.gameObject.LocateMyFSM("Dream Nail").Fsm; | ||
|
||
(new[] { "Warp Effect", "Warp End" }) | ||
.ForEach(name => activateFsmStateActions.Invoke( | ||
dreamNailFSM.GetState(name), | ||
new object[] { 0 } | ||
)); | ||
|
||
Ref.HC.gameObject.LocateMyFSM("Roar Lock") | ||
.FsmVariables.FindFsmBool("No Roar") | ||
.Value = false; | ||
StaticVariableList.SetValue("skipRemoveDreamOrbs", true); | ||
|
||
yield return new WaitForSeconds(2); | ||
|
||
Ref.HC.FaceLeft(); | ||
|
||
#endregion | ||
|
||
#region Substitute DGate data | ||
|
||
string origDGateScene = Ref.PD.dreamGateScene; | ||
float origDGateX = Ref.PD.dreamGateX; | ||
float origDGateY = Ref.PD.dreamGateY; | ||
|
||
Ref.PD.dreamGateScene = "GG_Atrium_Roof"; | ||
Ref.PD.dreamGateX = 105.6243f; | ||
Ref.PD.dreamGateY = 73.4129f; | ||
|
||
#endregion | ||
|
||
// Do teleport | ||
activateFsmStateActions.Invoke( | ||
dreamNailFSM.GetState("New Scene"), | ||
new object[] { 0 } | ||
); | ||
|
||
#region Restore DGate Data | ||
|
||
// Restore this before scene loaded to prevent spawning DGate | ||
Ref.PD.dreamGateScene = origDGateScene; | ||
|
||
yield return new WaitWhile(() => Ref.PD.disablePause); | ||
Ref.PD.dreamGateX = origDGateX; | ||
Ref.PD.dreamGateY = origDGateY; | ||
|
||
#endregion | ||
} | ||
|
||
|
||
private class TeleportOnDreamNail : MonoBehaviour { | ||
public void OnTriggerEnter2D(Collider2D collision) { | ||
if (collision.tag != "Dream Attack") { | ||
return; | ||
} | ||
|
||
if (!Ref.PD.finalBossDoorUnlocked) { | ||
return; | ||
} | ||
|
||
Logger.LogDebug("P5 teleport start"); | ||
StartCoroutine(Teleport()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters