Updated observation logic
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=381E17E8_002D2EE5_002DF04E_002D0121_002DEB1FF35E428B_002Fd_003APrivate_002Ff_003Astack_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APLCrashReporter_002EBuild_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FShared_003FEpic_0020Games_003FUE_005F5_002E7_003FEngine_003FSource_003FThirdParty_003FPLCrashReporter_003FPLCrashReporter_002EBuild_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||
@@ -47,7 +47,7 @@ Deferred to post-slice phases. Do **not** build these for the demo:
|
||||
|
||||
Each `VS-n` is a vertical task with a concrete exit check. VS-1 is the gate — it unblocks the entire risk side and should land first.
|
||||
|
||||
- **VS-1 — Coverage → embarrassment (THE dial).** Implement `ClothingManager::GetEffectiveCoverage(EBodyPart)` per §6.3.2 (`max()` of `CoveredBodyParts[b].Coverage` across equipped garments + active expose state; absent part = 0). Feed a per-part exposure weight into `StatsManager::SetObserved` and delete the `0.0f` stub (`StatsManager.h:43`, `StatsManager.cpp`). Day/night and recognition multipliers may be stubbed to `1.0` for now. **Exit:** standing nude in front of an NPC raises embarrassment visibly faster than standing fully clothed; per-garment coverage changes the rate monotonically.
|
||||
- **VS-1 — Coverage → embarrassment (THE dial). DONE (2026-05-30).** `ClothingManager::GetEffectiveCoverage(EBodyPart)` implements §6.3.2 (`max()` across covering garments; absent part = 0; fixed an earlier bug where non-covering garments reported full coverage and an empty equip set crashed `FMath::Max`). The `0.0f` stub in `StatsManager::TickComponent` is gone. Observation is now **per-observer directional**: `ANakedDesireCharacter::ComputeObservedExposure` reuses the existing two-trace (`boobs_root` / `pelvis`) LOS logic and sums `(1 - coverage)` over the revealing parts each observer can actually see; `CanBeSeenFrom` shares that helper (revealing = coverage below `ObservationRevealThreshold`, default 0.9 — replaces the old binary `IsBodyPartExposed` gate so revealing-but-not-nude clothing now ticks). `StatsManager` holds the live observer set (`SetObserved(bool, AActor*)`), re-traces each at 1Hz, normalizes to `[0,1]`, and applies a saturating crowd multiplier `1 + ObserverDensityScale * ln(N)`. Per-part weights are uniform for now. Active expose state (§6.3.6) is **not** yet folded into coverage — that's VS-3. Day/night and recognition multipliers still stubbed to `1.0`. **Exit:** standing nude in front of an NPC raises embarrassment visibly faster than standing fully clothed; per-garment coverage changes the rate monotonically.
|
||||
- **VS-2 — Lust + Pulse (minimal).** Add `Lust`/`MaxLust` and `Pulse`/baseline to `StatsManager`. Passive lust gain; pulse rises on run / exposure events / observed-while-exposed and decays at rest; pulse multiplies embarrassment **and** lust gain (§7.5). Masturbate quick-action resets lust. **Gating (§23 #25): home masturbation is always available; in-session masturbation is Slut-path-gated.** For the slice the in-session entry can ship open if path investment isn't wired yet, but keep the home-vs-session split in mind so it's a config flip later, not a rewrite. **Exit:** the three attributes visibly interact in a playtest — running spikes pulse, which accelerates embarrassment gain; masturbating drops lust.
|
||||
- **VS-3 — Expose action.** Radial-menu entry per equipped garment exposing the parts in its `CanExpose`; temporarily counts those parts as uncovered for VS-1 math; blocked when another garment covers the same part (§6.3.6). Reuses the existing `RadialMenu` + `ClothingManager`. **Exit:** flashing a coat in front of an NPC produces an embarrassment spike that ends when the expose ends.
|
||||
- **VS-4 — Commission accept + instant reward.** Add the Accept lifecycle (commit on accept, no penalty when un-accepted) and **instant reward crediting on `OnMissionCompleted`** — money to the save, XP to the shared pool, followers stub (§13.1/§13.2/§23 #23). `MissionsManager` currently completes a mission but credits nothing (`MissionsManager.cpp:27-32`) — wire crediting here. Ensure the typed goals the slice needs exist (`BeFullyNaked`, `BeFullyNakedNearNPCs`, `ExposeBodyPart` — partially covered by `FlashGoal`/`ExposeBodyPartRestriction`). Surface it through a **minimal forum/board widget** (accept + active-objective tracker) reusing the existing UI layer. **Exit:** accept a commission, satisfy it in the world, see money/XP/followers tick up at the moment of completion with no return-home step.
|
||||
@@ -102,8 +102,8 @@ State of the C++ module as of the latest pass. File references use `Source/Naked
|
||||
|
||||
- **Save subsystem (GDD §16)** — scaffolded but **not actually wired through gameplay**. `USaveSubsystem::SaveGame` (`SaveSubsystem.cpp:10-13`) delegates to `UGlobalSaveGameData::SaveGame`, which creates a *fresh empty* `UGlobalSaveGameData` (`GlobalSaveGameData.cpp:45-53`) and writes it — i.e., it does not capture the live player / wardrobe / world state at all. `USaveSubsystem::LoadGame` calls the static loader but discards the result without applying it (`SaveSubsystem.cpp:5-8`). `ClothingManager::HydrateClothing` (`ClothingManager.cpp:66-73`) is an empty stub with the previous logic commented out. Exit criterion of Phase 1 (round-trip an item with modified condition) is not met yet.
|
||||
- **Item identity → world (§6.1)** — `UItemInstance` GUIDs exist, but no item has been promoted to a world `AActor`. `ClothingManager::DropClothing` (`ClothingManager.cpp:156-163`) still only broadcasts `OnClothingDropped` — no spawn, no parent reassignment in any registry.
|
||||
- **Attributes (§7)** — `StatsManager` covers Embarrassment, Energy, Stamina with observation-driven gain now correctly tied to NPC perception. Missing: Lust, Pulse (§7.5), Recognition, Reputation, Followers, Wanted. Coverage weighting in the gain formula is stubbed at `0.0f` with a TODO marker (`StatsManager.cpp:30-32`). Food-buff hookpoints (per-rate multipliers for stamina regen, embarrassment-gain resistance, lust-gain resistance — see GDD §6.7) are not in place; future Phase 10 work depends on the attribute simulation accepting external multipliers cleanly.
|
||||
- **Coverage (§6.3.2)** — `UClothingItem::Coverage` exists; `ClothingManager::IsBodyTypeExposed` (`ClothingManager.cpp:14-25`) is still binary. No `GetEffectiveCoverage(EBodyPart)` function. **The locked formula is now `max(coverage)` across garments covering a body part** — not sum, and no underwear halving (§20 #20). `UClothingItem::IsUnderwear` is dead spec and should be removed during the Phase 1 cleanup.
|
||||
- **Attributes (§7)** — `StatsManager` covers Embarrassment, Energy, Stamina with observation-driven gain now correctly tied to NPC perception. Missing: Lust, Pulse (§7.5), Recognition, Reputation, Followers, Wanted. Coverage weighting in the gain formula is **live** (VS-1, §0.4) — per-observer directional exposure replaces the old `0.0f` stub. Food-buff hookpoints (per-rate multipliers for stamina regen, embarrassment-gain resistance, lust-gain resistance — see GDD §6.7) are not in place; future Phase 10 work depends on the attribute simulation accepting external multipliers cleanly.
|
||||
- **Coverage (§6.3.2)** — `ClothingManager::GetEffectiveCoverage(EBodyPart)` implements the locked `max(coverage)` across covering garments (VS-1). `ClothingManager::IsBodyPartExposed` remains binary and is still used by the censorship path; the observation/embarrassment path no longer relies on it. Active expose state (§6.3.6) is not yet folded into the coverage result (VS-3). `UClothingItem::IsUnderwear` is dead spec and should be removed during the Phase 1 cleanup.
|
||||
- **Body-part enums — duplicated** — both `Player/PrivateBodyPartType.h` (`EPrivateBodyPartType { FrontBottom, BackBottom, FrontTop }`) and `Clothing/BodyPart.h` (`EBodyPart { Boobs, Ass, Genitals }`) exist. `UClothingItem::CoveredBodyParts` uses the **old** enum; `UClothingItem::CanExpose` uses the **new** one. Half-migrated.
|
||||
- **Mission system** — composable goals work but lacks the typed objective steps from §13.4 (`BeFullyNaked`, `BeFullyNakedNearNPCs`, `WalkNakedDistance`, `MoveDistanceFromClothing`, `BeObservedByNPCType`, `TakePhotoAtLocation`, `DeliverItemTo`). Missions still hand-authored in `MissionsConfig::DailyMissions` keyed by day index — no procedural generation, no Accept lifecycle (§13.1 / §13.2), no path-filtering on the generator (§13.4).
|
||||
- **Day / night** — `NPCSpawner.cpp:38-41` reads `GetCurrentTime().Hours` and gates spawn cap, but does not affect embarrassment gain, NPC type weighting, or police spawning (see §1.3).
|
||||
|
||||
@@ -58,6 +58,30 @@ bool UClothingManager::IsBodyPartExposed(const EBodyPart BodyPart)
|
||||
return true;
|
||||
}
|
||||
|
||||
float UClothingManager::GetEffectiveCoverage(const EBodyPart BodyPart)
|
||||
{
|
||||
// GDD §6.3.2: effective coverage of a part = max() across garments that include it.
|
||||
// A garment that doesn't cover the part contributes nothing; nothing covering it = 0.
|
||||
float MaxCoverage = 0.0f;
|
||||
for (const auto& [Slot, Instance] : EquippedClothing)
|
||||
{
|
||||
if (!Instance)
|
||||
continue;
|
||||
|
||||
const UClothingItemDefinition* Definition = Instance->GetClothingItemDefinition();
|
||||
if (!Definition)
|
||||
continue;
|
||||
|
||||
for (const FBodyPartCoverage& Coverage : Definition->CoveredBodyParts)
|
||||
{
|
||||
if (Coverage.BodyPart == BodyPart)
|
||||
MaxCoverage = FMath::Max(MaxCoverage, Coverage.Coverage);
|
||||
}
|
||||
}
|
||||
|
||||
return MaxCoverage;
|
||||
}
|
||||
|
||||
void UClothingManager::HydrateClothing()
|
||||
{
|
||||
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
TArray<UClothingItemInstance*> GetEquippedClothing() const;
|
||||
UClothingItemInstance* GetSlotClothing(EClothingSlotType SlotType);
|
||||
bool IsBodyPartExposed(EBodyPart BodyPart);
|
||||
float GetEffectiveCoverage(EBodyPart BodyPart);
|
||||
|
||||
void HydrateClothing();
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void ANPCAIController::OnUnPossess()
|
||||
{
|
||||
if (bCurrentlyObserving && PlayerCharacter)
|
||||
{
|
||||
PlayerCharacter->StatsManager->SetObserved(false);
|
||||
PlayerCharacter->StatsManager->SetObserved(false, GetPawn());
|
||||
bCurrentlyObserving = false;
|
||||
}
|
||||
Super::OnUnPossess();
|
||||
@@ -65,5 +65,5 @@ void ANPCAIController::OnTargetPerceptionUpdate(AActor* Actor, FAIStimulus Stimu
|
||||
return;
|
||||
|
||||
bCurrentlyObserving = bSensed;
|
||||
PlayerCharacter->StatsManager->SetObserved(bSensed);
|
||||
PlayerCharacter->StatsManager->SetObserved(bSensed, GetPawn());
|
||||
}
|
||||
|
||||
@@ -134,38 +134,61 @@ UAISense_Sight::EVisibilityResult ANakedDesireCharacter::CanBeSeenFrom(const FCa
|
||||
FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested,
|
||||
float& OutSightStrength, int32* UserData, const FOnPendingVisibilityQueryProcessedDelegate* Delegate)
|
||||
{
|
||||
const FVector StartLocation = Context.ObserverLocation;
|
||||
OutNumberOfLoSChecksPerformed++;
|
||||
|
||||
bool bTopVisible = false;
|
||||
bool bBottomVisible = false;
|
||||
const float Exposure = ComputeObservedExposure(Context.ObserverLocation, Context.IgnoreActor, bTopVisible, bBottomVisible);
|
||||
|
||||
// An observer perceives the player only when a revealing body part is within their line of sight.
|
||||
if (Exposure > 0.0f)
|
||||
{
|
||||
const bool bSeenTop = bTopVisible && RevealAmount(EBodyPart::Boobs) > 0.0f;
|
||||
OutSeenLocation = GetMesh()->GetBoneLocation(FName(bSeenTop ? TEXT("boobs_root") : TEXT("pelvis")));
|
||||
OutSightStrength = 1.0f;
|
||||
return UAISense_Sight::EVisibilityResult::Visible;
|
||||
}
|
||||
|
||||
return UAISense_Sight::EVisibilityResult::NotVisible;
|
||||
}
|
||||
|
||||
float ANakedDesireCharacter::GetObservedExposureFrom(const FVector& ObserverLocation, const AActor* IgnoreActor)
|
||||
{
|
||||
bool bTopVisible = false;
|
||||
bool bBottomVisible = false;
|
||||
return ComputeObservedExposure(ObserverLocation, IgnoreActor, bTopVisible, bBottomVisible);
|
||||
}
|
||||
|
||||
float ANakedDesireCharacter::ComputeObservedExposure(const FVector& ObserverLocation, const AActor* IgnoreActor,
|
||||
bool& bOutTopVisible, bool& bOutBottomVisible)
|
||||
{
|
||||
const FVector BoobsBoneLocation = GetMesh()->GetBoneLocation(FName(TEXT("boobs_root")));
|
||||
const FVector PelvisBoneLocation = GetMesh()->GetBoneLocation(FName(TEXT("pelvis")));
|
||||
|
||||
OutNumberOfLoSChecksPerformed++;
|
||||
float Exposure = 0.0f;
|
||||
|
||||
FHitResult BoobsHitResult;
|
||||
const bool BoobsHit = CheckSight(StartLocation, BoobsBoneLocation, BoobsHitResult, Context.IgnoreActor);
|
||||
// Top region -> Boobs. A region is "visible" when its LOS trace is unobstructed (or only hits self).
|
||||
FHitResult TopHit;
|
||||
bOutTopVisible = !CheckSight(ObserverLocation, BoobsBoneLocation, TopHit, IgnoreActor) || TopHit.GetActor() == this;
|
||||
if (bOutTopVisible)
|
||||
Exposure += RevealAmount(EBodyPart::Boobs);
|
||||
|
||||
FHitResult PelvisHitResult;
|
||||
const bool PelvisHit = CheckSight(StartLocation, PelvisBoneLocation, PelvisHitResult, Context.IgnoreActor);
|
||||
|
||||
if ((!BoobsHit || BoobsHitResult.GetActor() == this) && ClothingManager->IsBodyPartExposed(EBodyPart::Boobs))
|
||||
// Bottom region (pelvis) -> Ass + Genitals; one trace gates both lower parts.
|
||||
FHitResult BottomHit;
|
||||
bOutBottomVisible = !CheckSight(ObserverLocation, PelvisBoneLocation, BottomHit, IgnoreActor) || BottomHit.GetActor() == this;
|
||||
if (bOutBottomVisible)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Boobs hit"));
|
||||
OutSeenLocation = BoobsBoneLocation;
|
||||
OutSightStrength = 1.0f;
|
||||
return UAISense_Sight::EVisibilityResult::Visible;
|
||||
Exposure += RevealAmount(EBodyPart::Ass);
|
||||
Exposure += RevealAmount(EBodyPart::Genitals);
|
||||
}
|
||||
|
||||
if ((!PelvisHit || PelvisHitResult.GetActor() == this) &&
|
||||
(ClothingManager->IsBodyPartExposed(EBodyPart::Ass) || ClothingManager->IsBodyPartExposed(EBodyPart::Genitals)))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Pelvis hit"));
|
||||
OutSeenLocation = PelvisBoneLocation;
|
||||
OutSightStrength = 1.0f;
|
||||
return UAISense_Sight::EVisibilityResult::Visible;
|
||||
}
|
||||
return Exposure;
|
||||
}
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("Not visoble"));
|
||||
|
||||
return UAISense_Sight::EVisibilityResult::NotVisible;
|
||||
float ANakedDesireCharacter::RevealAmount(const EBodyPart BodyPart)
|
||||
{
|
||||
const float Coverage = ClothingManager->GetEffectiveCoverage(BodyPart);
|
||||
return Coverage < ObservationRevealThreshold ? (1.0f - Coverage) : 0.0f;
|
||||
}
|
||||
|
||||
bool ANakedDesireCharacter::CheckSight(const FVector& StartLocation, const FVector& EndLocation, FHitResult& HitResult,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "GameFramework/Character.h"
|
||||
#include "InputAction.h"
|
||||
#include "InputMappingContext.h"
|
||||
#include "NakedDesire/Clothing/BodyPart.h"
|
||||
#include "NakedDesire/Global/Gait.h"
|
||||
#include "NakedDesire/Global/NakedDesireUserSettings.h"
|
||||
#include "NakedDesire/Global/Stance.h"
|
||||
@@ -122,6 +123,17 @@ public:
|
||||
virtual void BeginPlay() override;
|
||||
virtual UAISense_Sight::EVisibilityResult CanBeSeenFrom(const FCanBeSeenFromContext& Context, FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested, float& OutSightStrength, int32* UserData = nullptr, const FOnPendingVisibilityQueryProcessedDelegate* Delegate = nullptr) override;
|
||||
|
||||
// Player exposure as read by an observer at ObserverLocation, in [0, 3]: the sum over the
|
||||
// LOS-visible body regions (top -> Boobs, bottom -> Ass + Genitals) of (1 - effective coverage)
|
||||
// for parts below ObservationRevealThreshold. 0 means nothing revealing is visible to them.
|
||||
// Queried per observing NPC each tick by UStatsManager to drive embarrassment (GDD §7.1).
|
||||
float GetObservedExposureFrom(const FVector& ObserverLocation, const AActor* IgnoreActor);
|
||||
|
||||
// Below this effective coverage [0,1] a body part reads as "revealing": observers notice it and
|
||||
// it contributes to embarrassment. At or above it the part is treated as decently covered.
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Observation")
|
||||
float ObservationRevealThreshold = 0.9f;
|
||||
|
||||
private:
|
||||
EGait Gait = EGait::Walk;
|
||||
EStance Stance = EStance::Stand;
|
||||
@@ -136,6 +148,14 @@ private:
|
||||
|
||||
bool CheckSight(const FVector& StartLocation, const FVector& EndLocation, FHitResult& HitResult, const AActor* IgnoreActor);
|
||||
|
||||
// Traces observer->boobs_root and observer->pelvis for line of sight (top / bottom regions),
|
||||
// then sums (1 - coverage) over the revealing parts in each LOS-visible region. The out-bools
|
||||
// report raw line of sight per region (before coverage), used to pick a seen location.
|
||||
float ComputeObservedExposure(const FVector& ObserverLocation, const AActor* IgnoreActor, bool& bOutTopVisible, bool& bOutBottomVisible);
|
||||
|
||||
// (1 - effective coverage) when BodyPart is below ObservationRevealThreshold, else 0.
|
||||
float RevealAmount(EBodyPart BodyPart);
|
||||
|
||||
UFUNCTION(Exec)
|
||||
void LogTest();
|
||||
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
|
||||
#include "StatsManager.h"
|
||||
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
// Max raw exposure one observer can read at once: Boobs + Ass + Genitals fully exposed, equal
|
||||
// weights (GDD §7.1 — per-part weighting is uniform for now). Normalizes per-observer exposure
|
||||
// to [0,1] so EmbarrassmentGainRate reads as "gain/sec at full exposure, single close observer".
|
||||
constexpr float MaxObservedExposure = 3.0f;
|
||||
}
|
||||
|
||||
UStatsManager::UStatsManager()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
@@ -13,6 +23,8 @@ void UStatsManager::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
OwnerCharacter = Cast<ANakedDesireCharacter>(GetOwner());
|
||||
|
||||
EmbarrassmentUpdate.Broadcast(Embarrassment, MaxEmbarrassment);
|
||||
StaminaUpdate.Broadcast(Stamina, MaxStamina);
|
||||
EnergyUpdate.Broadcast(Energy, MaxEnergy);
|
||||
@@ -23,21 +35,63 @@ void UStatsManager::TickComponent(float DeltaTime, enum ELevelTick TickType,
|
||||
{
|
||||
DecreaseEnergy(0.9f);
|
||||
|
||||
if (ObserverCount > 0)
|
||||
{
|
||||
// TODO (#05): replace 0.0f with ClothingManager->GetEffectiveCoverage() when that lands.
|
||||
constexpr float CoverageWeight = 0.0f;
|
||||
IncreaseEmbarrassment(EmbarrassmentGainRate * (1.0f - CoverageWeight) * DeltaTime);
|
||||
}
|
||||
const float ExposureRate = ComputeObservedExposureRate();
|
||||
if (ExposureRate > 0.0f)
|
||||
IncreaseEmbarrassment(EmbarrassmentGainRate * ExposureRate * DeltaTime);
|
||||
else
|
||||
{
|
||||
DecreaseEmbarrassment(EmbarrassmentDecayRate * DeltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
void UStatsManager::SetObserved(const bool bObserved, const float CoverageWeight)
|
||||
float UStatsManager::ComputeObservedExposureRate()
|
||||
{
|
||||
ObserverCount = FMath::Max(0, bObserved ? ObserverCount + 1 : ObserverCount - 1);
|
||||
if (!OwnerCharacter)
|
||||
return 0.0f;
|
||||
|
||||
// Sum each active observer's normalized exposure, re-traced live so redressing / exposing
|
||||
// updates the rate immediately even while the observer set is unchanged.
|
||||
float SumNormalizedExposure = 0.0f;
|
||||
int32 ActiveObservers = 0;
|
||||
|
||||
for (int32 i = Observers.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
AActor* Observer = Observers[i].Get();
|
||||
if (!Observer)
|
||||
{
|
||||
Observers.RemoveAtSwap(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
const float Exposure = OwnerCharacter->GetObservedExposureFrom(Observer->GetActorLocation(), Observer);
|
||||
if (Exposure > 0.0f)
|
||||
{
|
||||
SumNormalizedExposure += Exposure / MaxObservedExposure;
|
||||
++ActiveObservers;
|
||||
}
|
||||
}
|
||||
|
||||
if (ActiveObservers == 0)
|
||||
return 0.0f;
|
||||
|
||||
// Mean per-observer exposure, then a saturating crowd multiplier (diminishing returns).
|
||||
const float MeanExposure = SumNormalizedExposure / ActiveObservers;
|
||||
const float DensityMultiplier = 1.0f + ObserverDensityScale * FMath::Loge(static_cast<float>(ActiveObservers));
|
||||
return MeanExposure * DensityMultiplier;
|
||||
}
|
||||
|
||||
void UStatsManager::Init(UClothingManager* InClothingManager)
|
||||
{
|
||||
ClothingManager = InClothingManager;
|
||||
}
|
||||
|
||||
void UStatsManager::SetObserved(const bool bObserved, AActor* Observer)
|
||||
{
|
||||
if (!Observer)
|
||||
return;
|
||||
|
||||
if (bObserved)
|
||||
Observers.AddUnique(Observer);
|
||||
else
|
||||
Observers.Remove(Observer);
|
||||
}
|
||||
|
||||
void UStatsManager::IncreaseEmbarrassment(const float Amount)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "StatsManager.generated.h"
|
||||
|
||||
class UClothingManager;
|
||||
class ANakedDesireCharacter;
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FAttributeUpdateSignature, float, CurrentValue, float, MaxValue);
|
||||
|
||||
|
||||
@@ -19,8 +21,6 @@ class NAKEDDESIRE_API UStatsManager : public UActorComponent
|
||||
float Energy = 1000.0f;
|
||||
float MaxEnergy = 1000.0f;
|
||||
|
||||
int32 ObserverCount = 0;
|
||||
|
||||
public:
|
||||
UStatsManager();
|
||||
|
||||
@@ -30,17 +30,22 @@ public:
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Embarrassment")
|
||||
float EmbarrassmentDecayRate = 1.0f;
|
||||
|
||||
protected:
|
||||
// Crowd scaling: N active observers multiply embarrassment gain by 1 + ObserverDensityScale * ln(N).
|
||||
// A single observer (N=1) is the x1 baseline; extra observers add with diminishing returns.
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Embarrassment")
|
||||
float ObserverDensityScale = 0.5f;
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
void Init(UClothingManager* InClothingManager);
|
||||
|
||||
public:
|
||||
float Stamina = 100.0f;
|
||||
float MaxStamina = 100.0f;
|
||||
|
||||
// Called by NPCAIController when sight is gained or lost.
|
||||
// CoverageWeight: fraction of body covered [0..1]; pass 0.0f until #05 (GetEffectiveCoverage) lands.
|
||||
void SetObserved(bool bObserved, float CoverageWeight = 0.0f);
|
||||
// Called by NPCAIController when an NPC gains or loses sight of the player. Observer is the
|
||||
// observing pawn; its live location is re-traced each tick to weight embarrassment by the
|
||||
// body parts that observer can actually see (GDD §7.1).
|
||||
void SetObserved(bool bObserved, AActor* Observer);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void IncreaseEmbarrassment(float Amount);
|
||||
@@ -58,4 +63,19 @@ public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FAttributeUpdateSignature EnergyUpdate;
|
||||
|
||||
private:
|
||||
// Re-traces every current observer against the player's live coverage and returns the
|
||||
// normalized embarrassment-gain factor (0 when nothing revealing is currently observed).
|
||||
float ComputeObservedExposureRate();
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UClothingManager> ClothingManager;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<ANakedDesireCharacter> OwnerCharacter;
|
||||
|
||||
// NPCs currently perceiving the player (added/removed via SetObserved). Weak so a destroyed
|
||||
// observer drops out without dangling; stale entries are compacted during the tick.
|
||||
TArray<TWeakObjectPtr<AActor>> Observers;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user