Skip to content

Commit

Permalink
Merge branch 'rhelmot:master' into feature/activate-switch-rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy-Vidaurri authored Sep 5, 2024
2 parents 888ad50 + 9f913be commit c9741a3
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 22 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,4 @@ dist
edited_maps
.vscode
promo
!**/packages/lib-stripped/
12 changes: 12 additions & 0 deletions Randomizer/Entities/FindTheoPhone.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Monocle;

Expand Down Expand Up @@ -28,24 +29,28 @@ 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()));

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);
Expand All @@ -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()
Expand All @@ -92,5 +99,10 @@ private IEnumerator StandBackUp()
this.Player.Sprite.Play("idle");
yield return 0.2f;
}

public int GetState()
{
return this.State;
}
}
}
18 changes: 18 additions & 0 deletions Randomizer/Patches/qol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<CS_FindTheoPhone>().Any() && lvl.Entities.OfType<CS_FindTheoPhone>().ToList()[0].State == 1 && self.StateMachine == 0 ||
lvl.InCutscene && lvl.Entities.OfType<CS_FindTheoPhone>().Any() && lvl.Entities.OfType<CutsceneEntity>().Count() > 1)
{
lvl.Entities.OfType<CS_FindTheoPhone>().ToList()[0].OnEnd(lvl);
}
orig(self);
}

}

public class DisablableTextMenu : TextMenu
Expand Down
16 changes: 8 additions & 8 deletions Randomizer/RandoLogic/RandoLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntityData> 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++)
Expand All @@ -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)
Expand All @@ -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;
}
Expand Down
24 changes: 10 additions & 14 deletions Randomizer/Randomizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,45 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Celeste">
<HintPath>..\packages\Celeste.exe</HintPath>
<HintPath>..\packages\lib-stripped\Celeste.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FNA">
<HintPath>..\packages\FNA.dll</HintPath>
<HintPath>..\packages\lib-stripped\FNA.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MMHOOK_Celeste">
<HintPath>..\packages\MMHOOK_Celeste.dll</HintPath>
<HintPath>..\packages\lib-stripped\MMHOOK_Celeste.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Mono.Cecil">
<HintPath>..\packages\Mono.Cecil.dll</HintPath>
<HintPath>..\packages\lib-stripped\Mono.Cecil.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Mono.Cecil.Mdb">
<HintPath>..\packages\Mono.Cecil.Mdb.dll</HintPath>
<HintPath>..\packages\lib-stripped\Mono.Cecil.Mdb.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Mono.Cecil.Pdb">
<HintPath>..\packages\Mono.Cecil.Pdb.dll</HintPath>
<HintPath>..\packages\lib-stripped\Mono.Cecil.Pdb.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Mono.Cecil.Rocks">
<HintPath>..\packages\Mono.Cecil.Rocks.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Steamworks.NET">
<HintPath>..\packages\Steamworks.NET.dll</HintPath>
<HintPath>..\packages\lib-stripped\Mono.Cecil.Rocks.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="YamlDotNet">
<HintPath>..\packages\YamlDotNet.dll</HintPath>
<HintPath>..\packages\lib-stripped\YamlDotNet.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod.Utils">
<HintPath>..\packages\MonoMod.Utils.dll</HintPath>
<HintPath>..\packages\lib-stripped\MonoMod.Utils.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod.RuntimeDetour">
<HintPath>..\packages\MonoMod.RuntimeDetour.dll</HintPath>
<HintPath>..\packages\lib-stripped\MonoMod.RuntimeDetour.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
Binary file added packages/lib-stripped/Celeste.exe
Binary file not shown.
Binary file added packages/lib-stripped/FNA.dll
Binary file not shown.
Binary file added packages/lib-stripped/MMHOOK_Celeste.dll
Binary file not shown.
Binary file added packages/lib-stripped/Mono.Cecil.Mdb.dll
Binary file not shown.
Binary file added packages/lib-stripped/Mono.Cecil.Pdb.dll
Binary file not shown.
Binary file added packages/lib-stripped/Mono.Cecil.Rocks.dll
Binary file not shown.
Binary file added packages/lib-stripped/Mono.Cecil.dll
Binary file not shown.
Binary file added packages/lib-stripped/MonoMod.RuntimeDetour.dll
Binary file not shown.
Binary file added packages/lib-stripped/MonoMod.Utils.dll
Binary file not shown.
Binary file added packages/lib-stripped/YamlDotNet.dll
Binary file not shown.

0 comments on commit c9741a3

Please sign in to comment.