コード例 #1
0
ファイル: NounShip.cpp プロジェクト: BlackYoup/darkspace
void NounShip::initialize()
{
	NounBody::initialize();

	initializeGadgets();
	initializeEnhancements();
	initializeUnits();
	updateCharacter();

	m_nDynamicsTick = m_Tick;
	m_nIgnoreCollisionTick = m_Tick + INGORE_COLLISION_TIME;
	m_Signature = 0;
}
コード例 #2
0
ファイル: NounShip.cpp プロジェクト: BlackYoup/darkspace
bool NounShip::read( const InStream & input )
{
	if (! NounBody::read( input ) )
		return false;

	// make sure we have all our traits after serialization
	if (! findTrait( TraitReplication::classKey() ) )
		attachTrait( new TraitReplication() );
	if (! findTrait( TraitMovement::classKey() ) )
		attachTrait( new TraitMovement() );
	if (! findTrait( TraitOrbit::classKey() ) )
		attachTrait( new TraitOrbit() );

	m_fHeading = m_fSetHeading = m_vOrientation.m_fYaw;
	m_fLastSetHeading = m_fSetHeading;
	m_fLastSetVelocity = m_fSetVelocity;
	m_fLastYaw = m_fYaw;

	// a bug caused these values to go NAN when all the drives were removed from the ship
#if defined(_WIN32)
	if ( _isnan( m_fHeading ) )
		m_fHeading = 0.0f;
	if ( _isnan( m_fVelocity ) )
		m_fVelocity = 0.0f;
#else
	if ( isnan( m_fHeading ) )
		m_fHeading = 0.0f;
	if ( isnan( m_fVelocity ) )
		m_fVelocity = 0.0f;
#endif

	// update the ship frame
	m_Frame = Matrix33( m_fPitch, m_fHeading, m_fRoll );

	initializeGadgets();
	initializeEnhancements();
	updateCharacter();
	updateDamageBits();

	// reset and reapply all modifiers
	resetModifiers();
	for(int i=0;i<m_Enhancements.size();++i)
		m_Enhancements[i]->applyModifiers( true );

	// until we add slots for enhancements, just set max to 8
	// TODO: Add 
	m_MaxEnhancements = 8;
	m_nIgnoreCollisionTick = 0;

	return true;
}
コード例 #3
0
ファイル: CharacterObject.cpp プロジェクト: darkf/openrw
void CharacterObject::tick(float dt)
{
	if(controller) {
		controller->update(dt);
	}

	animator->tick(dt);
	updateCharacter(dt);

	// Ensure the character doesn't need to be reset
	if(getPosition().z < -100.f) {
		resetToAINode();
	}
}
コード例 #4
0
ファイル: NounShip.cpp プロジェクト: BlackYoup/darkspace
void NounShip::setup()
{
	NounBody::setup();

	// clear all flags
	clearFlags( FLAG_ALL );
	// remove all damage
	m_Damage = 0;

	initializeGadgets();
	initializeEnhancements();
	initializeUnits();

	// update the characteristics of this ship
	updateCharacter();
	// fill energy
	m_Energy = maxEnergy();
}
コード例 #5
0
ファイル: game.c プロジェクト: AugustoRuiz/cpctelera
////////////////////////////////////////////////////////////////////////////////
// Plays a complete game, until the death of the main character
//
u16 game(u16 hiscore) {
   u8 alive = 1;        // Main character still alive?
   TCharacter* c;       // Pointer to main character

   // Initialize game
   initializeGameScreen(hiscore);   // Set up Game Screen
   initializeEntities();            // Set up initial entities
   c = getCharacter();              // Get the main character

   /////
   // Main Game Loop (while character is alive)
   /////
   while(alive) {
      updateUser(c);                // Update user status (depending on keypresses)
      scrollWorld();                // Update world scrolling
      alive = updateCharacter(c);   // Update character status     
      cpct_waitVSYNC();             // Wait for VSYNC and...
      drawAll();                    // ..draw everything
   }

   // Return final score, at the end of the game
   return getScore();
}
コード例 #6
0
ファイル: NounShip.cpp プロジェクト: BlackYoup/darkspace
void NounShip::updateShip( dword nTick )
{
	PROFILE_FUNCTION();

	// update despawn/docking logic..
	updateDespawn();
	// update the ships gadgets
	updateGadgets( nTick );
	// update high-level AI
	updateLogic( nTick );		

	// repair / reload ship when in orbit
	if ( nTick >= m_nRepairTick )
	{
		m_nRepairTick = nTick + DEFAULT_REPAIR_RATE;
		if ( inOrbit() )
		{
			// handle ship repairs when in orbit around friendly planet with a ship yard
			NounPlanet * pPlanet = WidgetCast<NounPlanet>( orbiting() );
			if ( pPlanet != NULL )
			{
				if ( pPlanet->isFriend( this ) )
				{
					repair( pPlanet, PLANET_REPAIR_RATE, true );
					reload( pPlanet );
				}
				else if ( (pPlanet->flags() & NounPlanet::FLAG_HYDROGEN) != 0 )
				{
					// if planet has hydrogen, then refuel the jump drive
					if ( jumpDrive() != NULL )
						jumpDrive()->reload( pPlanet );
				}
			}
		}
	}

	if ( nTick >= m_nUpdateTick )
	{
		m_nUpdateTick = nTick + SHIP_UPDATE_RATE;
		// update characteristics
		updateCharacter();
		// update low-level AI
		updateCommand();
		// update the repair queue
		updateRepairQueue();
		// update the contact list
		updateContacts();
		// drain off some damage from the damage list
		updateThreats();
	}

	if ( m_bIncoming )
	{
		ASSERT( userId() == 0 );
		avoidCollision();
		m_bIncoming = false;
	}

	updatePointDefense();
	updateFireCheck();

}
コード例 #7
0
ファイル: ResourceWindow.cpp プロジェクト: gsi-upm/SmartSim
void ResourceWindow::updateGUI()
{

	SmartBody::SBScene* scene = SmartBody::SBScene::getScene();
	SmartBody::SBAssetManager* assetManager = scene->getAssetManager();

	resourceTree->sortorder(FL_TREE_SORT_ASCENDING);	
	// update path tree	
	updatePath(getTreeFromName("script path"), SmartBody::SBScene::getScene()->getAssetPaths("script"));	
	updatePath(getTreeFromName("motion path"), SmartBody::SBScene::getScene()->getAssetPaths("motion"));	
	updatePath(getTreeFromName("audio path"), SmartBody::SBScene::getScene()->getAssetPaths("audio"));	
	updatePath(getTreeFromName("mesh path"), SmartBody::SBScene::getScene()->getAssetPaths("mesh"));	
	

	// update sequence file list

	const std::vector<std::string> scriptPaths = SmartBody::SBScene::getScene()->getAssetPaths("script");
	resourceTree->clear_children(getTreeFromName("scriptfiles"));
	for (size_t p = 0; p < scriptPaths.size(); p++)
	{
		updateScriptFiles(getTreeFromName("scriptfiles"), scriptPaths[p]);
	}	

	// update runtime scripts
	resourceTree->clear_children(getTreeFromName("script"));
	std::vector<std::string> scriptName = scene->getScriptNames();
	for (size_t i = 0; i < scriptName.size(); i++)
	{
		SmartBody::SBScript* script = scene->getScript(scriptName[i]);
		updateScript(getTreeFromName("script"), script);
	}

	// update skeleton
	resourceTree->clear_children(getTreeFromName("skeleton"));
	std::vector<std::string> skeletons = scene->getSkeletonNames();
	for (size_t c = 0; c < skeletons.size(); c++)
	{
		SmartBody::SBSkeleton * skel = scene->getSkeleton(skeletons[c]);
		updateSkeleton(getTreeFromName("skeleton"), skel);
	}

	// update joint maps
	resourceTree->clear_children(getTreeFromName("jointmap"));	
	SmartBody::SBJointMapManager* jointMapManager = scene->getJointMapManager();
	std::vector<std::string> jointMapNames = jointMapManager->getJointMapNames();
	for (std::vector<std::string>::iterator iter = jointMapNames.begin();
		 iter != jointMapNames.end(); 
		 iter++)
	{
		Fl_Tree_Item* boneMapItem = resourceTree->add(getTreeFromName("jointmap"), (*iter).c_str());
		updateJointMap(boneMapItem, jointMapManager->getJointMap((*iter)));
	}

	// update gesture maps
	resourceTree->clear_children(getTreeFromName("gesturemap"));
	SmartBody::SBGestureMapManager* gestureMapManager = scene->getGestureMapManager();
	std::vector<std::string> gestureMapNames = gestureMapManager->getGestureMapNames();
	for (std::vector<std::string>::iterator iter = gestureMapNames.begin();
		 iter != gestureMapNames.end(); 
		 iter++)
	{
		Fl_Tree_Item* gestureMapItem = resourceTree->add(getTreeFromName("gesturemap"), (*iter).c_str());
		updateGestureMap(gestureMapItem, gestureMapManager->getGestureMap((*iter)));
	}

	// update motion map
	resourceTree->clear_children(getTreeFromName("motion"));
	std::vector<std::string> motionNames = scene->getMotionNames();
	for (size_t i = 0; i < motionNames.size(); i++)
	{
		//resourceTree->add(treeItemList[ITEM_MOTION],mi->first.c_str());
		SmartBody::SBMotion * motion = scene->getMotion(motionNames[i]);
		updateMotion(getTreeFromName("motion"), motion);
	}

	SmartBody::SBAnimationBlendManager* blendManager = scene->getBlendManager();
	// update animation blend map
	resourceTree->clear_children(getTreeFromName("blend"));
	std::vector<std::string> blendNames = blendManager->getBlendNames();
	for (size_t i = 0; i < blendNames.size(); i++)
	{
		//resourceTree->add(treeItemList[ITEM_MOTION],mi->first.c_str());
		SmartBody::SBAnimationBlend * blend = blendManager->getBlend(blendNames[i]);
		updateAnimationBlend(getTreeFromName("blend"), blend);
	}

	// update blend transition map
	resourceTree->clear_children(getTreeFromName("transition"));
	std::vector<std::string> transitionNames = blendManager->getTransitionNames();
	for (size_t i = 0; i < transitionNames.size(); i++)
	{
		//resourceTree->add(treeItemList[ITEM_MOTION],mi->first.c_str());
		SmartBody::SBAnimationTransition * transition = blendManager->getTransitionByName(transitionNames[i]);
		updateBlendTransition(getTreeFromName("transition"), transition);
	}

	// update mesh map
	resourceTree->clear_children(getTreeFromName("mesh"));
	std::vector<std::string> meshNames = assetManager->getDeformableMeshNames();
	for (size_t i = 0; i < meshNames.size(); i++)
	{
		DeformableMesh* mesh = assetManager->getDeformableMesh(meshNames[i]);
		Fl_Tree_Item* meshItem = resourceTree->add(getTreeFromName("mesh"), mesh->getName().c_str());
		updateMesh(meshItem, mesh);
	}


	// update face definition map
	resourceTree->clear_children(getTreeFromName("facedefinition"));
	std::vector<std::string> faceNames = scene->getFaceDefinitionNames();
	for (size_t i = 0; i < faceNames.size(); i++)
	{
		//resourceTree->add(treeItemList[ITEM_MOTION],mi->first.c_str());
		SmartBody::SBFaceDefinition * face = scene->getFaceDefinition(faceNames[i]);
		if (!face)
			continue;
		Fl_Tree_Item* faceTree = resourceTree->add(getTreeFromName("facedefinition"), face->getName().c_str());
		updateFaceDefinition(faceTree, face);
	}

	// update event handler list
	SmartBody::SBEventManager* eventManager = SmartBody::SBScene::getScene()->getEventManager();
	std::map<std::string, SmartBody::SBEventHandler*>& eventMap = eventManager->getEventHandlers();
	std::map<std::string, SmartBody::SBEventHandler*>::iterator ei;
	resourceTree->clear_children(getTreeFromName("eventhandler"));
	for ( ei  = eventMap.begin();
		  ei != eventMap.end();
		  ei++)
	{
		updateEventHandler(getTreeFromName("eventhandler"), ei->second);
	}
	// Below are instance objects :

	// update pawn objects
	resourceTree->clear_children(getTreeFromName("pawn"));
	const std::vector<std::string>& pawnNames = scene->getPawnNames();
	for (size_t i = 0; i < pawnNames.size(); i++)
	{
		SmartBody::SBPawn* pawn = scene->getPawn(pawnNames[i]);
		updatePawn(getTreeFromName("pawn"), pawn);
	}

	// update characters
	resourceTree->clear_children(getTreeFromName("character"));
	const std::vector<std::string>& charNames = scene->getCharacterNames();
	for (size_t i = 0; i < charNames.size(); i++)
	{
		SmartBody::SBCharacter* character = scene->getCharacter(charNames[i]);
		resourceTree->sortorder(FL_TREE_SORT_ASCENDING);
		updateCharacter(getTreeFromName("character"), character);
	}

	
// 	for (SBPhysicsObjMap::iterator iter = phySim->getPhysicsObjMap().begin();
// 		 iter != phySim->getPhysicsObjMap().end();
// 		 iter++)
// 	{
// 		SBPhysicsObj* obj = (*iter).second;
// 		if (dynamic_cast<SbmJointObj*>(obj) == NULL)
// 		{
// 
// 		}
// 	}

	// update services
	SmartBody::SBServiceManager* serviceManager = scene->getServiceManager();
	std::map<std::string, SmartBody::SBService*>& serviceMap = serviceManager->getServices();

	resourceTree->clear_children(getTreeFromName("service"));
	for (std::map<std::string, SmartBody::SBService*>::iterator iter = serviceMap.begin();
		iter != serviceMap.end();
		iter++)
	{
		SmartBody::SBService* service = (*iter).second;
		resourceTree->sortorder(FL_TREE_SORT_ASCENDING);	
		SmartBody::SBPhysicsManager* phyManager = dynamic_cast<SmartBody::SBPhysicsManager*>(service);
		if (phyManager)
			updatePhysicsManager(getTreeFromName("service"),phyManager);
		else
			updateService(getTreeFromName("service"), service);
	}

	// update behavior sets
	resourceTree->clear_children(getTreeFromName("behaviorset"));
	std::map<std::string, SmartBody::SBBehaviorSet*>& behaviorSets = scene->getBehaviorSetManager()->getBehaviorSets();
	for (std::map<std::string, SmartBody::SBBehaviorSet*>::iterator iter = behaviorSets.begin();
		 iter != behaviorSets.end();
		 iter++)
	{
		SmartBody::SBBehaviorSet* behaviorSet = (*iter).second;
		updateBehaviorSet(getTreeFromName("behaviorset"), behaviorSet);
	}


	_dirty = false;

	if (_firstTime)
	{
		hideTree();
		_firstTime = false;
	}
}