void UGISInventoryBaseComponent::InitializeComponent() { Super::InitializeComponent(); //if (!bHasBeenInitialized) //{ ENetRole CurrentRole = GetOwnerRole(); ENetMode CurrentNetMode = GetNetMode(); //PrimaryComponentTick.bStartWithTickEnabled = bTickInventory; if (CurrentRole == ROLE_Authority || CurrentNetMode == ENetMode::NM_Standalone) InitializeInventoryTabs(); if (CurrentRole < ROLE_Authority || CurrentNetMode == ENetMode::NM_Standalone) { if (InventoryContainerClass) { UObject* Outer = GetWorld()->GetGameInstance() ? StaticCast<UObject*>(GetWorld()->GetGameInstance()) : StaticCast<UObject*>(GetWorld()); InventoryContainer = ConstructObject<UGISContainerBaseWidget>(InventoryContainerClass, Outer); if (InventoryContainer) { ULocalPlayer* Player = World->GetFirstLocalPlayerFromController(); //temporary InventoryContainer->SetPlayerContext(FLocalPlayerContext(Player)); //temporary InventoryContainer->Initialize(); InventoryContainer->InventoryComponent = this; //call last InventoryContainer->InitializeContainer(); } } UObject* Outer = GetWorld()->GetGameInstance() ? StaticCast<UObject*>(GetWorld()->GetGameInstance()) : StaticCast<UObject*>(GetWorld()); if (LootWidgetClass) { LootWidget = ConstructObject<UGISLootContainerBaseWidget>(LootWidgetClass, Outer); if (LootWidget) { ULocalPlayer* Player = GetWorld()->GetFirstLocalPlayerFromController(); //temporary LootWidget->SetPlayerContext(FLocalPlayerContext(Player)); //temporary LootWidget->Initialize(); LootWidget->SetVisibility(ESlateVisibility::Hidden); } } } if (CurrentRole == ROLE_Authority || CurrentNetMode == ENetMode::NM_Standalone) ClientLoadInventory(); //} }
void UUserWidget::SetOwningLocalPlayer(ULocalPlayer* LocalPlayer) { if ( LocalPlayer ) { PlayerContext = FLocalPlayerContext(LocalPlayer); } }