Log inGet started
World

Slime Arena 史莱姆竞技场

Branchmain
Branchesmain
Commit01fdfbe924

README.md

Vitals

The numbers of one living thing — hp, maxHp, level, xp, xpToNext, attack, invuln and dead — as one synced component, plus the rules that own them.

Attach it to anything that can be hurt: a player's body with { player = true }, a slime root with { maxHp = Rules.SLIME_MAX_HP, hp = Rules.SLIME_MAX_HP } and player left false. Every read and every change from outside goes through game.combat.vitals, which decides whether this peer may write it; the component body only ever runs on the peer that owns the entity, and that is what keeps health correct across four peers.

Methods: applyDamage(amount, attackerId), applyHeal(amount), addXp(amount) (which resolves every level-up it earns: max HP +20, attack +5, full heal), die(attackerId) and respawn() (full bar, Rules.INVULN_TIME of invulnerability). It has no sibling components; nothing else is required beside it.