Added phone item
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "PhoneItemDefinition.h"
|
||||
|
||||
#include "PhoneItemInstance.h"
|
||||
|
||||
TSubclassOf<UItemInstance> UPhoneItemDefinition::GetInstanceClass() const
|
||||
{
|
||||
return UPhoneItemInstance::StaticClass();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NakedDesire/Items/ItemDefinition.h"
|
||||
#include "PhoneItemDefinition.generated.h"
|
||||
|
||||
// Immutable definition for a phone (GDD §6.2 / §9.9). A phone is a regular UItemInstance item that
|
||||
// lives in the wardrobe / bag and occupies the dedicated phone slot when active (§6.5).
|
||||
// Phone-tier stats (camera / livestream / battery-capacity multipliers, §9.9) are deferred to Phase 8/9.
|
||||
UCLASS(BlueprintType)
|
||||
class NAKEDDESIRE_API UPhoneItemDefinition : public UItemDefinition
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual TSubclassOf<UItemInstance> GetInstanceClass() const override;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Phone")
|
||||
float MaxBattery = 100.0f;
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "PhoneItemInstance.h"
|
||||
|
||||
#include "PhoneItemDefinition.h"
|
||||
#include "StructUtils/InstancedStruct.h"
|
||||
|
||||
void UPhoneItemInstance::CaptureState(FInstancedStruct& OutState) const
|
||||
{
|
||||
FPhoneInstanceState PhoneState;
|
||||
PhoneState.CurrentBattery = CurrentBattery;
|
||||
OutState.InitializeAs<FPhoneInstanceState>(PhoneState);
|
||||
}
|
||||
|
||||
void UPhoneItemInstance::ApplyState(const FInstancedStruct& InState)
|
||||
{
|
||||
if (const FPhoneInstanceState* PhoneState = InState.GetPtr<FPhoneInstanceState>())
|
||||
{
|
||||
CurrentBattery = PhoneState->CurrentBattery;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "PhoneItemDefinition.h"
|
||||
#include "NakedDesire/Items/ItemInstance.h"
|
||||
#include "PhoneItemInstance.generated.h"
|
||||
|
||||
/** Per-instance mutable state for a phone. Battery is per-phone-instance (§9.9). */
|
||||
USTRUCT()
|
||||
struct FPhoneInstanceState : public FItemInstanceState
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(SaveGame)
|
||||
float CurrentBattery = 100.0f;
|
||||
};
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class NAKEDDESIRE_API UPhoneItemInstance : public UItemInstance
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Charge of this specific phone, [0,1]. Drain / charge logic lands with the phone battery system (Phase 8/9).
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Phone Item")
|
||||
float CurrentBattery = 100.0f;
|
||||
|
||||
UPhoneItemDefinition* GetPhoneItemDefinition() const { return Cast<UPhoneItemDefinition>(ItemDefinition); }
|
||||
|
||||
protected:
|
||||
virtual void CaptureState(FInstancedStruct& OutState) const override;
|
||||
virtual void ApplyState(const FInstancedStruct& InState) override;
|
||||
};
|
||||
Reference in New Issue
Block a user