package Ball import ItemObject import BasicSpells import ClosureTimers import Key import Builder public class BallItem extends ItemObject boolean picked = false boolean followWalkable = true UnitEntity holder construct(vec2 pos, player owner) super(pos, CreateItem(BALL_ITEM_ID, pos.x, pos.y), CreateUnit(owner, KEY_DUMMY_ID, pos.x, pos.y, 0)) override function onUse(UnitEntity user) override function onPickup(UnitEntity holder) if holder instanceof Builder terminate() else picked = true this.holder = holder holder.actor.addAbility(BALL_SPELL_ID) setup.actor.hide() override function onDrop(UnitEntity e) picked = false holder = null if e.actor.hasAbility(BALL_SPELL_ID) e.actor.removeAbility(BALL_SPELL_ID) nullTimer() -> actor.remove() actor = CreateItem(BALL_ITEM_ID, pos.x, pos.y) actor.setEntity(this) else nullTimer() -> actor.remove() override function update() function onIdle(vec2 pos) this.pos = pos.toVec3() actor.setVisible(true) setup.setXY(pos.toVec3()) setup.actor.show() nullTimer() -> actor.remove() actor = CreateItem(BALL_ITEM_ID, pos.x, pos.y) actor.setEntity(this)