Compare commits
No commits in common. "gurkan.bug.fix" and "main" have entirely different histories.
gurkan.bug
...
main
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,88 +1,14 @@
|
|||||||
#include "Components/MujocoActuatorComponent.h"
|
#include "Components/MujocoActuatorComponent.h"
|
||||||
#include "Components/MujocoClassComponent.h"
|
|
||||||
|
|
||||||
UMujocoActuatorComponent::UMujocoActuatorComponent()
|
UMujocoActuatorComponent::UMujocoActuatorComponent()
|
||||||
{
|
{
|
||||||
PrimaryComponentTick.bCanEverTick = false;
|
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<UMujocoClassComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UMujocoActuatorComponent::OnRegister()
|
|
||||||
{
|
|
||||||
Super::OnRegister();
|
|
||||||
|
|
||||||
// Try to find class component in owner during component registration
|
|
||||||
if (!ClassComponent)
|
|
||||||
{
|
|
||||||
if (AActor* Owner = GetOwner())
|
|
||||||
{
|
|
||||||
ClassComponent = Owner->FindComponentByClass<UMujocoClassComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
#if WITH_EDITORONLY_DATA
|
||||||
void UMujocoActuatorComponent::OnComponentCreated()
|
void UMujocoActuatorComponent::OnComponentCreated()
|
||||||
{
|
{
|
||||||
Super::OnComponentCreated();
|
Super::OnComponentCreated();
|
||||||
|
|
||||||
// Try to find class component in owner during creation
|
|
||||||
if (!ClassComponent)
|
|
||||||
{
|
|
||||||
if (AActor* Owner = GetOwner())
|
|
||||||
{
|
|
||||||
ClassComponent = Owner->FindComponentByClass<UMujocoClassComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GEngine && GetWorld())
|
if (GEngine && GetWorld())
|
||||||
{
|
{
|
||||||
FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName());
|
FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName());
|
||||||
@ -93,18 +19,6 @@ void UMujocoActuatorComponent::OnComponentCreated()
|
|||||||
void UMujocoActuatorComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
void UMujocoActuatorComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||||
{
|
{
|
||||||
Super::PostEditChangeProperty(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())
|
if (GEngine && GetWorld())
|
||||||
{
|
{
|
||||||
FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName());
|
FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName());
|
||||||
|
@ -1,130 +0,0 @@
|
|||||||
#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<UMujocoJointComponent>(Component))
|
|
||||||
{
|
|
||||||
SetJointComponent(JointComp);
|
|
||||||
}
|
|
||||||
else if (UMujocoActuatorComponent* ActuatorComp = Cast<UMujocoActuatorComponent>(Component))
|
|
||||||
{
|
|
||||||
SetActuatorComponent(ActuatorComp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UMujocoClassComponent::RemoveAssociatedComponent(UActorComponent* Component)
|
|
||||||
{
|
|
||||||
if (Component)
|
|
||||||
{
|
|
||||||
AssociatedComponents.Remove(Component);
|
|
||||||
|
|
||||||
// Also update single references if applicable
|
|
||||||
if (UMujocoJointComponent* JointComp = Cast<UMujocoJointComponent>(Component))
|
|
||||||
{
|
|
||||||
if (JointComponent == JointComp)
|
|
||||||
{
|
|
||||||
JointComponent = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (UMujocoActuatorComponent* ActuatorComp = Cast<UMujocoActuatorComponent>(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
|
|
@ -1,89 +1,15 @@
|
|||||||
#include "Components/MujocoJointComponent.h"
|
#include "Components/MujocoJointComponent.h"
|
||||||
#include "Components/MujocoBodyComponent.h"
|
#include "Components/MujocoBodyComponent.h"
|
||||||
#include "Components/MujocoClassComponent.h"
|
|
||||||
|
|
||||||
UMujocoJointComponent::UMujocoJointComponent()
|
UMujocoJointComponent::UMujocoJointComponent()
|
||||||
{
|
{
|
||||||
PrimaryComponentTick.bCanEverTick = false;
|
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<UMujocoClassComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UMujocoJointComponent::OnRegister()
|
|
||||||
{
|
|
||||||
Super::OnRegister();
|
|
||||||
|
|
||||||
// Try to find class component in owner during component registration
|
|
||||||
if (!ClassComponent)
|
|
||||||
{
|
|
||||||
if (AActor* Owner = GetOwner())
|
|
||||||
{
|
|
||||||
ClassComponent = Owner->FindComponentByClass<UMujocoClassComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
#if WITH_EDITORONLY_DATA
|
||||||
void UMujocoJointComponent::OnComponentCreated()
|
void UMujocoJointComponent::OnComponentCreated()
|
||||||
{
|
{
|
||||||
Super::OnComponentCreated();
|
Super::OnComponentCreated();
|
||||||
|
|
||||||
// Try to find class component in owner during creation
|
|
||||||
if (!ClassComponent)
|
|
||||||
{
|
|
||||||
if (AActor* Owner = GetOwner())
|
|
||||||
{
|
|
||||||
ClassComponent = Owner->FindComponentByClass<UMujocoClassComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GEngine && GetWorld())
|
if (GEngine && GetWorld())
|
||||||
{
|
{
|
||||||
if (UMujocoBodyComponent* ParentBody = Cast<UMujocoBodyComponent>(GetAttachParent()))
|
if (UMujocoBodyComponent* ParentBody = Cast<UMujocoBodyComponent>(GetAttachParent()))
|
||||||
@ -103,18 +29,6 @@ void UMujocoJointComponent::OnComponentCreated()
|
|||||||
void UMujocoJointComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
void UMujocoJointComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||||
{
|
{
|
||||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
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())
|
if (GEngine && GetWorld())
|
||||||
{
|
{
|
||||||
FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName());
|
FString UniqueName = GenerateUniqueName(GetWorld(), this, GetName());
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "Enums/MujocoEnums.h"
|
#include "Enums/MujocoEnums.h"
|
||||||
#include "Structs/MujocoActuator.h"
|
#include "Structs/MujocoActuator.h"
|
||||||
#include "Misc/UniqueNamedComponent.h"
|
#include "Misc/UniqueNamedComponent.h"
|
||||||
#include "Components/MujocoClassComponent.h"
|
|
||||||
#include "MujocoActuatorComponent.generated.h"
|
#include "MujocoActuatorComponent.generated.h"
|
||||||
|
|
||||||
UCLASS(Blueprintable, ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"), ShowCategories = (Mobility), editinlinenew, meta = (BlueprintSpawnableComponent))
|
UCLASS(Blueprintable, ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"), ShowCategories = (Mobility), editinlinenew, meta = (BlueprintSpawnableComponent))
|
||||||
@ -21,30 +20,8 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco")
|
||||||
FMujocoActuatorV2 Actuator;
|
FMujocoActuatorV2 Actuator;
|
||||||
|
|
||||||
// Reference to the class component
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco", meta = (AllowPrivateAccess = "true"))
|
|
||||||
TObjectPtr<UMujocoClassComponent> 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
|
#if WITH_EDITORONLY_DATA
|
||||||
virtual void OnComponentCreated() override;
|
virtual void OnComponentCreated() override;
|
||||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
|
||||||
virtual void OnRegister() override;
|
|
||||||
};
|
};
|
||||||
|
@ -1,94 +0,0 @@
|
|||||||
#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<FString, FString> 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<UActorComponent*> AssociatedComponents;
|
|
||||||
|
|
||||||
// Single reference to a joint component
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco")
|
|
||||||
TObjectPtr<class UMujocoJointComponent> JointComponent;
|
|
||||||
|
|
||||||
// Single reference to an actuator component
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco")
|
|
||||||
TObjectPtr<class UMujocoActuatorComponent> 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; }
|
|
||||||
};
|
|
@ -5,7 +5,6 @@
|
|||||||
#include "Components/SceneComponent.h"
|
#include "Components/SceneComponent.h"
|
||||||
#include "Structs/MujocoJoint.h"
|
#include "Structs/MujocoJoint.h"
|
||||||
#include "Misc/UniqueNamedComponent.h"
|
#include "Misc/UniqueNamedComponent.h"
|
||||||
#include "Components/MujocoClassComponent.h"
|
|
||||||
#include "MujocoJointComponent.generated.h"
|
#include "MujocoJointComponent.generated.h"
|
||||||
|
|
||||||
UCLASS(Blueprintable, ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"), editinlinenew, meta = (BlueprintSpawnableComponent))
|
UCLASS(Blueprintable, ClassGroup = (Rendering, Common), hidecategories = (Object, Activation, "Components|Activation"), editinlinenew, meta = (BlueprintSpawnableComponent))
|
||||||
@ -22,30 +21,8 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco")
|
||||||
FMujocoJoint Joint;
|
FMujocoJoint Joint;
|
||||||
|
|
||||||
// Reference to the class component
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mujoco", meta = (AllowPrivateAccess = "true"))
|
|
||||||
TObjectPtr<UMujocoClassComponent> 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
|
#if WITH_EDITORONLY_DATA
|
||||||
virtual void OnComponentCreated() override;
|
virtual void OnComponentCreated() override;
|
||||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
|
||||||
virtual void OnRegister() override;
|
|
||||||
};
|
};
|
||||||
|
@ -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"
|
#include "Core/LuckyRobotsGameInstance.h"
|
||||||
@ -663,30 +663,6 @@ void ULuckyRobotsGameInstance::SetLuckyRobot(FString RobotName)
|
|||||||
UE_LOG(LogTemp, Error, TEXT("Invalid robot name: %s"), *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()
|
void ULuckyRobotsGameInstance::LuckyRobots()
|
||||||
{
|
{
|
||||||
UEnum* EnumPtr = StaticEnum<ERobotsName>();
|
UEnum* EnumPtr = StaticEnum<ERobotsName>();
|
||||||
@ -698,7 +674,7 @@ void ULuckyRobotsGameInstance::LuckyRobots()
|
|||||||
Name = Name.Replace(TEXT("ERobotsName::"), TEXT(""));
|
Name = Name.Replace(TEXT("ERobotsName::"), TEXT(""));
|
||||||
GameUserWidget->DoLogItemAdd("Robot:", Name, ELogItemType::Consol);
|
GameUserWidget->DoLogItemAdd("Robot:", Name, ELogItemType::Consol);
|
||||||
UE_LOG(LogTemp, Display, TEXT("Robot: %s"), *Name);
|
UE_LOG(LogTemp, Display, TEXT("Robot: %s"), *Name);
|
||||||
if (EUnrealBuildType::Development == CheckBuildConfiguration())
|
if (GEngine)
|
||||||
{
|
{
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, FString::Printf(TEXT("Robot selected: %s"), *Name));
|
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, FString::Printf(TEXT("Robot selected: %s"), *Name));
|
||||||
}
|
}
|
||||||
|
@ -327,8 +327,7 @@ public:
|
|||||||
void SetLuckyRobot(FString RobotName);
|
void SetLuckyRobot(FString RobotName);
|
||||||
UFUNCTION(exec)
|
UFUNCTION(exec)
|
||||||
void LuckyRobots();
|
void LuckyRobots();
|
||||||
UFUNCTION(Exec)
|
|
||||||
void LuckyLevelOpen(FString LevelName);
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
EUnrealBuildType CheckBuildConfiguration() const;
|
EUnrealBuildType CheckBuildConfiguration() const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user