本文整理匯總了C++中GetNetMode函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetNetMode函數的具體用法?C++ GetNetMode怎麽用?C++ GetNetMode使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetNetMode函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ClientSlotSwap
void UGISInventoryBaseComponent::AddItemOnSlot(const FGISSlotInfo& TargetSlotType, const FGISSlotInfo& LastSlotType)
{
//Before we start swapping item, let's check if tags match!
if (!TargetSlotType.CurrentInventoryComponent->RequiredTags.MatchesAny(LastSlotType.CurrentInventoryComponent->OwnedTags, false))
return;
//next check should be against item tags, but that's later!
//Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotTabIndex].ItemData
if (TargetSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData == nullptr)
{
TWeakObjectPtr<UGISItemData> TargetItem = LastSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[LastSlotType.SlotTabIndex].TabSlots[LastSlotType.SlotIndex].ItemData;
TWeakObjectPtr<UGISItemData> LastItem = TargetSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData; //Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData;
TargetSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData = TargetItem;
LastSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[LastSlotType.SlotTabIndex].TabSlots[LastSlotType.SlotIndex].ItemData = nullptr;
TargetItem->OnItemAddedToSlot();
//FGISSlotSwapInfo SlotSwapInfo;
SlotSwapInfo.LastSlotIndex = LastSlotType.SlotIndex;
SlotSwapInfo.LastTabIndex = LastSlotType.SlotTabIndex;
SlotSwapInfo.LastSlotData = LastItem;
SlotSwapInfo.LastSlotComponent = LastSlotType.CurrentInventoryComponent;
SlotSwapInfo.TargetSlotIndex = TargetSlotType.SlotIndex;
SlotSwapInfo.TargetTabIndex = TargetSlotType.SlotTabIndex;
SlotSwapInfo.TargetSlotData = TargetItem;
SlotSwapInfo.TargetSlotComponent = TargetSlotType.CurrentInventoryComponent;
if (GetNetMode() == ENetMode::NM_Standalone)
OnItemSlotSwapped.Broadcast(SlotSwapInfo);
ClientSlotSwap(SlotSwapInfo);
}
else
{
TWeakObjectPtr<UGISItemData> TargetItem = LastSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[LastSlotType.SlotTabIndex].TabSlots[LastSlotType.SlotIndex].ItemData;
TWeakObjectPtr<UGISItemData> LastItem = TargetSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData; //Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData;
TargetSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[TargetSlotType.SlotTabIndex].TabSlots[TargetSlotType.SlotIndex].ItemData = TargetItem;
LastSlotType.CurrentInventoryComponent->Tabs.InventoryTabs[LastSlotType.SlotTabIndex].TabSlots[LastSlotType.SlotIndex].ItemData = LastItem;
TargetItem->OnItemAddedToSlot();
LastItem->OnItemAddedToSlot();
//FGISSlotSwapInfo SlotSwapInfo;
SlotSwapInfo.LastSlotIndex = LastSlotType.SlotIndex;
SlotSwapInfo.LastTabIndex = LastSlotType.SlotTabIndex;
SlotSwapInfo.LastSlotData = LastItem;
SlotSwapInfo.LastSlotComponent = LastSlotType.CurrentInventoryComponent;
SlotSwapInfo.TargetSlotIndex = TargetSlotType.SlotIndex;
SlotSwapInfo.TargetTabIndex = TargetSlotType.SlotTabIndex;
SlotSwapInfo.TargetSlotData = TargetItem;
SlotSwapInfo.TargetSlotComponent = TargetSlotType.CurrentInventoryComponent;
if (GetNetMode() == ENetMode::NM_Standalone)
OnItemSlotSwapped.Broadcast(SlotSwapInfo);
ClientSlotSwap(SlotSwapInfo);
}
}
示例2: GetNetMode
void AARCharacter::PossessedBy(AController* NewController)
{
ARPController = Cast<AARPlayerController>(NewController);
if ((GetNetMode() == ENetMode::NM_Standalone
|| GetNetMode() == ENetMode::NM_Client)
&& ARPController)
{
Abilities->PCOwner = ARPController;
Abilities->InitializeGUI();
}
Super::PossessedBy(NewController);
}
示例3: DealDamage
void AShooterWeapon_Instant::ProcessInstantHit_Confirmed(const FHitResult& Impact, const FVector& Origin, const FVector& ShootDir, int32 RandomSeed, float ReticleSpread)
{
// handle damage
if (ShouldDealDamage(Impact.GetActor()))
{
DealDamage(Impact, ShootDir);
}
// play FX on remote clients
if (Role == ROLE_Authority)
{
HitNotify.Origin = Origin;
HitNotify.RandomSeed = RandomSeed;
HitNotify.ReticleSpread = ReticleSpread;
}
// play FX locally
if (GetNetMode() != NM_DedicatedServer)
{
const FVector EndTrace = Origin + ShootDir * InstantConfig.WeaponRange;
const FVector EndPoint = Impact.GetActor() ? Impact.ImpactPoint : EndTrace;
SpawnTrailEffect(EndPoint);
SpawnImpactEffects(Impact);
}
}
示例4: ProcessInstantHit
void AShooterWeapon_Instant::ProcessInstantHit(const FHitResult& Impact, const FVector& Origin, const FVector& ShootDir, int32 RandomSeed, float ReticleSpread)
{
if (MyPawn && MyPawn->IsLocallyControlled() && GetNetMode() == NM_Client)
{
// if we're a client and we've hit something that is being controlled by the server
if (Impact.GetActor() && Impact.GetActor()->GetRemoteRole() == ROLE_Authority)
{
// notify the server of the hit
ServerNotifyHit(Impact, ShootDir, RandomSeed, ReticleSpread);
}
else if (Impact.GetActor() == NULL)
{
if (Impact.bBlockingHit)
{
// notify the server of the hit
ServerNotifyHit(Impact, ShootDir, RandomSeed, ReticleSpread);
}
else
{
// notify server of the miss
ServerNotifyMiss(ShootDir, RandomSeed, ReticleSpread);
}
}
}
// process a confirmed hit
ProcessInstantHit_Confirmed(Impact, Origin, ShootDir, RandomSeed, ReticleSpread);
}
示例5: GetWorld
void APawn::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (!IsPendingKill())
{
GetWorld()->AddPawn( this );
// Automatically add Controller to AI Pawns if we are allowed to.
if (AutoPossessPlayer == EAutoReceiveInput::Disabled)
{
if (AutoPossessAI != EAutoPossessAI::Disabled && Controller == NULL && GetNetMode() != NM_Client)
{
const bool bPlacedInWorld = (GetWorld()->bStartup);
if ((AutoPossessAI == EAutoPossessAI::PlacedInWorldOrSpawned) ||
(AutoPossessAI == EAutoPossessAI::PlacedInWorld && bPlacedInWorld) ||
(AutoPossessAI == EAutoPossessAI::Spawned && !bPlacedInWorld))
{
SpawnDefaultController();
}
}
}
// update movement component's nav agent values
UpdateNavAgent();
}
}
示例6: PreInitializeComponents
void APawn::PreInitializeComponents()
{
Super::PreInitializeComponents();
if (Instigator == nullptr)
{
Instigator = this;
}
if (AutoPossessPlayer != EAutoReceiveInput::Disabled && GetNetMode() != NM_Client )
{
const int32 PlayerIndex = int32(AutoPossessPlayer.GetValue()) - 1;
APlayerController* PC = UGameplayStatics::GetPlayerController(this, PlayerIndex);
if (PC)
{
PC->Possess(this);
}
else
{
GetWorld()->PersistentLevel->RegisterActorForAutoReceiveInput(this, PlayerIndex);
}
}
UpdateNavigationRelevance();
}
示例7: ForceNetUpdate
void APawn::PossessedBy(AController* NewController)
{
AController* const OldController = Controller;
Controller = NewController;
ForceNetUpdate();
if (Controller->PlayerState != NULL)
{
PlayerState = Controller->PlayerState;
}
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
{
if (GetNetMode() != NM_Standalone)
{
SetReplicates(true);
SetAutonomousProxy(true);
}
}
else
{
CopyRemoteRoleFrom(GetDefault<APawn>());
}
// dispatch Blueprint event if necessary
if (OldController != NewController)
{
ReceivePossessed(Controller);
}
}
示例8: PreInitializeComponents
void AWorldSettings::PreInitializeComponents()
{
Super::PreInitializeComponents();
// create the emitter pool
// we only need to do this for the persistent level's WorldSettings as sublevel actors will have their WorldSettings set to it on association
if (GetNetMode() != NM_DedicatedServer && IsInPersistentLevel())
{
UWorld* World = GetWorld();
check(World);
// only create once -
if (World->MyParticleEventManager == NULL && !GEngine->ParticleEventManagerClassPath.IsEmpty())
{
TSubclassOf<AParticleEventManager> ParticleEventManagerClass = Cast<UClass>(StaticLoadObject(UClass::StaticClass(), NULL, *GEngine->ParticleEventManagerClassPath, NULL, LOAD_NoWarn, NULL));
if (ParticleEventManagerClass != NULL)
{
FActorSpawnParameters SpawnParameters;
SpawnParameters.Owner = this;
SpawnParameters.Instigator = Instigator;
World->MyParticleEventManager = World->SpawnActor<AParticleEventManager>(ParticleEventManagerClass, SpawnParameters );
}
}
}
}
示例9: GetSlotsInTab
void UGISInventoryBaseComponent::CopyItemsFromOtherInventoryTab(class UGISInventoryBaseComponent* OtherIn, int32 OtherTabIndex, int32 TargetTabIndex)
{
if (OtherIn)
{
int32 OtherSlotCount = OtherIn->GetSlotsInTab(OtherTabIndex);
int32 TargetSlotCount = GetSlotsInTab(TargetTabIndex);
if (OtherSlotCount > TargetSlotCount)
{
for (int32 Index = 0; Index < TargetSlotCount; Index++)
{
SetItemDataInSlot(TargetTabIndex, Index, OtherIn->GetItemDataInSlot(OtherTabIndex,Index));
OnCopyItemsFromOtherInventoryTab(Tabs.InventoryTabs[TargetTabIndex].TabSlots[Index].ItemData);
}
}
else
{
for (int32 Index = 0; Index < OtherSlotCount; Index++)
{
SetItemDataInSlot(TargetTabIndex, Index, OtherIn->GetItemDataInSlot(OtherTabIndex, Index));
OnCopyItemsFromOtherInventoryTab(Tabs.InventoryTabs[TargetTabIndex].TabSlots[Index].ItemData);
}
}
TabUpdateInfo.ReplicationCounter++;
TabUpdateInfo.TargetTabIndex = TargetTabIndex;
if (GetNetMode() == ENetMode::NM_Standalone)
OnTabChanged.ExecuteIfBound(TabUpdateInfo.TargetTabIndex);
}
}
示例10: GetOwnerRole
void UGISInventoryBaseComponent::InitializeWidgets(APlayerController* PCIn)
{
ENetRole CurrentRole = GetOwnerRole();
ENetMode CurrentNetMode = GetNetMode();
if (CurrentRole < ROLE_Authority || CurrentNetMode == ENetMode::NM_Standalone)
{
if (InventoryConfiguration.IsValid())
{
InventoryContainer = CreateWidget<UGISContainerBaseWidget>(PCIn, InventoryConfiguration.InventoryContainerClass);
if (InventoryContainer)
{
InventoryContainer->InitializeContainer(InventoryConfiguration, this, PCIn);
InventoryContainer->SetVisibility(InventoryConfiguration.InventoryVisibility);
//call last
}
}
if (LootConfiguration.IsValid())
{
LootWidget = CreateWidget<UGISLootContainerBaseWidget>(PCIn, LootConfiguration.LootWidgetClass);
if (LootWidget)
{
LootWidget->InitializeLootWidget(LootConfiguration, this, PCIn);
LootWidget->SetVisibility(LootConfiguration.LootWindowVisibility);
}
}
}
}
示例11: GetWorld
void ANTPlayerController::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
AccumulativeDeltaTime += DeltaSeconds;
// If we're the Client and we haven't updated Ping in a while, try to get a ping update
const float LocTimeSec = GetWorld()->GetTimeSeconds();
if (((LocTimeSec - LastPingCalcTime) > 0.5f) && (GetNetMode() == NM_Client))
{
LastPingCalcTime = LocTimeSec;
ServerBouncePing(LocTimeSec);
}
if (PlayerState)
{
if (Role == ROLE_Authority && !IsLocalController())
{
GEngine->AddOnScreenDebugMessage(-1, DeltaSeconds, FColor::Blue, FString::Printf(TEXT("Server Ping %f - TimeStamp %i"), PlayerState->ExactPing, GetLocalTime()));
}
else if (Role < ROLE_Authority)
{
GEngine->AddOnScreenDebugMessage(-1, DeltaSeconds, FColor::Green, FString::Printf(TEXT("Client Ping %f - TimeStamp %i"), PlayerState->ExactPing, GetNetworkTime()));
}
}
}
示例12: onPickedUp
void AFPSGWeapon::onPickedUp(class AActor* otherActor)
{
GEngine->AddOnScreenDebugMessage(-1, 6.0f, FColor::Red, "AFPSGWeapon::onPickedUp");
/*
* Overlaps on AFPSGWeapon will only be executed on the server since only the server owns the boxCollisionComponent
*/
//Just return if we are a client (should not happen, but checks just in case)
if (Role < ROLE_Authority && GetNetMode() == NM_Client)
{
return;
}
// Get the character that picked up the weapon
AFPSGCharacter* theCharacter = Cast<AFPSGCharacter>(otherActor);
if (theCharacter != NULL)
{
if (GEngine != NULL)
{
//GEngine->AddOnScreenDebugMessage(-1, 6.0f, FColor::Red, TEXT("AFPSGWeapon::onPickedUp"));
}
theCharacter->manageWeapon(this);
}
}
示例13: GetWorld
void AGameplayDebuggingReplicator::TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction)
{
Super::TickActor(DeltaTime, TickType, ThisTickFunction);
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
UWorld* World = GetWorld();
if (!IsGlobalInWorld() || !World || GetNetMode() == ENetMode::NM_Client || !IGameplayDebugger::IsAvailable())
{
// global level replicator don't have any local player and it's prepared to work only on servers
return;
}
UGameInstance* GameInstance = World->GetGameInstance();
if (!GameInstance || !World->IsGameWorld())
{
return;
}
PlayerControllersUpdateDelay -= DeltaTime;
if (PlayerControllersUpdateDelay <= 0)
{
for (FConstPlayerControllerIterator Iterator = World->GetPlayerControllerIterator(); Iterator; Iterator++)
{
APlayerController* PC = *Iterator;
if (PC)
{
IGameplayDebugger& Debugger = IGameplayDebugger::Get();
Debugger.CreateGameplayDebuggerForPlayerController(PC);
}
}
PlayerControllersUpdateDelay = 5;
}
#endif
}
示例14: CalculateReloadAmmo
void AGWWeaponRanged::EndReload()
{
if (Role < ROLE_Authority)
{
if (!CheckIfCanReload())
return;
CalculateReloadAmmo();
ServerEndReload();
}
else
{
/*
Impelemtnsome reload mechanic..
1. Where is ammo coming from ?
2. How it is setup ?
3. Does weapon have it's own magazine max ammo count, or is it stored externally ?
*/
if (!CheckIfCanReload())
return;
CalculateReloadAmmo();
ReloadEndCount++;
if (GetNetMode() == ENetMode::NM_Standalone)
OnRep_ReloadEnd();
}
}
示例15: onClickEndGame
void AFPSGPlayerController::onClickEndGame() const
{
//Make sure it is the server calling the function
if (Role < ROLE_Authority && GetNetMode() == NM_Client) return;
//GEngine->AddOnScreenDebugMessage(-1, 40.0f, FColor::Cyan, "AFPSGPlayerController::onClickEndGame");
IOnlineSubsystem* onlineSubsystem = IOnlineSubsystem::Get();
IOnlineSessionPtr sessions = onlineSubsystem != NULL ? onlineSubsystem->GetSessionInterface() : NULL;
if (sessions.IsValid())
{
UWorld* world = GetWorld();
AFPSGGameState* gameState = world != NULL ? world->GetGameState<AFPSGGameState>() : NULL;
if (gameState != NULL)
{
//Retrieve the session state and match state
EOnlineSessionState::Type sessionState = sessions->GetSessionState(GameSessionName);
FName matchState = gameState->GetMatchState();
//Only attempt to end the game if both the session and match are in progress
if (sessionState == EOnlineSessionState::Type::InProgress && matchState == MatchState::InProgress)
{
gameState->onClickEndGame();
}
}
}
}