diff --git a/Content/Developers/Wdev/Robots/BP_Stretch.uasset b/Content/Developers/Wdev/Robots/BP_Stretch.uasset index 5af2659f..407f376e 100644 Binary files a/Content/Developers/Wdev/Robots/BP_Stretch.uasset and b/Content/Developers/Wdev/Robots/BP_Stretch.uasset differ diff --git a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.dll b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.dll index e14537e7..942223cb 100644 Binary files a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.dll and b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.dll differ diff --git a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.exp b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.exp index 0c3da7ef..cd44fe25 100644 Binary files a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.exp and b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.exp differ diff --git a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.pdb b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.pdb index deb9a7da..736befc1 100644 Binary files a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.pdb and b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujoco-Win64-DebugGame.pdb differ diff --git a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.dll b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.dll index 51ff30d4..042b9f6e 100644 Binary files a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.dll and b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.dll differ diff --git a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.pdb b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.pdb index c077cd77..b3ee3a8e 100644 Binary files a/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.pdb and b/Plugins/LuckyMujoco/Binaries/Win64/UnrealEditor-LuckyMujocoEditor-Win64-DebugGame.pdb differ diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoActuatorComponent.cpp b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoActuatorComponent.cpp index d26eb2b7..e204c614 100644 --- a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoActuatorComponent.cpp +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoActuatorComponent.cpp @@ -1,14 +1,88 @@ #include "Components/MujocoActuatorComponent.h" +#include "Components/MujocoClassComponent.h" UMujocoActuatorComponent::UMujocoActuatorComponent() { PrimaryComponentTick.bCanEverTick = false; + ClassComponent = nullptr; +} + +void UMujocoActuatorComponent::BeginPlay() +{ + Super::BeginPlay(); + + // Try to find class component in owner if not set + if (!ClassComponent) + { + if (AActor* Owner = GetOwner()) + { + ClassComponent = Owner->FindComponentByClass(); + } + } +} + +void UMujocoActuatorComponent::OnRegister() +{ + Super::OnRegister(); + + // Try to find class component in owner during component registration + if (!ClassComponent) + { + if (AActor* Owner = GetOwner()) + { + ClassComponent = Owner->FindComponentByClass(); + } + } +} + +void UMujocoActuatorComponent::SetClassComponent(UMujocoClassComponent* NewClassComponent) +{ + if (NewClassComponent != ClassComponent) + { + // Remove from old class component if exists + if (ClassComponent) + { + ClassComponent->RemoveAssociatedComponent(this); + } + + ClassComponent = NewClassComponent; + + // Add to new class component if valid + if (ClassComponent) + { + ClassComponent->AddAssociatedComponent(this); + } + } +} + +FString UMujocoActuatorComponent::GetClassParameter(const FString& ParamName) const +{ + if (ClassComponent && ClassComponent->ClassData.Parameters.Contains(ParamName)) + { + return *ClassComponent->ClassData.Parameters.Find(ParamName); + } + return FString(); +} + +bool UMujocoActuatorComponent::HasClassComponent() const +{ + return ClassComponent != nullptr; } #if WITH_EDITORONLY_DATA void UMujocoActuatorComponent::OnComponentCreated() { Super::OnComponentCreated(); + + // Try to find class component in owner during creation + if (!ClassComponent) + { + if (AActor* Owner = GetOwner()) + { + ClassComponent = Owner->FindComponentByClass(); + } + } + if (GEngine && GetWorld()) { FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName()); @@ -19,6 +93,18 @@ void UMujocoActuatorComponent::OnComponentCreated() void UMujocoActuatorComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { Super::PostEditChangeProperty(PropertyChangedEvent); + + const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; + + if (PropertyName == GET_MEMBER_NAME_CHECKED(UMujocoActuatorComponent, ClassComponent)) + { + // Update associations when class component is changed in editor + if (ClassComponent) + { + ClassComponent->AddAssociatedComponent(this); + } + } + if (GEngine && GetWorld()) { FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName()); diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoClassComponent.cpp b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoClassComponent.cpp new file mode 100644 index 00000000..5b2d107f --- /dev/null +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoClassComponent.cpp @@ -0,0 +1,130 @@ +#include "Components/MujocoClassComponent.h" +#include "Components/MujocoJointComponent.h" +#include "Components/MujocoActuatorComponent.h" + +UMujocoClassComponent::UMujocoClassComponent() +{ + PrimaryComponentTick.bCanEverTick = false; + JointComponent = nullptr; + ActuatorComponent = nullptr; +} + +void UMujocoClassComponent::AddAssociatedComponent(UActorComponent* Component) +{ + if (Component) + { + AssociatedComponents.AddUnique(Component); + + // Also update single references if applicable + if (UMujocoJointComponent* JointComp = Cast(Component)) + { + SetJointComponent(JointComp); + } + else if (UMujocoActuatorComponent* ActuatorComp = Cast(Component)) + { + SetActuatorComponent(ActuatorComp); + } + } +} + +void UMujocoClassComponent::RemoveAssociatedComponent(UActorComponent* Component) +{ + if (Component) + { + AssociatedComponents.Remove(Component); + + // Also update single references if applicable + if (UMujocoJointComponent* JointComp = Cast(Component)) + { + if (JointComponent == JointComp) + { + JointComponent = nullptr; + } + } + else if (UMujocoActuatorComponent* ActuatorComp = Cast(Component)) + { + if (ActuatorComponent == ActuatorComp) + { + ActuatorComponent = nullptr; + } + } + } +} + +void UMujocoClassComponent::SetClassParameter(const FString& ParamName, const FString& ParamValue) +{ + ClassData.Parameters.Add(ParamName, ParamValue); +} + +void UMujocoClassComponent::SetJointComponent(UMujocoJointComponent* NewJointComponent) +{ + if (NewJointComponent != JointComponent) + { + // Remove old joint if exists + if (JointComponent) + { + RemoveAssociatedComponent(JointComponent); + } + + JointComponent = NewJointComponent; + ClassData.ClassType = EMujocoClassType::Joint; + + // Add to associated components if valid + if (JointComponent) + { + AssociatedComponents.AddUnique(JointComponent); + JointComponent->SetClassComponent(this); + } + } +} + +void UMujocoClassComponent::SetActuatorComponent(UMujocoActuatorComponent* NewActuatorComponent) +{ + if (NewActuatorComponent != ActuatorComponent) + { + // Remove old actuator if exists + if (ActuatorComponent) + { + RemoveAssociatedComponent(ActuatorComponent); + } + + ActuatorComponent = NewActuatorComponent; + ClassData.ClassType = EMujocoClassType::Actuator; + + // Add to associated components if valid + if (ActuatorComponent) + { + AssociatedComponents.AddUnique(ActuatorComponent); + ActuatorComponent->SetClassComponent(this); + } + } +} + +#if WITH_EDITORONLY_DATA +void UMujocoClassComponent::OnComponentCreated() +{ + Super::OnComponentCreated(); +} + +void UMujocoClassComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) +{ + Super::PostEditChangeProperty(PropertyChangedEvent); + + const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; + + if (PropertyName == GET_MEMBER_NAME_CHECKED(UMujocoClassComponent, JointComponent)) + { + if (JointComponent) + { + SetJointComponent(JointComponent); + } + } + else if (PropertyName == GET_MEMBER_NAME_CHECKED(UMujocoClassComponent, ActuatorComponent)) + { + if (ActuatorComponent) + { + SetActuatorComponent(ActuatorComponent); + } + } +} +#endif \ No newline at end of file diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoJointComponent.cpp b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoJointComponent.cpp index f214e608..b1a95c13 100644 --- a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoJointComponent.cpp +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Components/MujocoJointComponent.cpp @@ -1,38 +1,124 @@ #include "Components/MujocoJointComponent.h" #include "Components/MujocoBodyComponent.h" +#include "Components/MujocoClassComponent.h" UMujocoJointComponent::UMujocoJointComponent() { PrimaryComponentTick.bCanEverTick = false; + ClassComponent = nullptr; +} + +void UMujocoJointComponent::BeginPlay() +{ + Super::BeginPlay(); + + // Try to find class component in owner if not set + if (!ClassComponent) + { + if (AActor* Owner = GetOwner()) + { + ClassComponent = Owner->FindComponentByClass(); + } + } +} + +void UMujocoJointComponent::OnRegister() +{ + Super::OnRegister(); + + // Try to find class component in owner during component registration + if (!ClassComponent) + { + if (AActor* Owner = GetOwner()) + { + ClassComponent = Owner->FindComponentByClass(); + } + } +} + +void UMujocoJointComponent::SetClassComponent(UMujocoClassComponent* NewClassComponent) +{ + if (NewClassComponent != ClassComponent) + { + // Remove from old class component if exists + if (ClassComponent) + { + ClassComponent->RemoveAssociatedComponent(this); + } + + ClassComponent = NewClassComponent; + + // Add to new class component if valid + if (ClassComponent) + { + ClassComponent->AddAssociatedComponent(this); + } + } +} + +FString UMujocoJointComponent::GetClassParameter(const FString& ParamName) const +{ + if (ClassComponent && ClassComponent->ClassData.Parameters.Contains(ParamName)) + { + return *ClassComponent->ClassData.Parameters.Find(ParamName); + } + return FString(); +} + +bool UMujocoJointComponent::HasClassComponent() const +{ + return ClassComponent != nullptr; } #if WITH_EDITORONLY_DATA -void UMujocoJointComponent::OnComponentCreated() +void UMujocoJointComponent::OnComponentCreated() { - Super::OnComponentCreated(); - if (GEngine && GetWorld()) - { - if (UMujocoBodyComponent* ParentBody = Cast(GetAttachParent())) - { - FString BodyName = ParentBody->GetName(); - FString UniqueName = GenerateUniqueName(GetWorld(), this, BodyName + TEXT("_Joint")); - Rename(*UniqueName); - } - else - { - FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName()); - Rename(*UniqueName); - } - } + Super::OnComponentCreated(); + + // Try to find class component in owner during creation + if (!ClassComponent) + { + if (AActor* Owner = GetOwner()) + { + ClassComponent = Owner->FindComponentByClass(); + } + } + + if (GEngine && GetWorld()) + { + if (UMujocoBodyComponent* ParentBody = Cast(GetAttachParent())) + { + FString BodyName = ParentBody->GetName(); + FString UniqueName = GenerateUniqueName(GetWorld(), this, BodyName + TEXT("_Joint")); + Rename(*UniqueName); + } + else + { + FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName()); + Rename(*UniqueName); + } + } } -void UMujocoJointComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) +void UMujocoJointComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { - Super::PostEditChangeProperty(PropertyChangedEvent); - if (GEngine && GetWorld()) - { - FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName()); - Rename(*UniqueName); - } + Super::PostEditChangeProperty(PropertyChangedEvent); + + const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None; + + if (PropertyName == GET_MEMBER_NAME_CHECKED(UMujocoJointComponent, ClassComponent)) + { + // Update associations when class component is changed in editor + if (ClassComponent) + { + ClassComponent->AddAssociatedComponent(this); + } + } + + if (GEngine && GetWorld()) + { + FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName()); + Rename(*UniqueName); + } } #endif diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoActuatorComponent.h b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoActuatorComponent.h index 3571b1b3..25ceeeb7 100644 --- a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoActuatorComponent.h +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoActuatorComponent.h @@ -4,6 +4,7 @@ #include "Enums/MujocoEnums.h" #include "Structs/MujocoActuator.h" #include "Misc/UniqueNamedComponent.h" +#include "Components/MujocoClassComponent.h" #include "MujocoActuatorComponent.generated.h" UCLASS(Blueprintable, ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"), ShowCategories = (Mobility), editinlinenew, meta = (BlueprintSpawnableComponent)) @@ -20,8 +21,30 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") FMujocoActuatorV2 Actuator; + // Reference to the class component + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco", meta = (AllowPrivateAccess = "true")) + TObjectPtr ClassComponent; + + // Function to set class component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void SetClassComponent(UMujocoClassComponent* NewClassComponent); + + // Function to get class parameters + UFUNCTION(BlueprintCallable, Category = "Mujoco") + FString GetClassParameter(const FString& ParamName) const; + + // Function to check if has class component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + bool HasClassComponent() const; + #if WITH_EDITORONLY_DATA virtual void OnComponentCreated() override; virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; #endif + +protected: + virtual void BeginPlay() override; + + // Called when the game starts or when spawned + virtual void OnRegister() override; }; diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoClassComponent.h b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoClassComponent.h new file mode 100644 index 00000000..7fae2f46 --- /dev/null +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoClassComponent.h @@ -0,0 +1,94 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "Enums/MujocoEnums.h" +#include "Misc/UniqueNamedComponent.h" +#include "MujocoClassComponent.generated.h" + +UENUM(BlueprintType) +enum class EMujocoClassType : uint8 +{ + None UMETA(DisplayName = "None"), + Joint UMETA(DisplayName = "Joint"), + Actuator UMETA(DisplayName = "Actuator") +}; + +USTRUCT(BlueprintType) +struct FMujocoClassData +{ + GENERATED_BODY() + + // Class name for the Mujoco element + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + FString ClassName; + + // Type of the class + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + EMujocoClassType ClassType = EMujocoClassType::None; + + // Additional class-specific parameters can be added here + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + TMap Parameters; +}; + +UCLASS(Blueprintable, ClassGroup = (Mujoco), meta = (BlueprintSpawnableComponent)) +class LUCKYMUJOCO_API UMujocoClassComponent : public UActorComponent, public TUniqueNamedComponent +{ + GENERATED_BODY() + +public: + UMujocoClassComponent(); + + UPROPERTY(Transient, VisibleAnywhere, Category = "Mujoco") + int32 MujocoID = -1; + + // Class data for the Mujoco element + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + FMujocoClassData ClassData; + + // Reference to associated components (joints, actuators, etc.) + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + TArray AssociatedComponents; + + // Single reference to a joint component + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + TObjectPtr JointComponent; + + // Single reference to an actuator component + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") + TObjectPtr ActuatorComponent; + +#if WITH_EDITORONLY_DATA + virtual void OnComponentCreated() override; + virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; +#endif + + // Function to add associated components + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void AddAssociatedComponent(UActorComponent* Component); + + // Function to remove associated components + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void RemoveAssociatedComponent(UActorComponent* Component); + + // Function to set class parameters + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void SetClassParameter(const FString& ParamName, const FString& ParamValue); + + // Function to set single joint component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void SetJointComponent(class UMujocoJointComponent* NewJointComponent); + + // Function to set single actuator component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void SetActuatorComponent(class UMujocoActuatorComponent* NewActuatorComponent); + + // Function to get single joint component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + class UMujocoJointComponent* GetJointComponent() const { return JointComponent; } + + // Function to get single actuator component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + class UMujocoActuatorComponent* GetActuatorComponent() const { return ActuatorComponent; } +}; \ No newline at end of file diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoJointComponent.h b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoJointComponent.h index 227c41e5..22ad5f03 100644 --- a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoJointComponent.h +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Components/MujocoJointComponent.h @@ -5,6 +5,7 @@ #include "Components/SceneComponent.h" #include "Structs/MujocoJoint.h" #include "Misc/UniqueNamedComponent.h" +#include "Components/MujocoClassComponent.h" #include "MujocoJointComponent.generated.h" UCLASS(Blueprintable, ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"), editinlinenew, meta = (BlueprintSpawnableComponent)) @@ -21,8 +22,30 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco") FMujocoJoint Joint; + // Reference to the class component + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco", meta = (AllowPrivateAccess = "true")) + TObjectPtr ClassComponent; + + // Function to set class component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void SetClassComponent(UMujocoClassComponent* NewClassComponent); + + // Function to get class parameters + UFUNCTION(BlueprintCallable, Category = "Mujoco") + FString GetClassParameter(const FString& ParamName) const; + + // Function to check if has class component + UFUNCTION(BlueprintCallable, Category = "Mujoco") + bool HasClassComponent() const; + #if WITH_EDITORONLY_DATA virtual void OnComponentCreated() override; virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; #endif + +protected: + virtual void BeginPlay() override; + + // Called when the game starts or when spawned + virtual void OnRegister() override; }; diff --git a/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp b/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp index 41081cbc..f4e8e8e8 100644 --- a/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp +++ b/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp @@ -1,4 +1,4 @@ -// Fill out your copyright notice in the Description page of Project Settings. +// Fill out your copyright notice in the Description page of Project Settings. #include "Core/LuckyRobotsGameInstance.h" @@ -663,6 +663,30 @@ void ULuckyRobotsGameInstance::SetLuckyRobot(FString RobotName) UE_LOG(LogTemp, Error, TEXT("Invalid robot name: %s"), *RobotName); } } + +void ULuckyRobotsGameInstance::LuckyLevelOpen(FString LevelName) +{ + if (LevelName.IsEmpty()) + { + UE_LOG(LogTemp, Warning, TEXT("Level name is empty!")); + return; + } + + // Level opening logic + if (UWorld* World = GetWorld()) + { + FName LevelFName(*LevelName); + if (FPackageName::DoesPackageExist(LevelName)) + { + UGameplayStatics::OpenLevel(World, FName(*LevelName)); + UE_LOG(LogTemp, Log, TEXT("Opening level: %s"), *LevelName); + } + else + { + UE_LOG(LogTemp, Error, TEXT("Level '%s' does not exist!"), *LevelName); + } + } +} void ULuckyRobotsGameInstance::LuckyRobots() { UEnum* EnumPtr = StaticEnum(); @@ -674,7 +698,7 @@ void ULuckyRobotsGameInstance::LuckyRobots() Name = Name.Replace(TEXT("ERobotsName::"), TEXT("")); GameUserWidget->DoLogItemAdd("Robot:", Name, ELogItemType::Consol); UE_LOG(LogTemp, Display, TEXT("Robot: %s"), *Name); - if (GEngine) + if (EUnrealBuildType::Development == CheckBuildConfiguration()) { GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, FString::Printf(TEXT("Robot selected: %s"), *Name)); } diff --git a/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h b/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h index d6b16840..c5eacf15 100644 --- a/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h +++ b/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h @@ -327,7 +327,8 @@ public: void SetLuckyRobot(FString RobotName); UFUNCTION(exec) void LuckyRobots(); - + UFUNCTION(Exec) + void LuckyLevelOpen(FString LevelName); UFUNCTION(BlueprintPure) EUnrealBuildType CheckBuildConfiguration() const;