Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 9 additions & 2 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) {
this.player = player;
this.bookTextKey = bookTextKey;
this.readFlag = readFlag;
this.readFlagInverted = readFlagInverted;
}

public override void OnBegin(Level level) {
Expand All @@ -24,6 +28,9 @@ public override void OnEnd(Level level) {
if (poem != null) {
poem.RemoveSelf();
}
if(readFlag != "") {
level.Session.SetFlag(readFlag, !readFlagInverted);
}
}

private IEnumerator Routine() {
Expand Down Expand Up @@ -134,4 +141,4 @@ public IEnumerator EaseOut() {
}
}
}
}
}
29 changes: 28 additions & 1 deletion Code/Entities/ShroomBookInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,30 @@ 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(enableFlag[0] == '!') {
enableFlagInverted = true;
enableFlag = enableFlag[1..];
}

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


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

public override void Awake(Scene scene) {

if(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
4 changes: 4 additions & 0 deletions Loenn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ 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