本文整理汇总了C++中IAttachment::GetIAttachmentObject方法的典型用法代码示例。如果您正苦于以下问题:C++ IAttachment::GetIAttachmentObject方法的具体用法?C++ IAttachment::GetIAttachmentObject怎么用?C++ IAttachment::GetIAttachmentObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttachment
的用法示例。
在下文中一共展示了IAttachment::GetIAttachmentObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMaterialOnEntity
//--------------------------------------------------------------------------------------------------
// Name: SetMaterialOnEntity
// Desc: Sets material on entity
//--------------------------------------------------------------------------------------------------
void CGameEffect::SetMaterialOnEntity(IMaterial* pMaterial,EntityId entityId,PodArray<ItemString>* bodyAttachmentNameArray)
{
if(pMaterial && bodyAttachmentNameArray)
{
IEntity* pEntity = gEnv->pEntitySystem->GetEntity(entityId);
if(pEntity)
{
SEntitySlotInfo slotInfo;
bool gotSlotInfo = pEntity->GetSlotInfo(0, slotInfo);
if(gotSlotInfo && slotInfo.pCharacter)
{
IAttachmentManager* pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
if(pAttachmentManager)
{
int attachmentCount = bodyAttachmentNameArray->size();
for(int i=0; i<attachmentCount; i++)
{
IAttachment* attachment = pAttachmentManager->GetInterfaceByName(((*bodyAttachmentNameArray)[i]).c_str());
if(attachment)
{
IAttachmentObject* attachmentObj = attachment->GetIAttachmentObject();
if(attachmentObj)
{
attachmentObj->SetReplacementMaterial(pMaterial);
}
}
}
}
}
}
}
}//-------------------------------------------------------------------------------------------------
示例2: PickStowSlot
int PickStowSlot(IAttachmentManager *pAttachmentManager, const char *slot1, const char *slot2)
{
int ret = -1;
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(slot1);
if(pAttachment && !pAttachment->GetIAttachmentObject())
{
ret = 0;
}
else
{
pAttachment = pAttachmentManager->GetInterfaceByName(slot2);
if(pAttachment && !pAttachment->GetIAttachmentObject())
{
ret = 1;
}
}
return ret;
}
示例3: UnHideAttachment
void UnHideAttachment(SActivationInfo* pActInfo)
{
IAttachment* pAttachment = GetAttachment(pActInfo);
if(pAttachment)
{
pAttachment->HideAttachment(0);
IAttachmentObject* pAttachmentObject = pAttachment->GetIAttachmentObject();
if((pAttachmentObject != NULL) && (pAttachmentObject->GetAttachmentType() == IAttachmentObject::eAttachment_Entity))
{
IEntity* pAttachedEntity = gEnv->pEntitySystem->GetEntity( static_cast<CEntityAttachment*>(pAttachmentObject)->GetEntityId() );
if(pAttachedEntity)
{
pAttachedEntity->Hide(false);
}
}
}
}
示例4: EnableDebugAnimText
void CVar::EnableDebugAnimText(IConsoleCmdArgs *args)
{
if (args && args->GetArgCount() > 1)
{
const char* szFilterName = args->GetArg(1);
bool enable = true;
if (args->GetArgCount() > 2)
{
enable = (strcmp(args->GetArg(2), "0") != 0);
}
CEntitySystem* pEntitySystem = GetIEntitySystem();
IEntity *entity = pEntitySystem->FindEntityByName(szFilterName);
if (entity)
{
uint32 numSlots = entity->GetSlotCount();
for (uint32 i=0; i<numSlots; i++)
{
ICharacterInstance *charInst = entity->GetCharacter(i);
if (charInst)
{
charInst->GetISkeletonAnim()->SetDebugging(enable);
IAttachmentManager* pAttachmentManager = charInst->GetIAttachmentManager();
for(int32 attachmentIndex=0; attachmentIndex<pAttachmentManager->GetAttachmentCount(); ++attachmentIndex)
{
IAttachment* pAttachment = pAttachmentManager->GetInterfaceByIndex(attachmentIndex);
assert(pAttachment);
IAttachmentObject* pObject = pAttachment->GetIAttachmentObject();
if (pObject)
{
ICharacterInstance* pObjectCharInst = pObject->GetICharacterInstance();
if (pObjectCharInst)
{
pObjectCharInst->GetISkeletonAnim()->SetDebugging(enable);
}
}
}
}
}
}
}
}
示例5: GetLightSource
ILightSource* CEffectsController::GetLightSource(const TAttachedEffectId effectId) const
{
CRY_ASSERT(m_pOwnerEntity);
TAttachedEffects::const_iterator effectCit = std::find(m_attachedEffects.begin(), m_attachedEffects.end(), effectId);
if (effectCit != m_attachedEffects.end())
{
const SEffectInfo &effectInfo = *effectCit;
if (effectInfo.entityEffectSlot >= 0)
{
SEntitySlotInfo slotInfo;
if(m_pOwnerEntity->GetSlotInfo(effectInfo.entityEffectSlot, slotInfo) && slotInfo.pLight)
{
return slotInfo.pLight;
}
}
if (effectInfo.characterEffectSlot >= 0)
{
SEntitySlotInfo slotInfo;
if (m_pOwnerEntity->GetSlotInfo(effectInfo.characterEffectSlot, slotInfo) && slotInfo.pCharacter)
{
IAttachmentManager *pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(effectInfo.helperName.c_str());
if (pAttachment)
{
IAttachmentObject *pAttachmentObject = pAttachment->GetIAttachmentObject();
if (pAttachmentObject != NULL && (pAttachmentObject->GetAttachmentType() == IAttachmentObject::eAttachment_Light))
{
return static_cast<CLightAttachment *>(pAttachmentObject)->GetLightSource();
}
}
}
}
}
return NULL;
}
示例6: SetLightRadius
//------------------------------------------------------------------------
void CItem::SetLightRadius(float radius, uint32 id)
{
TEffectInfoMap::const_iterator it = m_effects.find(id);
if (it == m_effects.end())
return;
const SEffectInfo &info = it->second;
SEntitySlotInfo slotInfo;
ILightSource* pLightSource = 0;
if (info.slot != -1)
{
if (GetEntity()->GetSlotInfo(info.slot, slotInfo) && slotInfo.pLight)
pLightSource = static_cast<ILightSource*>(slotInfo.pLight);
}
else if (info.characterSlot != -1)
{
if (GetEntity()->GetSlotInfo(info.characterSlot, slotInfo) && slotInfo.pCharacter)
{
IAttachmentManager *pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(info.helper.c_str());
if (pAttachment)
{
CLightAttachment *pLightAttachment = static_cast<CLightAttachment *>(pAttachment->GetIAttachmentObject());
if (pLightAttachment)
pLightSource = pLightAttachment->GetLightSource();
}
}
}
if (pLightSource)
{
CDLight& light = pLightSource->GetLightProperties();
light.m_fRadius = radius;
pLightSource->SetLightProperties(light);
}
}
示例7: UpdateStowedWeapons
void CHandGrenades::UpdateStowedWeapons()
{
CActor *pOwnerActor = GetOwnerActor();
if (!pOwnerActor)
return;
ICharacterInstance *pOwnerCharacter = pOwnerActor->GetEntity()->GetCharacter(0);
if (!pOwnerCharacter)
return;
IStatObj *pTPObj = GetEntity()->GetStatObj(eIGS_ThirdPerson);
if (!pTPObj)
return;
int ammoCount = m_fm ? pOwnerActor->GetInventory()->GetAmmoCount(m_fm->GetAmmoType()) : 0;
if (IsSelected() && (ammoCount > 0))
{
ammoCount--;
}
if (!pOwnerActor->IsThirdPerson())
{
ammoCount = 0;
}
int numGrenDiff = ammoCount - m_numStowedCopies;
if(numGrenDiff != 0)
{
if (m_stowSlot < 0)
{
m_stowSlot = PickStowSlot(pOwnerCharacter->GetIAttachmentManager(), m_sharedparams->params.bone_attachment_01.c_str(), m_sharedparams->params.bone_attachment_02.c_str());
}
if (m_stowSlot >= 0)
{
bool attach = numGrenDiff > 0;
int tot = abs(numGrenDiff);
IAttachmentManager *pAttachmentManager = pOwnerCharacter->GetIAttachmentManager();
IAttachment *pAttachment = NULL;
for (int i=0; i<tot; i++)
{
//--- Generate the secondary slot from the first by adding one to the attachment name, is all we need at present...
const char *attach1 = (m_stowSlot == 0) ? m_sharedparams->params.bone_attachment_01.c_str() : m_sharedparams->params.bone_attachment_02.c_str();
int lenAttachName = strlen(attach1);
stack_string attach2(attach1, lenAttachName-1);
attach2 += (attach1[lenAttachName-1]+1);
if (attach)
{
pAttachment = pAttachmentManager->GetInterfaceByName(attach1);
if(pAttachment && pAttachment->GetIAttachmentObject())
{
pAttachment = pAttachmentManager->GetInterfaceByName(attach2);
}
if (pAttachment && !pAttachment->GetIAttachmentObject())
{
CCGFAttachment *pCGFAttachment = new CCGFAttachment();
pCGFAttachment->pObj = pTPObj;
pAttachment->AddBinding(pCGFAttachment);
pAttachment->HideAttachment(0);
pAttachment->HideInShadow(0);
m_numStowedCopies++;
}
}
else
{
pAttachment = pAttachmentManager->GetInterfaceByName(attach2);
if(!pAttachment || !pAttachment->GetIAttachmentObject())
{
pAttachment = pAttachmentManager->GetInterfaceByName(attach1);
}
if (pAttachment && pAttachment->GetIAttachmentObject())
{
pAttachment->ClearBinding();
m_numStowedCopies--;
}
}
}
}
}
}
示例8: GetEntity
//------------------------------------------------------------------------
bool CC4Projectile::StickToCharacter(bool stick,IEntity *pActor)
{
if(!pActor)
return false;
//Check for friendly AI
if(pActor->GetAI())
{
if(CWeapon *pWeapon = GetWeapon())
{
if(CActor *pPlayer = pWeapon->GetOwnerActor())
{
if(IAIObject *pPlayerAI = pPlayer->GetEntity()->GetAI())
{
if(pActor->GetAI()->IsFriendly(pPlayerAI, false))
{
return false;
}
}
}
}
}
ICharacterInstance *pCharacter = pActor->GetCharacter(0);
if(!pCharacter)
return false;
//Actors doesn't support constraints, try to stick as character attachment
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = NULL;
//Select one of the attachment points
Vec3 charOrientation = pActor->GetRotation().GetColumn1();
Vec3 c4ToChar = pActor->GetWorldPos() - GetEntity()->GetWorldPos();
c4ToChar.Normalize();
//if(c4ToChar.Dot(charOrientation)>0.0f)
//pAttachment = pAttachmentManager->GetInterfaceByName("c4_back");
//else
pAttachment = pAttachmentManager->GetInterfaceByName("c4_front");
if(!pAttachment)
{
GameWarning("No c4 face attachment found in actor");
if(!pAttachment)
return false;
}
if(stick)
{
//Check if there's already one
if(IAttachmentObject *pAO = pAttachment->GetIAttachmentObject())
return false;
CEntityAttachment *pEntityAttachment = new CEntityAttachment();
pEntityAttachment->SetEntityId(GetEntityId());
pAttachment->AddBinding(pEntityAttachment);
pAttachment->HideAttachment(0);
m_stuck = true;
}
else
{
pAttachment->ClearBinding();
m_stuck = false;
}
return true;
}
示例9: SetupFromSource
void CAICorpse::SetupFromSource( IEntity& sourceEntity, ICharacterInstance& characterInstance, const uint32 priority)
{
// 1.- Move resources from source entity, into AICorpse
GetEntity()->SetFlags(GetEntity()->GetFlags() | (ENTITY_FLAG_CASTSHADOW));
sourceEntity.MoveSlot(GetEntity(), 0);
// Moving everything from one slot into another will also clear the render proxies in the source.
// Thus, we need to invalidate the model so that it will be properly reloaded when a non-pooled
// entity is restored from a save-game.
CActor* sourceActor = static_cast<CActor*>(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(sourceEntity.GetId()));
if (sourceActor != NULL)
{
sourceActor->InvalidateCurrentModelName();
}
// 2.- After 'MoveSlot()', characterInstance is now stored inside CAICorpse
// It needs to be now updated from the entity system
characterInstance.SetFlags( characterInstance.GetFlags() | CS_FLAG_UPDATE );
#if AI_CORPSES_ENABLE_SERIALIZE
m_modelName = characterInstance.GetFilePath();
#endif
// 3.- Search for any attached weapon and clone them
IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
IAttachmentManager* pAttachmentManager = characterInstance.GetIAttachmentManager();
const uint32 attachmentCount = (uint32)pAttachmentManager->GetAttachmentCount();
for(uint32 i = 0; i < attachmentCount ; ++i)
{
IAttachment* pAttachment = pAttachmentManager->GetInterfaceByIndex(i);
assert(pAttachment != NULL);
IAttachmentObject* pAttachmentObject = pAttachment->GetIAttachmentObject();
if((pAttachmentObject == NULL) || (pAttachmentObject->GetAttachmentType() != IAttachmentObject::eAttachment_Entity))
continue;
const EntityId attachedEntityId = static_cast<CEntityAttachment*>(pAttachmentObject)->GetEntityId();
IItem* pItem = pItemSystem->GetItem(attachedEntityId);
if(pItem != NULL)
{
if(AllowCloneAttachedItem( pItem->GetEntity()->GetClass() ))
{
if(m_attachedItemsInfo.size() < m_attachedItemsInfo.max_size())
{
AttachedItem attachedItemInfo;
attachedItemInfo.pClass = pItem->GetEntity()->GetClass();
attachedItemInfo.attachmentName = pAttachment->GetName();
attachedItemInfo.id = CloneAttachedItem( attachedItemInfo, pAttachment );
m_attachedItemsInfo.push_back(attachedItemInfo);
}
}
}
}
//Only accept requested priority if it has attached weapons
m_priority = (m_attachedItemsInfo.size() > 0) ? priority : 0;
//Force physics to sleep immediately (if not already)
IPhysicalEntity* pCorpsePhysics = GetEntity()->GetPhysics();
if(pCorpsePhysics != NULL)
{
pe_action_awake awakeAction;
awakeAction.bAwake = 0;
pCorpsePhysics->Action( &awakeAction );
}
}