Add investor startup sequence
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// Copyright Pacificao. All Rights Reserved.
|
||||
|
||||
#include "AgrarianDemoNoticeActor.h"
|
||||
|
||||
#include "AgrarianDemoNoticeWidget.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Engine/World.h"
|
||||
#include "TimerManager.h"
|
||||
|
||||
AAgrarianDemoNoticeActor::AAgrarianDemoNoticeActor()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = false;
|
||||
NoticeWidgetClass = UAgrarianDemoNoticeWidget::StaticClass();
|
||||
}
|
||||
|
||||
void AAgrarianDemoNoticeActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
APlayerController* PlayerController = GetWorld() ? GetWorld()->GetFirstPlayerController() : nullptr;
|
||||
if (!PlayerController || !NoticeWidgetClass)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveNoticeWidget = CreateWidget<UAgrarianDemoNoticeWidget>(PlayerController, NoticeWidgetClass);
|
||||
if (!ActiveNoticeWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveNoticeWidget->VersionLabel = VersionLabel;
|
||||
ActiveNoticeWidget->DemoNotice = DemoNotice;
|
||||
ActiveNoticeWidget->AddToViewport(100);
|
||||
|
||||
GetWorldTimerManager().SetTimer(RemoveNoticeTimerHandle, this, &AAgrarianDemoNoticeActor::RemoveNotice, NoticeDurationSeconds, false);
|
||||
}
|
||||
|
||||
void AAgrarianDemoNoticeActor::RemoveNotice()
|
||||
{
|
||||
if (ActiveNoticeWidget)
|
||||
{
|
||||
ActiveNoticeWidget->RemoveFromParent();
|
||||
ActiveNoticeWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user