State for Sprite Enchantment
Allow an enchanted sprite to completely alter its behavior when its internal magic shifts.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Sprite Enchantment
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
function SpriteContext() constructor {
current_state = undefined;
static set_state = function(_state) { current_state = _state; };
static perform_magic = function() { current_state.execute(self); };
}
function DormantState() constructor {
static execute = function(_context) {
// Pulse slowly
};
}
function AwakenedState() constructor {
static execute = function(_context) {
// Emit fierce particles
};
}
The State pattern embodies metamorphosis. A sprite fluctuating between Dormant and Awakened does not rely on massive conditional structures. Instead, its very core state is swapped, fundamentally changing how it reacts to magical invocation while appearing as the same outward entity.
Runic Tags:
#gml
#behavioral
#state