Files
zeling_v2/Assets/_Game/Scripts/Equipment/ToolSO.cs
T
2026-05-25 11:54:37 +08:00

60 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
using BaseGames.Player.States;
using BaseGames.Localization;
namespace BaseGames.Equipment
{
/// <summary>
/// 工具使用效果接口(架构 09_ProgressionModule §7)。
/// </summary>
public interface IToolEffect
{
void Use(PlayerController player);
}
/// <summary>
/// 带冷却时间的工具接口(可选实现)。
/// </summary>
public interface IToolCooldown
{
float CooldownDuration { get; }
}
/// <summary>
/// 典型实现:治疗药水效果。
/// </summary>
[Serializable]
public class HealToolEffect : IToolEffect
{
public int HealAmount = 4;
public void Use(PlayerController player) => player.Stats.HealHP(HealAmount);
}
/// <summary>
/// 主动工具数据 SO(架构 09_ProgressionModule §7)。
/// 资产路径: Assets/ScriptableObjects/Equipment/Tools/Tool_{Name}.asset
/// </summary>
[CreateAssetMenu(menuName = "BaseGames/Equipment/Tool")]
public class ToolSO : ScriptableObject, ILocalizableAsset
{
public string toolId;
public string displayNameKey;
public Sprite icon;
[Tooltip("-1 = 无限使用次数")]
public int maxUses = 1;
[SerializeReference]
public IToolEffect effect;
public IEnumerable<LocalizationKeyRef> GetLocalizationKeys()
{
if (!string.IsNullOrEmpty(displayNameKey))
yield return new LocalizationKeyRef(displayNameKey, "Items", nameof(displayNameKey));
}
}
}