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


C++ CBaseEntity::GetHasAttributesInterfacePtr方法代码示例

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


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

示例1: ApplyAttributeFloat

float CAttributeManager::ApplyAttributeFloat( float flValue, const CBaseEntity *pEntity, string_t strAttributeClass )
{
	if ( m_bParsingMyself || m_hOuter.Get() == NULL )
	{
		return flValue;
	}

	// Safeguard to prevent potential infinite loops.
	m_bParsingMyself = true;

	for ( int i = 0; i < m_AttributeProviders.Count(); i++ )
	{
		CBaseEntity *pProvider = m_AttributeProviders[i].Get();

		if ( !pProvider || pProvider == pEntity )
			continue;

		IHasAttributes *pAttributes = pProvider->GetHasAttributesInterfacePtr();

		if ( pAttributes )
		{
			flValue = pAttributes->GetAttributeManager()->ApplyAttributeFloat( flValue, pEntity, strAttributeClass );
		}
	}

	IHasAttributes *pAttributes = m_hOuter->GetHasAttributesInterfacePtr();
	CBaseEntity *pOwner = pAttributes->GetAttributeOwner();

	if ( pOwner )
	{
		IHasAttributes *pOwnerAttrib = pOwner->GetHasAttributesInterfacePtr();
		if ( pOwnerAttrib )
		{
			flValue = pOwnerAttrib->GetAttributeManager()->ApplyAttributeFloat( flValue, pEntity, strAttributeClass );
		}
	}

	m_bParsingMyself = false;

	return flValue;
}
开发者ID:TenmaPL,项目名称:TF2Classic,代码行数:41,代码来源:attribute_manager.cpp

示例2: ReapplyProvision

void CTFPowerupBottle::ReapplyProvision()
{
	CTFWearable::ReapplyProvision();
	
	CBaseEntity *owner = this->GetOwnerEntity();
	if (owner == nullptr) {
		return;
	}
	
	IHasAttributes *owner_ihasattr = owner->GetHasAttributesInterfacePtr();
	if (owner_ihasattr == nullptr) {
		return;
	}
	
	if (this->m_bActive) {
		if (!owner_ihasattr->GetAttributeManager()->IsBeingProvidedToBy(this)) {
			this->GetAttributeManager()->ProvideTo(owner);
		}
	} else {
		this->GetAttributeManager()->StopProvidingTo(owner);
	}
	
	CTFPlayer *player = dynamic_cast<CTFPlayer *>(owner);
	if (player == nullptr) {
		return;
	}
	
	/* BUG: because "canteen_specialist" is an integer attribute, the call to
	 * AttribHookValue<int> will truncate any fractional part of the powerup
	 * duration */
	float duration = CAttributeManager::AttribHookValue<float>(0.0f,
		"powerup_duration", this, nullptr, true);
	duration = CAttributeManager::AttribHookValue<int>((int)duration,
		"canteen_specialist", player, nullptr, true);
	
	CTFPlayer *share_with = nullptr;
	int share_attr = 0;
	
	if (player->IsPlayerClass(TF_CLASS_MEDIC)) {
		CTFWeaponBase *weapon = player->GetActiveWeapon();
		if (weapon != nullptr) {
			CWeaponMedigun *medigun = dynamic_cast<CWeaponMedigun *>(weapon);
			if (medigun != nullptr) {
				share_with = ToTFPlayer(medigun->GetHealTarget());
				if (share_with != nullptr) {
					share_attr = CAttributeManager::AttribHookValue<int>(0,
						"canteen_specialist", player, nullptr, true);
				}
			}
		}
	}
	
	bool did_share = false;
	
	if (CAttributeManager::AttribHookValue<int>(0, "critboost",
		this, nullptr, true) != 0) {
		if (this->m_bActive) {
			player->m_Shared.AddCond(TF_COND_CRITBOOSTED_USER_BUFF, duration);
			
			if (share_with != nullptr && share_attr != 0) {
				share_with->m_Shared.AddCond(TF_COND_CRITBOOSTED_USER_BUFF,
					duration);
				did_share = true;
			}
		} else {
			player->m_Shared.RemoveCond(TF_COND_CRITBOOSTED_USER_BUFF, true);
		}
	}
	
	if (CAttributeManager::AttribHookValue<int>(0, "ubercharge",
		this, nullptr, true) != 0) {
		if (this->m_bActive) {
			player->m_Shared.AddCond(TF_COND_INVULNERABLE_USER_BUFF, duration);
			
			if (player->IsPlayerClass(TF_CLASS_ENGINEER)) {
				int obj_count = player->GetObjectCount();
				if (obj_count > 0) {
					for (int i = obj_count - 1; i != -1; --i) {
						CBaseObject *obj = player->GetObject(i);
						if (obj != nullptr) {
							CObjectSentrygun *sentry = dynamic_cast<CObjectSentrygun *>(obj);
							if (sentry != nullptr && !sentry->m_bCarried) {
								sentry->m_nShieldLevel = 2;
								// TODO: set float @ CObjectSentrygun+0xb14
								// to gpGlobals->curtime + duration
							}
						}
					}
				}
			} else if (share_with != nullptr && share_attr != 0) {
				share_with->m_Shared.AddCond(TF_COND_INVULNERABLE_USER_BUFF,
					duration);
				did_share = true;
			}
		} else {
			player->m_Shared.RemoveCond(TF_COND_INVULNERABLE_USER_BUFF, true);
		}
	}
	
	if (CAttributeManager::AttribHookValue<int>(0, "recall",
//.........这里部分代码省略.........
开发者ID:Msalinas2877,项目名称:mvm-reversed,代码行数:101,代码来源:tf_item_powerup_bottle.cpp


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