diff --git a/Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs b/Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs index 4d27307a7..6d3a84e60 100644 --- a/Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs +++ b/Assets/Obi/Scripts/Common/DataStructures/NativeList/ObiNativeList.cs @@ -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 } diff --git a/Assets/Scripts/Fishing/Player/FPlayer.Input.cs b/Assets/Scripts/Fishing/Player/FPlayer.Input.cs index 28834db39..4c0f0370c 100644 --- a/Assets/Scripts/Fishing/Player/FPlayer.Input.cs +++ b/Assets/Scripts/Fishing/Player/FPlayer.Input.cs @@ -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)) { diff --git a/Assets/Scripts/Fishing/Player/FPlayer.cs b/Assets/Scripts/Fishing/Player/FPlayer.cs index 753eafec4..077a32be9 100644 --- a/Assets/Scripts/Fishing/Player/FPlayer.cs +++ b/Assets/Scripts/Fishing/Player/FPlayer.cs @@ -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 Tackles = new List(); public FRod Rod { get; private set; } + public event Action OnFishingSetEquiped; + public event Action OnFishingSetUnequip; + protected override void OnAwake() { Character = gameObject.GetComponent(); @@ -81,9 +85,24 @@ namespace NBF } Rod = - item.Config.InstantiateAndComponent(SceneSettings.Instance.GearNode, Vector3.zero, Quaternion.identity); + item.Config.InstantiateAndComponent(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; } } diff --git a/Assets/Scripts/Fishing/Player/PlayerAnimator.cs b/Assets/Scripts/Fishing/Player/PlayerAnimator.cs index ef4a41fbe..5e0d11a98 100644 --- a/Assets/Scripts/Fishing/Player/PlayerAnimator.cs +++ b/Assets/Scripts/Fishing/Player/PlayerAnimator.cs @@ -58,24 +58,18 @@ namespace NBF _Animator.keepAnimatorStateOnDisable = true; _IK = GetComponent(); _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); - // } } } \ No newline at end of file diff --git a/Assets/Scripts/Fishing/Tackle/FRod.cs b/Assets/Scripts/Fishing/Tackle/FRod.cs index 9843f283c..65140ee87 100644 --- a/Assets/Scripts/Fishing/Tackle/FRod.cs +++ b/Assets/Scripts/Fishing/Tackle/FRod.cs @@ -35,7 +35,7 @@ namespace NBF /// 鱼线处理器 /// 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(); } - + 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(path); - + // var toRodConnector = rodAsset.lineConnector.GetComponent(); GameObject obj = Instantiate(prefab, GearRoot.position, Quaternion.identity, GearRoot); - + lineHandler = obj.GetComponent(); // 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; diff --git a/Fishing2.sln.DotSettings.user b/Fishing2.sln.DotSettings.user index 5598e03e3..e7f1c9329 100644 --- a/Fishing2.sln.DotSettings.user +++ b/Fishing2.sln.DotSettings.user @@ -55,6 +55,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded