Files
Cielonos/Assets/Scripts/MainGame/Rewards/CombatRewardInstruction.cs
SoulliesOfficial 39b43680a9 爆更
2026-07-18 03:16:20 -04:00

77 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using Cielonos.MainGame.Inventory;
using Cielonos.MainGame.Interactions;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Cielonos.MainGame.Rewards
{
/// <summary>
/// Combat 节点奖励的基础类型。
/// RareMaterial 是即时奖励SupplyPack/MechanicalTable 会生成交互物并阻塞节点完成。
/// </summary>
public enum CombatRewardInstructionType
{
RareMaterial,
SupplyPack,
MechanicalTable,
}
/// <summary>
/// 一条奖励指令。Profile 负责配置它Resolver 会 Clone 后交给 Modifier 和 Dispatcher 使用。
/// </summary>
[Serializable]
[InlineProperty]
[HideReferenceObjectPicker]
public class CombatRewardInstruction
{
[HorizontalGroup("Row", Width = 0.28f)]
[HideLabel]
public CombatRewardInstructionType type = CombatRewardInstructionType.RareMaterial;
[HorizontalGroup("Row", Width = 0.22f)]
[LabelText("Count")]
[MinValue(1)]
public int count = 1;
[ShowIf(nameof(IsRareMaterial))]
[LabelText("RareMaterial Range")]
public Vector2Int rareMaterialRange = new(10, 20);
public bool IsRareMaterial => type == CombatRewardInstructionType.RareMaterial;
public bool UsesInteractable => type == CombatRewardInstructionType.SupplyPack || type == CombatRewardInstructionType.MechanicalTable;
public string ResolveInteractablePrefabId()
{
return type switch
{
CombatRewardInstructionType.SupplyPack => nameof(SupplyPack),
CombatRewardInstructionType.MechanicalTable => nameof(MechanicalTable),
_ => string.Empty,
};
}
public int RollRareMaterial(System.Random rng)
{
if (rng == null)
{
return 0;
}
int min = Mathf.Min(rareMaterialRange.x, rareMaterialRange.y);
int max = Mathf.Max(rareMaterialRange.x, rareMaterialRange.y);
return Mathf.Max(0, rng.Next(min, max + 1));
}
public CombatRewardInstruction Clone()
{
return new CombatRewardInstruction
{
type = type,
count = count,
rareMaterialRange = rareMaterialRange,
};
}
}
}