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


C++ DYNAMIC_CAST函数代码示例

本文整理汇总了C++中DYNAMIC_CAST函数的典型用法代码示例。如果您正苦于以下问题:C++ DYNAMIC_CAST函数的具体用法?C++ DYNAMIC_CAST怎么用?C++ DYNAMIC_CAST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: AddItemHealthPercentOwner

TESForm * AddItemHealthPercentOwner(TESObjectREFR* thisObj, UInt32 refID, SInt32 NumItems, float Health, TESForm* pOwner, UInt32 Rank)
{
	if (!thisObj) return NULL;

	TESForm * pForm = LookupFormByID(refID);
	if (!pForm) return NULL;
	TESHealthForm* pHealth = DYNAMIC_CAST(pForm, TESForm, TESHealthForm);
	if (!pHealth && (Health != -1.0)) {
		_MESSAGE("\t\tInventoryInfo\t\tAddItemHealthPercentOwner:\tInvalid refID:%#10X, no health attribute", thisObj->refID);
		return NULL;
	}
	TESScriptableForm* pScript = DYNAMIC_CAST(pForm, TESForm, TESScriptableForm);
	if (pScript && !pScript->script) pScript = NULL;  // Only existing scripts matter

	ExtraHealth* pXHealth = NULL;
	ExtraOwnership* pXOwner = NULL;
	ExtraRank* pXRank = NULL;
	ExtraCount* pXCount = NULL;
	ExtraDataList* pExtraDataList = NULL;
	ExtraScript * pXScript = NULL;

	if (!(1.0 == Health) || pOwner || Rank || pScript) {
		pExtraDataList = ExtraDataList::Create();
		if (!(1.0 == Health)) {
			pXHealth = ExtraHealth::Create();
			if (!pExtraDataList->Add(pXHealth))
				FormHeap_Free(pXHealth);
			else
				pXHealth->health = pHealth->GetHealth() * Health;
		}
		if (pOwner) {
			pXOwner = ExtraOwnership::Create();
			if (!pExtraDataList->Add(pXOwner))
				FormHeap_Free(pXOwner);
			else
				pXOwner->owner = pOwner;
		}
		if (Rank) {
			pXRank = ExtraRank::Create();
			if (!pExtraDataList->Add(pXRank))
				FormHeap_Free(pXRank);
			else
				pXRank->rank = Rank;
		}
		if (pScript) {
			pXScript = ExtraScript::Create(pForm, true);
			if (!pExtraDataList->Add(pXScript))
				FormHeap_Free(pXScript);
		}
	}
	thisObj->AddItem(pForm, pExtraDataList, NumItems);
	return pForm;
}
开发者ID:Alenett,项目名称:TES-Reloaded-Source,代码行数:53,代码来源:InventoryInfo.cpp

示例2: SetGoldValue

	void SetGoldValue(TESForm* thisForm, UInt32 value)
	{
		if (!thisForm)
			return;
		TESValueForm* pValue = DYNAMIC_CAST(thisForm, TESForm, TESValueForm);
		if (pValue)
			pValue->value = value;
		else {
			AlchemyItem* alchemyItem = DYNAMIC_CAST(thisForm, TESForm, AlchemyItem);
			if(alchemyItem && (alchemyItem->itemData.flags & AlchemyItem::kFlag_ManualCalc) == AlchemyItem::kFlag_ManualCalc)
				alchemyItem->itemData.value = value;
		}
	}
开发者ID:NecroReindeer,项目名称:comp140-api-hacking,代码行数:13,代码来源:PapyrusForm.cpp

示例3: isMacroApplication

