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

86 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using Cielonos.MainGame.Inventory;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Cielonos.MainGame.Rewards
{
public enum RewardEntryMode
{
FixedItem,
ItemPool,
UpgradeComponent
}
[CreateAssetMenu(fileName = "RewardProfile", menuName = "Cielonos/Rewards/Reward Profile")]
public class RewardProfile : SerializedScriptableObject
{
[TitleGroup("Offer Settings")]
[MinValue(1)]
public int offerCount = 3;
[TitleGroup("Skip Compensation")]
[LabelText("RareMaterial Range")]
public Vector2Int skipRareMaterialRange = Vector2Int.zero;
[TitleGroup("Entries")]
[HideLabel]
[ListDrawerSettings(ShowIndexLabels = false)]
public List<RewardEntry> entries = new();
public int RollSkipCompensation(System.Random rng)
{
if (rng == null || skipRareMaterialRange == Vector2Int.zero)
{
return 0;
}
int min = Mathf.Min(skipRareMaterialRange.x, skipRareMaterialRange.y);
int max = Mathf.Max(skipRareMaterialRange.x, skipRareMaterialRange.y);
return rng.Next(min, max + 1);
}
}
[Serializable]
[InlineProperty]
[HideReferenceObjectPicker]
[LabelWidth(82)]
public class RewardEntry
{
[HorizontalGroup("Name")]
[HideLabel]
public string displayName = "New Reward Entry";
[HorizontalGroup("Rules", Width = 0.34f)]
[LabelText("Mode")]
public RewardEntryMode mode;
[HorizontalGroup("Rules", Width = 0.33f)]
[LabelText("Weight")]
[MinValue(0)]
public int weight = 1;
[HorizontalGroup("Rules", Width = 0.33f)]
[LabelText("Repeat")]
public bool allowRepeat = false;
[ShowIf(nameof(UsesItemPrefab))]
[AssetsOnly]
[Required]
[LabelText("Item")]
public ItemBase itemPrefab;
[ShowIf(nameof(UsesItemPool))]
[HideLabel]
public RewardItemFilter filter = new();
[LabelText("Quantity")]
[Tooltip("只对 Consumable 生效;普通装备始终生成一件。")]
public Vector2Int quantityRange = Vector2Int.one;
private bool UsesItemPrefab => mode == RewardEntryMode.FixedItem || mode == RewardEntryMode.UpgradeComponent;
private bool UsesItemPool => mode == RewardEntryMode.ItemPool;
}
}