RealtimeStyleTransferRuntime/Source/LyraGame/Teams/AsyncAction_ObserveTeam.h

56 lines
1.8 KiB
C
Raw Permalink Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
2022-09-13 07:18:28 +00:00
#include "Delegates/Delegate.h"
2022-05-23 18:41:30 +00:00
#include "Engine/CancellableAsyncAction.h"
2022-09-13 07:18:28 +00:00
#include "HAL/Platform.h"
#include "UObject/Object.h"
#include "UObject/ScriptInterface.h"
#include "UObject/UObjectGlobals.h"
#include "UObject/WeakInterfacePtr.h"
2022-05-23 18:41:30 +00:00
#include "AsyncAction_ObserveTeam.generated.h"
2022-09-13 07:18:28 +00:00
class ILyraTeamAgentInterface;
struct FFrame;
2022-05-23 18:41:30 +00:00
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTeamObservedAsyncDelegate, bool, bTeamSet, int32, TeamId);
/**
* Watches for team changes in the specified object
*/
UCLASS()
class UAsyncAction_ObserveTeam : public UCancellableAsyncAction
{
GENERATED_UCLASS_BODY()
public:
// Watches for team changes on the specified team agent
// - It will will fire once immediately to give the current team assignment
// - For anything that can ever belong to a team (implements ILyraTeamAgentInterface),
// it will also listen for team assignment changes in the future
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly="true", Keywords="Watch"))
static UAsyncAction_ObserveTeam* ObserveTeam(UObject* TeamAgent);
//~UBlueprintAsyncActionBase interface
virtual void Activate() override;
virtual void SetReadyToDestroy() override;
//~End of UBlueprintAsyncActionBase interface
public:
// Called when the team is set or changed
UPROPERTY(BlueprintAssignable)
FTeamObservedAsyncDelegate OnTeamChanged;
private:
// Watches for team changes on the specified team actor
static UAsyncAction_ObserveTeam* InternalObserveTeamChanges(TScriptInterface<ILyraTeamAgentInterface> TeamActor);
private:
UFUNCTION()
void OnWatchedAgentChangedTeam(UObject* TeamAgent, int32 OldTeam, int32 NewTeam);
TWeakInterfacePtr<ILyraTeamAgentInterface> TeamInterfacePtr;
};