|
| 1 | +module SpringCollab2020ForegroundReflectionTentacles |
| 2 | + |
| 3 | +using ..Ahorn, Maple |
| 4 | + |
| 5 | +@mapdef Entity "SpringCollab2020/ForegroundReflectionTentacles" ForegroundReflectionTentacles(x::Integer, y::Integer, |
| 6 | + nodes::Array{Tuple{Integer, Integer}, 1}=Tuple{Integer, Integer}[], fear_distance::String="", slide_until::Integer=0) |
| 7 | + |
| 8 | +const placements = Ahorn.PlacementDict( |
| 9 | + "Foreground Tentacles (Spring Collab 2020)" => Ahorn.EntityPlacement( |
| 10 | + ForegroundReflectionTentacles, |
| 11 | + "point", |
| 12 | + Dict{String, Any}(), |
| 13 | + function(entity) |
| 14 | + entity.data["nodes"] = [(Int(entity.data["x"]) + 32, Int(entity.data["y"]))] |
| 15 | + end |
| 16 | + ) |
| 17 | +) |
| 18 | + |
| 19 | +# Maple definition doesn't have "Fake keys" |
| 20 | +const fearDistance = Dict{String, String}( |
| 21 | + "None" => "", |
| 22 | + "Close" => "close", |
| 23 | + "Medium" => "medium", |
| 24 | + "Far" => "far" |
| 25 | +) |
| 26 | + |
| 27 | +Ahorn.nodeLimits(entity::ForegroundReflectionTentacles) = 1, -1 |
| 28 | + |
| 29 | +Ahorn.editingOptions(entity::ForegroundReflectionTentacles) = Dict{String, Any}( |
| 30 | + "fear_distance" => fearDistance |
| 31 | +) |
| 32 | + |
| 33 | +function Ahorn.selection(entity::ForegroundReflectionTentacles) |
| 34 | + nodes = get(entity.data, "nodes", ()) |
| 35 | + x, y = Ahorn.position(entity) |
| 36 | + |
| 37 | + res = Ahorn.Rectangle[Ahorn.Rectangle(x - 12, y - 12, 24, 24)] |
| 38 | + |
| 39 | + for node in nodes |
| 40 | + nx, ny = Int.(node) |
| 41 | + |
| 42 | + push!(res, Ahorn.Rectangle(nx - 12, ny - 12, 24, 24)) |
| 43 | + end |
| 44 | + |
| 45 | + return res |
| 46 | +end |
| 47 | + |
| 48 | +function drawTentacleIcon(ctx::Ahorn.Cairo.CairoContext, x, y) |
| 49 | + Ahorn.drawImage(ctx, Ahorn.Assets.tentacle, x - 12, y - 12) |
| 50 | +end |
| 51 | + |
| 52 | +function Ahorn.renderSelectedAbs(ctx::Ahorn.Cairo.CairoContext, entity::ForegroundReflectionTentacles) |
| 53 | + px, py = Ahorn.position(entity) |
| 54 | + |
| 55 | + for node in get(entity.data, "nodes", ()) |
| 56 | + nx, ny = Int.(node) |
| 57 | + |
| 58 | + Ahorn.drawArrow(ctx, px, py, nx, ny, Ahorn.colors.selection_selected_fc, headLength=6) |
| 59 | + drawTentacleIcon(ctx, nx, ny) |
| 60 | + |
| 61 | + px, py = nx, ny |
| 62 | + end |
| 63 | +end |
| 64 | + |
| 65 | +function Ahorn.renderAbs(ctx::Ahorn.Cairo.CairoContext, entity::ForegroundReflectionTentacles, room::Maple.Room) |
| 66 | + x, y = Ahorn.position(entity) |
| 67 | + drawTentacleIcon(ctx, x, y) |
| 68 | +end |
| 69 | + |
| 70 | +end |
0 commit comments