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


C++ IEntity::AttachChild方法代码示例

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


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

示例1: Open

//------------------------------------------------------------------------
void CParachute::Open()
{
    // not used any more
    return;

    IEntity* pCanvas = m_pEntitySystem->GetEntity(m_canvasId);

    // enable canvas physics
    EnablePhysics(pCanvas, true);

    if (!pCanvas->GetPhysics())
    {
        CryLog("[Parachute] Canvas physics enabling failed!");
        return;
    }

    // set canvas to players pos
    IEntity* pOwner = GetOwner();
    pCanvas->SetWorldTM(pOwner->GetWorldTM());
    pCanvas->AttachChild(pOwner);
    m_actorId = pOwner->GetId();

    // attach player to canvas
    GetOwnerActor()->LinkToVehicle(m_canvasId);

    m_isOpened = true;
    EnableUpdate(true, eIUS_General);

    pe_action_awake awake;
    awake.bAwake = true;
    pCanvas->GetPhysics()->Action(&awake);

    if (pOwner->GetPhysics())
    {
        pe_status_dynamics dyn;
        if (pOwner->GetPhysics()->GetStatus(&dyn))
        {
            // set parachute to player's speed
            pe_action_set_velocity vel;
            vel.v = 0.75f*dyn.v;
            pCanvas->GetPhysics()->Action(&vel);
        }
    }
}
开发者ID:RenEvo,项目名称:dead6,代码行数:45,代码来源:Parachute.cpp

示例2: OnReset

void CHeavyMountedWeapon::OnReset()
{
	BaseClass::OnReset();

	m_rippedOff = m_rippingOff = false;
	m_stats.mounted = true;
	m_rotatingSoundID = INVALID_SOUNDID;
	m_lastUsedFrame = -1;

	Physicalize(false, false);

	RequireUpdate(eIUS_General);

	if (m_linkedParentId != 0)
	{
		IEntity* pLinkedParent = gEnv->pEntitySystem->GetEntity(m_linkedParentId);
		if (pLinkedParent)
		{
			pLinkedParent->AttachChild(GetEntity());
		}
		m_linkedParentId = 0;
	}
}
开发者ID:Xydrel,项目名称:Infected,代码行数:23,代码来源:HeavyMountedWeapon.cpp

示例3: FixAttachment

void CLaserBeam::FixAttachment(IEntity* pLaserEntity)
{
	m_usingEntityAttachment = false;

	IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();
	CItem* pOwnerItem = static_cast<CItem*>(pItemSystem->GetItem(m_ownerEntityId));

	if (pOwnerItem)
	{
		IEntity* pOwnerEntity = pOwnerItem->GetEntity();
		IEntity* pAttachedEntity = pOwnerEntity;
		const char* attach_helper = "laser_term";

		Vec3 offset = pOwnerItem->GetSlotHelperPos(m_geometrySlot, attach_helper, false);

		if(m_geometrySlot == eIGS_FirstPerson)
		{
			if(pOwnerItem->IsAccessory())
			{
				EntityId parentId = pOwnerItem->GetParentId();

				if(parentId)
				{
					if(CItem* pParentItem = static_cast<CItem*>(pItemSystem->GetItem(parentId)))
					{
						const SAccessoryParams* pParams = pParentItem->GetAccessoryParams(pAttachedEntity->GetClass());

						attach_helper = pParams->attach_helper.c_str();
						pAttachedEntity = pParentItem->GetEntity();
					}
				}
			}

			if(pAttachedEntity)
			{
				ICharacterInstance *pCharacter = pAttachedEntity->GetCharacter(eIGS_FirstPerson);
				if (pCharacter)
				{
					IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();

					IAttachment *pLaserAttachment = pAttachmentManager->GetInterfaceByName(LASER_ATTACH_NAME);

					if(!pLaserAttachment)
					{
						IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(attach_helper);

						if(pAttachment)
						{
							const char* pBone = pCharacter->GetICharacterModel()->GetICharacterModelSkeleton()->GetJointNameByID(pAttachment->GetJointID());

							pLaserAttachment = pAttachmentManager->CreateAttachment(LASER_ATTACH_NAME, CA_BONE, pBone);

							if(pLaserAttachment)
							{
								QuatT relative = pAttachment->GetAttRelativeDefault();

								if(pOwnerItem->GetEntity() != pAttachedEntity)
								 {
									Matrix34 mtx(relative);
									relative.t = relative * offset;
								}

								pLaserAttachment->SetAttRelativeDefault(relative);
							}
						}
					}

					if(pLaserAttachment)
					{
						CEntityAttachment* pEntAttach = new CEntityAttachment;

						pEntAttach->SetEntityId(m_laserEntityId);
						pLaserAttachment->AddBinding(pEntAttach);
						pLaserAttachment->HideAttachment(0);

						m_usingEntityAttachment = true;
					}		
				}
			}
		}	

		if(!m_usingEntityAttachment && pOwnerEntity)
		{
			pOwnerEntity->AttachChild(pLaserEntity);
			pLaserEntity->SetLocalTM(Matrix34::CreateTranslationMat(offset));
		}
	}
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:88,代码来源:Laser.cpp


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