Implement new TangibleInterface appraoch
This commit is contained in:
Binary file not shown.
BIN
Content/TanActor.uasset
LFS
Normal file
BIN
Content/TanActor.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/TangibleActor.uasset
LFS
BIN
Content/TangibleActor.uasset
LFS
Binary file not shown.
BIN
Content/TangibleComponent.uasset
LFS
BIN
Content/TangibleComponent.uasset
LFS
Binary file not shown.
BIN
Content/__ExternalActors__/LpxLevel/E/4Q/3EJ0O2NJBUVLG13CK094EE.uasset
LFS
Normal file
BIN
Content/__ExternalActors__/LpxLevel/E/4Q/3EJ0O2NJBUVLG13CK094EE.uasset
LFS
Normal file
Binary file not shown.
@@ -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);
|
||||
|
||||
@@ -76,9 +76,12 @@ public:
|
||||
//
|
||||
bool Playing;
|
||||
|
||||
// Amount of elapsed time.
|
||||
// Amount of elapsed time since BeginPlay.
|
||||
float EngineSeconds;
|
||||
|
||||
// When do we next trigger the thread event (relative to EngineSeconds).
|
||||
// When do we next trigger the thread event.
|
||||
float NextThreadTrigger;
|
||||
|
||||
// When do we next rotate the cube.
|
||||
float NextRotateCube;
|
||||
};
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TangibleComponentBase.h"
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UTangibleComponentBase::UTangibleComponentBase()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UTangibleComponentBase::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UTangibleComponentBase::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "TangibleComponentBase.generated.h"
|
||||
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType, ClassGroup = (Custom), meta = (BlueprintSpawnableComponent), ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
class INTEGRATION_API UTangibleComponentBase : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UTangibleComponentBase();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
|
||||
|
||||
};
|
||||
6
Source/Integration/TangibleInterface.cpp
Normal file
6
Source/Integration/TangibleInterface.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TangibleInterface.h"
|
||||
|
||||
// Add default functionality here for any ITangibleInterface functions that are not pure virtual.
|
||||
27
Source/Integration/TangibleInterface.h
Normal file
27
Source/Integration/TangibleInterface.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "TangibleInterface.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UTangibleInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class INTEGRATION_API ITangibleInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category = "Tangible Functionality")
|
||||
void TurnFromCXX();
|
||||
};
|
||||
Reference in New Issue
Block a user