Skip to content

Commit 73bd0d7

Browse files
authored
Merge pull request #171 from EverestAPI/custom_respawn_time_refill
Refill with custom respawn time
2 parents 9dbf09b + 83c38ce commit 73bd0d7

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module SpringCollab2020CustomRespawnTimeRefill
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Entity "SpringCollab2020/CustomRespawnTimeRefill" CustomRespawnTimeRefill(x::Integer, y::Integer, twoDash::Bool=false, respawnTime::Number=2.5)
6+
7+
const placements = Ahorn.PlacementDict(
8+
"Refill (Custom Respawn Time) (Spring Collab 2020)" => Ahorn.EntityPlacement(
9+
CustomRespawnTimeRefill
10+
),
11+
12+
"Refill (Two Dashes, Custom Respawn Time) (Spring Collab 2020)" => Ahorn.EntityPlacement(
13+
CustomRespawnTimeRefill,
14+
"point",
15+
Dict{String, Any}(
16+
"twoDash" => true
17+
)
18+
)
19+
)
20+
21+
spriteOneDash = "objects/refill/idle00"
22+
spriteTwoDash = "objects/refillTwo/idle00"
23+
24+
function getSprite(entity::CustomRespawnTimeRefill)
25+
twoDash = get(entity.data, "twoDash", false)
26+
27+
return twoDash ? spriteTwoDash : spriteOneDash
28+
end
29+
30+
function Ahorn.selection(entity::CustomRespawnTimeRefill)
31+
x, y = Ahorn.position(entity)
32+
sprite = getSprite(entity)
33+
34+
return Ahorn.getSpriteRectangle(sprite, x, y)
35+
end
36+
37+
function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::CustomRespawnTimeRefill, room::Maple.Room)
38+
sprite = getSprite(entity)
39+
Ahorn.drawSprite(ctx, sprite, 0, 0)
40+
end
41+
42+
end

Ahorn/lang/en_gb.lang

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,7 @@ placements.entities.SpringCollab2020/SeekerStatueCustomColors.tooltips.attackPar
264264
placements.entities.SpringCollab2020/SeekerStatueCustomColors.tooltips.regenParticleColor1=The first color of the particles the seeker emits when respawning.
265265
placements.entities.SpringCollab2020/SeekerStatueCustomColors.tooltips.regenParticleColor2=The second color of the particles the seeker emits when respawning.
266266
placements.entities.SpringCollab2020/SeekerStatueCustomColors.tooltips.trailColor=The color of the trail the seeker leaves behind it when "dashing".
267+
268+
# Custom Respawn Time Refill
269+
placements.entities.SpringCollab2020/CustomRespawnTimeRefill.tooltips.twoDash=Whether the refill should give two dashes.
270+
placements.entities.SpringCollab2020/CustomRespawnTimeRefill.tooltips.respawnTime=The delay (in seconds) before the refill respawns after being collected.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Celeste.Mod.Entities;
2+
using Microsoft.Xna.Framework;
3+
using Monocle;
4+
using MonoMod.Utils;
5+
using System;
6+
7+
namespace Celeste.Mod.SpringCollab2020.Entities {
8+
[CustomEntity("SpringCollab2020/CustomRespawnTimeRefill")]
9+
class CustomRespawnTimeRefill : Refill {
10+
public CustomRespawnTimeRefill(EntityData data, Vector2 offset) : base(data, offset) {
11+
DynData<Refill> self = new DynData<Refill>(this);
12+
float respawnTime = data.Float("respawnTime", 2.5f);
13+
14+
// wrap the original OnPlayer method to modify the respawnTimer if it gets reset to 2.5f.
15+
PlayerCollider collider = Get<PlayerCollider>();
16+
Action<Player> orig = collider.OnCollide;
17+
collider.OnCollide = player => {
18+
orig(player);
19+
if (self.Get<float>("respawnTimer") == 2.5f) {
20+
self["respawnTimer"] = respawnTime;
21+
}
22+
};
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)