Skip to content

Commit 9b173e8

Browse files
committed
Horizontal room wrap controller (from Celsius)
1 parent cd75124 commit 9b173e8

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module SpringCollab2020HorizontalRoomWrapController
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Entity "SpringCollab2020/HorizontalRoomWrapController" HorizontalRoomWrapController(x::Integer, y::Integer)
6+
7+
const placements = Ahorn.PlacementDict(
8+
"Horizontal Room Wrap Controller (Spring Collab 2020)" => Ahorn.EntityPlacement(
9+
HorizontalRoomWrapController
10+
)
11+
)
12+
13+
function Ahorn.selection(entity::HorizontalRoomWrapController)
14+
x, y = Ahorn.position(entity)
15+
16+
return Ahorn.Rectangle(x - 12, y - 12, 24, 24)
17+
end
18+
19+
Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::HorizontalRoomWrapController, room::Maple.Room) = Ahorn.drawSprite(ctx, "ahorn/SpringCollab2020/horizontal_room_wrap", 0, 0)
20+
21+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Celeste.Mod.Entities;
2+
using Monocle;
3+
4+
namespace Celeste.Mod.SpringCollab2020.Entities {
5+
/// <summary>
6+
/// A controller creating a horizontal room wrap effect in the room it is placed in.
7+
/// Pulled straight from Celsius by 0x0ade.
8+
/// </summary>
9+
[CustomEntity("SpringCollab2020/HorizontalRoomWrapController")]
10+
public class HorizontalRoomWrapController : Entity {
11+
public override void Update() {
12+
base.Update();
13+
14+
Camera camera = SceneAs<Level>().Camera;
15+
Player player = Scene.Tracker.GetEntity<Player>();
16+
if (player != null) {
17+
if (player.Left > camera.Right + 12f) {
18+
// right -> left wrap
19+
player.Right = camera.Left - 4f;
20+
} else if (player.Right < camera.Left - 4f) {
21+
// left -> right wrap
22+
player.Left = camera.Right + 12f;
23+
}
24+
}
25+
}
26+
}
27+
28+
}
347 Bytes
Loading

0 commit comments

Comments
 (0)