Exemplo n.º 1
0
void EntityScheduler::RemoveEntity(Entity* entity, FRAME_LIST_T& frameList, uint32 skip)
{
   PHASE_MAP_T::iterator iter = _phaseMap.find(entity);
   assert(iter != _phaseMap.end());
   if(iter != _phaseMap.end())
   {
      // Get the value
      int32 phase = iter->second;
      // Remove it from the phase map
      _phaseMap.erase(iter);
      // Iterate through the frameList and remove them all.
      for(int idx = phase; idx < TICKS_PER_SECOND; idx += skip)
      {
         RemoveEntity(entity, frameList[idx]);
      }
      // If this item needed a display update, remove
      // that as well.
      if(entity->IsFlagClear(Entity::HF_NO_DISPLAY_UPDATE))
      {
         RemoveEntity(entity, _needUpdateDisplay);
      }
      if(entity->IsFlagClear(Entity::HF_NO_DISPLAY_UPDATE))
      {
         RemoveEntity(entity, _needUpdateDisplay);
      }
   }
}
Exemplo n.º 2
0
	void ManagerModel::ColissionWall() {
		int index = 0;
		while(index < mEntities.size()) {
			Entity *e = mEntities[index];
			if (e->Type() == ENTITY_PLAYER) {
				Player *player = ((Player*)e);
				if (player->mPos.x < player->GetRadius() + 10) {
					player->mPos.x = player->GetRadius() + 10;
				}

				if (player->mPos.x + player->GetRadius() > mPlayArea.x - 15) {
					player->mPos.x = mPlayArea.x - player->GetRadius() - 15;//Sprite is rotated.
				}

				if (player->mPos.y < player->GetRadius()) {
					player->mPos.y = player->GetRadius();
				}

				if (player->mPos.y > mPlayArea.y - player->GetRadius()) {
					player->mPos.y = mPlayArea.y - player->GetRadius();
				}

			} else if (e->Type() == ENTITY_BULLET) {
				Shot *bullet = ((Shot*)e);
				if (bullet->mPos.x > mPlayArea.x) {
					RemoveEntity(e);
					--index;
				}
			} else if (e->Type() == ENTITY_ASTEROID) {
				Asteroid *asteroid = ((Asteroid*)e);
				if (asteroid->mPos.x + asteroid->GetRadius() < 0 ||
					asteroid->mPos.y + asteroid->GetRadius() < 0) {
					int type = asteroid->mType;
					RemoveEntity(e);
					AddAsteroid(type, 2, Vec2(1, 1), Vec2(0));
					--index;
				}
			} else if (e->Type() == ENTITY_HEALTHPACKAGE) {
				HealthPackage *healthPackage = ((HealthPackage*)e);
				if (healthPackage->mPos.x + healthPackage->GetRadius() < 0 ||
					healthPackage->mPos.y + healthPackage->GetRadius() < 0) {

					RemoveEntity(e);
					--index;
				}
			}

			++index;
		}
	}
