Procedural M_UI_UniversalBar material (SDF rounded-rect, fill/delayed/shield/ penalty-zones/stripes/segments/flash/pulse), 6 preset instances, animated UUniversalBarWidget + UUniversalHUDWidget + global UUniversalBarsSubsystem API, UUniversalBarsTheme DataAsset, and a ready WBP_HUD_InGame with zone-tracking status chips. See README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
2.1 KiB
C++
51 lines
2.1 KiB
C++
// 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<UUniversalHUDWidget> 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<UUniversalHUDWidget> HUD;
|
|
};
|