Files
2026-03-04 10:03:45 +08:00

62 lines
2.1 KiB
C#

using UFS2.Gameplay;
using UnityEngine;
[CreateAssetMenu(menuName = "Data/FishFightData", fileName = "FishFightData")]
public class FishFightData : ScriptableObject
{
[Tooltip("Defines the fish's tugging force on the line during an active fight.\nX-axis: Fish body weight (Kg)\nY-axis: Force applied to the fishing equipment (Kg)")]
public AnimationCurve weightTuggingActiveFight;
[Tooltip("Defines the fish's tugging force on the line when resting.\nX-axis: Fish body weight (Kg)\nY-axis: Force applied to the fishing equipment (Kg)")]
public AnimationCurve weightTuggingWeakFight;
[Tooltip("Defines the tugging force a fish exerts on the line after it has stopped fighting and is fully exhausted\nX-axis: Fish body weight (Kg)\nY-axis: Force applied to the fishing equipment (Kg)")]
public AnimationCurve weightTuggingExhausted;
[Tooltip("Determines how long the fish will fight before becoming exhausted.\nX-axis: Fish body weight (Kg)\nY-axis: Fight duration (seconds)")]
public AnimationCurve fightTime;
public float GetTuggingForceActiveFight(FishEntity fishEntity)
{
return weightTuggingActiveFight.Evaluate(fishEntity.Weight);
}
public float GetTuggingForceWeakFight(FishEntity fishEntity)
{
return weightTuggingWeakFight.Evaluate(fishEntity.Weight);
}
public float GetTuggingForceExhausted(FishEntity fishEntity)
{
return weightTuggingExhausted.Evaluate(fishEntity.Weight);
}
public float GetFightTime(FishEntity fishEntity)
{
return fightTime.Evaluate(fishEntity.Weight);
}
private void OnValidate()
{
EnsureCurveExtrapolation(weightTuggingActiveFight);
EnsureCurveExtrapolation(weightTuggingWeakFight);
EnsureCurveExtrapolation(weightTuggingExhausted);
EnsureCurveExtrapolation(fightTime);
}
private void EnsureCurveExtrapolation(AnimationCurve curve)
{
if (curve.keys.Length >= 2)
{
Keyframe key = curve.keys[0];
Keyframe key2 = curve.keys[curve.keys.Length - 1];
curve.preWrapMode = WrapMode.Once;
curve.postWrapMode = WrapMode.Once;
key.inTangent = 0f;
key2.outTangent = 0f;
curve.MoveKey(0, key);
curve.MoveKey(curve.keys.Length - 1, key2);
}
}
}