Files
Fishing2/Assets/Scripts/Fishing/New/Data/Item/PlayerItem.cs
2026-03-22 21:35:27 +08:00

115 lines
2.6 KiB
C#

using System.Collections.Generic;
using Fantasy;
using Fantasy.Entitas;
using NBF.Utils;
using UnityEngine;
namespace NBF
{
/// <summary>
/// 玩家物品
/// </summary>
public class PlayerItem : Entity
{
public Player Owner;
/// <summary>
/// 配置id
/// </summary>
public int ConfigID;
public List<int> BindItems = new List<int>();
#region Rod专属
private bool _stretchRope = true;
public bool StretchRope
{
get => _stretchRope;
set
{
_stretchRope = value;
Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
{
Item = this
});
}
}
private float _lineLength = 4.2f;
/// <summary>
/// 线长度
/// </summary>
public float LineLength
{
get => _lineLength;
set
{
_lineLength = value;
Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
{
Item = this
});
}
}
private float _floatLength = 0.7f;
/// <summary>
/// 浮漂线长度
/// </summary>
public float FloatLength
{
get => _floatLength;
set
{
_floatLength = value;
Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
{
Item = this
});
}
}
private float _tension;
/// <summary>
/// 拉力
/// </summary>
public float Tension
{
get => _tension;
set
{
if (!Mathf.Approximately(_tension, value))
{
_tension = value;
}
Scene.EventComponent.Publish(new PlayerItemRodLingChangeEvent
{
Item = this
});
}
}
#endregion
public void Init(Player player, int configId, List<int> bindItems)
{
Owner = player;
ConfigID = configId;
BindItems.Clear();
BindItems.AddRange(bindItems);
// var itemType = bindInfo.Item.GetItemType();
// if (itemType == ItemType.Rod)
// {
// var rod = AddComponent<PlayerItemRod>();
// rod.Init(bindInfo);
// }
}
}
}