Move tangible state into TangibleComponent

This commit is contained in:
2023-09-25 18:00:34 -04:00
parent 2f5baf2e9f
commit 254524aab6
11 changed files with 211 additions and 72 deletions

View File

@@ -0,0 +1,56 @@
// 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 "TangibleComponent.generated.h"
/*
* TangibleComponent
*
* The TangibleManager procedurally injects a TangibleComponent
* into the actor. This gives us a place to store tangible-specific
* actor properties, such as the tangible Id, the animation queue,
* and so forth.
*
* To cooperate the with the garbage collector, don't store pointers
* to TangibleComponents in data structures. Instead, store a pointer
* to the actor and then use GetComponentByClass to retrieve the
* TangibleComponent on demand.
*
*/
class UTangibleManager;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class INTEGRATION_API UTangibleComponent : public UActorComponent
{
GENERATED_BODY()
public:
UTangibleComponent();
// The tangible ID.
UPROPERTY()
uint64 TangibleId;
// The actor that we're a part of.
UPROPERTY()
TWeakObjectPtr<AActor> Actor;
// Our tangible Manager.
UPROPERTY()
TWeakObjectPtr<UTangibleManager> TangibleManager;
// Animation tracker
FlxAnimTracker AnimTracker;
// Current Plane.
FString Plane;
void Init(UTangibleManager* tm, AActor* a, int64 id);
AActor* GetActor() const { return Actor.Get(); }
};