// 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 "MapDeathTrigger.generated.h"

class UShapeComponent;

/**
 * Mapper-facing proxy for the game's death trigger -- the kill volume that respawns the
 * player at the last checkpoint.
 *
 * This is NOT the game's ARespawnTrigger. That class is AngelScript
 * (/Script/Angelscript.RespawnTrigger) and its volume lives in BP_DeathTrigger, so neither
 * is reachable from a vanilla-UE mapping project.
 *
 * Place this actor instead. At map load the shipped game swaps it for the real
 * BP_DeathTrigger at this same transform, copies this Box onto the Blueprint's own "Box",
 * and destroys the proxy. See Docs/SYNC.md for the swap contract, and the game's
 * Docs/CodeNotes.md [MODPROXY-01] for the rationale.
 *
 * A map may contain any number of these.
 */
UCLASS(Blueprintable, meta = (DisplayName = "Death Trigger"))
class VHOLUME_API AMapDeathTrigger : public AActor
{
    GENERATED_BODY()

public:
    AMapDeathTrigger();

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Death Trigger")
    USceneComponent *Root;

    // The kill volume. Overlapping it is the whole actor: the swap copies this extent and
    // relative transform onto BP_DeathTrigger's own "Box", so sizing it here is the only
    // thing a mapper authors.
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Death Trigger")
    UBoxComponent *Box;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Death Trigger")
    UBillboardComponent *Billboard;

    // Deliberately NO UPROPERTY the swap copies -- this proxy is geometry only. The game's
    // ARespawnTrigger declares bShowDeathTooltip and RespawnCustomText; both are held back
    // because a mod map has no reason to reword the death message, and RespawnCustomText is
    // an FText, i.e. mapper-authored strings shipped inside a pak. Adding either later is a
    // matching UPROPERTY on both sides and nothing else.

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