static const malLambda* isMacroApplication(malValuePtr obj, malEnvPtr env)
{
    if (const malSequence* seq = isPair(obj)) {
        if (malSymbol* sym = DYNAMIC_CAST(malSymbol, seq->first())) {
            if (malEnvPtr symEnv = env->find(sym->value())) {
                malValuePtr value = sym->eval(symEnv);
                if (malLambda* lambda = DYNAMIC_CAST(malLambda, value)) {
                    return lambda->isMacro() ? lambda : NULL;
                }
            }
        }
    }
    return NULL;
}
开发者ID:1989tianlong,项目名称:mal,代码行数:14,代码来源:stepA_mal.cpp

示例4: GetValue

	UInt32 GetValue(TESForm* thisForm)
	{
		if (!thisForm)
			return 0;
		TESValueForm* pValue = DYNAMIC_CAST(thisForm, TESForm, TESValueForm);
		if (pValue)
			return pValue->value;
		else {
			AlchemyItem* alchemyItem = DYNAMIC_CAST(thisForm, TESForm, AlchemyItem);
			if(alchemyItem && (alchemyItem->itemData.flags & AlchemyItem::kFlag_ManualCalc) == AlchemyItem::kFlag_ManualCalc)
				return alchemyItem->itemData.value;
		}
		return 0;
	}
开发者ID:NecroReindeer,项目名称:comp140-api-hacking,代码行数:14,代码来源:PapyrusForm.cpp

示例5: getActiveDisplays

	VMResultArray<TESObjectREFR*> getActiveDisplays(StaticFunctionTag*, BSFixedString characterName)
	{
		VMResultArray<TESObjectREFR*> results;
		Json::Value jsonDisplayList = ReadDisplayData();

		for (auto & jsonDisplay : jsonDisplayList.getMemberNames()) 
		{
			TESObjectREFR* displayObj = DYNAMIC_CAST(GetJCStringForm(jsonDisplay), TESForm, TESObjectREFR);
			
			if (strlen(characterName.data))
			{
				for (auto & contributor : jsonDisplayList[jsonDisplay.c_str()]["contributors"])
				{
					if (contributor.asString() == characterName.data)
						results.push_back(displayObj);
				}
			} 
			else 
			{
				results.push_back(displayObj);
			}
		}
		
		return results;
	}
开发者ID:Verteiron,项目名称:PersistentLegacy,代码行数:25,代码来源:PapyrusDBM_Utils.cpp

示例6: DYNAMIC_CAST

	void ShootingAttacker::AimAndShoot()
	{
		auto settings = DYNAMIC_CAST(m_Settings, ShootingAttackerSettings);

		// aim
		Vector3 vPosition = GetAbsolutePosition();
		Vector3 vAimDirection = (m_ShootTarget->GetAbsolutePosition() - vPosition).Normalize();		
		m_vLookAt = Math::Damp(m_vLookAt, vAimDirection, g_fDeltaTime, settings->m_fLookAtDuration);
		LookAt(m_vLookAt);

		// shoot
		if(m_fShootTimer < 0.0f)
		{
			Bullet::BulletParams params;
			Vector3 vBulletLocalPos = GetRotationMatrix().TransformVect(m_vBulletOffset);

			params.vPosition = vPosition + vBulletLocalPos;
			params.vDirection = vAimDirection;
			params.fSpeed = m_fBulletSpeed;
			params.fLife = m_fBulletLife;
			params.fRadius = m_fBulletSize/2.0f;
			params.damage = settings->m_fBulletDamage;

			SFXMGR->GetEnemyPulseManager()->AddBullet(params);
			AUDIOMGR->Play(AudioManager::S_EnemyPulse);

			m_fShootTimer = m_fBulletFrequency;
		}

		m_fShootTimer -= g_fDeltaTime;
	}	
开发者ID:aminere,项目名称:StarportsPublic,代码行数:31,代码来源:ShootingAttacker.cpp