Exemplo n.º 3
0
void CEntityManager::UpdateAll(float dtTime)
{
	for(unsigned int i = 0; i < MAX_ENTITIES; i++) {
		if(entities[i] != NULL) {
			entities[i]->Update(dtTime);
			if(entities[i]->signalDeath) {
				RemoveEntity(i);
				continue;
			}

			for(unsigned int j = 0; j < MAX_ENTITIES; j++) {
				if(entities[j] != NULL) {
					/* Do not compare to itself */
					if(entities[j] == entities[i]) {
						continue;
					}
					auto phys = GetComponent<CComponent_Physical>(entities[i]);
					if(phys) {
						auto entityPhys = GetComponent<CComponent_Physical>(entities[j]);
						if(entityPhys) {
							if(entityPhys->rect.Collides(phys->rect)) {
								CMessage_CollideWithEntity msg;
								msg.entity = entities[j];
								entities[i]->GetComponents()->HandleMessage(&msg);
							}
						}
					}
				}
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: Clears all entity lists and releases entities
//-----------------------------------------------------------------------------
void CClientEntityList::Release( void )
{
	// Free all the entities.
	ClientEntityHandle_t iter = FirstHandle();
	ClientEntityHandle_t next;
	while( iter != InvalidHandle() )
	{
		next = NextHandle( iter );
		
		// Try to call release on anything we can.
		IClientNetworkable *pNet = GetClientNetworkableFromHandle( iter );
		if ( pNet )
		{
			pNet->Release();
		}
		else
		{
			// Try to call release on anything we can.
			IClientThinkable *pThinkable = GetClientThinkableFromHandle( iter );
			if ( pThinkable )
			{
				pThinkable->Release();
			}
		}
		RemoveEntity( iter );

		iter = next;
	}

	m_iNumServerEnts = 0;
	m_iMaxServerEnts = 0;
	m_iMaxUsedServerIndex = -1;
}
Exemplo n.º 5
0
void WBScene::Tick()
{
	PROFILE_FUNCTION;

	// Delete any destroyed entities this scene owns
	BEGIN_ITERATING_ENTITIES;
	FOR_EACH_MAP( EntityIter, m_Entities, uint, SEntityRef )
	{
		const SEntityRef& EntityRef = EntityIter.GetValue();
		WBEntity* const pEntity = EntityRef.m_Entity;
		DEVASSERT( pEntity );
		if( !EntityRef.m_Removed && pEntity->IsDestroyed() )
		{
			SafeDeleteNoNull( pEntity );
		}
	}
	END_ITERATING_ENTITIES;

	// Deferred removal of entities
	for( uint HandleIndex = 0; HandleIndex < m_DeferredRemoveHandles.Size(); ++HandleIndex )
	{
		const uint Handle = m_DeferredRemoveHandles[ HandleIndex ];
		RemoveEntity( Handle );
	}
	m_DeferredRemoveHandles.Clear();
}
Exemplo n.º 6
0
void World::DestroyEntity( Entity* pEntity )
{
    pEntity->SetWorld(NULL);
    RemoveEntity( pEntity );

    pEntity->Kill();
    GD_DELETE(pEntity);
}
void SimpleScene::RemoveEntity(SimpleObject* sObj, SimpleID sLay) {

	auto l = GetLayer(sLay);
	if (l != nullptr) {
		l->RemoveEntity(sObj);
		sObj->RemovedFromScene(this, l);
	}
}
Exemplo n.º 8
0
 void CDynamics2DEngine::TransferEntities() {
    for(size_t i = 0; i < m_vecTransferData.size(); ++i) {
       CPhysicsEngine& cToEngine = CSimulator::GetInstance().GetPhysicsEngine(m_vecTransferData[i].EngineId);
       cToEngine.AddEntity(*m_vecTransferData[i].Entity);
       RemoveEntity(*m_vecTransferData[i].Entity);
    }
    m_vecTransferData.clear();
 }
Exemplo n.º 9
0
		Terrain::~Terrain() {
#if 0
			RemoveEntity( entity );
			delete program;
			delete dirtTexture;
			delete grassTexture;
			delete snowTexture;
#endif
		}
void DemoEntityManager::RemoveEntity (DemoEntity* const ent)
{
	for (dListNode* node = dList<DemoEntity*>::GetFirst(); node; node = node->GetNext()) {
		if (node->GetInfo() == ent) {
			RemoveEntity (node);
			break;
		}
	}
}
Exemplo n.º 11
0
void CAIThread::OnEntityUpdateRemove( const WORD nEntity )
{
	ASSERT( m_pBotDoc != NULL );
	if ( m_pBotDoc->IsReady() )
	{
		CEntity* pEntity = m_pBotDoc->GetEntity( nEntity );
		RemoveEntity( pEntity );
	}
}
Exemplo n.º 12
0
	void ManagerModel::RemoveDeadExplosion() {
		int index = 0;
		while (index < mEntities.size()) {
			Entity *e = mEntities[index];
			if (e->Type() == ENTITY_EXPLOSION) {
				if (e->IsDead()) {
					RemoveEntity(e);
					--index;
				}
			}
			++index;
		}
	}
Exemplo n.º 13
0
void dd::World::RemoveEntity(EntityID entity)
{
	m_EntitiesToRemove.insert(entity);

	auto it = m_EntityChildren.find(entity);
	if (it != m_EntityChildren.end())
	{
		for (auto entity : it->second)
		{
			RemoveEntity(entity);
		}
	}
}
Exemplo n.º 14
0
void EntityScheduler::DeRegister(Entity* entity)
{
   if(entity->IsFlagSet(Entity::HF_UPDATE_PRIO_1))
   {
      RemoveEntity(entity, _prio1Updates);
   }
   else if(entity->IsFlagSet(Entity::HF_UPDATE_PRIO_2))
   {
      RemoveEntity(entity, _prio2Updates, 2);
   }
   else if(entity->IsFlagSet(Entity::HF_UPDATE_PRIO_3))
   {
      RemoveEntity(entity, _prio2Updates, 3);
   }
   else if(entity->IsFlagSet(Entity::HF_UPDATE_PRIO_4))
   {
      RemoveEntity(entity, _prio2Updates, 10);
   }
   else if(entity->IsFlagSet(Entity::HF_UPDATE_PRIO_5))
   {
      RemoveEntity(entity, _prio2Updates, 30);
   }
}
Exemplo n.º 15
0
void CGameWorld::RemoveEntities()
{
	// destroy objects marked for destruction
	for(int i = 0; i < NUM_ENTTYPES; i++)
		for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt; )
		{
			m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
			if(pEnt->m_MarkedForDestroy)
			{
				RemoveEntity(pEnt);
				pEnt->Destroy();
			}
			pEnt = m_pNextTraverseEntity;
		}
}
Exemplo n.º 16
0
void OutdoorLevel::RemoveEntity(Entity *ent, BOOL bChildren)
{
    if(!GetEntityData(ent))
        return;

    int i;
    BOOL isLight = ent->IsOf(GetClass(Light));
    BOOL isMeshEnt = ent->IsOf(GetClass(MeshEntity));

    OutdoorEntityData *entData = GetOutdoorEntityData(ent);

    if(entData->Blocks.Num() || entData->VisBlocks.Num())
    {
        if(isLight)
        {
            for(i=0; i<entData->Blocks.Num(); i++)
                entData->Blocks[i]->lights.RemoveItem(static_cast<Light*>(ent));

            for(i=0; i<entData->VisBlocks.Num(); i++)
                entData->VisBlocks[i]->visLights.RemoveItem(static_cast<Light*>(ent));
        }
        else
        {
            for(i=0; i<entData->Blocks.Num(); i++)
                entData->Blocks[i]->entities.RemoveItem(ent);

            if(isMeshEnt)
            {
                for(i=0; i<entData->VisBlocks.Num(); i++)
                    entData->VisBlocks[i]->visMeshEntities.RemoveItem(static_cast<MeshEntity*>(ent));
            }
            else
            {
                for(i=0; i<entData->VisBlocks.Num(); i++)
                    entData->VisBlocks[i]->visEntities.RemoveItem(ent);
            }
        }
    }

    DestroyObject(GetEntityData(ent));
    GetEntityData(ent) = NULL;

    if(bChildren)
    {
        for(i=0; i<ent->NumChildren(); i++)
            RemoveEntity(ent->GetChild(i));
    }
}
Exemplo n.º 17
0
bool PhysicsManager::OnEvent(Event::IEvent* e)
{
	if (e->eType == "PhysicsObj Created")
	{
		Event::PhysicsCreationEvent* event = static_cast<Event::PhysicsCreationEvent*>(e);
		RegisterEntity(event->entity, event->rbType, event->mass, event->scale);
		return true;
	}
	else if (e->eType == "PhysicsObj Destroyed")
	{
		Event::PhysicsCreationEvent* event = static_cast<Event::PhysicsCreationEvent*>(e);
		RemoveEntity(event->entity);
		return true;
	}
	return false;
}
Exemplo n.º 18
0
void World::Kill()
{
    List<Entity*>::const_iterator itEntity;
    for(itEntity = mEntities.begin(); itEntity != mEntities.end(); itEntity = mEntities.begin())
    {
        Entity* entity = (*itEntity);
        RemoveEntity(entity);

        if( entity->GetOwner() == this )
        {
            entity->Kill();
            GD_DELETE(entity);
        }
    }

    mWorldInitialized = false;
}
Exemplo n.º 19
0
void GreekfireTouch(edict_t *ent, edict_t *other)
{
	vec3_t vel;

	if (other == ent->local.eOwner)
		return;

	if(other->v.bTakeDamage)
		MONSTER_Damage(other,ent,50,0);

    // [25/6/2012] Simplified ~hogsy
	Math_VectorCopy(ent->v.velocity,vel);
	Math_VectorInverse(vel);

	Engine.Particle(ent->v.origin,vel,5,"spark",17);

	// [25/6/2012] Simplified ~hogsy
	Math_VectorClear(ent->v.velocity);

	RemoveEntity(ent);
}
Exemplo n.º 20
0
/// Removes the Entity and re-inserts it to it's new location
bool PhysicsOctree::RepositionEntity(Entity * entity)
{
	// Check for vfcOctree node in Entity.
	PhysicsOctree * node = entity->physics->octreeNode;
	if (node == NULL){
		return false;
	}
	assert(node);
	/// Why do we check this? This means that the entity will not move to a lesser vfcOctree node even if that is possibubul öAö
	int status = node->IsEntityInside(entity);
	switch(status)
	{
		case INSIDE:
			/// Still inside the node it was in on the start of the frame? Then leave it be.
			return true;
		case OUTSIDE: case INTERSECT:
			// Send it upwards until it fits
			while(true)
			{
				if (node->parent == NULL){
					std::cout<<"\nWARNING: Object outside root node! Unregistering from physics!";
					entity->physics->octreeNode = NULL;
			//		assert(false && "Entity at root-node yet outside/intersecting it!");
					/// Unregister th entity by default if it exceeds the boundaries!
					PhysicsManager::Instance()->UnregisterEntity(entity);
					return false;
				}
				node = node->parent;
				if (node->IsEntityInside(entity) == INSIDE){
					RemoveEntity(entity);
					assert(node->AddEntity(entity));
					return true;
				}
			}
			break;
	}
	return true;
}
    bool CommunityHealthWorkerEventCoordinator::notifyOnEvent( IIndividualHumanEventContext *context, 
                                                              const EventTrigger& trigger)
    {
        if( IsRemoveIndividualEvent( trigger ) )
        {
            RemoveEntity( context );
        }
        else
        {
            float current_time = m_Parent->GetSimulationTime().time;

            if( m_pInterventionNode != nullptr )
            {
                INodeEventContext* p_nec = context->GetNodeEventContext();
                AddEntity( current_time, p_nec->GetId().data, p_nec, m_QueueNode );
            }
            else
            {
                AddEntity( current_time, context->GetSuid().data, context, m_QueueIndividual );
            }
        }
        return true;
    }
Exemplo n.º 22
0
void DisplayShots(Entity *&pShots)
{
	Entity *pTrav = pShots ;
	Entity *pTemp ;
	Point ptPlayerUFL, ptPlayerLBR, ptShotUFL, ptShotLBR ;
	ptPlayerUFL = Player.ptLocation + Player.pModel->ptBBUpperFrontLeft ;
	ptPlayerLBR = Player.ptLocation + Player.pModel->ptBBLowerBackRight ;

	while (pTrav != 0)
	{
		ptShotUFL = pTrav->ptLocation + pTrav->pModel->ptBBLowerBackRight ;
		ptShotLBR = pTrav->ptLocation + pTrav->pModel->ptBBUpperFrontLeft ;
		if (pTrav->ptLocation.dX < 50 && pTrav->ptLocation.dX > -50 &&
			pTrav->ptLocation.dZ < 100 && pTrav->ptLocation.dZ > -100)
		{
			if (!bExplode && (
					(ptPlayerUFL < ptShotUFL && ptPlayerLBR > ptShotUFL) || 
					(ptPlayerUFL < ptShotLBR && ptPlayerLBR > ptShotLBR) ||
					(ptShotUFL < ptPlayerUFL && ptShotLBR > ptPlayerUFL) || 
					(ptShotUFL < ptPlayerLBR && ptShotLBR > ptPlayerLBR)))
			{
				bExplode = true ;
				iCount = 0 ;
			}
			pTrav->Display() ;
			if (!bPause) pTrav->ptLocation = pTrav->ptLocation + pTrav->ptDirection ;
			pTrav = pTrav->pNext ;
		} else 
		{
			pTemp = pTrav ;
			pTrav = pTrav->pNext ;
			pTemp->pModel = 0 ;
			RemoveEntity(pShots, pTemp) ;
		}
	}
}
Exemplo n.º 23
0
void DisplayEnemies()
{
	Entity *pTrav = pEnemys ;
	Entity *pTravShots ;
	Entity *pTemp ;
	bool bShot ;
	Point ptBBModelUFL, ptBBModelLBR, ptBBShotUFL, ptBBShotLBR ;
	while (pTrav != 0)
	{
		if (pTrav->ptLocation.dZ > -100)
		{
			ptBBModelUFL = pTrav->ptLocation + pTrav->pModel->ptBBUpperFrontLeft ;
			ptBBModelLBR = pTrav->ptLocation + pTrav->pModel->ptBBLowerBackRight ;

			bShot = false ;
			pTravShots = pPlayerShots ;
			while (pTravShots != 0)
			{
				ptBBShotUFL = pTravShots->ptLocation + pTravShots->pModel->ptBBUpperFrontLeft ;
				ptBBShotLBR = pTravShots->ptLocation + pTravShots->pModel->ptBBLowerBackRight ;

				if ((ptBBModelUFL < ptBBShotUFL && ptBBModelLBR > ptBBShotUFL) || 
					(ptBBModelUFL < ptBBShotLBR && ptBBModelLBR > ptBBShotLBR))
				{
					bShot = true ;

					MakeExplosion(pTrav->ptLocation, 500) ;

					if (!bExplode)
					{
						iScore += 100 ;
						printf ("Score: %i\n", iScore) ;
					}

					pTemp = pTrav ;
					pTrav = pTrav->pNext ;
					pTemp->pModel = 0 ;
					RemoveEntity(pEnemys, pTemp) ;
					pTravShots->pModel = 0 ;
					RemoveEntity(pPlayerShots, pTravShots) ;
					break ;
				}
				pTravShots = pTravShots->pNext ;
			}

			if (!bShot)
			{
				ptBBShotUFL = Player.ptLocation + Player.pModel->ptBBUpperFrontLeft ;
				ptBBShotLBR = Player.ptLocation + Player.pModel->ptBBLowerBackRight ;

				if (!bExplode && ((ptBBModelUFL < ptBBShotUFL && ptBBModelLBR > ptBBShotUFL) || 
									(ptBBModelUFL < ptBBShotLBR && ptBBModelLBR > ptBBShotLBR)))
				{
					bExplode = true ;
					iCount = 0 ; 

					MakeExplosion(pTrav->ptLocation, 500) ;
					pTemp = pTrav ;
					pTrav = pTrav->pNext ;
					pTemp->pModel = 0 ;
					RemoveEntity(pEnemys, pTemp) ;
				} else
				{
//					if (randp() > 0.99)
					if (!bExplode && randp() > 0.99)
						FireShot(pTrav, pEnemyShots) ;
					pTrav->Display() ;
					if (!bPause) pTrav->ptLocation = pTrav->ptLocation + pTrav->ptDirection ;
					pTrav = pTrav->pNext ;
				}
			}
		} else 
		{
			pTemp = pTrav ;
			pTrav = pTrav->pNext ;
			pTemp->pModel = 0 ;
			RemoveEntity(pEnemys, pTemp) ;
		}
	}
}
Exemplo n.º 24
0
//------------------------------------------------------------------------
void CAmmoPickup::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory)
{
	if(!CheckAmmoRestrictions(pickerId))
		return;

	SetOwnerId(pickerId);

	CActor *pActor=GetActor(pickerId);

	if (!pActor)
		return;

	IInventory *pInventory = GetActorInventory(pActor);
	if (!pInventory)
		return;

	if (IsServer())
	{
		// bonus ammo is always put in the actor's inv
		if (!m_bonusammo.empty())
		{
			for (TAmmoMap::iterator it=m_bonusammo.begin(); it!=m_bonusammo.end(); ++it)
			{
				int count=it->second;

				SetInventoryAmmoCount(it->first, GetInventoryAmmoCount(it->first)+count);

				if(pActor->IsPlayer())
				{
					ShouldSwitchGrenade(it->first);
					OnIncendiaryAmmoPickedUp(it->first,count);
				}
			}

			m_bonusammo.clear();
		}

		for (TAmmoMap::iterator it=m_ammo.begin(); it!=m_ammo.end(); ++it)
		{
			int count=it->second;

			SetInventoryAmmoCount(it->first, GetInventoryAmmoCount(it->first)+count);

			if(pActor->IsPlayer())
			{
				ShouldSwitchGrenade(it->first);
				OnIncendiaryAmmoPickedUp(it->first,count);
			}
		}

		if (!m_ammoName.empty() && m_ammoCount)
		{
			IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(m_ammoName.c_str());
			SetInventoryAmmoCount(pClass, GetInventoryAmmoCount(pClass)+m_ammoCount);

			if(pActor->IsPlayer())
			{
				ShouldSwitchGrenade(pClass);
				OnIncendiaryAmmoPickedUp(pClass,m_ammoCount);
			}
		}

		TriggerRespawn();
	}

	//Play sound
	if(!m_pickup_sound.empty())
	{
		IEntity *pPicker = m_pEntitySystem->GetEntity(pickerId);
		if(pPicker)
		{
			IEntitySoundProxy* pSoundProxy = (IEntitySoundProxy*)pPicker->GetProxy(ENTITY_PROXY_SOUND);

			if(pSoundProxy)
			{
				//Execute sound at picker position
				pSoundProxy->PlaySound(m_pickup_sound, pPicker->GetWorldPos(),FORWARD_DIRECTION, FLAG_SOUND_DEFAULT_3D, eSoundSemantic_Weapon);
			}
		}
	}

	RemoveEntity();
}
Exemplo n.º 25
0
	virtual void OnEntityDeleted( CBaseEntity *pEntity )
	{
		if ( !(pEntity->GetFlags() & FL_AIMTARGET) )
			return;
		RemoveEntity(pEntity);
	}
void DemoEntityManager::Cleanup ()
{
	// is we are run asynchronous we need make sure no update in on flight.
	if (m_world) {
		NewtonWaitForUpdateToFinish (m_world);
	}

	// destroy all remaining visual objects
	while (dList<DemoEntity*>::GetFirst()) {
		RemoveEntity (dList<DemoEntity*>::GetFirst());
	}

	m_sky = NULL;

	// destroy the Newton world
	if (m_world) {
		// get serialization call back before destroying the world
		NewtonDestroy (m_world);
		m_world = NULL;
	}

	//	memset (&demo, 0, sizeof (demo));
	// check that there are no memory leak on exit
	dAssert (NewtonGetMemoryUsed () == 0);

	// create the newton world
	m_world = NewtonCreate();

	// link the work with this user data
	NewtonWorldSetUserData(m_world, this);

	// set joint serialization call back
	CustomJoint::Initalize(m_world);

	// add all physics pre and post listeners
	//	m_preListenerManager.Append(new DemoVisualDebugerListener("visualDebuger", m_world));
	new DemoEntityListener (this);
	m_cameraManager = new DemoCameraListener(this);
	//	m_postListenerManager.Append (new DemoAIListener("aiManager"));

	// set the default parameters for the newton world
	// set the simplified solver mode (faster but less accurate)
	NewtonSetSolverModel (m_world, 4);

	// newton 300 does not have world size, this is better controlled by the client application
	//dVector minSize (-500.0f, -500.0f, -500.0f);
	//dVector maxSize ( 500.0f,  500.0f,  500.0f);
	//NewtonSetWorldSize (m_world, &minSize[0], &maxSize[0]); 

	// set the performance track function
	//NewtonSetPerformanceClock (m_world, dRuntimeProfiler::GetTimeInMicrosenconds);

	// clean up all caches the engine have saved
	NewtonInvalidateCache (m_world);

	// Set the Newton world user data
	NewtonWorldSetUserData(m_world, this);


	// we start without 2d render
	m_renderHood = NULL;
	m_renderHoodContext = NULL;
}
Exemplo n.º 27
0
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char *setup)
{
	CActor *pActor=GetActor(pickerId);
	if (!pActor)
		return;

	if(!CheckAmmoRestrictions(pickerId))
	{
		if (IsServer())
			g_pGame->GetGameRules()->SendTextMessage(eTextMessageCenter, "@ammo_maxed_out", eRMI_ToClientChannel, pActor->GetChannelId(), (string("@")+GetEntity()->GetClass()->GetName()).c_str());
		return;
	}

	TriggerRespawn();

	GetEntity()->EnablePhysics(false);
	Physicalize(false, false);

	bool soundEnabled = IsSoundEnabled();
	EnableSound(sound);

	SetViewMode(0);		
	SetOwnerId(pickerId);

	CopyRenderFlags(GetOwner());

	Hide(true);
	m_stats.dropped = false;
	m_stats.brandnew = false;


	IInventory *pInventory = pActor->GetInventory();
	if (!pInventory)
	{
		GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName());
		return;
	}

	if(!pInventory->HasAccessory(GetEntity()->GetClass()))
	{
		pInventory->AddAccessory(GetEntity()->GetClass());
	}

	OnPickedUp(pickerId, m_sharedparams->params.unique);	

	PlayAction(g_pItemStrings->pickedup);

	EnableSound(soundEnabled);

	if (IsServer() && !IsDemoPlayback())
	{
		if(!gEnv->bMultiplayer)
			RemoveEntity();
		else if(g_pGame->GetGameRules())
			g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg
	}

	if (IsServer())
	{
		GetGameObject()->SetNetworkParent(pickerId);
		if ((GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY)) == 0)
		{
			pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());

			const char *displayName=GetDisplayName();
}
	}
}
Exemplo n.º 28
0
void CAccessory::PickUp(EntityId pickerId, bool sound, bool select/* =true */, bool keepHistory/* =true */, const char *setup /*= NULL*/)
{
    CActor *pActor=GetActor(pickerId);
    if (!pActor)
        return;

    TriggerRespawn();

    GetEntity()->EnablePhysics(false);
    Physicalize(false, false);

    bool soundEnabled = IsSoundEnabled();
    EnableSound(sound);

    SetViewMode(0);
    SetOwnerId(pickerId);

    CopyRenderFlags(GetOwner());

    Hide(true);
    m_stats.dropped = false;
    m_stats.detached = false;
    m_stats.brandnew = false;


    IInventory *pInventory = pActor->GetInventory();
    if (!pInventory)
        {
            GameWarning("Actor '%s' has no inventory, when trying to pickup '%s'!",pActor->GetEntity()->GetName(),GetEntity()->GetName());
            return;
        }

    if (!pActor->IsPlayer() || pActor->IsClient() || gEnv->bMultiplayer)
        {
            bool hasAccessory = pInventory->HasAccessory(GetEntity()->GetClass());
            bool hasAccessoryForThisWeapon = pInventory->HasAccessory(GetEntity()->GetClass());

            if (!hasAccessoryForThisWeapon)
                pInventory->AddAccessory(GetEntity()->GetClass());
            if (!hasAccessory)
                ProcessAccessoryAmmoCapacities(pInventory, true);
            if (!hasAccessoryForThisWeapon)
                ProcessAccessoryAmmo(pInventory);
        }

    OnPickedUp(pickerId, m_sharedparams->params.unique);

    if (select)
        {
            PlayAction(GetFragmentIds().pickedup);
        }

    EnableSound(soundEnabled);

    bool isLocalEntity = GetEntity()->GetFlags()&(ENTITY_FLAG_CLIENT_ONLY|ENTITY_FLAG_SERVER_ONLY) ? true : false;

    if (IsServer() && !IsDemoPlayback())
        {
            if(!gEnv->bMultiplayer || isLocalEntity)
                RemoveEntity();
            else if(g_pGame->GetGameRules())
                g_pGame->GetGameRules()->ScheduleEntityRemoval(GetEntityId(),10.0f,false); //Give some time to the clients to pick the msg
        }

    if (IsServer())
        {
            GetGameObject()->SetNetworkParent(pickerId);
            if (!isLocalEntity)
                {
                    pActor->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, sound), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());
                }
        }
}
Exemplo n.º 29
0
void
mapClient::MoveEntityTo( entType entity, uint8 x, uint8 y )
{
	RemoveEntity(entity);
	PutEntityAt(entity,x,y);
}
Exemplo n.º 30
0
void EntityManager::RemoveEntity(PhyxObject* _object)
{
	RemoveEntity( _object->GetID() );
}