Exemple #1
0
bool EntityManager::DeletePlayer(Client * client)
{
    gemActor *actor = client->GetActor();
    if (actor && actor->GetCharacterData()!=NULL)
    {
        // take the actor off his mount if he got one
        if(actor->GetMount())
            RemoveRideRelation(actor);
            
        //As we show the logged in status only when the client gets ready we check if it 
        //was ready before doing this
        if(client->IsReady())
        {
            // Check for buddy list members
            usermanager->NotifyBuddies(client, UserManager::LOGGED_OFF);
        
            // Check for Guild members to notify
            usermanager->NotifyGuildBuddies(client, UserManager::LOGGED_OFF);
            
            //check for alliance members to notify
            usermanager->NotifyAllianceBuddies(client, UserManager::LOGGED_OFF);
        }

        // Any objects wanting to know when the actor is 'gone' are callback'd here.
        actor->Disconnect();

        if (!dynamic_cast<gemNPC*> (actor))  // NPC cast null means a human player
        {
            // Save current character state in the database
            psServer::CharacterLoader.SaveCharacterData(actor->GetCharacterData(),actor);
        }
         
        gemActor *familiar = client->GetFamiliar();
        if ( familiar != NULL && familiar->IsValid())
        {
            // Send OwnerActionLogoff Perception

            //familiar->Disconnect();
            Debug3(LOG_NET,client->GetClientNum(),"EntityManager Removing actor %s from client %s.",familiar->GetName(),client->GetName() );
            psServer::CharacterLoader.SaveCharacterData(familiar->GetCharacterData(),familiar);
            client->SetFamiliar( NULL );
            RemoveActor( familiar );
        }

        // This removes the actor from the world data
        Debug3(LOG_NET,client->GetClientNum(),"EntityManager Removing actor %s from client %s.",actor->GetName(),client->GetName() );
        gem->RemoveClientFromLootables(client->GetClientNum());
        client->SetActor(NULL); // Prevent anyone from getting to a deleted actor through the client
        RemoveActor(actor);
    }
    return true;
}
Exemple #2
0
/*
-----------------------------------------------------------------------------
 Function: 

 Parameters:

 Returns:

 Notes: 
-----------------------------------------------------------------------------
*/
PUBLIC void ProcessGuards( void )
{
	int n, tex;
	assert( NumGuards < MAX_GUARDS );
	for( n = 0 ; n < NumGuards ; ++n )
	{
		if( ! DoGuard( &Guards[ n ] ) )
		{ // remove guard from the game forever!
			RemoveActor( &Guards[ n-- ] );
			continue;
		}

		Sprite_SetPos( Guards[ n ].sprite, Guards[ n ].x, Guards[ n ].y, Guards[ n ].angle );
		tex = objstate[ Guards[ n ].type ][ Guards[ n ].state ].texture;
		
		if( objstate[ Guards[ n ].type ][ Guards[ n ].state ].rotate )
		{
			if( Guards[ n ].type == en_rocket || Guards[ n ].type == en_hrocket )
			{
				tex += r_add8dir[ Get8dir( angle_wise( FINE2RAD(Player.position.angle), FINE2RAD(Guards[ n ].angle) ) ) ];				
			}
			else
			{
				tex += add8dir[ Get8dir( angle_wise( FINE2RAD(Player.position.angle), FINE2RAD(Guards[ n ].angle) ) ) ];				
			}
		}
		
		Sprite_SetTex( Guards[ n ].sprite, 0, tex );
	}
}
Exemple #3
0
bool EntityManager::AddRideRelation(gemActor *rider, gemActor *mount)
{
    if(!rider || !mount)
    {
        Error1("Wrong pointers in AddRideRelation()");
        return false;
    }

    if(rider->GetMount())
    {
        psserver->SendSystemError(rider->GetClientID(), "You are already on a mount.");
        return false;
    }

    psCharacter *mountChar = mount->GetCharacterData();
    RemoveActor(mount);
    CacheManager::GetSingleton().RemoveFromCache(CacheManager::GetSingleton().MakeCacheName("char",mountChar->GetPID().Unbox()));
    rider->SetMount(mountChar);

    rider->UpdateProxList(true);

    float movMod = mountChar->GetRaceInfo()->GetSpeedModifier();
    if( movMod != rider->GetCharacterData()->GetRaceInfo()->GetSpeedModifier())
    {
        psMoveModMsg modMsg(rider->GetClientID(), psMoveModMsg::MULTIPLIER,
                            csVector3(movMod), movMod);
        modMsg.SendMessage();
    }

    return true;
}
/***********************************************************
animate actors
***********************************************************/
int ExternalPlayersHandler::Process(double tnow, float tdiff)
{
	// update from external info
	ThreadSafeWorkpile * wp = ThreadSafeWorkpile::getInstance();
	std::vector<LbaNet::ActorInfo> vecai;
	std::vector<long> vecq;
	std::vector<LbaNet::ActorLifeInfo> veclai;
	std::vector<std::pair<long, LbaNet::LaunchInfo> > mb_vec;
	std::vector<long> mb_cb_vec;
	std::vector<LbaNet::GhostActorInfo> veclghost;

	wp->GetExtActorUpdate(vecai);
	wp->GetQuittedActors(vecq);
	wp->GetExtActorLifeUpdate(veclai);
	wp->GetMagicBallPlayed(mb_vec);
	wp->GetMagicBallComeback(mb_cb_vec);
	wp->GetExtGhostUpdate(veclghost);

	for(size_t i=0; i<vecai.size(); ++i)
		UpdateActor(vecai[i]);
	for(size_t i=0; i<veclai.size(); ++i)
		UpdateLifeActor(veclai[i]);
	for(size_t i=0; i<vecq.size(); ++i)
		RemoveActor(vecq[i]);

	for(size_t i=0; i<mb_cb_vec.size(); ++i)
		MagicBallComeback(mb_cb_vec[i]);
	for(size_t i=0; i<mb_vec.size(); ++i)
		MagicBallPlayed(mb_vec[i].first, mb_vec[i].second);

	for(size_t i=0; i<veclghost.size(); ++i)
		UpdateGhost(veclghost[i]);


	// update actors spped and animation
	std::map<long, ExternalPlayer *>::iterator it = _actors.begin();
	std::map<long, ExternalPlayer *>::iterator end = _actors.end();

	for(;it!=end; ++it)
		it->second->Process(tnow, tdiff);

	return 0;
}
Exemple #5
0
void GeometryDisplay::connectSTL(QString stlFile) {

	RemoveActor(STLactor);
	STLactor = NULL;
	
  if(!QFile::exists(stlFile)) return;

  reader->SetFileName(stlFile.toStdString().c_str());
  reader->Update();
 
  // Visualize

  STLmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  STLmapper->SetInputConnection(reader->GetOutputPort());
 
  STLactor = vtkSmartPointer<vtkActor>::New();
  STLactor->SetMapper(STLmapper);
  STLactor->GetProperty()->SetDiffuseColor(0,0,1);

  AddActor(STLactor);
  reset();
}
Exemple #6
0
void GeometryDisplay::clearPoint() {
  RemoveActor(pointActor);
}
Exemple #7
0
void MeshDisplay::HideMesh() {
  RemoveActor(actor);
}
/**
 * Removes the actor from its level's actor list and generally cleans up the engine's internal state.
 * What this function does not do, but is handled via garbage collection instead, is remove references
 * to this actor from all other actors, and kill the actor's resources.  This function is set up so that
 * no problems occur even if the actor is being destroyed inside its recursion stack.
 *
 * @param	ThisActor				Actor to remove.
 * @param	bNetForce				[opt] Ignored unless called during play.  Default is false.
 * @param	bShouldModifyLevel		[opt] If true, Modify() the level before removing the actor.  Default is true.
 * @return							true if destroy, false if actor couldn't be destroyed.
 */
