diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..e2366564 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: '**' + paths: + - 'Randomizer/**' + - '.github/**' + pull_request: + branches: '**' + paths: + - 'Randomizer/**' + - '.github/**' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Prepare + run: mkdir -p ${{ github.workspace }}/dist + + - name: Build and Bundle + run: bash ${{ github.workspace }}/bundle.sh + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: CelesteRandomizer + path: ${{ github.workspace }}/dist/Randomizer_*.zip + diff --git a/.gitignore b/.gitignore index e33db852..8bb3e946 100644 --- a/.gitignore +++ b/.gitignore @@ -246,3 +246,4 @@ dist edited_maps .vscode promo +!**/packages/lib-stripped/ \ No newline at end of file diff --git a/Randomizer/Entities/FindTheoPhone.cs b/Randomizer/Entities/FindTheoPhone.cs index 7632a4ba..14781904 100644 --- a/Randomizer/Entities/FindTheoPhone.cs +++ b/Randomizer/Entities/FindTheoPhone.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Runtime.InteropServices; using Microsoft.Xna.Framework; using Monocle; @@ -28,12 +29,14 @@ public class CS_FindTheoPhone : CutsceneEntity private Player Player; private float TargetX; private FindTheoPhone Phone; + public int State; // 0 for not run, 1 for run but not end, 2 for finished public CS_FindTheoPhone(Player player, FindTheoPhone phone) { this.Player = player; this.TargetX = phone.X + 8; this.Phone = phone; + this.State = 0; } public override void OnBegin(Level level) => this.Add(new Coroutine(this.Routine())); @@ -41,11 +44,13 @@ public CS_FindTheoPhone(Player player, FindTheoPhone phone) private bool SavedInvincible; private IEnumerator Routine() { + this.State = 1; this.Player.Speed = Vector2.Zero; this.SavedInvincible = SaveData.Instance.Assists.Invincible; SaveData.Instance.Assists.Invincible = true; this.Player.StateMachine.State = 11; this.Player.Facing = (Facings)Math.Sign(this.TargetX - this.Player.X); + AddTag(Tags.Persistent); yield return 0.5f; var point = this.Level.Camera.CameraToScreen(this.Player.Position); point.X = Math.Min(Math.Max(point.X, this.Level.Camera.Viewport.Width / 4f), this.Level.Camera.Viewport.Width * 3f / 4f); @@ -63,9 +68,11 @@ public override void OnEnd(Level level) }; reseter.Tag |= Tags.Global; Engine.Scene.Add(reseter); + RemoveTag(Tags.Persistent); this.Player.StateMachine.State = 0; this.Level.Session.DoNotLoad.Add(this.Phone.ID); this.Phone.RemoveSelf(); + this.State = 2; } private IEnumerator ResetInvincible() @@ -92,5 +99,10 @@ private IEnumerator StandBackUp() this.Player.Sprite.Play("idle"); yield return 0.2f; } + + public int GetState() + { + return this.State; + } } } diff --git a/Randomizer/Patches/qol.cs b/Randomizer/Patches/qol.cs index 01133ae1..4b7e8cba 100644 --- a/Randomizer/Patches/qol.cs +++ b/Randomizer/Patches/qol.cs @@ -10,6 +10,10 @@ using MonoMod.Cil; using MonoMod.Utils; using MonoMod.RuntimeDetour; +using Celeste.Mod.Entities; +using On.Celeste.Mod.Entities; +using Celeste.Mod.Randomizer.Entities; +using System.Runtime.Remoting.Contexts; namespace Celeste.Mod.Randomizer { @@ -47,6 +51,7 @@ private void LoadQol() IL.Celeste.CS06_Campfire.OnEnd += FuckUpWayLess; IL.Celeste.LightningRenderer.Track += TrackExtraSpace; On.Celeste.LockBlock.OnPlayer += NoKeySkips; + On.Celeste.Player.Update += PreventInvincibility; // https://github.com/EverestAPI/CelesteTAS-EverestInterop/blob/master/CelesteTAS-EverestInterop/EverestInterop/DisableAchievements.cs // Before hooking Achievements.Register, check the size of the method. @@ -106,6 +111,8 @@ private void UnloadQol() IL.Celeste.LightningRenderer.Track -= TrackExtraSpace; IL.Celeste.HeartGem.Awake -= SpecialHeartColors; On.Celeste.LockBlock.OnPlayer -= NoKeySkips; + On.Celeste.Player.Update -= PreventInvincibility; + foreach (var detour in this.SpecialHooksQol) { @@ -752,6 +759,17 @@ public static void MadlibsStats(string blank = "WAVEDASHING", int runs = 100000) Engine.Commands.Log($"{kv.Value} {kv.Key}"); } } + public static void PreventInvincibility(On.Celeste.Player.orig_Update orig, Player self) + { + Level lvl = (Engine.Scene as Level); + if (lvl.InCutscene && lvl.Entities.OfType().Any() && lvl.Entities.OfType().ToList()[0].State == 1 && self.StateMachine == 0 || + lvl.InCutscene && lvl.Entities.OfType().Any() && lvl.Entities.OfType().Count() > 1) + { + lvl.Entities.OfType().ToList()[0].OnEnd(lvl); + } + orig(self); + } + } public class DisablableTextMenu : TextMenu diff --git a/Randomizer/RandoLogic/RandoLogic.cs b/Randomizer/RandoLogic/RandoLogic.cs index 0577923b..aafcce60 100644 --- a/Randomizer/RandoLogic/RandoLogic.cs +++ b/Randomizer/RandoLogic/RandoLogic.cs @@ -660,8 +660,6 @@ private void PlaceTheoPhone(MapData map) char at(int xx, int yy) => yy >= lines.Count ? '0' : xx >= lines[yy].Length ? '0' : lines[yy][xx]; var height = lines.Count; var width = lines.Select(j => j.Length).Max(); - IEnumerable spinners = lvl.Entities.Where(e => e.Name == "spinner" || e.Name == "spikesUp" || - e.Name == "greenBlocks" || e.Name == "redBlocks" || e.Name == "yellowBlocks"); var found = false; int x = 0, y = 0; for (int i = 0; i < 20 && !found; i++) @@ -680,13 +678,15 @@ private void PlaceTheoPhone(MapData map) { y++; } - var safe = !spinners.Where(e => + var BehindEnt = lvl.Entities.Where(e => { - var entWidth = e.Name != "spinner" ? e.Width : 8; - var entHeight = e.Name != "spinner" && e.Name != "spikesUp" ? e.Height : 0; - return e.Position.X / 8 + entWidth / 8 >= x && e.Position.X / 8 - 1 <= x && e.Position.Y / 8 + entHeight / 8 == y; - }).Any(); + // entities that don't have these fields default to 0, + // but to be certain the player can see the phone, check one tile over + var entWidth = e.Width + 8; + var entHeight = e.Height + 8; + return e.Position.X / 8 + entWidth / 8 >= x && e.Position.X / 8 - 1 <= x && e.Position.Y / 8 + entHeight / 8 >= y && e.Position.Y / 8 - 1 <= y; + }).Any(); var InsideRoof = lvl.FgDecals.Where(fg => { if (fg.Scale.X < 0) @@ -695,7 +695,7 @@ private void PlaceTheoPhone(MapData map) } return (fg.Position.X) / 8 <= x && (fg.Position.X + 8 * fg.Scale.X) / 8 >= x && (fg.Position.Y + 4) / 8 == y; }).Any(); - if (at(x + 1, y - 1) == '0' && at(x + 1, y) != '0' && safe && !InsideRoof) + if (at(x + 1, y - 1) == '0' && at(x + 1, y) != '0' && !BehindEnt && !InsideRoof) { found = true; } diff --git a/Randomizer/Randomizer.csproj b/Randomizer/Randomizer.csproj index 276d523e..80b002f1 100644 --- a/Randomizer/Randomizer.csproj +++ b/Randomizer/Randomizer.csproj @@ -35,49 +35,45 @@ - ..\packages\Celeste.exe + ..\packages\lib-stripped\Celeste.exe False - ..\packages\FNA.dll + ..\packages\lib-stripped\FNA.dll False - ..\packages\MMHOOK_Celeste.dll + ..\packages\lib-stripped\MMHOOK_Celeste.dll False - ..\packages\Mono.Cecil.dll + ..\packages\lib-stripped\Mono.Cecil.dll False - ..\packages\Mono.Cecil.Mdb.dll + ..\packages\lib-stripped\Mono.Cecil.Mdb.dll False - ..\packages\Mono.Cecil.Pdb.dll + ..\packages\lib-stripped\Mono.Cecil.Pdb.dll False - ..\packages\Mono.Cecil.Rocks.dll - False - - - ..\packages\Steamworks.NET.dll + ..\packages\lib-stripped\Mono.Cecil.Rocks.dll False - ..\packages\YamlDotNet.dll + ..\packages\lib-stripped\YamlDotNet.dll False - ..\packages\MonoMod.Utils.dll + ..\packages\lib-stripped\MonoMod.Utils.dll False - ..\packages\MonoMod.RuntimeDetour.dll + ..\packages\lib-stripped\MonoMod.RuntimeDetour.dll False diff --git a/packages/lib-stripped/Celeste.exe b/packages/lib-stripped/Celeste.exe new file mode 100644 index 00000000..a8b45747 Binary files /dev/null and b/packages/lib-stripped/Celeste.exe differ diff --git a/packages/lib-stripped/FNA.dll b/packages/lib-stripped/FNA.dll new file mode 100644 index 00000000..82398263 Binary files /dev/null and b/packages/lib-stripped/FNA.dll differ diff --git a/packages/lib-stripped/MMHOOK_Celeste.dll b/packages/lib-stripped/MMHOOK_Celeste.dll new file mode 100644 index 00000000..f1214be7 Binary files /dev/null and b/packages/lib-stripped/MMHOOK_Celeste.dll differ diff --git a/packages/lib-stripped/Mono.Cecil.Mdb.dll b/packages/lib-stripped/Mono.Cecil.Mdb.dll new file mode 100644 index 00000000..30c75653 Binary files /dev/null and b/packages/lib-stripped/Mono.Cecil.Mdb.dll differ diff --git a/packages/lib-stripped/Mono.Cecil.Pdb.dll b/packages/lib-stripped/Mono.Cecil.Pdb.dll new file mode 100644 index 00000000..8398257e Binary files /dev/null and b/packages/lib-stripped/Mono.Cecil.Pdb.dll differ diff --git a/packages/lib-stripped/Mono.Cecil.Rocks.dll b/packages/lib-stripped/Mono.Cecil.Rocks.dll new file mode 100644 index 00000000..abb4ab74 Binary files /dev/null and b/packages/lib-stripped/Mono.Cecil.Rocks.dll differ diff --git a/packages/lib-stripped/Mono.Cecil.dll b/packages/lib-stripped/Mono.Cecil.dll new file mode 100644 index 00000000..205bab27 Binary files /dev/null and b/packages/lib-stripped/Mono.Cecil.dll differ diff --git a/packages/lib-stripped/MonoMod.RuntimeDetour.dll b/packages/lib-stripped/MonoMod.RuntimeDetour.dll new file mode 100644 index 00000000..9a2dc53d Binary files /dev/null and b/packages/lib-stripped/MonoMod.RuntimeDetour.dll differ diff --git a/packages/lib-stripped/MonoMod.Utils.dll b/packages/lib-stripped/MonoMod.Utils.dll new file mode 100644 index 00000000..4c5433b8 Binary files /dev/null and b/packages/lib-stripped/MonoMod.Utils.dll differ diff --git a/packages/lib-stripped/YamlDotNet.dll b/packages/lib-stripped/YamlDotNet.dll new file mode 100644 index 00000000..2978ac9b Binary files /dev/null and b/packages/lib-stripped/YamlDotNet.dll differ