Skip to content

Commit f53298c

Browse files
authored
Custom Winged Strawberry (#27)
Custom Winged Strawberry Co-authored-by: Maik Macho <[email protected]>
2 parents 13471a1 + 0d2e668 commit f53298c

File tree

8 files changed

+92
-9
lines changed

8 files changed

+92
-9
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module SpringCollab2020DiagonalWingedStrawberry
2+
using ..Ahorn, Maple
3+
@mapdef Entity "SpringCollab2020/diagonalWingedStrawberry" DiagonalWingedStrawberry(x::Integer, y::Integer, order::Integer=-1, checkpointID::Integer=-1)
4+
5+
const placements = Ahorn.PlacementDict(
6+
"Diagonal Winged Strawberry (Spring Collab 2020)" => Ahorn.EntityPlacement(
7+
DiagonalWingedStrawberry
8+
)
9+
)
10+
11+
function Ahorn.selection(entity::DiagonalWingedStrawberry)
12+
x, y = Ahorn.position(entity)
13+
14+
return Ahorn.getSpriteRectangle("collectables/strawberry/wings01", x, y)
15+
end
16+
17+
function Ahorn.renderAbs(ctx::Ahorn.Cairo.CairoContext, entity::DiagonalWingedStrawberry, room::Maple.Room)
18+
x, y = Ahorn.position(entity)
19+
20+
Ahorn.drawSprite(ctx, "collectables/strawberry/wings01", x, y)
21+
end
22+
23+
end

Ahorn/lang/en_gb.lang

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Diagonal Winged Strawberry
2+
3+
placements.entities.SpringCollab2020/diagonalWingedStrawberry.tooltips.order=The order within a checkpoint. When -1, Everest automatically sets it.
4+
placements.entities.SpringCollab2020/diagonalWingedStrawberry.tooltips.checkpointID=The checkpoint the berry is located within. When -1, Everest automatically sets it.
5+
16
# Cave Wall
27
placements.entities.SpringCollab2020/caveWall.tooltips.tiletype=Changes the visual appearance of the wall.
38

@@ -23,4 +28,4 @@ placements.triggers.SpringCollab2020/SmoothCameraOffsetTrigger.tooltips.position
2328
placements.triggers.SpringCollab2020/SmoothCameraOffsetTrigger.tooltips.onlyOnce=If checked, the trigger will be disabled when the player first leaves it.
2429

2530
# Dash Spring
26-
placements.entities.SpringCollab2020/dashSpring.tooltips.playerCanUse=Determines whether the player is able to interact with the spring.
31+
placements.entities.SpringCollab2020/dashSpring.tooltips.playerCanUse=Determines whether the player is able to interact with the spring.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Celeste.Mod.Entities;
2+
using Microsoft.Xna.Framework;
3+
using Monocle;
4+
using MonoMod.Cil;
5+
using MonoMod.RuntimeDetour;
6+
using System;
7+
using System.Reflection;
8+
9+
namespace Celeste.Mod.SpringCollab2020.Entities {
10+
[CustomEntity("SpringCollab2020/diagonalWingedStrawberry")]
11+
[RegisterStrawberry(true, false)]
12+
class DiagonalWingedStrawberry : Strawberry {
13+
public DiagonalWingedStrawberry(EntityData data, Vector2 offset, EntityID gid) : base(FixData(data), offset, gid) {
14+
OriginalOnDash = typeof(Strawberry).GetMethod("OnDash", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
15+
16+
// Components.ToArray() is used because the map fails to load when using merely "Components" for some reason.
17+
foreach (Component comp in Components.ToArray()) {
18+
if (comp is DashListener)
19+
Components.Remove(comp);
20+
}
21+
22+
Add(new DashListener {
23+
OnDash = new Action<Vector2>(OnDiagDash)
24+
});
25+
}
26+
27+
private void OnDiagDash(Vector2 dir) {
28+
if (CheckDirection(dir))
29+
OriginalOnDash.Invoke(this, new object[] { dir });
30+
}
31+
32+
private bool CheckDirection(Vector2 dir) {
33+
bool xOk = false;
34+
bool yOk = false;
35+
36+
if (Math.Abs(dir.X) - .707 <= .01)
37+
xOk = true;
38+
39+
if (Math.Abs(dir.Y) - .707 <= .01 && dir.Y < 0)
40+
yOk = true;
41+
42+
if (xOk && yOk)
43+
return true;
44+
45+
return false;
46+
}
47+
48+
private static EntityData FixData(EntityData data) {
49+
data.Values["winged"] = true;
50+
return data;
51+
}
52+
53+
private MethodInfo OriginalOnDash;
54+
}
55+
}

SpringCollab2020.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>net452</TargetFrameworks>
@@ -45,4 +45,4 @@
4545
</Otherwise>
4646
</Choose>
4747

48-
</Project>
48+
</Project>

SpringCollab2020Module.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Celeste.Mod.SpringCollab2020.Entities;
1+
using Celeste.Mod.SpringCollab2020.Entities;
22
using Celeste.Mod.SpringCollab2020.Triggers;
33

44
namespace Celeste.Mod.SpringCollab2020 {
@@ -11,13 +11,13 @@ public SpringCollab2020Module() {
1111
}
1212

1313
public override void Load() {
14-
NoRefillField.Load();
14+
NoRefillField.Load();
1515
FloatierSpaceBlock.Load();
1616
}
1717

1818
public override void Unload() {
19-
NoRefillField.Unload();
19+
NoRefillField.Unload();
2020
FloatierSpaceBlock.Unload();
21-
}
21+
}
2222
}
23-
}
23+
}

everest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
DLL: bin/Debug/net452/SpringCollab2020.dll
44
Dependencies:
55
- Name: Everest
6-
Version: 1.1311.0
6+
Version: 1.1336.0

lib-stripped/Celeste.exe

5.5 KB
Binary file not shown.

lib-stripped/MMHOOK_Celeste.dll

28.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)