59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Rewards
|
|
{
|
|
/// <summary>
|
|
/// 一次 Combat 节点奖励结算的运行时会话。
|
|
/// 用于记录已生成的交互奖励位置和待领取数量,防止玩家在奖励未处理完时进入下一个节点。
|
|
/// </summary>
|
|
public class CombatRewardSession
|
|
{
|
|
private readonly List<Vector3> _occupiedSpawnPositions = new();
|
|
private int _pendingCount;
|
|
private int _spawnIndex;
|
|
|
|
public CombatRewardSession(CombatRewardContext context)
|
|
{
|
|
Context = context;
|
|
IsActive = true;
|
|
}
|
|
|
|
public CombatRewardContext Context { get; }
|
|
public bool IsActive { get; private set; }
|
|
public int PendingCount => _pendingCount;
|
|
public IReadOnlyList<Vector3> OccupiedSpawnPositions => _occupiedSpawnPositions;
|
|
|
|
public int NextSpawnIndex()
|
|
{
|
|
// 与 ZoneManager 的 SpawnGroup 索引配合,让多个奖励按固定序号寻找出生点。
|
|
return _spawnIndex++;
|
|
}
|
|
|
|
public void RegisterPendingReward(Vector3 spawnPosition)
|
|
{
|
|
// 交互奖励实体生成成功后登记,领取时再 Resolve。
|
|
_pendingCount++;
|
|
_occupiedSpawnPositions.Add(spawnPosition);
|
|
}
|
|
|
|
public bool ResolvePendingReward()
|
|
{
|
|
if (_pendingCount <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_pendingCount--;
|
|
return true;
|
|
}
|
|
|
|
public void End()
|
|
{
|
|
IsActive = false;
|
|
_pendingCount = 0;
|
|
_occupiedSpawnPositions.Clear();
|
|
}
|
|
}
|
|
}
|