init
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "InteractableBase.h"
|
||||
#include "Components/WidgetComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "NakedDesire/InteractionSystem/InteractionManager.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
|
||||
AInteractableBase::AInteractableBase()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.TickInterval = 0.25f;
|
||||
|
||||
RootSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
|
||||
RootComponent = RootSceneComponent;
|
||||
|
||||
WidgetAnchor = CreateDefaultSubobject<USceneComponent>(TEXT("Widget Anchor"));
|
||||
WidgetAnchor->SetupAttachment(RootComponent);
|
||||
|
||||
InteractionTrigger = CreateDefaultSubobject<UWidgetComponent>(TEXT("Interaction Trigger"));
|
||||
InteractionTrigger->SetupAttachment(WidgetAnchor);
|
||||
|
||||
InteractionTrigger->SetDrawSize(FVector2D(35, 35));
|
||||
InteractionTrigger->SetWidgetSpace(EWidgetSpace::Screen);
|
||||
InteractionTrigger->SetWindowFocusable(false);
|
||||
}
|
||||
|
||||
void AInteractableBase::Tick(float DeltaSeconds)
|
||||
{
|
||||
Super::Tick(DeltaSeconds);
|
||||
|
||||
if (!Player)
|
||||
{
|
||||
if (ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0))
|
||||
{
|
||||
Player = Cast<ANakedDesireCharacter>(PlayerCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
if (Player)
|
||||
{
|
||||
const TScriptInterface<IInteractionTarget> NearestInteractionTarget = Player->InteractionManager->GetNearestInteractionTarget();
|
||||
if (NearestInteractionTarget.GetObject() == this)
|
||||
{
|
||||
InteractionTrigger->SetVisibility(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
InteractionTrigger->SetVisibility(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "NakedDesire/InteractionSystem/InteractionTarget.h"
|
||||
#include "InteractableBase.generated.h"
|
||||
|
||||
class ANakedDesireCharacter;
|
||||
class UWidgetComponent;
|
||||
|
||||
UCLASS()
|
||||
class NAKEDDESIRE_API AInteractableBase : public AActor, public IInteractionTarget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
USceneComponent* RootSceneComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
USceneComponent* WidgetAnchor = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
UWidgetComponent* InteractionTrigger = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
ANakedDesireCharacter* Player = nullptr;
|
||||
|
||||
public:
|
||||
AInteractableBase();
|
||||
|
||||
protected:
|
||||
virtual void Tick(float DeltaSeconds) override;
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "Wardrobe.h"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "InteractableBase.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Wardrobe.generated.h"
|
||||
|
||||
class UClothingItemData;
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class NAKEDDESIRE_API AWardrobe : public AInteractableBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
|
||||
TArray<UClothingItemData*> ClothingItems;
|
||||
};
|
||||
Reference in New Issue
Block a user