拿起放下物品

This commit is contained in:
2026-01-02 00:23:48 +08:00
parent bfdfcfe2cd
commit 943d6a0c09
6 changed files with 62 additions and 65 deletions

View File

@@ -107,8 +107,16 @@ namespace Obi
}
#if ENABLE_UNITY_COLLECTIONS_CHECKS
// dispose of atomic safety handle:
AtomicSafetyHandle.CheckDeallocateAndThrow(m_SafetyHandle);
AtomicSafetyHandle.Release(m_SafetyHandle);
try
{
AtomicSafetyHandle.CheckDeallocateAndThrow(m_SafetyHandle);
AtomicSafetyHandle.Release(m_SafetyHandle);
}
catch (Exception e)
{
}
#endif
}

View File

@@ -44,6 +44,8 @@ namespace NBF
else if (action == InputDef.Player.ToBag)
{
//取消手持物品
Log.Info($"取消手持物品");
Game.Instance.StartCoroutine(UnUseItem());
}
else if (action.StartsWith(InputDef.Player.QuickStarts))
{

View File

@@ -8,6 +8,7 @@ using NBF.Fishing2;
using NBF.Utils;
using UnityEngine;
using UnityEngine.InputSystem;
using Object = UnityEngine.Object;
namespace NBF
{
@@ -28,6 +29,9 @@ namespace NBF
public readonly List<FRod> Tackles = new List<FRod>();
public FRod Rod { get; private set; }
public event Action<FHandItem> OnFishingSetEquiped;
public event Action OnFishingSetUnequip;
protected override void OnAwake()
{
Character = gameObject.GetComponent<CharacterMovement>();
@@ -81,9 +85,24 @@ namespace NBF
}
Rod =
item.Config.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero, Quaternion.identity);
item.Config.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero,
Quaternion.identity);
yield return Rod.InitRod(this, item);
Tackles.Add(Rod);
OnFishingSetEquiped?.Invoke(Rod);
}
}
public IEnumerator UnUseItem()
{
OnFishingSetUnequip?.Invoke();
if (Rod != null)
{
yield return new WaitForSeconds(0.35f);
yield return Rod.Destroy();
Destroy(Rod.gameObject);
Tackles.Remove(Rod);
Rod = null;
}
}

View File

@@ -58,24 +58,18 @@ namespace NBF
_Animator.keepAnimatorStateOnDisable = true;
_IK = GetComponent<PlayerIK>();
_isInit = true;
Player.OnFishingSetEquiped += OnFishingSetEquiped_OnRaised;
Player.OnFishingSetUnequip += OnFishingSetUnequip;
Player.Data.OnStateChange += PlayerFSMState_OnValueChanged;
}
private void OnDestroy()
{
Player.OnFishingSetEquiped -= OnFishingSetEquiped_OnRaised;
Player.OnFishingSetUnequip -= OnFishingSetUnequip;
Player.Data.OnStateChange += PlayerFSMState_OnValueChanged;
}
// private void OnEnable()
// {
// playerFSMState.OnValueChanged += PlayerFSMState_OnValueChanged;
// }
//
// private void OnDisable()
// {
// playerFSMState.OnValueChanged -= PlayerFSMState_OnValueChanged;
// }
private void OnFishingSetUnequip()
{
@@ -99,12 +93,18 @@ namespace NBF
// }
}
// private void OnFishingSetEquiped_OnRaised(FishingSetController set)
// {
// _isTorsoLayerEnabled = true;
// var reel = Player.Rod.Reel;
// // _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
// }
private void OnFishingSetEquiped_OnRaised(FHandItem item)
{
if (item is FRod rod)
{
_isTorsoLayerEnabled = true;
// var reel = Player.Rod.Reel;
// _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
}
else
{
}
}
private void PlayAnimation(string state, string layer)
{
@@ -233,40 +233,5 @@ namespace NBF
SetLayerWeight(Torso,
Mathf.MoveTowards(layerWeight, _isTorsoLayerEnabled ? 1f : 0f, Time.deltaTime * 3f));
}
// private void LateUpdate()
// {
// if (!_isInit) return;
// UpdateAnimator();
// }
//
//
// private void UpdateAnimator()
// {
// Animator.SetBool(OnGround, Player.Data.IsGrounded);
// float value3 = Mathf.Lerp(Animator.GetFloat(Forward), Player.Data.Speed / 5f, Time.deltaTime * 20f);
// Animator.SetFloat(Forward, value3);
//
// // 平滑处理
// // float smoothedTurn = Mathf.SmoothDamp(Animator.GetFloat(Turn),
// // MapUnit.RotationSpeed,
// // ref turnSmoothVelocity,
// // smoothingTime
// // );
//
// float smoothedTurn = Mathf.Lerp(Animator.GetFloat(Turn), Player.Data.RotationSpeed, Time.deltaTime * 10f);
// Animator.SetFloat(Turn, smoothedTurn);
//
//
// float layerWeight = Animator.GetLayerWeight(Animator.GetLayerIndex(Torso));
// SetLayerWeight(Torso,
// Mathf.MoveTowards(layerWeight, _isTorsoLayerEnabled ? 1f : 0f, Time.deltaTime * 3f));
// }
//
// public void SetLayerWeight(string layer, float weight)
// {
// Animator.SetLayerWeight(Animator.GetLayerIndex(layer), weight);
// }
}
}

View File

@@ -35,7 +35,7 @@ namespace NBF
/// 鱼线处理器
/// </summary>
public FLineHandler lineHandler;
public Transform GearRoot;
// public FWaterDisplacement LureHookWaterDisplacement;
@@ -60,6 +60,11 @@ namespace NBF
public IEnumerator Destroy()
{
if (GearRoot != null)
{
Object.Destroy(GearRoot.gameObject);
}
yield return 1;
}
@@ -134,8 +139,7 @@ namespace NBF
lineItemInfo = child;
}
}
yield return 1;
if (Reel)
@@ -151,18 +155,18 @@ namespace NBF
{
Bobber.Init(Player, this);
}
if (Hook)
{
Hook.Init(Player, this);
// LureHookWaterDisplacement = Hook.GetComponent<FWaterDisplacement>();
}
if (Bait)
{
Bait.Init(Player, this);
}
if (Lure)
{
Lure.Init(Player, this);
@@ -182,7 +186,6 @@ namespace NBF
}
public void CreateFishingHandler()
{
if (lineHandler == null)
@@ -201,7 +204,6 @@ namespace NBF
}
public void CreateObiFishingLine(int currentLineTypeIndex)
{
// if ((bool)Owner.Gears.Reel && !currentLineHandler)
@@ -211,10 +213,10 @@ namespace NBF
var path =
$"Assets/ResRaw/Prefabs/{indexNames[currentLineTypeIndex]}.prefab"; //$"GameItemsPrefabs/Lines/{indexNames[currentLineTypeIndex]}";
var prefab = Assets.Load<GameObject>(path);
// var toRodConnector = rodAsset.lineConnector.GetComponent<Rigidbody>();
GameObject obj = Instantiate(prefab, GearRoot.position, Quaternion.identity, GearRoot);
lineHandler = obj.GetComponent<FLineHandler>();
// lineHandler.transform.SetParent(toRodConnector.transform);
lineHandler.transform.position = Asset.lineConnector.position;
@@ -226,7 +228,7 @@ namespace NBF
SceneSettings.Instance.obiFixedUpdater.solvers.Add(obiSolver);
}
}
public void SetRing(RodRingAsset ringAsset)
{
if (Asset.rings == null || Asset.rings.Length < 1) return;