1+ module SpringCollab2020CustomSoundBerry
2+
3+ using .. Ahorn, Maple
4+
5+ @mapdef Entity " SpringCollab2020/CustomSoundBerry" CustomSoundBerry (x:: Integer , y:: Integer , winged:: Bool = false , moon:: Bool = false ,
6+ checkpointID:: Integer = - 1 , order:: Integer = - 1 , nodes:: Array{Tuple{Integer, Integer}, 1} = Tuple{Integer, Integer}[],
7+ strawberryWingFlapSound:: String = " event:/game/general/strawberry_wingflap" , strawberryPulseSound:: String = " event:/game/general/strawberry_pulse" ,
8+ strawberryBlueTouchSound:: String = " event:/game/general/strawberry_blue_touch" , strawberryTouchSound:: String = " event:/game/general/strawberry_touch" ,
9+ strawberryLaughSound:: String = " event:/game/general/strawberry_laugh" , strawberryFlyAwaySound:: String = " event:/game/general/strawberry_flyaway" ,
10+ strawberryGetSound:: String = " event:/game/general/strawberry_get" )
11+
12+ const placements = Ahorn. PlacementDict (
13+ " Sound Test Berry (Spring Collab 2020; DO NOT USE IN MAPS)" => Ahorn. EntityPlacement (
14+ CustomSoundBerry
15+ )
16+ )
17+
18+ # winged, has pips, moon
19+ sprites = Dict {Tuple{Bool, Bool, Bool}, String} (
20+ (false , false , false ) => " collectables/strawberry/normal00" ,
21+ (true , false , false ) => " collectables/strawberry/wings01" ,
22+ (false , true , false ) => " collectables/ghostberry/idle00" ,
23+ (true , true , false ) => " collectables/ghostberry/wings01" ,
24+
25+ (false , false , true ) => " collectables/moonBerry/normal00" ,
26+ (true , false , true ) => " collectables/moonBerry/ghost00" ,
27+ (false , true , true ) => " collectables/moonBerry/ghost00" ,
28+ (true , true , true ) => " collectables/moonBerry/ghost00"
29+ )
30+
31+ seedSprite = " collectables/strawberry/seed00"
32+
33+ Ahorn. nodeLimits (entity:: CustomSoundBerry ) = 0 , - 1
34+
35+ function Ahorn. selection (entity:: CustomSoundBerry )
36+ x, y = Ahorn. position (entity)
37+
38+ nodes = get (entity. data, " nodes" , ())
39+ moon = get (entity. data, " moon" , false )
40+ winged = get (entity. data, " winged" , false )
41+ hasPips = length (nodes) > 0
42+
43+ sprite = sprites[(winged, hasPips, moon)]
44+
45+ res = Ahorn. Rectangle[Ahorn. getSpriteRectangle (sprite, x, y)]
46+
47+ for node in nodes
48+ nx, ny = node
49+
50+ push! (res, Ahorn. getSpriteRectangle (seedSprite, nx, ny))
51+ end
52+
53+ return res
54+ end
55+
56+ function Ahorn. renderSelectedAbs (ctx:: Ahorn.Cairo.CairoContext , entity:: CustomSoundBerry )
57+ x, y = Ahorn. position (entity)
58+
59+ for node in get (entity. data, " nodes" , ())
60+ nx, ny = node
61+
62+ Ahorn. drawLines (ctx, Tuple{Number, Number}[(x, y), (nx, ny)], Ahorn. colors. selection_selected_fc)
63+ end
64+ end
65+
66+ function Ahorn. renderAbs (ctx:: Ahorn.Cairo.CairoContext , entity:: CustomSoundBerry , room:: Maple.Room )
67+ x, y = Ahorn. position (entity)
68+
69+ nodes = get (entity. data, " nodes" , ())
70+ moon = get (entity. data, " moon" , false )
71+ winged = get (entity. data, " winged" , false )
72+ hasPips = length (nodes) > 0
73+
74+ sprite = sprites[(winged, hasPips, moon)]
75+
76+ for node in nodes
77+ nx, ny = node
78+
79+ Ahorn. drawSprite (ctx, seedSprite, nx, ny)
80+ end
81+
82+ Ahorn. drawSprite (ctx, sprite, x, y)
83+ end
84+
85+ end
0 commit comments