示例7: HasItemAbility

	bool HasItemAbility(Actor * actor, TESForm* baseForm, BaseExtraList * extraData)
	{
		if(actor && baseForm) {
			tList<ActiveEffect> * effects = actor->magicTarget.GetActiveEffects();
			for(UInt32 i = 0; i < effects->Count(); i++) {
				ActiveEffect* effect = effects->GetNthItem(i);
				if(effect->sourceItem == baseForm) { // Check the item
					EnchantmentItem * enchantment = NULL;
					TESEnchantableForm * enchantable = DYNAMIC_CAST(baseForm, TESForm, TESEnchantableForm);
					if(enchantable) { // Check the item for a base enchantment
						enchantment = enchantable->enchantment;
					}
					if(extraData) { // Check the extra data for enchantment
						ExtraEnchantment* extraEnchant = static_cast<ExtraEnchantment*>(extraData->GetByType(kExtraData_Enchantment));
						if(extraEnchant) {
							enchantment = extraEnchant->enchant;
						}
					}

					if(effect->item == enchantment) {
						return true;
					}
				}
			}
		}

		return false;
	}
开发者ID:NecroReindeer,项目名称:comp140-api-hacking,代码行数:28,代码来源:PapyrusWornObject.cpp

示例8: Cmd_SetPackageTargetReference_Execute

bool Cmd_SetPackageTargetReference_Execute(COMMAND_ARGS)
{
	*result = 0;

	//DEBUG_MESSAGE("\t\tSPT @\n");
	TESObjectREFR* pRefr = NULL;
	TESForm * pForm = NULL;
	TESPackage* pPackage = NULL;
	ExtractArgs(EXTRACT_ARGS, &pForm, &pRefr);
	if (!pRefr)
		if(!thisObj)
			return true;
		else
			pRefr = thisObj;
	//DEBUG_MESSAGE("\t\tSPT 0 Refr:[%08X]\n", pRefr->refID);
	if (!pForm)
			return true;
	//DEBUG_MESSAGE("\t\tSPT 1 Form:0x%x Refr:[%08X]\n", pForm, pRefr->refID);
	pPackage = DYNAMIC_CAST(pForm, TESForm, TESPackage);
	//DEBUG_MESSAGE("\t\tSPT 2 Package:0x%x Refr:[%08X]\n", pPackage, pRefr->refID);
	if (pPackage) {
		//if (pPackage->target)
		//	DEBUG_MESSAGE("target is %s", pPackage->target->StringForTargetCodeAndData());
		//DEBUG_MESSAGE("\t\tSPT 3 Package:[%08X] Refr:[%08X] Target:0x%x\n", pPackage->refID, pRefr->refID, pPackage->target);
		pPackage->SetTarget(pRefr);
		//DEBUG_MESSAGE("\t\tSPT 4 Package:[%08X] Refr:[%08X] Target:0x%x\n", pPackage->refID, pRefr->refID, pPackage->target);
		//if (pPackage->target)
		//	DEBUG_MESSAGE("target is %s", pPackage->target->StringForTargetCodeAndData());
	}
	return true;
}
开发者ID:Alenett,项目名称:TES-Reloaded-Source,代码行数:31,代码来源:Commands_Packages.cpp

示例9: Cmd_GetPackageLocation_Execute

bool Cmd_GetPackageLocation_Execute(COMMAND_ARGS)
{
	*result = 0;
	UInt32* refResult = (UInt32*)result;
	*refResult = 0;

	//DEBUG_MESSAGE("\t\tSPL @\n");
	TESForm * pForm = NULL;
	TESPackage* pPackage = NULL;
	ExtractArgs(EXTRACT_ARGS, &pForm);
	if (!pForm)
		return true;
	//DEBUG_MESSAGE("\t\tGPL 1 Package:[%x]\n", pForm);
	pPackage = DYNAMIC_CAST(pForm, TESForm, TESPackage);
	//DEBUG_MESSAGE("\t\tGPL 2 Package:[%x]\n", pPackage);
	if (pPackage && pPackage->location) {
		//DEBUG_MESSAGE("\t\tGPL 3 Package:%x\n", pPackage->refID);
		TESPackage::LocationData * pLocation = pPackage->GetLocationData();
		//DEBUG_MESSAGE("\t\GSPL 4 Package:%x Location:[%x]\n", pPackage->refID, pLocation);
		if (pLocation && pLocation->object.form)
			switch (pLocation->locationType) {
				case TESPackage::LocationData::kPackLocation_NearReference:
				case TESPackage::LocationData::kPackLocation_InCell:
				case TESPackage::LocationData::kPackLocation_ObjectID:
					*refResult = pLocation->object.form->refID;
					break;
				case TESPackage::LocationData::kPackLocation_ObjectType:
					*refResult = pLocation->object.objectCode;
					break;
		}

			//DEBUG_MESSAGE("\t\tSPL 5 Package:%x Location:[%x]\n", pPackage->refID, *refResult);
	}
	return true;
}
开发者ID:Alenett,项目名称:TES-Reloaded-Source,代码行数:35,代码来源:Commands_Packages.cpp

