The State: Evolving Familiar
Allow an object to alter its behavior when its internal state changes.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Evolution
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BLAZING-FAST ZIG ALCHEMY //
const std = @import("std");
pub const Familiar = struct {
state: *const StateVTable,
pub fn interact(self: *Familiar) void {
self.state.interact(self);
}
};
pub const StateVTable = struct {
interact: *const fn (self: *Familiar) void,
};
A familiar behaves vastly differently as a hatchling than as an elder wyrm. Instead of a colossal switch-case choking your logic, the Evolving Familiar wraps its current persona in a polymorphed state object. The entity’s identity remains consistent, but its pointer to reality shifts effortlessly.
Runic Tags:
#state
#behavioral
#zig
#evolution