Working on look-at Widgets, not done yet.
This commit is contained in:
BIN
Content/Luprex/lxGameMode.uasset
LFS
BIN
Content/Luprex/lxGameMode.uasset
LFS
Binary file not shown.
BIN
Content/Luprex/lxUtilityMacroLibrary.uasset
LFS
Executable file → Normal file
BIN
Content/Luprex/lxUtilityMacroLibrary.uasset
LFS
Executable file → Normal file
Binary file not shown.
@@ -182,7 +182,12 @@ void AIntegrationGameModeBase::LuaCallEnd(InvocationKind kind, AActor *place) {
|
|||||||
if (place == nullptr) {
|
if (place == nullptr) {
|
||||||
LuaCallEnd(kind, int64(0));
|
LuaCallEnd(kind, int64(0));
|
||||||
} else {
|
} else {
|
||||||
LuaCallEnd(kind, UlxTangible::GetActorTangible(place)->TangibleId);
|
UlxTangible *tan = UlxTangible::GetActorTangibleOrLog(place);
|
||||||
|
if (tan == nullptr) {
|
||||||
|
LuaCallResult.clear();
|
||||||
|
} else {
|
||||||
|
LuaCallEnd(kind, tan->TangibleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,16 +339,17 @@ int64 AIntegrationGameModeBase::GetPlayerId() {
|
|||||||
return PlayerId;
|
return PlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
AIntegrationGameModeBase *AIntegrationGameModeBase::GetFromWorld(UWorld *world) {
|
AIntegrationGameModeBase *AIntegrationGameModeBase::GetLuprexGameMode(UObject *context) {
|
||||||
AIntegrationGameModeBase *result = world->GetAuthGameMode<AIntegrationGameModeBase>();
|
AIntegrationGameModeBase *result = context->GetWorld()->GetAuthGameMode<AIntegrationGameModeBase>();
|
||||||
if (result == nullptr) {
|
if (result == nullptr) {
|
||||||
UE_LOG(LogBlueprint, Fatal, TEXT("No IntegrationGameModeBase in this context"));
|
UE_LOG(LogBlueprint, Fatal, TEXT("Not currently using a Luprex Game Mode."));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AIntegrationGameModeBase *AIntegrationGameModeBase::GetFromContext(UObject *context) {
|
bool AIntegrationGameModeBase::IsLookAtChanged(UObject *context) {
|
||||||
return GetFromWorld(context->GetWorld());
|
AIntegrationGameModeBase *mode = GetLuprexGameMode(context);
|
||||||
|
return mode->CurrentLookAt.HitObjectHandle != mode->PreviousLookAt.HitObjectHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIntegrationGameModeBase::UpdateLookAt() {
|
void AIntegrationGameModeBase::UpdateLookAt() {
|
||||||
@@ -362,6 +368,10 @@ void AIntegrationGameModeBase::UpdateLookAt() {
|
|||||||
APlayerCameraManager *cam = pc->PlayerCameraManager;
|
APlayerCameraManager *cam = pc->PlayerCameraManager;
|
||||||
if (cam == nullptr) return;
|
if (cam == nullptr) return;
|
||||||
|
|
||||||
CalculateLookAt(pawn, pc, cam);
|
CalculateLookAt(pc);
|
||||||
|
|
||||||
|
if (IsLookAtChanged(this)) {
|
||||||
|
LookAtChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,17 +46,32 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous")
|
UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous")
|
||||||
int64 GetPlayerId();
|
int64 GetPlayerId();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Look-At Detection")
|
UFUNCTION(BlueprintPure, meta = (CompactNodeTitle="LxGameMode", WorldContext = "context"), Category = "Luprex|Miscellaneous")
|
||||||
void SetLookAt(const FHitResult &hit) { CurrentLookAt = hit; }
|
static AIntegrationGameModeBase *GetLuprexGameMode(UObject *context);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||||
|
static void SetLookAt(UObject *context, const FHitResult &hit) { GetLuprexGameMode(context)->CurrentLookAt = hit; }
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Look-At Detection")
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||||
const FHitResult &GetLookAt() const { return CurrentLookAt; }
|
static const FHitResult &GetLookAt(UObject *context) { return GetLuprexGameMode(context)->CurrentLookAt; }
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Look-At Detection")
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||||
bool LookAtChanged() const { return CurrentLookAt.HitObjectHandle != PreviousLookAt.HitObjectHandle; }
|
static const AActor *GetLookAtActor(UObject *context) { return GetLuprexGameMode(context)->CurrentLookAt.GetActor(); }
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||||
|
static const FHitResult &GetPreviousLookAt(UObject *context) { return GetLuprexGameMode(context)->PreviousLookAt; }
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||||
|
static const AActor *GetPreviousLookAtActor(UObject *context) { return GetLuprexGameMode(context)->PreviousLookAt.GetActor(); }
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "context"),Category = "Luprex|Look-At Detection")
|
||||||
|
static bool IsLookAtChanged(UObject *context);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
||||||
|
void CalculateLookAt(APlayerController *PlayerController);
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
||||||
void CalculateLookAt(AActor *Player, APlayerController *PlayerController, APlayerCameraManager *Camera);
|
void LookAtChanged();
|
||||||
|
|
||||||
// Assemble a lua call. To call into lua:
|
// Assemble a lua call. To call into lua:
|
||||||
//
|
//
|
||||||
@@ -103,11 +118,6 @@ public:
|
|||||||
// to update luprex sockets and update luprex itself.
|
// to update luprex sockets and update luprex itself.
|
||||||
virtual uint32 Run() override;
|
virtual uint32 Run() override;
|
||||||
|
|
||||||
// Get the AIntegrationGameModeBase given any UObject
|
|
||||||
// If there is no AIntegrationGameModeBase in that world context, fatal error
|
|
||||||
static AIntegrationGameModeBase *GetFromWorld(UWorld *world);
|
|
||||||
static AIntegrationGameModeBase *GetFromContext(UObject *context);
|
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UlxTangibleManager *TangibleManager;
|
UlxTangibleManager *TangibleManager;
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ FString UlxLuaCallLibrary::AllFunctionsWithPrefix(const TCHAR *Prefix)
|
|||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallBegin(UObject *context, const FString &cname, const FString &fname) {
|
void UlxLuaCallLibrary::LuaCallBegin(UObject *context, const FString &cname, const FString &fname) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
mode->LuaCallBegin();
|
mode->LuaCallBegin();
|
||||||
sb.write_string(cname);
|
sb.write_string(cname);
|
||||||
@@ -213,7 +213,7 @@ void UlxLuaCallLibrary::LuaCallBegin(UObject *context, const FString &cname, con
|
|||||||
|
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place) {
|
void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
mode->LuaCallEnd(InvocationKind::LUA_INVOKE, place);
|
mode->LuaCallEnd(InvocationKind::LUA_INVOKE, place);
|
||||||
@@ -221,7 +221,7 @@ void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place) {
|
|||||||
|
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place) {
|
void UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
mode->LuaCallEnd(InvocationKind::LUA_PROBE, place);
|
mode->LuaCallEnd(InvocationKind::LUA_PROBE, place);
|
||||||
@@ -229,7 +229,7 @@ void UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place) {
|
|||||||
|
|
||||||
|
|
||||||
void UlxLuaCallLibrary::InvokeEngioMove(UObject *context, const FString &action, const FVector &xyz, double facing) {
|
void UlxLuaCallLibrary::InvokeEngioMove(UObject *context, const FString &action, const FVector &xyz, double facing) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallBegin();
|
FlxStreamBuffer &sb = mode->LuaCallBegin();
|
||||||
sb.write_string("engio");
|
sb.write_string("engio");
|
||||||
sb.write_string("move");
|
sb.write_string("move");
|
||||||
@@ -244,7 +244,7 @@ void UlxLuaCallLibrary::InvokeEngioMove(UObject *context, const FString &action,
|
|||||||
|
|
||||||
|
|
||||||
ELpxSimpleDynamicTag UlxLuaCallLibrary::LuaCallNextResultType(UObject *context) {
|
ELpxSimpleDynamicTag UlxLuaCallLibrary::LuaCallNextResultType(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
if (sb.empty()) return ELpxSimpleDynamicTag::None;
|
if (sb.empty()) return ELpxSimpleDynamicTag::None;
|
||||||
int64_t total_reads = sb.total_reads();
|
int64_t total_reads = sb.total_reads();
|
||||||
@@ -267,7 +267,7 @@ ELpxSimpleDynamicTag UlxLuaCallLibrary::LuaCallNextResultType(UObject *context)
|
|||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallArgument_string(UObject *context, const FString &pstring) {
|
void UlxLuaCallLibrary::LuaCallArgument_string(UObject *context, const FString &pstring) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::STRING);
|
||||||
@@ -281,7 +281,7 @@ void UlxLuaCallLibrary::LuaCallArgument_name(UObject *context, const FName &pnam
|
|||||||
if ((tokvalue == 0) && !namestr.empty()) {
|
if ((tokvalue == 0) && !namestr.empty()) {
|
||||||
FatalBlueprintError(TEXT("Names passed to lua must be short, and must contain only lowercase and digits"));
|
FatalBlueprintError(TEXT("Names passed to lua must be short, and must contain only lowercase and digits"));
|
||||||
}
|
}
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::TOKEN);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::TOKEN);
|
||||||
@@ -289,7 +289,7 @@ void UlxLuaCallLibrary::LuaCallArgument_name(UObject *context, const FName &pnam
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallArgument_float(UObject *context, double pfloat) {
|
void UlxLuaCallLibrary::LuaCallArgument_float(UObject *context, double pfloat) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
||||||
@@ -297,7 +297,7 @@ void UlxLuaCallLibrary::LuaCallArgument_float(UObject *context, double pfloat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallArgument_int(UObject *context, int value) {
|
void UlxLuaCallLibrary::LuaCallArgument_int(UObject *context, int value) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::NUMBER);
|
||||||
@@ -305,7 +305,7 @@ void UlxLuaCallLibrary::LuaCallArgument_int(UObject *context, int value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallArgument_vector(UObject *context, const FVector &pvector) {
|
void UlxLuaCallLibrary::LuaCallArgument_vector(UObject *context, const FVector &pvector) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
||||||
@@ -313,7 +313,7 @@ void UlxLuaCallLibrary::LuaCallArgument_vector(UObject *context, const FVector &
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallArgument_vector2d(UObject *context, const FVector2D &pvector) {
|
void UlxLuaCallLibrary::LuaCallArgument_vector2d(UObject *context, const FVector2D &pvector) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::VECTOR);
|
||||||
@@ -323,7 +323,7 @@ void UlxLuaCallLibrary::LuaCallArgument_vector2d(UObject *context, const FVector
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UlxLuaCallLibrary::LuaCallArgument_boolean(UObject *context, bool pbool) {
|
void UlxLuaCallLibrary::LuaCallArgument_boolean(UObject *context, bool pbool) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
CheckNotEmpty(sb);
|
CheckNotEmpty(sb);
|
||||||
sb.write_simple_dynamic_tag(SimpleDynamicTag::BOOLEAN);
|
sb.write_simple_dynamic_tag(SimpleDynamicTag::BOOLEAN);
|
||||||
@@ -339,7 +339,7 @@ void UlxLuaCallLibrary::LuaCallArgument_boolean(UObject *context, bool pbool) {
|
|||||||
|
|
||||||
|
|
||||||
FString UlxLuaCallLibrary::LuaCallReturnValue_string(UObject *context) {
|
FString UlxLuaCallLibrary::LuaCallReturnValue_string(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::STRING) FatalBlueprintError(TEXT("expected lua to return a string"));
|
if (tag != SimpleDynamicTag::STRING) FatalBlueprintError(TEXT("expected lua to return a string"));
|
||||||
@@ -347,7 +347,7 @@ FString UlxLuaCallLibrary::LuaCallReturnValue_string(UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FName UlxLuaCallLibrary::LuaCallReturnValue_name(UObject *context) {
|
FName UlxLuaCallLibrary::LuaCallReturnValue_name(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::TOKEN) FatalBlueprintError(TEXT("expected lua to return a name"));
|
if (tag != SimpleDynamicTag::TOKEN) FatalBlueprintError(TEXT("expected lua to return a name"));
|
||||||
@@ -355,7 +355,7 @@ FName UlxLuaCallLibrary::LuaCallReturnValue_name(UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double UlxLuaCallLibrary::LuaCallReturnValue_float(UObject *context) {
|
double UlxLuaCallLibrary::LuaCallReturnValue_float(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::NUMBER) FatalBlueprintError(TEXT("expected lua to return a float"));
|
if (tag != SimpleDynamicTag::NUMBER) FatalBlueprintError(TEXT("expected lua to return a float"));
|
||||||
@@ -363,7 +363,7 @@ double UlxLuaCallLibrary::LuaCallReturnValue_float(UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int UlxLuaCallLibrary::LuaCallReturnValue_int(UObject *context) {
|
int UlxLuaCallLibrary::LuaCallReturnValue_int(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::NUMBER) FatalBlueprintError(TEXT("expected lua to return a number"));
|
if (tag != SimpleDynamicTag::NUMBER) FatalBlueprintError(TEXT("expected lua to return a number"));
|
||||||
@@ -371,7 +371,7 @@ int UlxLuaCallLibrary::LuaCallReturnValue_int(UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FVector UlxLuaCallLibrary::LuaCallReturnValue_vector(UObject *context) {
|
FVector UlxLuaCallLibrary::LuaCallReturnValue_vector(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::VECTOR) FatalBlueprintError(TEXT("expected lua to return a vector"));
|
if (tag != SimpleDynamicTag::VECTOR) FatalBlueprintError(TEXT("expected lua to return a vector"));
|
||||||
@@ -379,7 +379,7 @@ FVector UlxLuaCallLibrary::LuaCallReturnValue_vector(UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FVector2D UlxLuaCallLibrary::LuaCallReturnValue_vector2d(UObject *context) {
|
FVector2D UlxLuaCallLibrary::LuaCallReturnValue_vector2d(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::VECTOR) FatalBlueprintError(TEXT("expected lua to return a vector"));
|
if (tag != SimpleDynamicTag::VECTOR) FatalBlueprintError(TEXT("expected lua to return a vector"));
|
||||||
@@ -388,7 +388,7 @@ FVector2D UlxLuaCallLibrary::LuaCallReturnValue_vector2d(UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool UlxLuaCallLibrary::LuaCallReturnValue_boolean(UObject *context) {
|
bool UlxLuaCallLibrary::LuaCallReturnValue_boolean(UObject *context) {
|
||||||
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetFromContext(context);
|
AIntegrationGameModeBase *mode = AIntegrationGameModeBase::GetLuprexGameMode(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
FlxStreamBuffer &sb = mode->LuaCallGetResult();
|
||||||
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
SimpleDynamicTag tag = sb.read_simple_dynamic_tag();
|
||||||
if (tag != SimpleDynamicTag::BOOLEAN) FatalBlueprintError(TEXT("expected lua to return a boolean"));
|
if (tag != SimpleDynamicTag::BOOLEAN) FatalBlueprintError(TEXT("expected lua to return a boolean"));
|
||||||
|
|||||||
@@ -141,25 +141,32 @@ void UlxTangible::Destroy() {
|
|||||||
NearAccordingToUnreal = false;
|
NearAccordingToUnreal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxTangible *UlxTangible::GetActorTangible(AActor *actor) {
|
UlxTangible *UlxTangible::GetActorTangibleQuiet(AActor *actor) {
|
||||||
UlxTangibleComponent* comp = actor->GetComponentByClass<UlxTangibleComponent>();
|
UlxTangibleComponent* comp = actor->GetComponentByClass<UlxTangibleComponent>();
|
||||||
check(comp != nullptr);
|
if (comp == nullptr) return nullptr;
|
||||||
UlxTangible *result = comp->Tangible.Get();
|
return comp->Tangible.Get();
|
||||||
check(result != nullptr);
|
}
|
||||||
return result;
|
|
||||||
|
UlxTangible *UlxTangible::GetActorTangibleOrLog(AActor *actor) {
|
||||||
|
UlxTangible *tan = GetActorTangibleQuiet(actor);
|
||||||
|
if (tan == nullptr) {
|
||||||
|
UE_LOG(LogBlueprint, Error, TEXT("Not a luprex tangible: %s"), *actor->GetName());
|
||||||
|
}
|
||||||
|
return tan;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UlxTangible::GetCurrentAnimation(AActor *target, FlxAnimationStep &step) {
|
void UlxTangible::GetCurrentAnimation(AActor *target, FlxAnimationStep &step) {
|
||||||
step = GetActorTangible(target)->AnimTracker.GetCurrentAnimation();
|
UlxTangible *tan = GetActorTangibleOrLog(target);
|
||||||
|
if (tan == nullptr) {
|
||||||
|
step = FlxAnimationStep();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
step = tan->AnimTracker.GetCurrentAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UlxTangible::FinishedAnimation(AActor *target, const FlxAnimationStep &step, bool AutoUpdate) {
|
void UlxTangible::FinishedAnimation(AActor *target, const FlxAnimationStep &step, bool AutoUpdate) {
|
||||||
if (target == nullptr)
|
UlxTangible *tan = GetActorTangibleOrLog(target);
|
||||||
{
|
if (tan == nullptr) return;
|
||||||
UE_LOG(LogBlueprint, Error, TEXT("In FinishedAnimation, tangible cannot be null"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UlxTangible *tan = GetActorTangible(target);
|
|
||||||
if (AutoUpdate)
|
if (AutoUpdate)
|
||||||
{
|
{
|
||||||
step.AutoUpdateXYZ(target);
|
step.AutoUpdateXYZ(target);
|
||||||
@@ -172,21 +179,32 @@ void UlxTangible::FinishedAnimation(AActor *target, const FlxAnimationStep &step
|
|||||||
}
|
}
|
||||||
|
|
||||||
FString UlxTangible::GetTangiblePlane(AActor* target) {
|
FString UlxTangible::GetTangiblePlane(AActor* target) {
|
||||||
return GetActorTangible(target)->Plane.ToString();
|
UlxTangible *tan = GetActorTangibleOrLog(target);
|
||||||
|
if (tan == nullptr) return TEXT("");
|
||||||
|
return tan->Plane.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UlxTangible::SetTangiblePlane(AActor* target, const FString& plane) {
|
void UlxTangible::SetTangiblePlane(AActor* target, const FString& plane) {
|
||||||
GetActorTangible(target)->Plane = FName(plane);
|
UlxTangible *tan = GetActorTangibleOrLog(target);
|
||||||
|
if (tan == nullptr) return;
|
||||||
|
tan->Plane = FName(plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UlxTangible::IsCurrentPlayer(AActor* target) {
|
bool UlxTangible::IsCurrentPlayer(AActor* target) {
|
||||||
UlxTangible *tan = GetActorTangible(target);
|
UlxTangible *tan = GetActorTangibleQuiet(target);
|
||||||
|
if (tan == nullptr) return false;
|
||||||
AIntegrationGameModeBase *gamemode = tan->Manager->GetGameMode();
|
AIntegrationGameModeBase *gamemode = tan->Manager->GetGameMode();
|
||||||
return (tan->TangibleId == gamemode->PlayerId);
|
return (tan->TangibleId == gamemode->PlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UlxTangible::IsLuprexTangible(AActor* target) {
|
||||||
|
UlxTangible *tan = GetActorTangibleQuiet(target);
|
||||||
|
return tan != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void UlxTangible::SetAutoFinish(AActor *target, const FString &action, const FVector &xyz) {
|
void UlxTangible::SetAutoFinish(AActor *target, const FString &action, const FVector &xyz) {
|
||||||
UlxTangible *tan = GetActorTangible(target);
|
UlxTangible *tan = GetActorTangibleOrLog(target);
|
||||||
|
if (tan == nullptr) return;
|
||||||
tan->AnimTracker.SetAutoFinish(action, xyz);
|
tan->AnimTracker.SetAutoFinish(action, xyz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,13 @@ public:
|
|||||||
|
|
||||||
// Convert an actor to a tangible.
|
// Convert an actor to a tangible.
|
||||||
//
|
//
|
||||||
static UlxTangible *GetActorTangible(AActor *actor);
|
// The logging version of this function will generate a log
|
||||||
|
// message if the actor is not a tangible, and it will then return
|
||||||
|
// nullptr. The quiet version will just return nullptr.
|
||||||
|
//
|
||||||
|
static UlxTangible *GetActorTangibleQuiet(AActor *actor);
|
||||||
|
static UlxTangible *GetActorTangibleOrLog(AActor *actor);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Set the actor's blueprint, and recreate the actor if necessary.
|
// Set the actor's blueprint, and recreate the actor if necessary.
|
||||||
@@ -143,8 +149,11 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Tangible")
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Tangible")
|
||||||
static void SetTangiblePlane(AActor* target, const FString& plane);
|
static void SetTangiblePlane(AActor* target, const FString& plane);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Tangible")
|
UFUNCTION(BlueprintPure, Meta = (DefaultToSelf = "target"), Category = "Luprex|Tangible")
|
||||||
static bool IsCurrentPlayer(AActor *target);
|
static bool IsCurrentPlayer(AActor *target);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Meta = (DefaultToSelf = "target"), Category = "Luprex|Tangible")
|
||||||
|
static bool IsLuprexTangible(AActor *target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user