// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/BoxComponent.h"
#include "Components/BillboardComponent.h"
#include "Components/StaticMeshComponent.h"

#include "MapSpeedBoost.generated.h"

class UShapeComponent;

/**
 * Mapper-facing proxy for the game's speed boost trigger.
 *
 * This is NOT the game's BP_SpeedBoostTrigger. Place this actor instead in a
 * vanilla-UE mapping project. At map load the shipped game swaps it for
 * BP_SpeedBoostTrigger, copies these properties across by name, and destroys
 * the proxy.
 *
 * The game-side Blueprint turns these designer values into the argument combo
 * expected by ANewParkourCharacter::DoSpeedBoost. The anti-cheat magic combo
 * (BoostInvariable, BoostType1..5, BoostDuration) stays inside the Blueprint
 * and is not mirrored here.
 */
UCLASS(Blueprintable, meta = (DisplayName = "Speed Boost"))
class VHOLUME_API AMapSpeedBoost : public AActor
{
    GENERATED_BODY()

public:
    AMapSpeedBoost();

    /** Root scene component. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Speed Boost")
    USceneComponent* Root;

    /** Overlap volume that triggers the boost. The swap copies this onto the game BP. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Speed Boost")
    UBoxComponent* Box;

    /** Editor-only icon. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Speed Boost")
    UBillboardComponent* Billboard;

    /** Placeholder visual mesh so the boost is visible and selectable in the editor. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Speed Boost")
    UStaticMeshComponent* PlaceholderVisual;

    /** Amount of speed to apply. */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Speed Boost",
              meta = (ClampMin = "0.0"))
    float SpeedBoostValue;

    /**
     * If true, SpeedBoostValue is added to the current speed boost.
     * Otherwise it replaces the current value.
     */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Speed Boost")
    bool SpeedBoostAdditive;

    /** Maximum speed cap while the boost is active. 0 = no cap. */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Speed Boost",
              meta = (ClampMin = "0.0"))
    float SpeedBoostMax;

private:
    void ApplyCollisionSetup(UShapeComponent* ShapeComp) const;
};
