Exemplo n.º 1
0
const Creature* MinionEquipment::getOwner(const Item* it) const {
  if (owners.count(it->getUniqueId())) {
    const Creature* c = owners.at(it->getUniqueId());
    if (!c->isDead() && needs(c, it, true, true))
      return c;
  }
  return nullptr;
}
Exemplo n.º 2
0
void MinionEquipment::updateOwners(const vector<Item*> items) {
  for (const Item* item : items)
    if (owners.count(item->getUniqueId())) {
      const Creature* c = owners.at(item->getUniqueId());
      if (c->isDead() || !needs(c, item, true, true))
        discard(item);
    }
}
Exemplo n.º 3
0
void MinionEquipment::updateOwners(const vector<Item*> items) {
  for (const Item* item : items)
    if (auto owner = owners.getMaybe(item)) {
      const Creature* c = *owner;
      if (c->isDead() || !needs(c, item, true, true))
        discard(item);
    }
}
Exemplo n.º 4
0
bool MinionEquipment::canTakeItem(const Creature* c, const Item* it) {
  if (const Creature* owner = getOwner(it)) {
    if (c == owner) {
      if (!needs(c, it)) {
        discard(it);
        return false;
      }
      return true;
    }
    if (owner->isDead())
      discard(it);
    else
      return false;
  }
  if (!getEquipmentType(it) || !c->isHumanoid())
    return false;
  return needs(c, it);
}
//---------------------------------------------------------------------
//  intialization 
//---------------------------------------------------------------------
void PhysicsModelTwoTemperature::initialize(void)
{
  string list[5] = {"heat_capacity",
           "electron_heat_capacity",
                    "heat_flux",
           "electron_heat_flux",
           "electron_phonon_exchange"};
  set<string> needs(list,list+5);
  vector< Material* >::iterator iter;
  for (iter = materials_.begin(); iter != materials_.end(); iter++) {
    Material * mat = *iter;
    if (! (mat->check_registry(needs)) ) {
      throw ATC_Error(0,"material " + mat->label() + " does not provide all interfaces for physics");
    }
  }
}
Exemplo n.º 6
0
void ProgramCache::useProgram(const Description& description) {

    // generate the key for the shader based on the description
    Key needs(computeKey(description));

     // look-up the program in the cache
    Program* program = mCache.valueFor(needs);
    if (program == NULL) {
        // we didn't find our program, so generate one...
        nsecs_t time = -systemTime();
        program = generateProgram(needs);
        mCache.add(needs, program);
        time += systemTime();

        //ALOGD(">>> generated new program: needs=%08X, time=%u ms (%d programs)",
        //        needs.mNeeds, uint32_t(ns2ms(time)), mCache.size());
    }

    // here we have a suitable program for this description
    if (program->isValid()) {
        program->use();
        program->setUniforms(description);
    }
}