本文整理汇总了C++中Asset::GetUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ Asset::GetUnit方法的具体用法?C++ Asset::GetUnit怎么用?C++ Asset::GetUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::GetUnit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
//
// 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);
}
示例2:
//
// Accept
//
// The given asset has been accepted
//
void Asset::Request::TypeBase::Accept(Asset &asset, Bool primary)
{
if (primary)
{
// Add the object to the list which are assigned to us
assigned.Append(&asset);
}
// Add this type to the amount tree
U32 type = asset.GetUnit()->GameType()->Id();
U32 *amount = amounts.Find(type);
if (amount)
{
(*amount)++;
}
else
{
amounts.Add(type, new U32(1));
}
}