示例10: Cmd_SetTexturePath_Execute

bool Cmd_SetTexturePath_Execute(COMMAND_ARGS)
{
	*result = 0;
	ExpressionEvaluator eval(PASS_COMMAND_ARGS);
	if (eval.ExtractArgs() && eval.NumArgs() > 0) {
		TESForm* form = NULL;
		if (eval.NumArgs() == 2) {
			form = eval.Arg(1)->GetTESForm();
		}
		else if (thisObj) {
			form = thisObj->baseForm;
		}

		TESTexture* tex = DYNAMIC_CAST(form, TESForm, TESTexture);
		if (tex) {
			const char* nuPath = eval.Arg(0)->GetString();
			if (nuPath) {
				tex->ddsPath.Set(nuPath);
				*result = 1;
			}
		}
	}

	return true;
}
开发者ID:Alenett,项目名称:TES-Reloaded-Source,代码行数:25,代码来源:Commands_String.cpp

示例11: DYNAMIC_CAST

void TESObjectARMA::GetNodeName(char * dstBuff, TESObjectREFR * refr, TESObjectARMO * armor, float weightOverride)
{
	float weight = 100.0;
	TESNPC * npc = DYNAMIC_CAST(refr->baseForm, TESForm, TESNPC);
	if(npc && npc->nextTemplate) {
		TESNPC * temp = npc->GetRootTemplate();
		if(temp) {
			weight = temp->weight;
		}
	}
	else
		weight = CALL_MEMBER_FN(refr, GetWeight)();

	weight /= 100.0;
	if(weightOverride >= 0.0) // Determines whether to factor weight into the name, -1 true, 1 false
		weight = weightOverride;

	weight *= 100.0;
	
	UInt32 sex = npc ? CALL_MEMBER_FN(npc, GetSex)() : 0;
	/*sprintf_s(dstBuff, MAX_PATH, "%s (%08X)[%d]/%s (%08X) [%2.0f%%]", 
		this->Unk_32(), // I really have no idea why they used a string here for a boolean value, probably legacy code
		this->formID,
		sex,
		armor->Unk_32(), 
		armor->formID, 
		weight);*/
	sprintf_s(dstBuff, MAX_PATH, " (%08X)[%d]/ (%08X) [%2.0f%%]", 
		this->formID,
		sex,
		armor->formID, 
		weight);
}
开发者ID:RealAntithesis,项目名称:JContainers,代码行数:33,代码来源:GameObjects.cpp

示例12: IsValidEntry

	bool IsValidEntry(TESContainer::Entry* pEntry, SInt32& numObjects)
	{
		if (pEntry) {
			numObjects = pEntry->count;
			TESForm* pForm = pEntry->form;

			if (DYNAMIC_CAST(pForm, TESForm, TESLevItem))
				return false;

			ExtraContainerMap::iterator it = m_map.find(pForm);
			ExtraContainerMap::iterator itEnd = m_map.end();
			if (it != itEnd) {
				UInt32 index = it->second;
				ExtraContainerChanges::EntryData* pXData = m_vec[index];
				if (pXData) {
					numObjects += pXData->countDelta;
				}
				// clear the object from the vector so we don't bother to look for it
				// in the second step
				m_vec[index] = NULL;
			}

			if (numObjects > 0) {
				//if (IsConsoleMode()) {
				//	PrintItemType(pForm);
				//}
				return true;
			}
		}
		return false;
	}
