Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Ahorn/entities/shroomBookInteraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ using ..Ahorn, Maple
y::Integer,
width::Integer=Maple.defaultBlockWidth,
height::Integer=Maple.defaultBlockHeight,
assetKey::String="shroompage"
assetKey::String="shroompage",
enableFlag::String="",
readFlag::String=""
)

const placements = Ahorn.PlacementDict(
Expand Down
2 changes: 2 additions & 0 deletions Ahorn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ placements.entities.ShroomHelper/RealityDistortionField.tooltips.rippleAreaMulti

# Shroom Book Interaction
placements.entities.ShroomHelper/ShroomBookInteraction.tooltips.assetKey=The image to display relative to Graphics/Atlases/Gui (do not include .png).
placements.entities.ShroomHelper/ShroomBookInteraction.tooltips.enableFlag=If specified, the entity will only load when the flag is True. Use ! prefix to invert.
placements.entities.ShroomHelper/ShroomBookInteraction.tooltips.readFlag=A flag to set when the player finishes reading. Use ! prefix to clear.

# Shroom Dash Switch
placements.entities.ShroomHelper/ShroomDashSwitch.tooltips.side=The direction the switch is facing.
Expand Down
13 changes: 9 additions & 4 deletions Code/Entities/ShroomBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ namespace Celeste.Mod.ShroomHelper.Entities {
public class ShroomBook : CutsceneEntity {
private readonly Player player;
private readonly string bookTextKey;
private readonly string readFlag;
private readonly bool readFlagInverted;
private PoemPage poem;

public ShroomBook(Player player, string bookTextKey) {
public ShroomBook(Player player, string bookTextKey, string readFlag = "", bool readFlagInverted = false) {
this.player = player;
this.bookTextKey = bookTextKey;
this.readFlag = readFlag;
this.readFlagInverted = readFlagInverted;
}

public override void OnBegin(Level level) {
Expand All @@ -21,8 +25,9 @@ public override void OnBegin(Level level) {
public override void OnEnd(Level level) {
player.StateMachine.Locked = false;
player.StateMachine.State = Player.StNormal;
if (poem != null) {
poem.RemoveSelf();
poem?.RemoveSelf();
if (!string.IsNullOrWhiteSpace(readFlag)) {
level.Session.SetFlag(readFlag, !readFlagInverted);
}
}

Expand Down Expand Up @@ -134,4 +139,4 @@ public IEnumerator EaseOut() {
}
}
}
}
}
28 changes: 26 additions & 2 deletions Code/Entities/ShroomBookInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@
namespace Celeste.Mod.ShroomHelper.Entities {
[CustomEntity("ShroomHelper/ShroomBookInteraction")]
public class ShroomBookInteraction : Entity {
public const string FlagPrefix = "it_";
public TalkComponent Talker;
public string assetKey;
public string enableFlag;
public string readFlag;
public bool enableFlagInverted = false;
public bool readFlagInverted = false;

public ShroomBookInteraction(EntityData data, Vector2 offset)
: base(data.Position + offset) {

Collider = new Hitbox(data.Width, data.Height);
assetKey = data.Attr("assetKey", "shroompage");

enableFlag = data.Attr("enableFlag", "");
if (!string.IsNullOrWhiteSpace(enableFlag) && enableFlag[0] == '!') {
enableFlagInverted = true;
enableFlag = enableFlag.Substring(1);
}

readFlag = data.Attr("readFlag", "");
if (!string.IsNullOrWhiteSpace(readFlag) && readFlag[0] == '!') {
readFlagInverted = true;
readFlag = readFlag.Substring(1);
}


Vector2 drawAt = new(data.Width / 2, 0f);
if (data.Nodes.Length != 0) {
drawAt = data.Nodes[0] - data.Position;
Expand All @@ -24,8 +40,16 @@ public ShroomBookInteraction(EntityData data, Vector2 offset)
Talker.PlayerMustBeFacing = false;
}

public override void Awake(Scene scene) {
if (string.IsNullOrWhiteSpace(enableFlag) || SceneAs<Level>().Session.GetFlag(enableFlag) != enableFlagInverted) {
base.Awake(scene);
} else {
RemoveSelf();
}
}

public void OnTalk(Player player) {
Scene.Add(new ShroomBook(player, assetKey));
Scene.Add(new ShroomBook(player, assetKey, readFlag, readFlagInverted));
}
}
}
6 changes: 4 additions & 2 deletions Loenn/entities/shroom_book_interaction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ shroom_book_interaction.placements = {
data = {
width = 8,
height = 8,
assetKey = "shroompage"
assetKey = "shroompage",
enableFlag = "",
readFlag = ""
}
}

return shroom_book_interaction
return shroom_book_interaction
2 changes: 2 additions & 0 deletions Loenn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ entities.ShroomHelper/ShroomDashSwitch.attributes.description.windPatternOnColli
# Shroom Book Interaction
entities.ShroomHelper/ShroomBookInteraction.placements.name.shroom_book_interaction=Shroom Book Interaction
entities.ShroomHelper/ShroomBookInteraction.attributes.description.assetKey=The image to display relative to Graphics/Atlases/Gui (do not include .png).
entities.ShroomHelper/ShroomBookInteraction.attributes.description.enableFlag=If specified, the entity will only load when the flag is True. Use ! prefix to invert.
entities.ShroomHelper/ShroomBookInteraction.attributes.description.readFlag=A flag to set when the player finishes reading. Use ! prefix to clear.

# Double Refill Booster
entities.ShroomHelper/DoubleRefillBooster.placements.name.double_refill_booster=Double Refill Booster
Expand Down
Loading