当前位置: 首页>>代码示例>>C++>>正文


C++ AInventory::GetDefault方法代码示例

本文整理汇总了C++中AInventory::GetDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ AInventory::GetDefault方法的具体用法?C++ AInventory::GetDefault怎么用?C++ AInventory::GetDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AInventory的用法示例。


在下文中一共展示了AInventory::GetDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandlePickup

bool ABackpackItem::HandlePickup (AInventory *item)
{
    // Since you already have a backpack, that means you already have every
    // kind of ammo in your inventory, so we don't need to look at the
    // entire PClass list to discover what kinds of ammo exist, and we don't
    // have to alter the MaxAmount either.
    if (item->IsKindOf (RUNTIME_CLASS(ABackpackItem)))
    {
        for (AInventory *probe = Owner->Inventory; probe != NULL; probe = probe->Inventory)
        {
            if (probe->GetClass()->ParentClass == RUNTIME_CLASS(AAmmo))
            {
                if (probe->Amount < probe->MaxAmount || sv_unlimited_pickup)
                {
                    int amount = static_cast<AAmmo*>(probe->GetDefault())->BackpackAmount;
                    // extra ammo in baby mode and nightmare mode
                    if (!(item->ItemFlags&IF_IGNORESKILL))
                    {
                        amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
                    }
                    probe->Amount += amount;
                    if (probe->Amount > probe->MaxAmount && !sv_unlimited_pickup)
                    {
                        probe->Amount = probe->MaxAmount;
                    }
                }
            }
        }
        // The pickup always succeeds, even if you didn't get anything
        item->ItemFlags |= IF_PICKUPGOOD;
        return true;
    }
    return false;
}
开发者ID:dwing4g,项目名称:gzdoom,代码行数:34,代码来源:a_ammo.cpp

示例2: DetachFromOwner

void ABackpackItem::DetachFromOwner ()
{
	// When removing a backpack, drop the player's ammo maximums to normal
	AInventory *item;

	for (item = Owner->Inventory; item != NULL; item = item->Inventory)
	{
		if (item->GetClass()->ParentClass == RUNTIME_CLASS(AAmmo) &&
			item->MaxAmount == static_cast<AAmmo*>(item)->BackpackMaxAmount)
		{
			item->MaxAmount = static_cast<AInventory*>(item->GetDefault())->MaxAmount;
			if (item->Amount > item->MaxAmount)
			{
				item->Amount = item->MaxAmount;
			}
		}
	}
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:18,代码来源:a_pickups.cpp


注:本文中的AInventory::GetDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。