예제 #1
0
파일: item.cpp 프로젝트: miki151/keeperrl
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());
}
예제 #2
0
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);
}
예제 #3
0
파일: item.cpp 프로젝트: gustavsen/keeperrl
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());
  }
}
예제 #4
0
파일: item.cpp 프로젝트: miki151/keeperrl
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);
  }
}
예제 #5
0
파일: item.cpp 프로젝트: gustavsen/keeperrl
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);
}
예제 #6
0
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);
}
예제 #7
0
파일: item.cpp 프로젝트: miki151/keeperrl
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;
    }
  }
}
예제 #8
0
void Square::setHeight(double h) {
  modViewObject().setAttribute(ViewObject::Attribute::HEIGHT, h);
  height = h;
}
예제 #9
0
파일: item.cpp 프로젝트: miki151/keeperrl
void Item::applyPrefix(const ItemPrefix& prefix) {
  modViewObject().setModifier(ViewObject::Modifier::AURA);
  ::applyPrefix(prefix, *attributes);
}
예제 #10
0
파일: square.cpp 프로젝트: Ancurio/keeperrl
void Square::setPosition(Vec2 v) {
  position = v;
  modViewObject().setPosition(v);
}