Implement new TangibleInterface appraoch

This commit is contained in:
2023-09-12 15:11:47 -04:00
parent 350816afb1
commit 7b58dea692
11 changed files with 69 additions and 79 deletions

View File

@@ -4,6 +4,7 @@
#include "lpx-drvutil.hpp"
#include "DebugPrint.h"
#include "TangibleManager.h"
#include "TangibleInterface.h"
#include "CommonTypes.h"
#include "AnimQueue.h"
#include <string>
@@ -68,6 +69,7 @@ void AIntegrationGameModeBase::ResetToInitialState()
// Reset the clocks.
EngineSeconds = 0;
NextThreadTrigger = 1.0;
NextRotateCube = 1.0;
}
@@ -94,14 +96,10 @@ void AIntegrationGameModeBase::UpdateConsoleOutput() {
void AIntegrationGameModeBase::MaybeTriggerUpdateTask(float deltaseconds) {
if (!Playing) return;
FLockedWrapper lockedwrap(LockableWrapper);
if (lockedwrap->engine != nullptr)
if (EngineSeconds >= NextThreadTrigger)
{
EngineSeconds += deltaseconds;
if (EngineSeconds >= NextThreadTrigger)
{
LuprexUpdateTask.Trigger();
NextThreadTrigger += 0.05;
}
LuprexUpdateTask.Trigger();
NextThreadTrigger += 0.05;
}
}
@@ -119,6 +117,19 @@ void AIntegrationGameModeBase::UpdateTangibles() {
for (int i = 0; i < aqueues.Num(); i++) {
FString debugq = FAnimQueueDecoder::DebugString(aqueues[i]);
}
// Tick all the tangibles.
if (EngineSeconds > NextRotateCube) {
for (int i = 0; i < live.Num(); i++) {
AActor* a = TangibleManager.GetTangible(live[i]);
check(a != nullptr);
bool hasInterface = a->GetClass()->ImplementsInterface(UTangibleInterface::StaticClass());
if (hasInterface) {
ITangibleInterface* iface = Cast<ITangibleInterface>(a);
iface->Execute_TurnFromCXX(a);
}
}
NextRotateCube += 0.5;
}
}
void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs)
@@ -142,6 +153,11 @@ void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs)
void AIntegrationGameModeBase::Tick(float deltaseconds)
{
Super::Tick(deltaseconds);
if (Playing)
{
EngineSeconds += deltaseconds;
}
UpdateConsoleOutput();
UpdateTangibles();
MaybeTriggerUpdateTask(deltaseconds);