// Copyright IHY. Universal Bars plugin. // Global access point for the active HUD. From any Blueprint/C++: // Get World Subsystem -> UniversalBarsSubsystem -> Set Health (0.5) // No widget reference needed. The HUD widget registers itself on construct. #pragma once #include "CoreMinimal.h" #include "Subsystems/WorldSubsystem.h" #include "UniversalBarsSubsystem.generated.h" class UUniversalHUDWidget; class APlayerController; UCLASS() class UNIVERSALBARS_API UUniversalBarsSubsystem : public UWorldSubsystem { GENERATED_BODY() public: // One-call accessor from any object with a world. UFUNCTION(BlueprintPure, Category="UniversalBars", meta=(WorldContext="WorldContextObject")) static UUniversalBarsSubsystem* Get(const UObject* WorldContextObject); // Spawn a HUD widget, add it to the viewport, and make it the active HUD. UFUNCTION(BlueprintCallable, Category="UniversalBars") UUniversalHUDWidget* CreateHUD(APlayerController* Owner, TSubclassOf HUDClass, int32 ZOrder = 0); UFUNCTION(BlueprintCallable, Category="UniversalBars") void RegisterHUD(UUniversalHUDWidget* InHUD); UFUNCTION(BlueprintCallable, Category="UniversalBars") void UnregisterHUD(UUniversalHUDWidget* InHUD); UFUNCTION(BlueprintPure, Category="UniversalBars") UUniversalHUDWidget* GetHUD() const { return HUD.Get(); } // ===== global forwarders (animated) ===== UFUNCTION(BlueprintCallable, Category="UniversalBars") void SetHealth(float Percent); UFUNCTION(BlueprintCallable, Category="UniversalBars") void SetStamina(float Percent); UFUNCTION(BlueprintCallable, Category="UniversalBars") void SetShield(float Percent); UFUNCTION(BlueprintCallable, Category="UniversalBars") void SetHunger(float Amount); UFUNCTION(BlueprintCallable, Category="UniversalBars") void SetWeight(float Amount); UFUNCTION(BlueprintCallable, Category="UniversalBars") void SetCold(float Amount); UFUNCTION(BlueprintCallable, Category="UniversalBars") void DamageHealth(float Delta); UFUNCTION(BlueprintCallable, Category="UniversalBars") void HealHealth(float Delta); private: UPROPERTY() TWeakObjectPtr HUD; };