using System; using System.Collections.Generic; using System.Linq; using UFS3; using UnityEngine; [CreateAssetMenu(fileName = "fishData", menuName = "Data/FishData")] public class FishData : ScriptableObject { [Serializable] public class LureDataAttractiveness { public LureData lureData; [Range(0f, 1f)] public float attractiveness = 1f; } [Serializable] public class BaitDataAttractiveness { public BaitData baitData; [Range(0f, 1f)] public float attractiveness = 1f; } public enum Deep { bottom = 0, overall = 1, surface = 2 } public enum Type { neutral = 0, predator = 1, passivePredator = 2 } public enum Rarity { sick = 0, weak = 1, common = 2, strong = 3, champion = 4, legendary = 5 } public enum Abilites { fastDash = 0, staminaBoost = 1, shine = 2, jump = 3, tailLure = 4 } public int ID = -1; public Sprite icon; private FishData archetypeData; public string fishName; [SerializeField] private Type type; [SerializeField] private Deep deep; [SerializeField] private float speed; [SerializeField] private Abilites[] abilites; [SerializeField] private GameObject[] models; [SerializeField] private float eyeDetectionDistance = 10f; [SerializeField] private float _PricePerKG = 1f; [SerializeField] private List AcceptedLuresAttractiveness = new List(); [SerializeField] private List AcceptedBaitsAttractiveness = new List(); public float areaDistance = 4f; [HideInInspector] public float Hunger; [HideInInspector] public float Stress; [HideInInspector] public float LifeCycle; [Tooltip("time = weight, value = length in cm")] public AnimationCurve LWR; public float Weight; [SerializeField] private bool _IsDebugMode; [SerializeField] private TextAsset _LWRParse; public float EyeDetectionDistance => eyeDetectionDistance; public string FishName => fishName; public float Speed => speed; public float GetPrice => Weight * _PricePerKG; public Type BehaviourType => type; public float Length => LWR.Evaluate(Weight); public float MinWeight => LWR.keys.Min((Keyframe k) => k.time); public float MaxWeight => LWR.keys.Max((Keyframe k) => k.time); public FishData GetArchetype { get { if (archetypeData != null) { Debug.LogWarning($"Archetype Data in {this} it's not null. See if that was intentional"); } return archetypeData; } set { archetypeData = value; } } public GameObject GetModel(float weight = 0f) { return models[0]; } public bool CheckLure(int lureID) { foreach (LureDataAttractiveness item in AcceptedLuresAttractiveness) { if (item.lureData.ID == lureID) { return true; } } return false; } public bool CheckBait(int baitID) { foreach (BaitDataAttractiveness item in AcceptedBaitsAttractiveness) { if (item.baitData.ID == baitID) { return true; } } return false; } private void ParseLWR() { string[] array = _LWRParse.text.Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); LWR = new AnimationCurve(); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(','); if (array3.Length != 2 || !float.TryParse(array3[0], out var result) || !float.TryParse(array3[1], out var result2)) { Debug.LogWarning("Failed to parse line: " + text); continue; } Keyframe key = new Keyframe(result2, result * 0.01f, 0f, 0f); LWR.AddKey(key); } } }