Skip to content

Commit

Permalink
Add "Always Spawn" option to Silver Berries (closes #110)
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Nov 24, 2024
1 parent a5eae8a commit c47b425
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Ahorn/entities/silverBerry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module CollabUtils2SilverBerry

using ..Ahorn, Maple

@mapdef Entity "CollabUtils2/SilverBerry" SilverBerry(x::Integer, y::Integer)
@mapdef Entity "CollabUtils2/SilverBerry" SilverBerry(x::Integer, y::Integer, alwaysSpawn::Bool=false)

const placements = Ahorn.PlacementDict(
"Silver Berry (Collab Utils 2 / READ DOCS)" => Ahorn.EntityPlacement(
Expand Down
3 changes: 3 additions & 0 deletions Ahorn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ placements.entities.CollabUtils2/FakeMiniHeart.tooltips.playPulseSound=Whether t
placements.entities.CollabUtils2/FakeMiniHeart.tooltips.playBreakSound=Whether the heart should play a refill sound when broken.
placements.entities.CollabUtils2/FakeMiniHeart.tooltips.flagOnBreak=If filled out, the given flag will be set when the fake mini heart is broken.

# Silver Berry
placements.entities.CollabUtils2/SilverBerry.tooltips.alwaysSpawn=If checked, the silver berry will always spawn, even if the player did not complete the map yet.

# Rainbow Berry
placements.entities.CollabUtils2/RainbowBerry.tooltips.levelSet=The rainbow berry will only spawn if all silver berries in this level set have been collected.
placements.entities.CollabUtils2/RainbowBerry.tooltips.maps=This setting allows to restrict which maps in the level set this rainbow berry takes into account. To do this, list the map names (.bin names only) separated by commas.\nLeave empty if you want the player to collect all silver berries in the level set to make the rainbow berry spawn.
Expand Down
4 changes: 3 additions & 1 deletion Entities/SilverBerry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public class SilverBerry : Strawberry {
private static ParticleType P_OrigGhostGlow;

private bool spawnedThroughGiveSilver = false;
private readonly bool alwaysSpawn;

public SilverBerry(EntityData data, Vector2 offset, EntityID gid) : base(data, offset, gid) {
new DynData<Strawberry>(this)["Golden"] = true;
alwaysSpawn = data.Bool("alwaysSpawn");

if (P_SilverGlow == null) {
P_SilverGlow = new ParticleType(P_Glow) {
Expand All @@ -39,7 +41,7 @@ public override void Added(Scene scene) {

Session session = (scene as Level).Session;
if (!spawnedThroughGiveSilver && ((session.FurthestSeenLevel != session.Level && session.Deaths != 0) ||
(!SaveData.Instance.CheatMode && !SaveData.Instance.Areas_Safe[session.Area.ID].Modes[(int) session.Area.Mode].Completed))) {
(!alwaysSpawn && !SaveData.Instance.CheatMode && !SaveData.Instance.Areas_Safe[session.Area.ID].Modes[(int) session.Area.Mode].Completed))) {

// we went in a further screen and die, or didn't complete the level once yet: don't have the berry spawn.
RemoveSelf();
Expand Down
5 changes: 4 additions & 1 deletion Loenn/entities/silverBerry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ silverBerry.name = "CollabUtils2/SilverBerry"
silverBerry.depth = -100
silverBerry.placements = {
{
name = "default"
name = "default",
data = {
alwaysSpawn = false
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Loenn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ entities.CollabUtils2/RainbowBerry.attributes.description.requires=The amount of

# Silver Berry
entities.CollabUtils2/SilverBerry.placements.name.default=Silver Berry
entities.CollabUtils2/SilverBerry.attributes.description.alwaysSpawn=If checked, the silver berry will always spawn, even if the player did not complete the map yet.

# Silver Block
entities.CollabUtils2/SilverBlock.placements.name.default=Silver Block
Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Name: CollabUtils2
Version: 1.10.13
Version: 1.10.14
DLL: bin/Release/net452/CollabUtils2.dll
Dependencies:
- Name: Everest
Expand Down

0 comments on commit c47b425

Please sign in to comment.