miaoda-game-resource-react
v0.3.2
Published
React bindings for HP, MP, stamina, and other resource pools.
Readme
miaoda-game-resource-react
Use this React adapter to render HP, MP, stamina, ammo, or other current/max resources without duplicating pool rules in components.
Install and use
pnpm add miaoda-game-resource-core miaoda-game-resource-reactimport { useResourceSnapshot } from 'miaoda-game-resource-react';
function ManaBar({ pool }: { pool: ResourcePool }) {
const resource = useResourceSnapshot(pool);
return <meter min={0} max={resource.max} value={resource.current} />;
}The hook observes committed pool changes. Spending, gaining, max-change policy, persistence, and damage rules remain in ResourcePool or the game controller.
