refactor(interaction): PersistenceSubsystem语义修正消耗状态
This commit is contained in:
@@ -99,7 +99,7 @@ void UInteractableComponent::Consume_Implementation()
|
|||||||
{
|
{
|
||||||
if (UPersistenceSubsystem* Persistence = GI->GetSubsystem<UPersistenceSubsystem>())
|
if (UPersistenceSubsystem* Persistence = GI->GetSubsystem<UPersistenceSubsystem>())
|
||||||
{
|
{
|
||||||
Persistence->MarkItemCollected(Data.ItemId);
|
Persistence->MarkInteractableConsumed(Data.ItemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ void UInteractableComponent::RestorePersistentState(UPersistenceSubsystem* Persi
|
|||||||
if (!Persistence) return;
|
if (!Persistence) return;
|
||||||
|
|
||||||
// oneShot 物品:已消耗 → 隐藏 + 禁用检测
|
// oneShot 物品:已消耗 → 隐藏 + 禁用检测
|
||||||
if (Data.bOneShot && Persistence->IsItemCollected(Data.ItemId))
|
if (Data.bOneShot && Persistence->IsInteractableConsumed(Data.ItemId))
|
||||||
{
|
{
|
||||||
bIsConsumed = true;
|
bIsConsumed = true;
|
||||||
if (DetectionSphere)
|
if (DetectionSphere)
|
||||||
|
|||||||
@@ -7,15 +7,15 @@
|
|||||||
// 物品消耗状态
|
// 物品消耗状态
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
bool UPersistenceSubsystem::IsItemCollected(FName ItemId) const
|
bool UPersistenceSubsystem::IsInteractableConsumed(FName InteractableId) const
|
||||||
{
|
{
|
||||||
return CollectedItemIDs.Contains(ItemId);
|
return ConsumedInteractableIDs.Contains(InteractableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPersistenceSubsystem::MarkItemCollected(FName ItemId)
|
void UPersistenceSubsystem::MarkInteractableConsumed(FName InteractableId)
|
||||||
{
|
{
|
||||||
CollectedItemIDs.Add(ItemId);
|
ConsumedInteractableIDs.Add(InteractableId);
|
||||||
UE_LOG(LogChildHood, Log, TEXT("PersistenceSubsystem: 物品已收集: %s"), *ItemId.ToString());
|
UE_LOG(LogChildHood, Log, TEXT("PersistenceSubsystem: 交互物已消耗: %s"), *InteractableId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -61,7 +61,7 @@ void UPersistenceSubsystem::SetCollectionState(const TSet<FName>& InIDs, int32 I
|
|||||||
|
|
||||||
void UPersistenceSubsystem::ResetAll()
|
void UPersistenceSubsystem::ResetAll()
|
||||||
{
|
{
|
||||||
CollectedItemIDs.Empty();
|
ConsumedInteractableIDs.Empty();
|
||||||
DoorStates.Empty();
|
DoorStates.Empty();
|
||||||
CollectionCollectedIDs.Empty();
|
CollectionCollectedIDs.Empty();
|
||||||
CollectionProgress = 0;
|
CollectionProgress = 0;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
* 因此将持久数据放在 GameInstanceSubsystem 中,与 World 生命周期解耦。
|
* 因此将持久数据放在 GameInstanceSubsystem 中,与 World 生命周期解耦。
|
||||||
*
|
*
|
||||||
* 当前持有:
|
* 当前持有:
|
||||||
* - CollectedItemIDs: 已收集物品 ID 集合
|
* - ConsumedInteractableIDs: 已消耗交互物 ID 集合(一次性交互物防重复触发)
|
||||||
* - DoorStates: 门开关状态映射
|
* - DoorStates: 门开关状态映射
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
@@ -27,13 +27,13 @@ public:
|
|||||||
|
|
||||||
// === 物品消耗状态 ===
|
// === 物品消耗状态 ===
|
||||||
|
|
||||||
/** 查询指定物品是否已被收集(跨场景持久) */
|
/** 查询指定交互物是否已被消耗(跨场景持久,一次性交互物防重复触发) */
|
||||||
UFUNCTION(BlueprintCallable, Category = "Persistence")
|
UFUNCTION(BlueprintCallable, Category = "Persistence")
|
||||||
bool IsItemCollected(FName ItemId) const;
|
bool IsInteractableConsumed(FName InteractableId) const;
|
||||||
|
|
||||||
/** 标记指定物品为已收集(写入持久层) */
|
/** 标记指定交互物为已消耗(写入持久层) */
|
||||||
UFUNCTION(BlueprintCallable, Category = "Persistence")
|
UFUNCTION(BlueprintCallable, Category = "Persistence")
|
||||||
void MarkItemCollected(FName ItemId);
|
void MarkInteractableConsumed(FName InteractableId);
|
||||||
|
|
||||||
// === 门状态 ===
|
// === 门状态 ===
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ public:
|
|||||||
void ResetAll();
|
void ResetAll();
|
||||||
|
|
||||||
// === 收集系统状态 ===
|
// === 收集系统状态 ===
|
||||||
// 与上方 CollectedItemIDs 区分:CollectedItemIDs 记录交互物消耗状态(交互系统用),
|
|
||||||
// 下方三个成员记录追踪品类的收集进度(收集系统用,技术方案第12节)。
|
// 下方三个成员记录追踪品类的收集进度(收集系统用,技术方案第12节)。
|
||||||
|
// 与上方的"交互物消耗状态"是两套完全独立的数据。
|
||||||
|
|
||||||
/** 获取收集状态(恢复用):追踪品类的已收集 ID 集合、当前进度、是否全部完成 */
|
/** 获取收集状态(恢复用):追踪品类的已收集 ID 集合、当前进度、是否全部完成 */
|
||||||
UFUNCTION(BlueprintCallable, Category = "Persistence|Collection")
|
UFUNCTION(BlueprintCallable, Category = "Persistence|Collection")
|
||||||
@@ -65,9 +65,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** 已收集物品 ID 集合 */
|
/** 已消耗交互物 ID 集合(一次性交互物防重复触发) */
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TSet<FName> CollectedItemIDs;
|
TSet<FName> ConsumedInteractableIDs;
|
||||||
|
|
||||||
/** 门开关状态映射(true=打开,false=关闭) */
|
/** 门开关状态映射(true=打开,false=关闭) */
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
|
|||||||
Reference in New Issue
Block a user