bool UWorld::DestroyActor( AActor* ThisActor, bool bNetForce, bool bShouldModifyLevel )
{
	check(ThisActor);
	check(ThisActor->IsValidLowLevel());
	//UE_LOG(LogSpawn, Log,  "Destroy %s", *ThisActor->GetClass()->GetName() );

	if (ThisActor->GetWorld() == NULL)
	{
		UE_LOG(LogSpawn, Warning, TEXT("Destroying %s, which doesn't have a valid world pointer"), *ThisActor->GetPathName());
	}

	// If already on list to be deleted, pretend the call was successful.
	// We don't want recursive calls to trigger destruction notifications multiple times.
	if (ThisActor->IsPendingKillPending())
	{
		return true;
	}

	// In-game deletion rules.
	if( IsGameWorld() )
	{
		// Never destroy the world settings actor. This used to be enforced by bNoDelete and is actually needed for 
		// seamless travel and network games.
		if (GetWorldSettings() == ThisActor)
		{
			return false;
		}

		// Can't kill if wrong role.
		if( ThisActor->Role!=ROLE_Authority && !bNetForce && !ThisActor->bNetTemporary )
		{
			return false;
		}

		// Don't destroy player actors.
		APlayerController* PC = Cast<APlayerController>(ThisActor);
		if ( PC )
		{
			UNetConnection* C = Cast<UNetConnection>(PC->Player);
			if( C )
			{	
				if( C->Channels[0] && C->State!=USOCK_Closed )
				{
					C->bPendingDestroy = true;
					C->Channels[0]->Close();
				}
				return false;
			}
		}
	}
	else
	{
		ThisActor->Modify();
	}

	// Prevent recursion
	//FMarkActorIsBeingDestroyed MarkActorIsBeingDestroyed(ThisActor);

	// Notify the texture streaming manager about the destruction of this actor.
	IStreamingManager::Get().NotifyActorDestroyed( ThisActor );

	// Tell this actor it's about to be destroyed.
	ThisActor->Destroyed();

	// Detach this actor's children
	TArray<AActor*> AttachedActors;
	ThisActor->GetAttachedActors(AttachedActors);

	if (AttachedActors.Num() > 0)
	{
		TInlineComponentArray<USceneComponent*> SceneComponents;
		ThisActor->GetComponents(SceneComponents);

		for (TArray< AActor* >::TConstIterator AttachedActorIt(AttachedActors); AttachedActorIt; ++AttachedActorIt)
		{
			AActor* ChildActor = *AttachedActorIt;
			if (ChildActor != NULL)
			{
				for (auto SceneCompIter = SceneComponents.CreateIterator(); SceneCompIter; ++SceneCompIter)
				{
					ChildActor->DetachSceneComponentsFromParent(*SceneCompIter, true);
				}
#if WITH_EDITOR
				if( GIsEditor )
				{
					GEngine->BroadcastLevelActorDetached(ChildActor, ThisActor);
				}
#endif
			}
		}
	}

	// Detach from anything we were attached to
	USceneComponent* RootComp = ThisActor->GetRootComponent();
	if( RootComp != NULL && RootComp->AttachParent != NULL)
	{
		AActor* OldParentActor = RootComp->AttachParent->GetOwner();
		if (OldParentActor)
		{
			OldParentActor->Modify();
		}

		ThisActor->DetachRootComponentFromParent();

#if WITH_EDITOR
		if( GIsEditor )
		{
			GEngine->BroadcastLevelActorDetached(ThisActor, OldParentActor);
		}
#endif
	}

	ThisActor->ClearComponentOverlaps();

	// If this actor has an owner, notify it that it has lost a child.
	if( ThisActor->GetOwner() )
	{
		ThisActor->SetOwner(NULL);
	}
	// Notify net players that this guy has been destroyed.
	UNetDriver* ActorNetDriver = GEngine->FindNamedNetDriver(this, ThisActor->NetDriverName);
	if (ActorNetDriver)
	{
		ActorNetDriver->NotifyActorDestroyed(ThisActor);
	}

	if ( DemoNetDriver )
	{
		DemoNetDriver->NotifyActorDestroyed( ThisActor );
	}

	// Remove the actor from the actor list.
	RemoveActor( ThisActor, bShouldModifyLevel );

	// Invalidate the lighting cache in the Editor.  We need to check for GIsEditor as play has not begun in network game and objects get destroyed on switching levels
	if ( GIsEditor )
	{
		ThisActor->InvalidateLightingCache();
#if WITH_EDITOR
		GEngine->BroadcastLevelActorDeleted(ThisActor);
#endif
	}
		
	// Clean up the actor's components.
	ThisActor->UnregisterAllComponents();

	// Mark the actor and its direct components as pending kill.
	ThisActor->MarkPendingKill();
	ThisActor->MarkPackageDirty();
	ThisActor->MarkComponentsAsPendingKill();

	// Unregister the actor's tick function
	const bool bRegisterTickFunctions = false;
	const bool bIncludeComponents = true;
	ThisActor->RegisterAllActorTickFunctions(bRegisterTickFunctions, bIncludeComponents);

	// Return success.
	return true;
}
void DllWrapperRemoveActor( ActorId actorId )
{
	RemoveActor( actorId );
}