#pragma once #include "CoreMinimal.h" #include "Core/DescentHandle.h" #include "Core/DescentWorldSubsystem.h" #include "DescentTools.generated.h" class ADescentCharacter; class UPointLightComponent; class UStaticMeshComponent; /** Hand tools of DESIGN_UE.md section 6.11 (M8: V9, V11): thrown flares and marker beacons. The flashlight is the character's own lamp. */ UCLASS() class THEDESCENT_API UDescentToolsSubsystem : public UDescentWorldSubsystem { GENERATED_BODY() public: static UDescentToolsSubsystem* Get(const UWorld* World); virtual void OnWorldBeginPlay(UWorld& InWorld) override; virtual void Deinitialize() override; /** LMB with the selected hotbar item out. Returns whether the item did something. */ bool UseSelected(ADescentCharacter* User, bool bSwimming); bool ThrowFlare(const FVector& FromM, const FVector& Dir); bool DropBeacon(const FVector& PosM); int32 FlaresAlive() const { return Flares.Num(); } int32 FlaresThrown = 0; TArray Markers; // beacons, world metres (the map and the HUD draw them) private: struct FFlare { FVector P = FVector::ZeroVector, V = FVector::ZeroVector; double Age = 0.0; bool bRest = false; TWeakObjectPtr Light; TWeakObjectPtr Mesh; }; void Step(double Dt); void EnsureActor(); TArray Flares; FDescentHandle StepHandle; UPROPERTY(Transient) TObjectPtr Visual; UPROPERTY(Transient) TArray> BeaconMeshes; };