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

@@ -3,11 +3,12 @@
#include "IntegrationGameModeBase.h"
#include "lpx-drvutil.hpp"
#include "DebugPrint.h"
#include "Tangible.h"
#include "TangibleComponent.h"
#include "TangibleManager.h"
#include "TangibleInterface.h"
#include "CommonTypes.h"
#include "AnimQueue.h"
#include "IntegrationGameState.h"
#include <string>
#include <string_view>
@@ -119,11 +120,13 @@ void AIntegrationGameModeBase::MaybeTriggerUpdateTask(float deltaseconds) {
// FStructProperty* sprop = FindFProperty<FStructProperty>(uclass, nname);
//}
#pragma optimize("", off)
void AIntegrationGameModeBase::UpdateTangibles() {
if (!Playing) return;
FlxLockedWrapper w(LockableWrapper);
int64 actor = w.GetActor();
TangibleManager->SetActor(actor);
TangibleManager->SetPlayer(actor);
TangibleManager->SetNear(w.GetNear(actor, 100, 100, 100));
for (int64 id : TangibleManager->GetNear()) {
TangibleManager->MakeTangible(id);
@@ -133,19 +136,16 @@ void AIntegrationGameModeBase::UpdateTangibles() {
StringViewVec aqueues = w.GetAnimationQueues(tanids);
for (int i = 0; i < tanids.Num(); i++) {
uint64_t tanid = tanids[i];
std::string_view aqueue = aqueues[i];
UlxTangible* t = TangibleManager->GetTangible(tanid);
check(t != nullptr);
t->AnimTracker.Update(aqueue);
UTangibleComponent *t = TangibleManager->GetTangible(tanid);
t->AnimTracker.Update(aqueues[i]);
TArray<uint64> aborted = t->AnimTracker.GetAborted();
for (uint64 hash : aborted) {
IlxTangibleInterface::Execute_AbortAnimation(t->Actor, hash);
IlxTangibleInterface::Execute_AbortAnimation(t->GetActor(), hash);
}
FlxAnimationStep step;
ElxAnimationMode mode = t->AnimTracker.GetNextStep(step);
if (mode != ElxAnimationMode::INVALID) {
bool started = IlxTangibleInterface::Execute_StartAnimation(t->Actor, mode, step);
bool started = IlxTangibleInterface::Execute_StartAnimation(t->GetActor(), mode, step);
if (started) {
t->AnimTracker.StartedStep(step.Hash);
}
@@ -252,4 +252,16 @@ void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
ResetToInitialState();
}
namespace IntegrationGameState {
UTangibleManager* GetTangibleManager(AActor *actor) {
AGameModeBase* gmb = actor->GetWorld()->GetAuthGameMode();
AIntegrationGameModeBase* igmb = Cast<AIntegrationGameModeBase>(gmb);
if (igmb == nullptr) {
return nullptr;
} else {
return igmb->TangibleManager;
}
}
} // namespace IntegrationGameState