本文整理汇总了C++中IAttachment::ClearBinding方法的典型用法代码示例。如果您正苦于以下问题:C++ IAttachment::ClearBinding方法的具体用法?C++ IAttachment::ClearBinding怎么用?C++ IAttachment::ClearBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAttachment
的用法示例。
在下文中一共展示了IAttachment::ClearBinding方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DetachEffect
void CEffectsController::DetachEffect(const TAttachedEffectId effectId)
{
CRY_ASSERT(m_pOwnerEntity);
TAttachedEffects::iterator effectIt = std::find(m_attachedEffects.begin(), m_attachedEffects.end(), effectId);
if (effectIt != m_attachedEffects.end())
{
const SEffectInfo& effectInfo = *effectIt;
if (effectInfo.entityEffectSlot >= 0)
{
m_pOwnerEntity->FreeSlot(effectInfo.entityEffectSlot);
}
else
{
ICharacterInstance *pCharacter = m_pOwnerEntity->GetCharacter(effectInfo.characterEffectSlot);
if (pCharacter)
{
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(effectInfo.helperName.c_str());
if(pAttachment)
{
pAttachment->ClearBinding();
}
}
}
m_attachedEffects.erase(effectIt);
}
}
示例2: AboutToBeRemoved
void CAICorpse::AboutToBeRemoved()
{
IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
ICharacterInstance* pCharacter = GetEntity()->GetCharacter(0);
IAttachmentManager* pAttachmentManager = (pCharacter != NULL) ? pCharacter->GetIAttachmentManager() : NULL;
for (uint32 i = 0; i < (uint32)m_attachedItemsInfo.size(); ++i)
{
AttachedItem& attachedItem = m_attachedItemsInfo[i];
IItem* pItem = pItemSystem->GetItem( attachedItem.id );
if((pItem != NULL) && ShouldDropOnCorpseRemoval( pItem->GetEntity()->GetClass() ))
{
IAttachment* pAttachment = (pAttachmentManager != NULL) ? pAttachmentManager->GetInterfaceByName( attachedItem.attachmentName.c_str() ) : NULL;
if(pAttachment != NULL)
{
pAttachment->ClearBinding();
}
pItem->Drop( 1.0f, false, true );
pItem->GetEntity()->SetFlags( pItem->GetEntity()->GetFlags() & ~ENTITY_FLAG_NO_SAVE );
attachedItem.id = 0;
}
}
}
示例3: DetachObject
void DetachObject(SActivationInfo *pActInfo)
{
IAttachment *pAttachment = GetAttachment(pActInfo);
if (pAttachment)
{
pAttachment->ClearBinding();
ActivateOutput(pActInfo, eOP_Detached, 0);
}
}
示例4: OnEntityEvent
void OnEntityEvent( IEntity* pEntity, SEntityEvent& event )
{
if (event.event==m_event)
{
if (m_pNewAttachment)
{
m_pNewAttachment->ClearBinding();
}
}
}
示例5: Leave
void CKVoltEffect::Leave()
{
if(m_particleEmitter)
{
gEnv->pParticleManager->DeleteEmitter(m_particleEmitter);
m_particleEmitter->Release();
m_particleEmitter = NULL;
}
IAttachment* screenAttachment = GetScreenAttachment();
if(screenAttachment)
{
screenAttachment->ClearBinding();
}
}
示例6: ResetCharacterAttachment
//------------------------------------------------------------------------
void CItem::ResetCharacterAttachment(int slot, const char *name)
{
ICharacterInstance *pCharacter = GetEntity()->GetCharacter(slot);
if (!pCharacter)
return;
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(name);
if (!pAttachment)
{
GameWarning("Item '%s' trying to reset attachment '%s' which does not exist!", GetEntity()->GetName(), name);
return;
}
pAttachment->ClearBinding();
}
示例7: ResetVulnerabilityEffects
//------------------------------------------------------------------------
int CScriptBind_Actor::ResetVulnerabilityEffects(IFunctionHandler *pH, int characterSlot)
{
CActor *pActor = GetActor(pH);
if (!pActor)
return pH->EndFunction();
IEntity* pEntity = pActor->GetEntity();
ICharacterInstance* pChar = pEntity->GetCharacter(characterSlot);
if (pChar)
{
IAttachmentManager* pMan = pChar->GetIAttachmentManager();
for (int i=0; i<pMan->GetAttachmentCount(); ++i)
{
IAttachment* pAtt = pMan->GetInterfaceByIndex(i);
if (strstr(pAtt->GetName(), "vulnerable"))
pAtt->ClearBinding();
}
}
return pH->EndFunction();
}
示例8: HandleEvent
void CAICorpse::HandleEvent( const SGameObjectEvent& gameObjectEvent )
{
if(gameObjectEvent.event == eCGE_ItemTakenFromCorpse)
{
assert(gameObjectEvent.param != NULL);
bool matchFound = false;
const EntityId itemId = *static_cast<const EntityId*>(gameObjectEvent.param);
for (uint32 i = 0; i < m_attachedItemsInfo.size(); ++i)
{
if(m_attachedItemsInfo[i].id == itemId)
{
ICharacterInstance* pCharacter = GetEntity()->GetCharacter(0);
if(pCharacter != NULL)
{
IAttachment* pAttachment = pCharacter->GetIAttachmentManager()->GetInterfaceByName( m_attachedItemsInfo[i].attachmentName.c_str() );
if(pAttachment != NULL)
{
pAttachment->ClearBinding();
}
}
m_attachedItemsInfo.removeAt(i);
matchFound = true;
break;
}
}
if(matchFound)
{
if(m_attachedItemsInfo.empty())
{
m_priority = 0; //Lower the priority once all attached items have been removed
}
}
}
}
示例9: 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--;
}
}
}
}
}
}
示例10: AttachLightEx
//.........这里部分代码省略.........
SEntitySlotInfo slotInfo;
SEffectInfo effectInfo;
effectInfo.slot = -1;
bool validSlot = GetEntity()->GetSlotInfo(slot, slotInfo) && (slotInfo.pCharacter || slotInfo.pStatObj);
if (!validSlot || slotInfo.pStatObj)
{
// get helper position
Vec3 position(0,0,0);
if (validSlot)
{
IStatObj *pStatsObj = slotInfo.pStatObj;
position = pStatsObj->GetHelperPos(helper);
position = GetEntity()->GetSlotLocalTM(slot, false).TransformPoint(position);
}
position+=offset;
// find a free slot
SEntitySlotInfo dummy;
int i=0;
while (GetEntity()->GetSlotInfo(eIGS_Last+i, dummy))
i++;
// move light slot to the helper position+offset
effectInfo.helper = helper;
effectInfo.slot = GetEntity()->LoadLight(eIGS_Last+i, &light);
if (effectInfo.slot != -1 && pMaterial)
GetEntity()->SetSlotMaterial(effectInfo.slot, pMaterial);
Matrix34 tm = Matrix34(Matrix33::CreateRotationVDir(dir));
tm.SetTranslation(position);
GetEntity()->SetSlotLocalTM(effectInfo.slot, tm);
}
else if (slotInfo.pCharacter) // bone attachment
{
effectInfo.helper = helper;
effectInfo.characterSlot = slot;
ICharacterInstance *pCharacter = slotInfo.pCharacter;
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helper);
if (!pAttachment)
{
GameWarning("Item '%s' trying to attach light to attachment '%s' which does not exist!", GetEntity()->GetName(), helper);
return 0;
}
CLightAttachment *pLightAttachment = new CLightAttachment();
pLightAttachment->LoadLight(light);
if (pMaterial)
{
if (ILightSource* pLightSource = pLightAttachment->GetLightSource())
pLightSource->SetMaterial(pMaterial);
}
if(light.m_Flags&DLF_CASTSHADOW_MAPS)
{
if (ILightSource* pLightSource = pLightAttachment->GetLightSource())
pLightSource->SetCastingException(pCasterException);
}
Matrix34 tm =Matrix34(Matrix33::CreateRotationVDir(dir));
tm.SetTranslation(offset);
pAttachment->AddBinding(pLightAttachment);
pAttachment->SetAttRelativeDefault(QuatT(tm));
}
m_effects.insert(TEffectInfoMap::value_type(m_effectGenId, effectInfo));
return m_effectGenId;
}
else if (id)
{
TEffectInfoMap::iterator it = m_effects.find(id);
if (it == m_effects.end())
return 0;
SEffectInfo &info = it->second;
if (info.slot>-1)
{
GetEntity()->FreeSlot(info.slot);
}
else
{
ICharacterInstance *pCharacter = GetEntity()->GetCharacter(info.characterSlot);
if (pCharacter)
{
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(info.helper.c_str());
pAttachment->ClearBinding();
}
}
m_effects.erase(it);
}
return 0;
}
示例11: AttachEffect
//------------------------------------------------------------------------
uint32 CItem::AttachEffect(int slot, uint32 id, bool attach, const char *effectName, const char *helper, const Vec3 &offset, const Vec3 &dir, float scale, bool prime)
{
if (m_stats.mounted)
slot=eIGS_FirstPerson;
if (attach)
{
if (!g_pGameCVars->i_particleeffects)
return 0;
IParticleEffect *pParticleEffect = gEnv->pParticleManager->FindEffect(effectName);
if (!pParticleEffect)
return 0;
// generate id
++m_effectGenId;
while (!m_effectGenId || (m_effects.find(m_effectGenId) != m_effects.end()))
++m_effectGenId;
SEntitySlotInfo slotInfo;
SEffectInfo effectInfo;
bool validSlot = GetEntity()->GetSlotInfo(slot, slotInfo) && (slotInfo.pCharacter || slotInfo.pStatObj);
if (!validSlot || slotInfo.pStatObj || (!helper || !helper[0]))
{
// get helper position
Vec3 position(0,0,0);
if (validSlot && helper && helper[0])
{
IStatObj *pStatsObj = slotInfo.pStatObj;
position = pStatsObj->GetHelperPos(helper);
position = GetEntity()->GetSlotLocalTM(slot, false).TransformPoint(position);
}
position+=offset;
// find a free slot
SEntitySlotInfo dummy;
int i=0;
while (GetEntity()->GetSlotInfo(eIGS_Last+i, dummy))
i++;
// move particle slot to the helper position+offset
effectInfo.helper = helper;
effectInfo.slot = GetEntity()->LoadParticleEmitter(eIGS_Last+i, pParticleEffect, 0, prime, true);
Matrix34 tm = IParticleEffect::ParticleLoc(position, dir, scale);
GetEntity()->SetSlotLocalTM(effectInfo.slot, tm);
}
else if (slotInfo.pCharacter) // bone attachment
{
effectInfo.helper = helper;
effectInfo.characterSlot = slot;
ICharacterInstance *pCharacter = slotInfo.pCharacter;
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helper);
if (!pAttachment)
{
GameWarning("Item '%s' trying to attach effect '%s' to attachment '%s' which does not exist!", GetEntity()->GetName(), effectName, helper);
return 0;
}
CEffectAttachment *pEffectAttachment = new CEffectAttachment(effectName, Vec3(0,0,0), Vec3(0,1,0), scale);
Matrix34 tm = Matrix34(Matrix33::CreateRotationVDir(dir));
tm.SetTranslation(offset);
pAttachment->AddBinding(pEffectAttachment);
pAttachment->SetAttRelativeDefault(QuatT(tm));
pEffectAttachment->UpdateAttachment(pAttachment);
if (pEffectAttachment->GetEmitter())
{
if (prime)
pEffectAttachment->GetEmitter()->Prime();
}
}
m_effects.insert(TEffectInfoMap::value_type(m_effectGenId, effectInfo));
return m_effectGenId;
}
else if (id)
{
TEffectInfoMap::iterator it = m_effects.find(id);
if (it == m_effects.end())
return 0;
SEffectInfo &info = it->second;
if (info.slot>-1)
{
GetEntity()->FreeSlot(info.slot);
}
else
{
ICharacterInstance *pCharacter = GetEntity()->GetCharacter(info.characterSlot);
if (pCharacter)
{
IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(info.helper.c_str());
if(pAttachment)
pAttachment->ClearBinding();
}
//.........这里部分代码省略.........
示例12: 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;
}