2023-09-26 17:00:30 -04:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Components/ActorComponent.h"
|
|
|
|
|
#include "AnimQueue.h"
|
|
|
|
|
#include "Tangible.generated.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UlxTangibleManager;
|
|
|
|
|
|
|
|
|
|
// This class does not need to be modified.
|
|
|
|
|
UINTERFACE(Blueprintable)
|
|
|
|
|
class UlxTangibleInterface : public UInterface
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* IlxTangibleInterface
|
|
|
|
|
*
|
|
|
|
|
* This class implements the interface that an Actor must implement
|
|
|
|
|
* in order for that Actor to be usable as a Tangible.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class INTEGRATION_API IlxTangibleInterface
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
|
|
|
|
public:
|
|
|
|
|
UFUNCTION(BlueprintImplementableEvent, Category = "Tangible Functionality")
|
2023-10-02 15:48:42 -04:00
|
|
|
bool AnimationStateChanged();
|
2023-09-26 17:00:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* UlxTangible
|
|
|
|
|
*
|
|
|
|
|
* The Tangible stores all the data we need for a tangible,
|
|
|
|
|
* such as the animation queue and so forth.
|
|
|
|
|
*
|
|
|
|
|
* From time to time, a tangible can change its blueprint class.
|
|
|
|
|
* To do that, we have to delete and recreate the actor. This
|
|
|
|
|
* is all set up so that it is possible to do that.
|
|
|
|
|
*
|
|
|
|
|
* The tangible has a place to store an Actor pointer. This
|
|
|
|
|
* actor pointer is allowed to be nullptr, especially in the
|
|
|
|
|
* case that the blueprint hasn't been set yet.
|
|
|
|
|
*
|
|
|
|
|
* This also serves as a repository for blueprint functions
|
|
|
|
|
* that operate on tangible actors.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
UCLASS()
|
|
|
|
|
class INTEGRATION_API UlxTangible : public UObject
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UlxTangible();
|
|
|
|
|
|
|
|
|
|
// My Tangible Manager.
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TObjectPtr<UlxTangibleManager> Manager;
|
|
|
|
|
|
|
|
|
|
// The tangible ID.
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
uint64 TangibleId;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TWeakObjectPtr<AActor> CurrentActor;
|
|
|
|
|
|
|
|
|
|
// The blueprint class of the actor.
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TSubclassOf<AActor> ActorBlueprint;
|
|
|
|
|
|
|
|
|
|
// Animation tracker
|
|
|
|
|
FlxAnimTracker AnimTracker;
|
|
|
|
|
|
|
|
|
|
// Current Plane.
|
2023-09-28 14:32:48 -04:00
|
|
|
FName Plane;
|
2023-09-26 17:00:30 -04:00
|
|
|
|
|
|
|
|
// True if luprex thinks this object is Near the player.
|
|
|
|
|
bool NearAccordingToLuprex;
|
|
|
|
|
|
2023-09-28 14:32:48 -04:00
|
|
|
// True if unreal thinks this object is Near the player.
|
|
|
|
|
bool NearAccordingToUnreal;
|
|
|
|
|
|
2023-09-26 17:00:30 -04:00
|
|
|
public:
|
2023-09-28 14:32:48 -04:00
|
|
|
// Initialize a new tangible.
|
|
|
|
|
//
|
|
|
|
|
// This links the tangible to its TangibleManager and
|
|
|
|
|
// sets the tangible's ID.
|
|
|
|
|
//
|
2023-09-26 17:00:30 -04:00
|
|
|
void Init(UlxTangibleManager *tm, int64 id);
|
|
|
|
|
|
2023-09-28 14:32:48 -04:00
|
|
|
// Destroy a tangible.
|
|
|
|
|
//
|
|
|
|
|
// Delete the actor associated with the tangible, if any,
|
|
|
|
|
// and clean up everything else.
|
|
|
|
|
//
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
|
|
// Get the actor associated with this tangible.
|
|
|
|
|
//
|
|
|
|
|
// Note that this may return nullptr: it is valid for a
|
|
|
|
|
// tangible to have no actor associated with it. This
|
|
|
|
|
// is most commonly the case if the blueprint class of
|
|
|
|
|
// the tangible is set to nullptr.
|
|
|
|
|
//
|
|
|
|
|
// Also bear in mind that if a tangible changes its blueprint
|
|
|
|
|
// class, then the actor will have to be deleted and
|
|
|
|
|
// recreated. In that case, GetActor will return a different
|
|
|
|
|
// pointer than before the blueprint change.
|
|
|
|
|
//
|
|
|
|
|
AActor* GetActor() const { return CurrentActor.Get(); }
|
|
|
|
|
|
|
|
|
|
// Get the location of the tangible.
|
|
|
|
|
//
|
|
|
|
|
// Note that if the actor is nullptr, the location is always
|
|
|
|
|
// at the origin.
|
|
|
|
|
//
|
|
|
|
|
FVector GetLocation() const;
|
|
|
|
|
|
|
|
|
|
// Check a blueprint class to see if it is valid as a Tangible.
|
|
|
|
|
//
|
|
|
|
|
// In order for a blueprint class to be used as a tangible,
|
|
|
|
|
// it must implement the interface IlxTangibleInterface.
|
|
|
|
|
// This function also returns true for nullptr.
|
|
|
|
|
//
|
2023-09-26 17:00:30 -04:00
|
|
|
static bool BlueprintIsTangible(TSubclassOf<AActor> bp);
|
|
|
|
|
|
2023-09-28 14:32:48 -04:00
|
|
|
// Change the blueprint class of the tangible.
|
|
|
|
|
//
|
|
|
|
|
// This requires the deletion and recreation of the Actor.
|
|
|
|
|
// The blueprint class must satisfy 'BlueprintIsTangible' above.
|
|
|
|
|
//
|
|
|
|
|
// It is legal to pass in nullptr for the blueprint class.
|
|
|
|
|
// Whenever the blueprint class is nullptr, the Actor is
|
|
|
|
|
// also nullptr. Ie, a tangible will have no Actor associated
|
|
|
|
|
// with it if its blueprint class is nullptr.
|
|
|
|
|
//
|
2023-09-26 17:00:30 -04:00
|
|
|
void SetActorBlueprintClass(TSubclassOf<AActor> bp);
|
|
|
|
|
|
2023-09-28 14:32:48 -04:00
|
|
|
// Update the animation queue from Luprex.
|
|
|
|
|
//
|
|
|
|
|
// This reads the animation queue, and then based on
|
|
|
|
|
// what is new in the animation queue, it calls into
|
|
|
|
|
// the Actor's TangibleInterface, calling methods such
|
|
|
|
|
// as 'StartAnimation' and 'AbortAnimation' as necessary.
|
|
|
|
|
//
|
|
|
|
|
// If the animation queue specifies a blueprint change,
|
|
|
|
|
// this function will eventually implement that by calling
|
|
|
|
|
// SetActorBlueprintClass above. This is not implemented
|
|
|
|
|
// yet.
|
|
|
|
|
//
|
|
|
|
|
void UpdateAnimationQueue(std::string_view aq);
|
2023-09-26 17:00:30 -04:00
|
|
|
|
|
|
|
|
public:
|
2023-10-02 15:48:42 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
|
|
|
|
static void GetCurrentAnimation(AActor *target, FlxAnimationStep &step);
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
2023-10-09 14:59:48 -04:00
|
|
|
static void FinishedAnimation(AActor *target, const FlxAnimationStep &step,
|
|
|
|
|
bool AutoUpdateXYZ = true, bool AutoUpdateFacing = true, bool AutoUpdatePlane = true);
|
2023-10-02 15:48:42 -04:00
|
|
|
|
2023-09-26 17:00:30 -04:00
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
|
|
|
|
static FString GetTangiblePlane(AActor* target);
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
|
|
|
|
static void SetTangiblePlane(AActor* target, const FString& plane);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* UlxTangibleComponent
|
|
|
|
|
*
|
|
|
|
|
* The TangibleComponent holds a pointer to the Tangible.
|
|
|
|
|
* This is the only purpose it serves: to make it possible to
|
|
|
|
|
* have the Actor point to its corresponding Tangible.
|
|
|
|
|
*
|
|
|
|
|
* The TangibleComponent is procedurally inserted into the Actor.
|
|
|
|
|
* The TangibleComponent is not visible to blueprints.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
|
|
|
|
class INTEGRATION_API UlxTangibleComponent : public UActorComponent
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UlxTangibleComponent() : Tangible(nullptr) {}
|
|
|
|
|
|
|
|
|
|
// The actor that we're a part of.
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TWeakObjectPtr<UlxTangible> Tangible;
|
|
|
|
|
};
|