Pieces and actors
import { Aside } from ‘@astrojs/starlight/components’;
Problem
Section titled “Problem”You need a player character on the harbor tile, a tavern keeper inside the tavern, and three hostile bandits camped on the road. Each has a different role flag + collision profile + interaction behavior.
Snippet
Section titled “Snippet”import { registerGameboardActor, spawnGameboardActor } from 'declarative-hex-worlds/actors';
const player = registerGameboardActor(world, { id: 'player:you', kind: 'player', tileKey: '4,2', team: 'players',});
const tavernKeeper = registerGameboardActor(world, { id: 'npc:keeper', kind: 'npc', tileKey: '1,4', team: 'neutrals',});
const bandit = registerGameboardActor(world, { id: 'enemy:bandit-1', kind: 'npc', tileKey: '5,3', team: 'bandits', hostility: { towards: ['players', 'neutrals'] },});What the library handles
Section titled “What the library handles”- Trait composition. Each actor gets
GameboardActor+ (IsPlayerActor|IsNpcActor|IsPropActor) + (IsHostileActorif applicable) traits. - Team-based queries.
HostileActorQueryreturns just the bandits relative to the player. - Tile occupancy. Spawn refuses to place an actor on a tile that has a blocking placement.