开发者ID:NecroReindeer,项目名称:comp140-api-hacking,代码行数:31,代码来源:PapyrusObjectReference.cpp

示例13: GetNumItems

	UInt32 GetNumItems(TESObjectREFR* pContainerRef)
	{
		if (!pContainerRef)
			return 0;

		TESContainer* pContainer = NULL;
		TESForm* pBaseForm = pContainerRef->baseForm;
		if (pBaseForm) {
			pContainer = DYNAMIC_CAST(pBaseForm, TESForm, TESContainer);
		}
		if (!pContainer)
			return 0;

		UInt32 count = 0;
			
		ExtraContainerChanges* pXContainerChanges = static_cast<ExtraContainerChanges*>(pContainerRef->extraData.GetByType(kExtraData_ContainerChanges));
		ExtraContainerInfo info(pXContainerChanges ? pXContainerChanges->data->objList : NULL);


		// first walk the base container
		if (pContainer) {
			ContainerCountIf counter(info);
			count = pContainer->CountIf(counter);
		}

		// now count the remaining items
		count += info.CountItems();

		return count;
	}
开发者ID:NecroReindeer,项目名称:comp140-api-hacking,代码行数:30,代码来源:PapyrusObjectReference.cpp

示例14: SHOOT_ASSERT

	//! visits a particular entity
	void ParticleVisitor::Visit(Entity* pTarget)
	{
		SHOOT_ASSERT(pTarget->IsA(ParticleGenerator::TypeID), "ParticleVisitor target is not of type ParticleGenerator");
		if(ParticleGenerator* pEmitter = DYNAMIC_CAST(pTarget, ParticleGenerator))		
			pEmitter->SetActive(m_bEmitterActive);
		super::Visit(pTarget);		
	}	
开发者ID:aminere,项目名称:StarportsPublic,代码行数:8,代码来源:ParticleVisitor.cpp

示例15: Cmd_GetCurrentPackage_Execute

bool Cmd_GetCurrentPackage_Execute(COMMAND_ARGS)
{
	*result = 0;
	UInt32* refResult = (UInt32*)result;
	*refResult = 0;

	//DEBUG_MESSAGE("\t\tGCP @\n");
	TESObjectREFR* pRefr = NULL;
	Actor * pActor = NULL;
	TESPackage* pPackage = NULL;
	ExtractArgs(EXTRACT_ARGS, &pRefr);
	if (!pRefr)
		if(!thisObj)
			return true;
		else
			pRefr = thisObj;
	//DEBUG_MESSAGE("\t\tGCP 0 Refr:%x\n", pRefr->refID);
	pActor = DYNAMIC_CAST(pRefr, TESObjectREFR, Actor);
	if (!pActor || !pActor->baseProcess)
			return true;
	//DEBUG_MESSAGE("\t\tGCP 1 Package:[%x] Refr:%x\n", pForm, pRefr->refID);
	pPackage = pActor->baseProcess->GetCurrentPackage();
	//DEBUG_MESSAGE("\t\tGCP 2 Package:[%x] Refr:%x\n", pPackage, pRefr->refID);
	if (pPackage) {
		*refResult = pPackage->refID;
		//DEBUG_MESSAGE("\t\tGCP 3 Package:%x  Refr:%x\n", *refResult, pRefr->refID);
	}
	if (IsConsoleMode())
		Console_Print("GetCurrentPackage >> [%08X] ", *result);
	return true;
}
开发者ID:Alenett,项目名称:TES-Reloaded-Source,代码行数:31,代码来源:Commands_Packages.cpp


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