// Copyright IHY. Vertical Partition Streaming plugin. // // In-world coordinator. One per streamed level (auto-spawned by the volume at // BeginPlay, or placed manually). Determines the tracked player's current cell, // drives the runtime subsystem at the configured interval, and hosts the debug // component. Keep this lightweight: the heavy lifting is in the subsystem. #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "VerticalPartitionTypes.h" #include "VerticalPartitionManager.generated.h" class UVerticalPartitionDescriptor; class UVerticalPartitionDebugComponent; class AVerticalPartitionVolume; UCLASS() class VERTICALPARTITION_API AVerticalPartitionManager : public AActor { GENERATED_BODY() public: AVerticalPartitionManager(); /** Descriptor to stream. If unset, the manager searches the level for a volume. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="VerticalPartition") TSoftObjectPtr Descriptor; /** Optional explicit volume (otherwise the first one found is used). */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="VerticalPartition") TObjectPtr Volume; /** Pawn whose position drives streaming. Defaults to local player pawn each tick. */ UPROPERTY(BlueprintReadWrite, Category="VerticalPartition") TWeakObjectPtr TrackedPawn; UPROPERTY(VisibleAnywhere, Category="VerticalPartition") TObjectPtr DebugComponent; virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; virtual void Tick(float DeltaSeconds) override; /** Snap streaming to the tracked pawn immediately (checkpoint / teleport). */ UFUNCTION(BlueprintCallable, Category="VerticalPartition") void RequestSnap() { bSnapNextUpdate = true; } /** Teleport the tracked pawn to the centre of a Z cell (debug). */ UFUNCTION(BlueprintCallable, Category="VerticalPartition") void TeleportToCell(int32 Z); private: float UpdateAccumulator = 0.f; bool bSnapNextUpdate = true; // snap on the first update bool bHavePrevPos = false; FVector PrevTrackedPos = FVector::ZeroVector; FVector SmoothedVelocity = FVector::ZeroVector; APawn* ResolveTrackedPawn(); bool BuildContext(struct FVerticalStreamingContext& OutCtx, float DeltaSeconds, bool& bOutTeleport); };