-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Originally implemented in Chronia Helper based on Helping Hand code, UnderDragon provided the modified code for it to be merged back into Helping Hand
- Loading branch information
Showing
9 changed files
with
257 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module MaxHelpingHandFlagTouchSwitchWall | ||
|
||
using ..Ahorn, Maple | ||
|
||
@mapdef Entity "MaxHelpingHand/FlagTouchSwitchWall" FlagTouchSwitchWall(x::Integer, y::Integer, width::Integer=16, height::Integer=16, | ||
flag::String="flag_touch_switch", icon::String="vanilla", persistent::Bool=false, hideIfFlag::String="", | ||
inactiveColor::String="5FCDE4", activeColor::String="FFFFFF", finishColor::String="F141DF", smoke::Bool=true, animationLength::Integer=6, | ||
inverted::Bool=false, allowDisable::Bool=false, playerCanActivate::Bool=true, hitSound::String="event:/game/general/touchswitch_any", | ||
completeSoundFromSwitch::String="event:/game/general/touchswitch_last_cutoff", completeSoundFromScene::String="event:/game/general/touchswitch_last_oneshot") | ||
|
||
const bundledIcons = String["vanilla", "tall", "triangle", "circle", "diamond", "double", "heart", "square", "wide", "winged", "cross", "drop", "hourglass", "split", "star", "triple"] | ||
|
||
const placements = Ahorn.PlacementDict( | ||
"Flag Touch Switch Wall (Maddie's Helping Hand)" => Ahorn.EntityPlacement( | ||
FlagTouchSwitchWall | ||
) | ||
) | ||
|
||
Ahorn.editingOrder(entity::FlagTouchSwitchWall) = String["x", "y", "width", "height", "inactiveColor", "activeColor", "finishColor", "hitSound", "completeSoundFromSwitch", "completeSoundFromScene"] | ||
|
||
Ahorn.editingOptions(entity::FlagTouchSwitchWall) = Dict{String,Any}( | ||
"icon" => bundledIcons | ||
) | ||
|
||
Ahorn.minimumSize(entity::FlagTouchSwitchWall) = 8, 8 | ||
Ahorn.resizable(entity::FlagTouchSwitchWall) = true, true | ||
Ahorn.selection(entity::FlagTouchSwitchWall) = Ahorn.getEntityRectangle(entity) | ||
|
||
function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::FlagTouchSwitchWall, room::Maple.Room) | ||
icon = get(entity.data, "icon", "vanilla") | ||
|
||
iconPath = "objects/touchswitch/icon00.png" | ||
if icon != "vanilla" | ||
iconPath = "objects/MaxHelpingHand/flagTouchSwitch/$(icon)/icon00.png" | ||
end | ||
|
||
width = get(entity.data, "width", 8) | ||
height = get(entity.data, "height", 8) | ||
|
||
Ahorn.drawRectangle(ctx, 0, 0, width, height, (0.0, 0.0, 0.0, 0.3), (1.0, 1.0, 1.0, 0.5)) | ||
Ahorn.drawSprite(ctx, iconPath, width / 2, height / 2) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Celeste.Mod.Entities; | ||
using Microsoft.Xna.Framework; | ||
using Monocle; | ||
|
||
namespace Celeste.Mod.MaxHelpingHand.Entities { | ||
[CustomEntity("MaxHelpingHand/FlagTouchSwitchWall")] | ||
public class FlagTouchSwitchWall : FlagTouchSwitch { | ||
protected override Vector2 IconPosition => new Vector2(Width / 2, Height / 2); | ||
|
||
public FlagTouchSwitchWall(EntityData data, Vector2 offset) : base(data, offset) { | ||
} | ||
|
||
protected override void setUpCollision(EntityData data) { | ||
Collider = new Hitbox(data.Width, data.Height); | ||
|
||
if (data.Bool("playerCanActivate", defaultValue: true)) { | ||
Add(new PlayerCollider(onPlayer, null, new Hitbox(data.Width, data.Height))); | ||
} | ||
|
||
Add(new HoldableCollider(onHoldable, new Hitbox(data.Width, data.Height))); | ||
Add(new SeekerCollider(onSeeker, new Hitbox(data.Width, data.Height))); | ||
} | ||
|
||
protected override void renderBorder() { | ||
Draw.HollowRect(X - 1, Y - 1, Width + 2, Height + 2, new Color(icon.Color.R, icon.Color.G, icon.Color.B, (int) (0.7f * 255))); | ||
Draw.Rect(X + 1, Y + 1, Width - 2, Height - 2, Color.Lerp(icon.Color, Calc.HexToColor("0a0a0a"), 0.5f) * 0.3f); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
local drawableSprite = require("structs.drawable_sprite") | ||
local utils = require("utils") | ||
|
||
local touchSwitch = {} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
local drawableSprite = require("structs.drawable_sprite") | ||
local drawableRectangle = require("structs.drawable_rectangle") | ||
|
||
local touchSwitch = {} | ||
|
||
touchSwitch.name = "MaxHelpingHand/FlagTouchSwitchWall" | ||
touchSwitch.depth = 2000 | ||
touchSwitch.minimumSize = {8, 8} | ||
touchSwitch.placements = { | ||
{ | ||
name = "touch_switch", | ||
data = { | ||
width = 16, | ||
height = 16, | ||
flag = "flag_touch_switch", | ||
icon = "vanilla", | ||
animationLength = 6, | ||
persistent = false, | ||
inactiveColor = "5FCDE4", | ||
activeColor = "FFFFFF", | ||
finishColor = "F141DF", | ||
smoke = true, | ||
inverted = false, | ||
allowDisable = false, | ||
playerCanActivate = true, | ||
hitSound = "event:/game/general/touchswitch_any", | ||
completeSoundFromSwitch = "event:/game/general/touchswitch_last_cutoff", | ||
completeSoundFromScene = "event:/game/general/touchswitch_last_oneshot", | ||
hideIfFlag = "" | ||
} | ||
} | ||
} | ||
|
||
function touchSwitch.fieldOrder(entity) | ||
local fieldOrder = {"x", "y", "width", "height", "inactiveColor", "activeColor", "finishColor", "hitSound", "completeSoundFromSwitch", "completeSoundFromScene"} | ||
|
||
-- only include animationLength to fieldOrder if the field exists, otherwise it will appear as nil in the entity properties window | ||
if entity.animationLength ~= nil then | ||
table.insert(fieldOrder, "animationLength") | ||
end | ||
|
||
return fieldOrder | ||
end | ||
|
||
touchSwitch.fieldInformation = { | ||
inactiveColor = { | ||
fieldType = "color" | ||
}, | ||
activeColor = { | ||
fieldType = "color" | ||
}, | ||
finishColor = { | ||
fieldType = "color" | ||
}, | ||
icon = { | ||
options = { "vanilla", "tall", "triangle", "circle", "diamond", "double", "heart", "square", "wide", "winged", "cross", "drop", "hourglass", "split", "star", "triple" } | ||
}, | ||
animationLength = { | ||
fieldType = "integer" | ||
} | ||
} | ||
|
||
function touchSwitch.sprite(room, entity) | ||
local containerSprite = drawableRectangle.fromRectangle('bordered', entity.x, entity.y, entity.width, entity.height, {0.0, 0.0, 0.0, 0.3}, {1.0, 1.0, 1.0, 0.5}) | ||
|
||
local iconResource = "objects/touchswitch/icon00" | ||
if entity.icon ~= "vanilla" then | ||
iconResource = "objects/MaxHelpingHand/flagTouchSwitch/" .. entity.icon .."/icon00" | ||
end | ||
|
||
local iconSprite = drawableSprite.fromTexture(iconResource, entity) | ||
iconSprite:setPosition(entity.x + entity.width / 2, entity.y + entity.height / 2) | ||
|
||
return {containerSprite, iconSprite} | ||
end | ||
|
||
return touchSwitch |
Oops, something went wrong.