-
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.
- Loading branch information
Showing
6 changed files
with
193 additions
and
25 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
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 |
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