Item::Item(const ItemAttributes& attr) : Renderable(ViewObject(*attr.viewId, ViewLayer::ITEM, capitalFirst(*attr.name))), attributes(attr), fire(attr.burnTime), canEquipCache(!!attributes->equipmentSlot), classCache(*attributes->itemClass) { if (!attributes->prefixes.empty()) modViewObject().setModifier(ViewObject::Modifier::AURA); modViewObject().setGenericId(getUniqueId().getGenericId()); }
void Square::tick(double time) { dirty = true; if (!inventory.isEmpty()) for (Item* item : inventory.getItems()) { item->tick(time, level, position); if (item->isDiscarded()) inventory.removeItem(item); } poisonGas.tick(level, position); if (creature && poisonGas.getAmount() > 0.2) { creature->poisonWithGas(min(1.0, poisonGas.getAmount())); } if (fire.isBurning()) { modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire.getSize()); Debug() << getName() << " burning " << fire.getSize(); for (Vec2 v : position.neighbors8(true)) if (fire.getSize() > Random.getDouble() * 40) level->getSquare(v)->setOnFire(fire.getSize() / 20); fire.tick(level, position); if (fire.isBurntOut()) { level->globalMessage(position, "The " + getName() + " burns out"); burnOut(); return; } if (creature) creature->setOnFire(fire.getSize()); for (Item* it : getItems()) it->setOnFire(fire.getSize(), level, position); for (Trigger* t : extractRefs(triggers)) t->setOnFire(fire.getSize()); } for (Trigger* t : extractRefs(triggers)) t->tick(time); tickSpecial(time); }
void Item::setOnFire(double amount, Position position) { bool burning = fire->isBurning(); string noBurningName = getTheName(); fire->set(amount); if (!burning && fire->isBurning()) { position.globalMessage(noBurningName + " catches fire"); modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire->getSize()); } }
void Item::fireDamage(Position position) { bool burning = fire->isBurning(); string noBurningName = getTheName(); fire->set(); if (!burning && fire->isBurning()) { position.globalMessage(noBurningName + " catches fire"); modViewObject().setModifier(ViewObject::Modifier::BURNING); } }
void Item::tick(double time, Position position) { if (fire->isBurning()) { Debug() << getName() << " burning " << fire->getSize(); position.setOnFire(fire->getSize()); modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire->getSize()); fire->tick(); if (!fire->isBurning()) { position.globalMessage(getTheName() + " burns out"); discarded = true; } } specialTick(time, position); }
void Square::setOnFire(double amount) { dirty = true; bool burning = fire.isBurning(); fire.set(amount); if (!burning && fire.isBurning()) { level->addTickingSquare(position); level->globalMessage(position, "The " + getName() + " catches fire."); modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire.getSize()); } if (creature) creature->setOnFire(amount); for (Item* it : getItems()) it->setOnFire(amount, level, position); }
void Item::tick(Position position) { PROFILE_BLOCK("Item::tick"); if (fire->isBurning()) { INFO << getName() << " burning "; position.fireDamage(0.2); modViewObject().setModifier(ViewObject::Modifier::BURNING); fire->tick(); if (!fire->isBurning()) { position.globalMessage(getTheName() + " burns out"); discarded = true; } } specialTick(position); if (timeout) { if (position.getGame()->getGlobalTime() >= *timeout) { discarded = true; } } }
void Square::setHeight(double h) { modViewObject().setAttribute(ViewObject::Attribute::HEIGHT, h); height = h; }
void Item::applyPrefix(const ItemPrefix& prefix) { modViewObject().setModifier(ViewObject::Modifier::AURA); ::applyPrefix(prefix, *attributes); }
void Square::setPosition(Vec2 v) { position = v; modViewObject().setPosition(v); }