コード例 #1
0
  //
  // Submit asset requests directly to the manager
  //
  Bool Asset::Request::TypeBase::DirectEvaluation(Manager &manager)
  {
    // Iterate the units in the base an evaluate them
    if (base.Alive())
    {
      for (UnitObjList::Iterator u(&base->GetUnits()); *u; u++)
      {
        if ((*u)->Alive())
        {
          UnitObj *unit = **u;
          manager.Evaluation(*this, *unit, config->GetAmounts().Find(unit->GameType()->Id()) ? 1.0f : 0.0f);
        }
      }
    }

    return (TRUE);
  }
コード例 #2
0
  //
  // Offer
  //
  // The given asset is being offered, do we want it ?
  //
  Bool Asset::Request::TypeBase::Offer(Asset &asset)
  {
    // Get the unit out of the asset
    UnitObj *unit = asset.GetUnit();
    ASSERT(unit)

    // Do we have enough of this type ?
    U32 type = unit->GameType()->Id();

    // We should only be offered this type if we asked for it
    ASSERT(config->GetAmount(type))

    // How many of this type do we currently have ?
    U32 *amount = amounts.Find(type);

    // Is this less that what we need ?
    return ((!amount || *amount < config->GetAmount(type)) ? TRUE : FALSE);
  }