Replace invoke_engio with invoke_lua_call

This commit is contained in:
2024-08-29 17:46:12 -04:00
parent d520189a94
commit a61a74a7b0
4 changed files with 60 additions and 6 deletions

View File

@@ -0,0 +1,2 @@
[/Script/AdvancedPreviewScene.SharedProfiles]

View File

@@ -142,7 +142,8 @@ void AIntegrationGameModeBase::InvokeEngioMove(const FString &action, const FVec
FTCHARToUTF8 utf8action(action);
std::string uaction(utf8action.Get(), utf8action.Length());
FlxStreamBuffer sb;
sb.write_string("move"); // Function name within engio
sb.write_string("engio");
sb.write_string("move");
sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING);
sb.write_string(uaction);
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
@@ -152,13 +153,14 @@ void AIntegrationGameModeBase::InvokeEngioMove(const FString &action, const FVec
std::string_view datapk = sb.view();
FlxLockedWrapper w(LockableWrapper);
int64 player = w.GetActor();
w->play_invoke_engio(w.Get(), player, datapk.size(), datapk.data());
w->play_invoke_lua_call(w.Get(), player, datapk.size(), datapk.data());
}
void AIntegrationGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, const FString &fs) {
if (fs == "\\invokeplayer") {
DPrint(TEXT("Trying to invoke 'myfunction' in lua"));
FlxStreamBuffer sb;
sb.write_string("engio");
sb.write_string("myfunction");
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
sb.write_double(3.0);
@@ -168,7 +170,7 @@ void AIntegrationGameModeBase::ExecuteDebuggingCommand(FlxLockedWrapper &w, cons
sb.write_fvector(FVector(2,3,4));
std::string_view datapk = sb.view();
int64 player = w.GetActor();
w->play_invoke_engio(w.Get(), player, datapk.size(), datapk.data());
w->play_invoke_lua_call(w.Get(), player, datapk.size(), datapk.data());
} else {
ConsoleOutput.AppendLine(TEXT("Unknown Command"));
}

View File

@@ -6,6 +6,7 @@
#include "IntegrationGameModeBase.h"
#define DEFAULT_BLUEPRINT (TEXT("TangibleStaticMesh"))
#define LOCTEXT_NAMESPACE "Tangible"
UlxTangible::UlxTangible()
{
@@ -113,7 +114,7 @@ void UlxTangible::MaybeExecuteAnimStateChanged() {
FString blueprint = AnimTracker.GetCurrentBlueprintName();
if (blueprint.IsEmpty()) blueprint = DEFAULT_BLUEPRINT;
SetActorBlueprint(blueprint);
IlxTangibleInterface::Execute_AnimationStateChanged(GetActor());
IlxTangibleInterface::Execute_AnimationQueueChanged(GetActor());
}
}
@@ -173,4 +174,44 @@ bool UlxTangible::IsCurrentPlayer(AActor* target) {
void UlxTangible::SetAutoFinish(AActor *target, const FString &action, const FVector &xyz) {
UlxTangible *tan = GetActorTangible(target);
tan->AnimTracker.SetAutoFinish(action, xyz);
}
}
void UlxTangible::Assert(bool condition, const FString &message) {
if (!condition) {
FBlueprintExceptionInfo ExceptionInfo(EBlueprintExceptionType::FatalError, FText::FromString(message));
FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo);
}
}
void UlxTangible::CallFunctionByName(UObject *object, const FString &namepart1, const FString &namepart2, const FString &fallback) {
FString fullname = namepart1 + namepart2;
if (!IsValid(object)) {
const FBlueprintExceptionInfo ExceptionInfo(
EBlueprintExceptionType::FatalError,
LOCTEXT("CallFunctionByName_ObjectIsNotValid", "In CallFunctionByName, object passed in is not valid.")
);
FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo);
return;
}
UFunction* function = object->FindFunction(FName(*fullname));
if (function == nullptr) {
function = object->FindFunction(FName(*fallback));
if (function == nullptr) {
const FBlueprintExceptionInfo ExceptionInfo(
EBlueprintExceptionType::FatalError,
LOCTEXT("CallFunctionByName_NoSuchFunction", "In CallFunctionByName, cannot find the named function or the fallback function.")
);
FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo);
return;
}
}
if (function->ParmsSize != 0) {
const FBlueprintExceptionInfo ExceptionInfo(
EBlueprintExceptionType::FatalError,
LOCTEXT("CallFunctionByName_FunctionHasParameters", "CallFunctionByName can only call functions that have no parameters and no return values.")
);
FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo);
return;
}
object->ProcessEvent(function, nullptr);
}

View File

@@ -33,7 +33,7 @@ class INTEGRATION_API IlxTangibleInterface
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
UFUNCTION(BlueprintImplementableEvent, Category = "Tangible Functionality")
bool AnimationStateChanged();
bool AnimationQueueChanged();
UFUNCTION(BlueprintImplementableEvent, Category = "Tangible Functionality")
void BecomePossessed();
@@ -171,6 +171,15 @@ public:
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
static void SetAutoFinish(AActor *target, const FString &action, const FVector &xyz);
// Quit the game, reporting an error message to the log.
UFUNCTION(BlueprintCallable, Category = Luprex)
static void Assert(bool condition, const FString &ErrorMessage);
// Call a function by name, on any UObject. If the function doesn't exist, calls
// the fallback function instead. If that isn't found either, returns false.
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
static void CallFunctionByName(UObject *target, const FString &NamePart1, const FString &NamePart2, const FString &fallback);
};