Files
stickman/scripts/trigger_registry.gd
T
ryan 6a1359f244 Add prop interaction system and throw mechanics specification
- Introduced `stickman_prop_interactor.gd` to manage prop interactions.
- Created `phase_11_prop_interactions.md` detailing the design and implementation of prop pickup, drop, and throw mechanics.
- Defined interaction states, action lifecycles, and event triggers for prop handling.
- Specified constraints for throw actions, including target positioning and velocity calculations.
- Established acceptance criteria for prop interactions and lifecycle management.
2026-09-25 23:42:26 -04:00

87 lines
2.2 KiB
GDScript

class_name TriggerRegistry
extends RefCounted
## TriggerRegistry - Registry of rule trigger templates (Phase 3c).
##
## Single source of truth for the trigger types the event system understands.
## Adding a new trigger type is just appending an entry here; the RuleEditor and
## the panels generate their UI from this registry.
const TRIGGER_TEMPLATES := {
"arrived_at_waypoint": {
"label": "Arrives at waypoint",
"icon": "📍",
"target_type": "waypoint",
},
"action_finished": {
"label": "Completes any action",
"icon": "✅",
"target_type": "action_type",
},
"speech_finished": {
"label": "Finishes speaking",
"icon": "💬",
"target_type": "none",
},
"entered_area": {
"label": "Enters trigger area",
"icon": "🎯",
"target_type": "area",
},
"collided": {
"label": "Collides with something",
"icon": "💥",
"target_type": "prop",
},
"prop_picked_up": {
"label": "Picks up a prop",
"icon": "🫴",
"target_type": "prop",
},
"prop_dropped": {
"label": "Drops a prop",
"icon": "⬇️",
"target_type": "prop",
},
"prop_thrown": {
"label": "Throws a prop",
"icon": "🏹",
"target_type": "prop",
},
}
static func types() -> Array[String]:
# Dictionary.keys() returns an untyped Array at runtime; build a genuinely
# typed Array[String] so callers can store it in typed locals (see
# RuleEditor._current_type).
var out: Array[String] = []
out.assign(TRIGGER_TEMPLATES.keys())
return out
static func has_type(type: String) -> bool:
return TRIGGER_TEMPLATES.has(type)
static func label(type: String) -> String:
var tpl: Dictionary = TRIGGER_TEMPLATES.get(type, {})
return String(tpl.get("label", type))
static func icon(type: String) -> String:
var tpl: Dictionary = TRIGGER_TEMPLATES.get(type, {})
return String(tpl.get("icon", ""))
## Which kind of stage target a trigger needs: "waypoint", "action_type",
## "area", "prop", or "none".
static func target_type(type: String) -> String:
var tpl: Dictionary = TRIGGER_TEMPLATES.get(type, {})
return String(tpl.get("target_type", "none"))
## Human-readable summary of a trigger, e.g. "Arrives at waypoint".
static func summarize(trigger: Dictionary) -> String:
var type := String(trigger.get("type", ""))
return "%s %s" % [icon(type), label(type)]