Esempio n. 1
0
//newWep should be either 'Rifle','Pistol' or 'None'
void EnemyCharacter::_actionChangeWeapon(const std::string& newWep)
{
	if(_currentWeapon.node != nullptr)
	{
		if(_currentWeapon.node->getAttachedObject(0) == nullptr)
		{
			//re-add the gun entity back to the original node.
			Ogre::Entity* characterEntity = static_cast<Ogre::Entity*>(_movableObject);
			Ogre::MovableObject* attachedWeap = characterEntity->detachObjectFromBone(_currentWeapon.weapon->_getGunNameString());
			_currentWeapon.node->attachObject(attachedWeap);
		}
	}

	//switch the _currentWeapon
	if(newWep == "Rifle"){ _currentWeapon = _weaponRifle; }
	if(newWep == "Pistol") { _currentWeapon = _weaponPistol; }
	if(newWep == "None") { _currentWeapon.node = nullptr; _currentWeapon.weapon = nullptr; }

	if(_currentWeapon.node != nullptr)
	{
		Ogre::MovableObject* unattachedWeap = _currentWeapon.node->detachObject(static_cast<unsigned short>(0));
		static_cast<Ogre::Entity*>(_movableObject)->attachObjectToBone("FIRESPOT",unattachedWeap);
	}
	
}
Esempio n. 2
0
void EC_Mesh::DetachMeshFromBone()
{
    if ((!entity_) || (!attached_to_bone_) || (!bone_parent_mesh_))
        return;
    
    Ogre::Entity* targetEntity = bone_parent_mesh_->GetEntity();
    if (targetEntity)
        targetEntity->detachObjectFromBone(entity_);
    else
        return;
    
    bone_parent_mesh_->bone_attached_mesh_ = 0;
    bone_parent_mesh_ = 0;
    attached_to_bone_ = false;
    bone_tagpoint_ = 0;
    
    // Reattach entity to normal placeable
    AttachEntity();
}