diff --git a/Assets/Resources/config/configs.json b/Assets/Resources/config/configs.json index e2205386d..eb4f78711 100644 --- a/Assets/Resources/config/configs.json +++ b/Assets/Resources/config/configs.json @@ -1,7 +1,373 @@ { + "WeightConfig": [ + { + "Id": 100001, + "Model": "Weights/Weight2_5g", + "Type": 0, + "Weight": 3 + } + ], + "RingConfig": [ + { + "Id": 120001, + "Model": "rod_rings/rumoi/rumoi_oxiline_spin" + }, + { + "Id": 120002, + "Model": "rod_rings/smt/smt_pure_ceramic_bolo" + } + ], + "LureConfig": [ + { + "Id": 80001, + "Model": "lures/express_fishing/crankbaits_1/775/crankbaits_775", + "Hook": [ + 700102 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 250 + }, + { + "Id": 80002, + "Model": "lures/express_fishing/poppers_1/poppers_590/poppers_590", + "Hook": [ + 700102 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 120 + }, + { + "Id": 80003, + "Model": "lures/express_fishing/softplastic/ef_supergrab_6/softplastic_g_1622", + "Hook": [ + 0 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 120 + }, + { + "Id": 80004, + "Model": "lures/express_fishing/softplastic/ef_superminnow_6/softplastic_m_1634", + "Hook": [ + 0 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 120 + } + ], + "ItemConfig": [ + { + "Id": 10001, + "Model": "rods/syberia/tele_10037/tele_10037_t13", + "Type": 1, + "Max": 0, + "AutoUse": 0 + }, + { + "Id": 10002, + "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", + "Type": 0, + "Max": 1100002, + "AutoUse": 0 + }, + { + "Id": 10003, + "Model": "rods/syberia/spin_10034/spin_10034_S60H", + "Type": 0, + "Max": 1100001, + "AutoUse": 0 + } + ], + "ReelConfig": [ + { + "Id": 40001, + "Model": "reels/syberia/spin_5002/spin_5002", + "Type": 0, + "GearRatio": [ + "7" + ], + "Size": 250, + "Strength": 40 + }, + { + "Id": 40002, + "Model": "reels/syberia/spin_5036/spin_5036", + "Type": 0, + "GearRatio": [ + "5" + ], + "Size": 120, + "Strength": 40 + } + ], + "LineConfig": [ + { + "Id": 60001, + "Model": "Lines/UFE Mono/UFE monoClear", + "Type": 0, + "Length": 7, + "Strength": 40, + "Size": 1 + }, + { + "Id": 60002, + "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", + "Type": 0, + "Length": 5, + "Strength": 40, + "Size": 1 + } + ], + "HookConfig": [ + { + "Id": 90001, + "Model": "hooks/alliance/c_hook_20789_20794/c_hook_20789", + "Type": 1, + "Zadzior": 1, + "Length": 0, + "Weight": 1 + }, + { + "Id": 90002, + "Model": "hooks/berserk_hooks/triple_20569_20577/triple_20569", + "Type": 1, + "Zadzior": 1, + "Length": 0, + "Weight": 1 + } + ], + "RodConfig": [ + { + "Id": 30001, + "Model": "rods/syberia/tele_10037/tele_10037_t13", + "Type": 1, + "Ring": 0, + "Length": 7, + "Weight": 250, + "Strength": 40, + "MaxRange": 67, + "ConstructionType": 0 + }, + { + "Id": 30002, + "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", + "Type": 0, + "Ring": 1100002, + "Length": 5, + "Weight": 120, + "Strength": 40, + "MaxRange": 30, + "ConstructionType": 0 + }, + { + "Id": 30003, + "Model": "rods/syberia/spin_10034/spin_10034_S60H", + "Type": 0, + "Ring": 1100001, + "Length": 5, + "Weight": 120, + "Strength": 40, + "MaxRange": 30, + "ConstructionType": 0 + } + ], + "FishConfig": [ + { + "Id": 210001, + "Model": [ + "Burbot_B" + ], + "Type": 0, + "SpeciesName": 10, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + }, + { + "Id": 210002, + "Model": [ + "CarpCommon_B" + ], + "Type": 0, + "SpeciesName": 11, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + }, + { + "Id": 210003, + "Model": [ + "CarpGrass_B" + ], + "Type": 0, + "SpeciesName": 14, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + }, + { + "Id": 210004, + "Model": [ + "CarpCrucian_B" + ], + "Type": 0, + "SpeciesName": 16, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + } + ], + "BasicConfig": [ + { + "Id": 1001, + "Name": "Weights/Weight2_5g", + "Val": [ + "0" + ] + } + ], + "InitConfig": [ + { + "Id": 1, + "ItemId": 30001, + "Amount": 1 + }, + { + "Id": 2, + "ItemId": 30002, + "Amount": 1 + }, + { + "Id": 3, + "ItemId": 30003, + "Amount": 1 + }, + { + "Id": 4, + "ItemId": 40001, + "Amount": 1 + }, + { + "Id": 5, + "ItemId": 50001, + "Amount": 1 + }, + { + "Id": 6, + "ItemId": 50002, + "Amount": 1 + }, + { + "Id": 7, + "ItemId": 50003, + "Amount": 1 + }, + { + "Id": 8, + "ItemId": 60001, + "Amount": 1 + }, + { + "Id": 9, + "ItemId": 70001, + "Amount": 1 + }, + { + "Id": 10, + "ItemId": 70002, + "Amount": 1 + }, + { + "Id": 11, + "ItemId": 80001, + "Amount": 1 + }, + { + "Id": 12, + "ItemId": 80002, + "Amount": 1 + }, + { + "Id": 13, + "ItemId": 80003, + "Amount": 1 + }, + { + "Id": 14, + "ItemId": 80004, + "Amount": 1 + }, + { + "Id": 15, + "ItemId": 90001, + "Amount": 1 + }, + { + "Id": 16, + "ItemId": 100001, + "Amount": 1 + }, + { + "Id": 17, + "ItemId": 10001, + "Amount": 100 + }, + { + "Id": 18, + "ItemId": 10002, + "Amount": 200 + } + ], + "BobberConfig": [ + { + "Id": 50001, + "Model": "bobbers/expressfishing/bob_25003/bob_25003", + "Type": 2, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + }, + { + "Id": 50002, + "Model": "bobbers/expressfishing/bob_25162_25163/bob_25162", + "Type": 0, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + }, + { + "Id": 50003, + "Model": "bobbers/expressfishing/bob_25166_25167/bob_25166", + "Type": 0, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + }, + { + "Id": 50004, + "Model": "bobbers/expressfishing/bob_25001/bob_25001", + "Type": 0, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + } + ], + "FeederConfig": [ + { + "Id": 110001, + "Model": "Feeders/Feeder 1/FeedTrash 1", + "Type": 0, + "Capacity": 100, + "Weight": 5 + } + ], "BaitConfig": [ { - "Id": 500001, + "Id": 70001, "Model": "baits/worm_01/worm_01", "EfficacyBase": 15, "Length": 0, @@ -20,7 +386,7 @@ ] }, { - "Id": 500002, + "Id": 70002, "Model": "baits/fly/fly", "EfficacyBase": 15, "Length": 0, @@ -37,7 +403,7 @@ ] }, { - "Id": 500003, + "Id": 70003, "Model": "baits/black_leech/black_leech", "EfficacyBase": 15, "Length": 0, @@ -50,7 +416,7 @@ ] }, { - "Id": 500004, + "Id": 70004, "Model": "baits/bread/bread", "EfficacyBase": 15, "Length": 0, @@ -63,261 +429,5 @@ "44|2" ] } - ], - "ReelConfig": [ - { - "Id": 200001, - "Model": "reels/syberia/spin_5002/spin_5002", - "Type": 0, - "GearRatio": [ - "7" - ], - "Size": 250, - "Strength": 40 - }, - { - "Id": 200002, - "Model": "reels/syberia/spin_5036/spin_5036", - "Type": 0, - "GearRatio": [ - "5" - ], - "Size": 120, - "Strength": 40 - } - ], - "FishConfig": [ - { - "Id": 2200001, - "Model": [ - "Burbot_B" - ], - "Type": 0, - "SpeciesName": 10, - "MinWeight": 1, - "MaxWeight": 34, - "Accept": 2100001 - }, - { - "Id": 2200002, - "Model": [ - "CarpCommon_B" - ], - "Type": 0, - "SpeciesName": 11, - "MinWeight": 1, - "MaxWeight": 34, - "Accept": 2100001 - }, - { - "Id": 2200003, - "Model": [ - "CarpGrass_B" - ], - "Type": 0, - "SpeciesName": 14, - "MinWeight": 1, - "MaxWeight": 34, - "Accept": 2100001 - }, - { - "Id": 2200004, - "Model": [ - "CarpCrucian_B" - ], - "Type": 0, - "SpeciesName": 16, - "MinWeight": 1, - "MaxWeight": 34, - "Accept": 2100001 - } - ], - "RodConfig": [ - { - "Id": 100001, - "Model": "rods/syberia/tele_10037/tele_10037_t13", - "Type": 1, - "Ring": 0, - "Length": 7, - "Weight": 250, - "Strength": 40, - "MaxRange": 67, - "ConstructionType": 0 - }, - { - "Id": 100002, - "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", - "Type": 0, - "Ring": 1100002, - "Length": 5, - "Weight": 120, - "Strength": 40, - "MaxRange": 30, - "ConstructionType": 0 - }, - { - "Id": 100003, - "Model": "rods/syberia/spin_10034/spin_10034_S60H", - "Type": 0, - "Ring": 1100001, - "Length": 5, - "Weight": 120, - "Strength": 40, - "MaxRange": 30, - "ConstructionType": 0 - } - ], - "HookConfig": [ - { - "Id": 700001, - "Model": "hooks/alliance/c_hook_20789_20794/c_hook_20789", - "Type": 1, - "Zadzior": 1, - "Length": 0, - "Weight": 1 - }, - { - "Id": 700002, - "Model": "hooks/berserk_hooks/triple_20569_20577/triple_20569", - "Type": 1, - "Zadzior": 1, - "Length": 0, - "Weight": 1 - } - ], - "LureConfig": [ - { - "Id": 600001, - "Model": "lures/express_fishing/crankbaits_1/775/crankbaits_775", - "Hook": [ - 700102 - ], - "EfficacyBase": 50, - "Length": 0, - "Weight": 250 - }, - { - "Id": 600002, - "Model": "lures/express_fishing/poppers_1/poppers_590/poppers_590", - "Hook": [ - 700102 - ], - "EfficacyBase": 50, - "Length": 0, - "Weight": 120 - }, - { - "Id": 600003, - "Model": "lures/express_fishing/softplastic/ef_supergrab_6/softplastic_g_1622", - "Hook": [ - 0 - ], - "EfficacyBase": 50, - "Length": 0, - "Weight": 120 - }, - { - "Id": 600004, - "Model": "lures/express_fishing/softplastic/ef_superminnow_6/softplastic_m_1634", - "Hook": [ - 0 - ], - "EfficacyBase": 50, - "Length": 0, - "Weight": 120 - } - ], - "Unit2Config": [ - { - "Id": 1, - "Name": "Unit01", - "Model": "Unit01" - } - ], - "RingConfig": [ - { - "Id": 1100001, - "Model": "rod_rings/rumoi/rumoi_oxiline_spin" - }, - { - "Id": 1100002, - "Model": "rod_rings/smt/smt_pure_ceramic_bolo" - } - ], - "FeederConfig": [ - { - "Id": 900001, - "Model": "Feeders/Feeder 1/FeedTrash 1", - "Type": 0, - "Capacity": 100, - "Weight": 5 - } - ], - "BobberConfig": [ - { - "Id": 300001, - "Model": "bobbers/expressfishing/bob_25003/bob_25003", - "Type": 2, - "Weight": 1, - "Displacement": 40, - "NightLight": 0 - }, - { - "Id": 300002, - "Model": "bobbers/expressfishing/bob_25162_25163/bob_25162", - "Type": 0, - "Weight": 1, - "Displacement": 40, - "NightLight": 0 - }, - { - "Id": 300003, - "Model": "bobbers/expressfishing/bob_25166_25167/bob_25166", - "Type": 0, - "Weight": 1, - "Displacement": 40, - "NightLight": 0 - }, - { - "Id": 300004, - "Model": "bobbers/expressfishing/bob_25001/bob_25001", - "Type": 0, - "Weight": 1, - "Displacement": 40, - "NightLight": 0 - } - ], - "LineConfig": [ - { - "Id": 400001, - "Model": "Lines/UFE Mono/UFE monoClear", - "Type": 0, - "Length": 7, - "Strength": 40, - "Size": 1 - }, - { - "Id": 400002, - "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", - "Type": 0, - "Length": 5, - "Strength": 40, - "Size": 1 - } - ], - "WeightConfig": [ - { - "Id": 800001, - "Model": "Weights/Weight2_5g", - "Type": 0, - "Weight": 3 - } - ], - "UnitConfig": [ - { - "Id": 1, - "Name": "Unit01", - "Model": "Unit01" - } ] } \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Cache.meta b/Assets/Scripts/Configs~/Cache.meta new file mode 100644 index 000000000..13ca635d5 --- /dev/null +++ b/Assets/Scripts/Configs~/Cache.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d89005a134404b88b748787a74946d20 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Configs~/Cache/ConfigContext.cs b/Assets/Scripts/Configs~/Cache/ConfigContext.cs new file mode 100644 index 000000000..4c1a3168d --- /dev/null +++ b/Assets/Scripts/Configs~/Cache/ConfigContext.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace NBF +{ + public interface IConfigContext + { + // 定义非泛型接口 + } + + public class ConfigContext : IConfigContext where T : ConfigBase + { + private static List _cacheList = new List(); + + #region Cache + + public void Association(List list) + { + if (list != null) + { + _cacheList = list; + } + } + + #endregion + + public int Count() + { + return _cacheList.Count; + } + + public int Count(Func predicate) + { + return _cacheList.Count(predicate); + } + + public T Get(int key) + { + return First(key); + } + + public T Fist() + { + return _cacheList.First(); + } + + public T Last() + { + return _cacheList.Last(); + } + + public T Fist(Predicate match) + { + return Get(match); + } + + public T Last(Predicate match) + { + return _cacheList.FindLast(match); + } + + public T Get(Predicate match) + { + return _cacheList.Find(match); + } + + public T GetRandom() + { + Random random = new Random(); + // 随机从列表中取一个对象 + return _cacheList[random.Next(_cacheList.Count)]; + } + + public List GetList() + { + return _cacheList; + } + + public List GetList(Predicate match) + { + return _cacheList.FindAll(match); + } + + private T First(int key) + { + return _cacheList.Find(t => t.id == key); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Cache/ConfigContext.cs.meta b/Assets/Scripts/Configs~/Cache/ConfigContext.cs.meta new file mode 100644 index 000000000..d6f758d4c --- /dev/null +++ b/Assets/Scripts/Configs~/Cache/ConfigContext.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 82dbb868b2724a85aa866e0bf9e88e91 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Cache/Configs.cs b/Assets/Scripts/Configs~/Cache/Configs.cs new file mode 100644 index 000000000..c4610a020 --- /dev/null +++ b/Assets/Scripts/Configs~/Cache/Configs.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +namespace NBF +{ + public static class Configs + { + private static readonly Dictionary _dictionary = new Dictionary(); + + static Configs() + { + } + + public static ConfigContext Table() where T : ConfigBase + { + var type = typeof(T); + if (_dictionary.TryGetValue(type, out var context)) + { + return context as ConfigContext; + } + + var jsonContext = new ConfigContext(); + _dictionary[type] = jsonContext; + return jsonContext; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Cache/Configs.cs.meta b/Assets/Scripts/Configs~/Cache/Configs.cs.meta new file mode 100644 index 000000000..161d50cb5 --- /dev/null +++ b/Assets/Scripts/Configs~/Cache/Configs.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1881c9eee25240ddbaecbf99546a8750 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Cache/TableNameAttribute.cs b/Assets/Scripts/Configs~/Cache/TableNameAttribute.cs new file mode 100644 index 000000000..9a9676b9a --- /dev/null +++ b/Assets/Scripts/Configs~/Cache/TableNameAttribute.cs @@ -0,0 +1,17 @@ +using System; + +namespace NBF +{ + [AttributeUsage(AttributeTargets.Class)] + public class TableNameAttribute : Attribute + { + public string Name; + public string Key; + + public TableNameAttribute(string name, string key = "id") + { + Name = name; + Key = key; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Cache/TableNameAttribute.cs.meta b/Assets/Scripts/Configs~/Cache/TableNameAttribute.cs.meta new file mode 100644 index 000000000..05932f62f --- /dev/null +++ b/Assets/Scripts/Configs~/Cache/TableNameAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 737030131eba4fd6ba6067b47fcae5d3 +timeCreated: 1744862554 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/ConfigAssets.Parse.cs b/Assets/Scripts/Configs~/ConfigAssets.Parse.cs new file mode 100644 index 000000000..39efaff89 --- /dev/null +++ b/Assets/Scripts/Configs~/ConfigAssets.Parse.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using NBC; +using Newtonsoft.Json.Linq; +using UnityEngine; + +namespace NBF +{ + public partial class ConfigAssets + { + private static readonly Type CustomType = typeof(ICustomParse); + + private static List ParseLine(JToken[] arr, TableNameAttribute tableNameAttribute) where T : ConfigBase + { + List list = new List(); + var type = typeof(T); + foreach (var jToken in arr) + { + T instance = null; + try + { + if (CustomType.IsAssignableFrom(type)) //自定义解析 + { + instance = Activator.CreateInstance(); + } + else + { + instance = jToken.ToObject(); + } + } + catch (Exception e) + { + Log.Error(e); + } + + if (instance != null) + { + var key = jToken[tableNameAttribute.Key].ToInt(); + if (key < 1) + { + if (instance.id > 0) + { + key = instance.id; + } + } + + try + { + if (key < 1) continue; + if (instance is ICustomParse customParse) + { + customParse.Parse(jToken); + } + + instance.id = key; + list.Add(instance); + } + catch (Exception e) + { + Log.Error(e); + } + } + } + + return list; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/ConfigAssets.Parse.cs.meta b/Assets/Scripts/Configs~/ConfigAssets.Parse.cs.meta new file mode 100644 index 000000000..221b4caad --- /dev/null +++ b/Assets/Scripts/Configs~/ConfigAssets.Parse.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 09494bd809bd47b29be0723c8671afb8 +timeCreated: 1744898106 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/ConfigAssets.cs b/Assets/Scripts/Configs~/ConfigAssets.cs new file mode 100644 index 000000000..e78d4afef --- /dev/null +++ b/Assets/Scripts/Configs~/ConfigAssets.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace NBF +{ + public partial class ConfigAssets : ScriptableObject + { + // public static string SavePath => $"Assets/ResRaw/Config/ConfigAssets.asset"; + public static string SavePath => $"Assets/Resources/Config/ConfigAssets.asset"; + private static ConfigAssets _inst; + + public static ConfigAssets Instance => _inst; + + public static void Init() + { + var asset = Resources.Load("config/ConfigAssets"); + if (asset != null) + { + asset.AssociationContexts(); + _inst = asset; + } + + // var assetProvider = NBC.Asset.Assets.LoadAsset(SavePath); + // if (assetProvider != null && assetProvider.Asset is ConfigAssets asset) + // { + // asset.AssociationContexts(); + // _inst = asset; + // } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/ConfigAssets.cs.meta b/Assets/Scripts/Configs~/ConfigAssets.cs.meta new file mode 100644 index 000000000..a3398331b --- /dev/null +++ b/Assets/Scripts/Configs~/ConfigAssets.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3d8691ef03f74aedb6cfd67e53cf664f +timeCreated: 1742999693 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor.meta b/Assets/Scripts/Configs~/Editor.meta new file mode 100644 index 000000000..7d23eff71 --- /dev/null +++ b/Assets/Scripts/Configs~/Editor.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2178333fb882410eb05c0f66a95c8880 +timeCreated: 1742998269 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor/CfgEditorUtil.cs b/Assets/Scripts/Configs~/Editor/CfgEditorUtil.cs new file mode 100644 index 000000000..f8c33bf5a --- /dev/null +++ b/Assets/Scripts/Configs~/Editor/CfgEditorUtil.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.IO; +using UnityEditor; +using UnityEngine; + +namespace NBF +{ + public static class CfgEditorUtil + { + [MenuItem("构建/配置表/生成脚本")] + public static void CreateScriptableObject() + { + EditorUtils.GetOrCreateAsset(ConfigAssets.SavePath); + GenConfigScripts(); + AssetDatabase.Refresh(); + } + + [MenuItem("构建/配置表/导表")] + public static void BuildExcel() + { + ExcelToJsonWindow.GenConfig(false); + AssetDatabase.Refresh(); + } + + [MenuItem("构建/配置表/导多语言")] + public static void BuildLanguage() + { + ExcelToJsonWindow.GenLanguage(); + AssetDatabase.Refresh(); + } + + #region 生成脚本 + + private static string GenPath = "Scripts/Configs/Gen"; + private static string TempPath = "Scripts/Configs/Editor/ConfigWarpTemplate"; + + public static void GenConfigScripts() + { + if (!Directory.Exists($"{Application.dataPath}/{GenPath}")) + { + return; + } + + var types = Reflection.GetAllNonAbstractDerivedTypes(); + Dictionary tableNameAttributes = new Dictionary(); + foreach (var type in types) + { + tableNameAttributes[type] = type.Name; + } + + // var canGen = CanGen(tableNameAttributes); + // + // if (!canGen) return; + GenParse(tableNameAttributes); + GenWarp(tableNameAttributes); + // GenBinder(tableNameAttributes); + AssetDatabase.Refresh(); + } + + private static bool CanGen(Dictionary tableNameAttributes) + { + // return true; + string filePath = Path.Combine(Application.dataPath, $"{GenPath}/Warps"); + if (!Directory.Exists(filePath)) return true; + var files = Directory.GetFiles(filePath); + List allFileName = new List(); + foreach (var file in files) + { + if (Path.GetExtension(file).ToLower() == ".meta") continue; + var fileName = Path.GetFileNameWithoutExtension(file); + allFileName.Add(fileName.Replace("Warp", "")); + } + + if (allFileName.Count != tableNameAttributes.Count) return true; + + foreach (var type in tableNameAttributes.Keys) + { + if (!allFileName.Contains(type.Name)) return true; + } + + return false; + } + + + private static void GenWarp(Dictionary tableNameAttributes) + { + // 为何使用生成式,不使用static静态泛型 ? 生成式扩展更强且不会破坏原类的集成结构,父类也不用是泛型类 + //否则比如 BaseConfig 类型来使用。集成结构会受很大限制,反而没有生成式来的灵活 + + string filePath = Path.Combine(Application.dataPath, TempPath); + if (File.Exists(filePath)) + { + // 读取文本内容 + string fileContent = File.ReadAllText(filePath); + var rootPath = $"{Application.dataPath}/{GenPath}/Warps"; + if (!Directory.Exists(rootPath)) + { + return; + } + + if (!Directory.Exists(rootPath)) + { + Directory.CreateDirectory(rootPath); + } + + foreach (var type in tableNameAttributes.Keys) + { + var content = fileContent.Replace("##NAME##", type.Name); + File.WriteAllText($"{rootPath}/{type.Name}Warp.cs", content); + } + } + else + { + Debug.LogError("生成代码模板不存在,请检查"); + } + } + + private static void GenParse(Dictionary tableNameAttributes) + { + if (!Directory.Exists($"{Application.dataPath}/{GenPath}")) + { + return; + } + + CodeWriter codeWriter = new CodeWriter(); + codeWriter.Writeln("/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/"); + codeWriter.Writeln(); + codeWriter.Writeln("using System;"); + codeWriter.Writeln("using System.Collections.Generic;"); + codeWriter.Writeln("using System.Reflection;"); + codeWriter.Writeln("using Newtonsoft.Json.Linq;"); + codeWriter.Writeln("using UnityEngine;"); + + codeWriter.Writeln(); + codeWriter.Writeln("namespace NBF"); + + codeWriter.StartBlock(); + + codeWriter.Writeln("public partial class ConfigAssets"); + codeWriter.StartBlock(); + + foreach (var type in tableNameAttributes.Keys) + { + // codeWriter.Writeln($"[HideInInspector] public List<{type.Name}> {type.Name}Arr;"); + codeWriter.Writeln($"public List<{type.Name}> {type.Name}Arr;"); + } + + codeWriter.Writeln(); + + codeWriter.Writeln("public void Parse(JToken[] arr, Type type)"); + codeWriter.StartBlock(); + codeWriter.Writeln("var tableNameAttribute = type.GetCustomAttribute();"); + codeWriter.Writeln("if (tableNameAttribute == null) return;"); + + foreach (var type in tableNameAttributes.Keys) + { + codeWriter.Writeln($"if (type == typeof({type.Name}))"); + codeWriter.StartBlock(); + codeWriter.Writeln($"{type.Name}Arr = ParseLine<{type.Name}>(arr, tableNameAttribute);"); + codeWriter.EndBlock(); + codeWriter.Writeln(); + } + + codeWriter.EndBlock(); + + codeWriter.Writeln(); + codeWriter.Writeln("public void AssociationContexts()"); + codeWriter.StartBlock(); + + foreach (var type in tableNameAttributes.Keys) + { + codeWriter.Writeln($"new ConfigContext<{type.Name}>().Association({type.Name}Arr);"); + } + + codeWriter.EndBlock(); + + + codeWriter.EndBlock(); + codeWriter.EndBlock(); + + codeWriter.Save($"{Application.dataPath}/{GenPath}/ConfigAssets.Gen.cs"); + } + + + private static void WriterCreateParse(CodeWriter codeWriter, Type type) + { + codeWriter.Writeln($"if (type == typeof({type.Name}))"); + codeWriter.StartBlock(); + codeWriter.Writeln($"return CreateParseTableTask<{type.Name}>();"); + codeWriter.EndBlock(); + codeWriter.Writeln(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor/CfgEditorUtil.cs.meta b/Assets/Scripts/Configs~/Editor/CfgEditorUtil.cs.meta new file mode 100644 index 000000000..7c99811e6 --- /dev/null +++ b/Assets/Scripts/Configs~/Editor/CfgEditorUtil.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5bc0ac74b225496da64195b28ce14cb2 +timeCreated: 1742998279 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor/CodeWriter.cs b/Assets/Scripts/Configs~/Editor/CodeWriter.cs new file mode 100644 index 000000000..c7b2365de --- /dev/null +++ b/Assets/Scripts/Configs~/Editor/CodeWriter.cs @@ -0,0 +1,105 @@ +using System; +using System.IO; +using System.Text; + +namespace NBF +{ + public interface ICodeWriterConfig + { + string BlockStart { get; set; } + string BlockEnd { get; set; } + bool BlockFromNewLine { get; set; } + bool UsingTabs { get; set; } + string EndOfLine { get; set; } + } + + public class DefCSharpCodeWriterConfig : ICodeWriterConfig + { + public string BlockStart { get; set; } = "{"; + public string BlockEnd { get; set; } = "}"; + public bool BlockFromNewLine { get; set; } + public bool UsingTabs { get; set; } = true; + public string EndOfLine { get; set; } + } + + public class CodeWriter + { + private ICodeWriterConfig _config; + + private StringBuilder _stringBuilder = new StringBuilder(); + + private int _nowTabCount; + + public CodeWriter() + { + Init(); + } + + public CodeWriter(ICodeWriterConfig config) + { + Init(config); + } + + public void Write(string content) + { + _stringBuilder.Append(content); + } + + public void Writeln() + { + _stringBuilder.Append(Environment.NewLine); + } + + public void Writeln(string str) + { + _stringBuilder.Append(GetLinePrefix()); + _stringBuilder.Append(str); + _stringBuilder.Append(Environment.NewLine); + } + + public void StartBlock() + { + Writeln(_config.BlockStart); + _nowTabCount++; + } + + public void EndBlock() + { + _nowTabCount--; + Writeln(_config.BlockEnd); + } + + public void Save(string path) + { + var dirPath = Path.GetDirectoryName(path); + if (dirPath != null && !Directory.Exists(dirPath)) + { + Directory.CreateDirectory(dirPath); + } + + var content = _stringBuilder.ToString(); + File.WriteAllText(path, content); + } + + #region 内部方法 + + private void Init(ICodeWriterConfig config = null) + { + _config = config ?? new DefCSharpCodeWriterConfig(); + } + + private string GetLinePrefix() + { + string ret = string.Empty; + if (!_config.UsingTabs) return ret; + for (var i = 0; i < _nowTabCount; i++) + { + ret += "\t"; + } + + return ret; + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor/CodeWriter.cs.meta b/Assets/Scripts/Configs~/Editor/CodeWriter.cs.meta new file mode 100644 index 000000000..d0d64bd8b --- /dev/null +++ b/Assets/Scripts/Configs~/Editor/CodeWriter.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: cf1ac73cd67e4bdc9de1a53a13f5b841 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor/ConfigWarpTemplate b/Assets/Scripts/Configs~/Editor/ConfigWarpTemplate new file mode 100644 index 000000000..51681f4f0 --- /dev/null +++ b/Assets/Scripts/Configs~/Editor/ConfigWarpTemplate @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class ##NAME## + { + private static ConfigContext<##NAME##> _context; + + private static ConfigContext<##NAME##> Context => _context ??= Configs.Table<##NAME##>(); + + public static ##NAME## Get(int key) + { + return Context.Get(key); + } + + public static ##NAME## Get(Predicate<##NAME##> match) + { + return Context.Get(match); + } + + public static ##NAME## Fist() + { + return Context.Fist(); + } + + public static ##NAME## Last() + { + return Context.Last(); + } + + public static ##NAME## Fist(Predicate<##NAME##> match) + { + return Context.Fist(match); + } + + public static ##NAME## Last(Predicate<##NAME##> match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func<##NAME##, bool> predicate) + { + return Context.Count(predicate); + } + + + public static List<##NAME##> GetList() + { + return Context.GetList(); + } + + public static List<##NAME##> GetList(Predicate<##NAME##> match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Editor/ConfigWarpTemplate.meta b/Assets/Scripts/Configs~/Editor/ConfigWarpTemplate.meta new file mode 100644 index 000000000..fc3837842 --- /dev/null +++ b/Assets/Scripts/Configs~/Editor/ConfigWarpTemplate.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4b77eee728204f26bc602016c4a20c86 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Configs~/Extemds.meta b/Assets/Scripts/Configs~/Extemds.meta new file mode 100644 index 000000000..d674680a6 --- /dev/null +++ b/Assets/Scripts/Configs~/Extemds.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8a50bb33d07439e9c7762e17bced2e0 +timeCreated: 1744862665 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Extemds/JTokenExtends.cs b/Assets/Scripts/Configs~/Extemds/JTokenExtends.cs new file mode 100644 index 000000000..e0b24a635 --- /dev/null +++ b/Assets/Scripts/Configs~/Extemds/JTokenExtends.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json.Linq; +using UnityEngine; + +namespace NBF +{ + public static class JTokenExtends + { + public static Vector2 ToVector2(this string str, string sp = ",") + { + Vector2 vector2 = Vector2.zero; + var arr = str.Split(sp); + if (arr.Length > 0) + { + float.TryParse(arr[0], out vector2.x); + if (arr.Length > 1) + { + float.TryParse(arr[1], out vector2.y); + } + } + + return vector2; + } + + public static Vector3 ToVector3(this string str, string sp = ",") + { + Vector3 vector2 = Vector3.zero; + var arr = str.Split(sp); + if (arr.Length > 0) + { + float.TryParse(arr[0], out vector2.x); + if (arr.Length > 1) + { + float.TryParse(arr[1], out vector2.y); + } + + if (arr.Length > 2) + { + float.TryParse(arr[2], out vector2.z); + } + } + + return vector2; + } + + public static T[] ToArr(this JToken token, string split = ",") where T : IConvertible + { + if (token is JArray array) + { + return array.ToObject(); + } + + if (token != null) + { + var str = token.ToString(); + if (string.IsNullOrWhiteSpace(str)) return Array.Empty(); + + var arr = str.Split(split); + try + { + return arr.Select(a => (T)Convert.ChangeType(a, typeof(T))).ToArray(); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + + return Array.Empty(); + } + + public static int ToInt(this JToken token) + { + if (token == null) + { + return 0; + } + + try + { + return (int)token; + } + catch (Exception e) + { + return 0; + } + } + + public static float ToFloat(this JToken token) + { + if (token == null) + { + return 0; + } + + try + { + return (float)token; + } + catch (Exception e) + { + return 0; + } + } + + public static string ToStr(this JToken token) + { + if (token != null) + { + return token.ToString(); + } + + return string.Empty; + } + + public static List ToList(this JToken token, string split = ",") where T : IConvertible + { + if (token is JArray array) + { + return array.ToObject>(); + } + + if (token != null) + { + var str = token.ToString(); + if (string.IsNullOrWhiteSpace(str)) return new List(); + var arr = str.Split(split); + return arr.Select( + a => string.IsNullOrWhiteSpace(a) ? default : (T)Convert.ChangeType(a, typeof(T))).ToList(); + } + + return new List(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Extemds/JTokenExtends.cs.meta b/Assets/Scripts/Configs~/Extemds/JTokenExtends.cs.meta new file mode 100644 index 000000000..89797cceb --- /dev/null +++ b/Assets/Scripts/Configs~/Extemds/JTokenExtends.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3d6ce3cc850f41b8ba83653660b928ce +timeCreated: 1744862670 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen.meta b/Assets/Scripts/Configs~/Gen.meta new file mode 100644 index 000000000..0dc52f34e --- /dev/null +++ b/Assets/Scripts/Configs~/Gen.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0eceaba126fb407583191d01e32bb735 +timeCreated: 1756050728 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/ConfigAssets.Gen.cs b/Assets/Scripts/Configs~/Gen/ConfigAssets.Gen.cs new file mode 100644 index 000000000..63afd189c --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/ConfigAssets.Gen.cs @@ -0,0 +1,122 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ + +using System; +using System.Collections.Generic; +using System.Reflection; +using Newtonsoft.Json.Linq; +using UnityEngine; + +namespace NBF +{ + public partial class ConfigAssets + { + public List BaitConfigArr; + public List BobberConfigArr; + public List FeederConfigArr; + public List FishAcceptConfigArr; + public List FishConfigArr; + public List HookConfigArr; + public List LeadersConfigArr; + public List LineConfigArr; + public List LureConfigArr; + public List ReelConfigArr; + public List RingConfigArr; + public List RodConfigArr; + public List UnitConfigArr; + public List WeightConfigArr; + + public void Parse(JToken[] arr, Type type) + { + var tableNameAttribute = type.GetCustomAttribute(); + if (tableNameAttribute == null) return; + if (type == typeof(BaitConfig)) + { + BaitConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(BobberConfig)) + { + BobberConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(FeederConfig)) + { + FeederConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(FishAcceptConfig)) + { + FishAcceptConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(FishConfig)) + { + FishConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(HookConfig)) + { + HookConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(LeadersConfig)) + { + LeadersConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(LineConfig)) + { + LineConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(LureConfig)) + { + LureConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(ReelConfig)) + { + ReelConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(RingConfig)) + { + RingConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(RodConfig)) + { + RodConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(UnitConfig)) + { + UnitConfigArr = ParseLine(arr, tableNameAttribute); + } + + if (type == typeof(WeightConfig)) + { + WeightConfigArr = ParseLine(arr, tableNameAttribute); + } + + } + + public void AssociationContexts() + { + new ConfigContext().Association(BaitConfigArr); + new ConfigContext().Association(BobberConfigArr); + new ConfigContext().Association(FeederConfigArr); + new ConfigContext().Association(FishAcceptConfigArr); + new ConfigContext().Association(FishConfigArr); + new ConfigContext().Association(HookConfigArr); + new ConfigContext().Association(LeadersConfigArr); + new ConfigContext().Association(LineConfigArr); + new ConfigContext().Association(LureConfigArr); + new ConfigContext().Association(ReelConfigArr); + new ConfigContext().Association(RingConfigArr); + new ConfigContext().Association(RodConfigArr); + new ConfigContext().Association(UnitConfigArr); + new ConfigContext().Association(WeightConfigArr); + } + } +} diff --git a/Assets/Scripts/Configs~/Gen/ConfigAssets.Gen.cs.meta b/Assets/Scripts/Configs~/Gen/ConfigAssets.Gen.cs.meta new file mode 100644 index 000000000..ed730e0fd --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/ConfigAssets.Gen.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: bd9bbc8f86e64a928533f493e39813ed \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps.meta b/Assets/Scripts/Configs~/Gen/Warps.meta new file mode 100644 index 000000000..15944082b --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 98e70a75b52b4728aec1e5b7f506695c +timeCreated: 1756050753 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/BaitConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/BaitConfigWarp.cs new file mode 100644 index 000000000..78fbf6fbf --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/BaitConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class BaitConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static BaitConfig Get(int key) + { + return Context.Get(key); + } + + public static BaitConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static BaitConfig Fist() + { + return Context.Fist(); + } + + public static BaitConfig Last() + { + return Context.Last(); + } + + public static BaitConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static BaitConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/BaitConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/BaitConfigWarp.cs.meta new file mode 100644 index 000000000..62c32df08 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/BaitConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5c6bdb0bae4da2a4da6aacaf58a1abc0 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/BobberConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/BobberConfigWarp.cs new file mode 100644 index 000000000..b6d3fac39 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/BobberConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class BobberConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static BobberConfig Get(int key) + { + return Context.Get(key); + } + + public static BobberConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static BobberConfig Fist() + { + return Context.Fist(); + } + + public static BobberConfig Last() + { + return Context.Last(); + } + + public static BobberConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static BobberConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/BobberConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/BobberConfigWarp.cs.meta new file mode 100644 index 000000000..53cac01ed --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/BobberConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 99b64c24f2bad454086ac41dd6aa7ffc \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/FeederConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/FeederConfigWarp.cs new file mode 100644 index 000000000..bb2f54b52 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/FeederConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class FeederConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static FeederConfig Get(int key) + { + return Context.Get(key); + } + + public static FeederConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static FeederConfig Fist() + { + return Context.Fist(); + } + + public static FeederConfig Last() + { + return Context.Last(); + } + + public static FeederConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static FeederConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/FeederConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/FeederConfigWarp.cs.meta new file mode 100644 index 000000000..8bd74b4f9 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/FeederConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: dc082eda2a5880148843ce9c21ed4eed \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/FishAcceptConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/FishAcceptConfigWarp.cs new file mode 100644 index 000000000..b8081592e --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/FishAcceptConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class FishAcceptConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static FishAcceptConfig Get(int key) + { + return Context.Get(key); + } + + public static FishAcceptConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static FishAcceptConfig Fist() + { + return Context.Fist(); + } + + public static FishAcceptConfig Last() + { + return Context.Last(); + } + + public static FishAcceptConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static FishAcceptConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/FishAcceptConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/FishAcceptConfigWarp.cs.meta new file mode 100644 index 000000000..e06497024 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/FishAcceptConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 23d45122e487d8f439bf063a4df7a4b7 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/FishConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/FishConfigWarp.cs new file mode 100644 index 000000000..6ea97f0fc --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/FishConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class FishConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static FishConfig Get(int key) + { + return Context.Get(key); + } + + public static FishConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static FishConfig Fist() + { + return Context.Fist(); + } + + public static FishConfig Last() + { + return Context.Last(); + } + + public static FishConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static FishConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/FishConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/FishConfigWarp.cs.meta new file mode 100644 index 000000000..81486f4f3 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/FishConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d60d97e94b1432c4e985a5469fd01409 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/HookConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/HookConfigWarp.cs new file mode 100644 index 000000000..c03d22af3 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/HookConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class HookConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static HookConfig Get(int key) + { + return Context.Get(key); + } + + public static HookConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static HookConfig Fist() + { + return Context.Fist(); + } + + public static HookConfig Last() + { + return Context.Last(); + } + + public static HookConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static HookConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/HookConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/HookConfigWarp.cs.meta new file mode 100644 index 000000000..a48eb7900 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/HookConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: fc38b93ab46f1bd4a83f81f1cd3b3e4c \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/LeadersConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/LeadersConfigWarp.cs new file mode 100644 index 000000000..ad4c8a8af --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/LeadersConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class LeadersConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static LeadersConfig Get(int key) + { + return Context.Get(key); + } + + public static LeadersConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static LeadersConfig Fist() + { + return Context.Fist(); + } + + public static LeadersConfig Last() + { + return Context.Last(); + } + + public static LeadersConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static LeadersConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/LeadersConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/LeadersConfigWarp.cs.meta new file mode 100644 index 000000000..f11b68d93 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/LeadersConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 7911fb1cf4470014eadb4d9db5db5861 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/LineConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/LineConfigWarp.cs new file mode 100644 index 000000000..7ae22d3ab --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/LineConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class LineConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static LineConfig Get(int key) + { + return Context.Get(key); + } + + public static LineConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static LineConfig Fist() + { + return Context.Fist(); + } + + public static LineConfig Last() + { + return Context.Last(); + } + + public static LineConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static LineConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/LineConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/LineConfigWarp.cs.meta new file mode 100644 index 000000000..48a663dea --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/LineConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1acb019fe35da324cb5a26e45c54532d \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/LureConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/LureConfigWarp.cs new file mode 100644 index 000000000..e26f0145e --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/LureConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class LureConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static LureConfig Get(int key) + { + return Context.Get(key); + } + + public static LureConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static LureConfig Fist() + { + return Context.Fist(); + } + + public static LureConfig Last() + { + return Context.Last(); + } + + public static LureConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static LureConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/LureConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/LureConfigWarp.cs.meta new file mode 100644 index 000000000..33df3e2ef --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/LureConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 74aae733a506d0840a1a7cc2623ed5fd \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/ReelConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/ReelConfigWarp.cs new file mode 100644 index 000000000..e7cb60301 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/ReelConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class ReelConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static ReelConfig Get(int key) + { + return Context.Get(key); + } + + public static ReelConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static ReelConfig Fist() + { + return Context.Fist(); + } + + public static ReelConfig Last() + { + return Context.Last(); + } + + public static ReelConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static ReelConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/ReelConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/ReelConfigWarp.cs.meta new file mode 100644 index 000000000..30120eb5a --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/ReelConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6bfa9f163eb97be418e04f1f62c607de \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/RingConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/RingConfigWarp.cs new file mode 100644 index 000000000..209da8dfb --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/RingConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class RingConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static RingConfig Get(int key) + { + return Context.Get(key); + } + + public static RingConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static RingConfig Fist() + { + return Context.Fist(); + } + + public static RingConfig Last() + { + return Context.Last(); + } + + public static RingConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static RingConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/RingConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/RingConfigWarp.cs.meta new file mode 100644 index 000000000..8a778e233 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/RingConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a52a98969f4fae44ba19533cb1ae552e \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/RodConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/RodConfigWarp.cs new file mode 100644 index 000000000..280781968 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/RodConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class RodConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static RodConfig Get(int key) + { + return Context.Get(key); + } + + public static RodConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static RodConfig Fist() + { + return Context.Fist(); + } + + public static RodConfig Last() + { + return Context.Last(); + } + + public static RodConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static RodConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/RodConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/RodConfigWarp.cs.meta new file mode 100644 index 000000000..33ef28386 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/RodConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 81f057dddf36a734ead19cd98e19a2e0 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/UnitConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/UnitConfigWarp.cs new file mode 100644 index 000000000..0398f08b0 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/UnitConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class UnitConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static UnitConfig Get(int key) + { + return Context.Get(key); + } + + public static UnitConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static UnitConfig Fist() + { + return Context.Fist(); + } + + public static UnitConfig Last() + { + return Context.Last(); + } + + public static UnitConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static UnitConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/UnitConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/UnitConfigWarp.cs.meta new file mode 100644 index 000000000..a260fdbd8 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/UnitConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 69acf2fddccdd7b4fae3ad883cbc50ec \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/WeightConfigWarp.cs b/Assets/Scripts/Configs~/Gen/Warps/WeightConfigWarp.cs new file mode 100644 index 000000000..7018eed48 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/WeightConfigWarp.cs @@ -0,0 +1,65 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改**/ +using System; +using System.Collections.Generic; + +namespace NBF +{ + [Serializable] + public partial class WeightConfig + { + private static ConfigContext _context; + + private static ConfigContext Context => _context ??= Configs.Table(); + + public static WeightConfig Get(int key) + { + return Context.Get(key); + } + + public static WeightConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static WeightConfig Fist() + { + return Context.Fist(); + } + + public static WeightConfig Last() + { + return Context.Last(); + } + + public static WeightConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static WeightConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Gen/Warps/WeightConfigWarp.cs.meta b/Assets/Scripts/Configs~/Gen/Warps/WeightConfigWarp.cs.meta new file mode 100644 index 000000000..a14f49de5 --- /dev/null +++ b/Assets/Scripts/Configs~/Gen/Warps/WeightConfigWarp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 43244884876723947bd6574d57b2349c \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem.meta b/Assets/Scripts/Configs~/Mem.meta new file mode 100644 index 000000000..23fea0283 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9fbbf78150ef486581fecb379fc3b1cd +timeCreated: 1742998650 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/BaitConfig.cs b/Assets/Scripts/Configs~/Mem/BaitConfig.cs new file mode 100644 index 000000000..36e636948 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/BaitConfig.cs @@ -0,0 +1,137 @@ +using System; +using System.Linq; +using UnityEngine; + +namespace NBF +{ + [TableName("gameBaits")] + public partial class BaitConfig : ConfigGearBase + { + public enum Type + { + Natural = 0, + Spinning = 1 + } + + + public Type type; + + public FishSpecies[] acceptFish; + + public Vector2 weightFishAccept = new Vector2(0f, 3f); + + + public float weight = 10f; + + public float lenght; + + public int amount = 1; + + + public int Level = 1; + + private Vector2 startedbaitValues; + + + public virtual bool CheckIsFishAccept(FishSpecies fishSpecies, float fishWeight = 0f) + { + var fish = FishConfig.Get(t => t.speciesName == fishSpecies); + if (fish == null) return false; + if (fish.type == FishConfig.Type.Predator && type == Type.Spinning) + { + Vector2 vector = weightFishAccept; + Debug.Log("Startowa wartosc przynety:" + vector.ToString()); + vector = startedbaitValues; + Debug.Log("Kolejna wartosc przynety 1:" + vector.ToString()); + Vector2 vector2 = new Vector2(0f, 0f); + if (startedbaitValues == vector2) + { + if (weightFishAccept.x > 0.01f && weightFishAccept.x <= 2.5f) + { + weightFishAccept.x = 0.01f; + } + else if (weightFishAccept.x > 2.5f && weightFishAccept.x <= 9.2f) + { + weightFishAccept.x = 2.5f; + } + else if (weightFishAccept.x > 9.2f && weightFishAccept.x <= 20f) + { + weightFishAccept.x = 8f; + } + else if (weightFishAccept.x > 20f && weightFishAccept.x <= 50f) + { + weightFishAccept.x = 14f; + } + else if (weightFishAccept.x > 50f && weightFishAccept.x <= 700f) + { + weightFishAccept.x = 22f; + } + else if (weightFishAccept.x > 700f) + { + weightFishAccept.x = 150f; + } + + if (weightFishAccept.y > 0.1f && weightFishAccept.y <= 3f) + { + weightFishAccept.y = 3f; + } + else if (weightFishAccept.y > 3f && weightFishAccept.y <= 9f) + { + weightFishAccept.y = 12f; + } + else if (weightFishAccept.y > 9f && weightFishAccept.y <= 24f) + { + weightFishAccept.y = 60f; + } + else if (weightFishAccept.y > 24f && weightFishAccept.y <= 50f) + { + weightFishAccept.y = 120f; + } + else if (weightFishAccept.y > 50f && weightFishAccept.y <= 105f) + { + weightFishAccept.y = 350f; + } + else if (weightFishAccept.y > 105f && weightFishAccept.y <= 170f) + { + weightFishAccept.y = 650f; + } + else if (weightFishAccept.y > 170f && weightFishAccept.y <= 500f) + { + weightFishAccept.y = 900f; + } + else if (weightFishAccept.y > 500f) + { + weightFishAccept.y = 1800f; + } + + startedbaitValues = weightFishAccept; + vector = startedbaitValues; + Debug.Log("Kolejna wartosc przynety: 2" + vector.ToString()); + } + + if (fishWeight >= weightFishAccept.x && fishWeight <= weightFishAccept.y) + { + vector = weightFishAccept; + Debug.Log("Fish accept lure: " + vector.ToString() + " weight:" + fishWeight); + return true; + } + } + else if (fish.type == FishConfig.Type.WhiteFish && type == Type.Natural) + { + if (acceptFish.Contains(fishSpecies)) + { + Debug.Log("Fish accept bait weight:" + fishWeight); + return true; + } + } + else if (fish.type == FishConfig.Type.Predator && type == Type.Natural && + acceptFish.Contains(fishSpecies)) + { + Debug.Log("Fish accept bait predator weight:" + fishWeight); + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/BaitConfig.cs.meta b/Assets/Scripts/Configs~/Mem/BaitConfig.cs.meta new file mode 100644 index 000000000..320c10ff7 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/BaitConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 29ac65179e8d469d96caa04ce15021d6 +timeCreated: 1742999023 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/BobberConfig.cs b/Assets/Scripts/Configs~/Mem/BobberConfig.cs new file mode 100644 index 000000000..0457d38b6 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/BobberConfig.cs @@ -0,0 +1,32 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameFloats")] + public partial class BobberConfig : ConfigGearBase + { + public enum Type + { + Slider = 0, + Waggler = 1, + PoleFloats = 2, + Sport = 3, + Ball = 4, + Sinker = 5 + } + + + public Type type; + + public float weight = 10f; + + public float displacement = 10f; + + public bool isNightLight; + + public int Level = 1; + + public int amount = 1; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/BobberConfig.cs.meta b/Assets/Scripts/Configs~/Mem/BobberConfig.cs.meta new file mode 100644 index 000000000..af742927d --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/BobberConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6297ba097dac45eb8f14f55dc5ad7d7b +timeCreated: 1742999241 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/CameraCfg.cs b/Assets/Scripts/Configs~/Mem/CameraCfg.cs new file mode 100644 index 000000000..f09a3ae5b --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/CameraCfg.cs @@ -0,0 +1,68 @@ +using System; +using UnityEngine; + +namespace NBF +{ + public enum CameraUpdateMode + { + Smooth, + Immediate, + } + + public enum CameraMode + { + Third, + Free, + } + + [Serializable] + public class CameraCfg + { + public CameraMode Mode; + public CameraUpdateMode UpdateMode; + + public float SmoothTime; + + public float NearClipPlane = 1; + public float FarClipPlane = 500; + + public Vector3 Near; + public Vector3 Far; + public float BestRatio = 0.5f; + + public Vector3 Distance + { + get { return this.Far - this.Near; } + } + + public Vector3 Best + { + get + { + switch (Mode) + { + case CameraMode.Third: + return this.Near + (this.Far - this.Near) * this.BestRatio; + default: + return Quaternion.Euler(this.PitchBest, 0, 0) * + (Vector3.back * (this.Near + (this.Far - this.Near) * this.BestRatio).magnitude); + } + } + } + + public float Yaw; + public bool YawAtThird; + + public float PitchBest; + public float PitchMin; + public float PitchMax; + } + + [CreateAssetMenu(menuName = "ET/CreateCameraConfig", fileName = "CameraCfg", order = 1)] + public class CameraScriptObject : ScriptableObject + { + public float ScaleTime = 6; + public CameraCfg ThirdCfg; + public CameraCfg FreeCfg; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/CameraCfg.cs.meta b/Assets/Scripts/Configs~/Mem/CameraCfg.cs.meta new file mode 100644 index 000000000..317f73ee2 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/CameraCfg.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5f43c20e40ae42239e4381c12ad7cc00 +timeCreated: 1756823027 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/ConfigBase.cs b/Assets/Scripts/Configs~/Mem/ConfigBase.cs new file mode 100644 index 000000000..6c0934d5e --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/ConfigBase.cs @@ -0,0 +1,53 @@ +using System; +using Newtonsoft.Json.Linq; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace NBF +{ + public interface IConfigJsonParse + { + void Parse(JToken row); + } + + public interface ICustomParse + { + void Parse(JToken row); + } + + [Serializable] + public abstract class ConfigBase + { + public string name; + + public int id; + } + + public abstract class ConfigGearBase : ConfigBase + { + public string modelPath = "Models/Rods/"; + + protected virtual string ModelRoot => "gfx/"; + + /// + /// 所属的组 + /// + public int group; + + public GameObject GetModelPrefab() + { + return Resources.Load(ModelRoot + modelPath) as GameObject; + } + + public GameObject Instantiate(Transform parent) + { + return Object.Instantiate(GetModelPrefab(), Vector3.zero, Quaternion.identity, parent); + } + + public GameObject Instantiate(Transform parent, Vector3 position, + Quaternion rotation) + { + return Object.Instantiate(GetModelPrefab(), position, rotation, parent); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/ConfigBase.cs.meta b/Assets/Scripts/Configs~/Mem/ConfigBase.cs.meta new file mode 100644 index 000000000..c41648f0c --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/ConfigBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bfb754c68ea2417685d3e29804c996fa +timeCreated: 1742998658 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/FeederConfig.cs b/Assets/Scripts/Configs~/Mem/FeederConfig.cs new file mode 100644 index 000000000..ca386fad3 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/FeederConfig.cs @@ -0,0 +1,25 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameFeeders")] + public partial class FeederConfig : ConfigGearBase + { + public enum Type + { + Feeder = 0 + } + + public Type type; + + public float weight = 10f; + + public float capacity = 10f; + + public int Level = 1; + + public int amount = 1; + + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/FeederConfig.cs.meta b/Assets/Scripts/Configs~/Mem/FeederConfig.cs.meta new file mode 100644 index 000000000..fb7067d21 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/FeederConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4a3acf5935cc49be8a1e655250ea28e9 +timeCreated: 1742999291 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/FishAcceptConfig.cs b/Assets/Scripts/Configs~/Mem/FishAcceptConfig.cs new file mode 100644 index 000000000..9b26f1d60 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/FishAcceptConfig.cs @@ -0,0 +1,12 @@ +namespace NBF +{ + [TableName("gameFishAccepts")] + public partial class FishAcceptConfig : ConfigBase + { + public int bait; + + public float min; + + public float max; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/FishAcceptConfig.cs.meta b/Assets/Scripts/Configs~/Mem/FishAcceptConfig.cs.meta new file mode 100644 index 000000000..f6ec8cb3e --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/FishAcceptConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 315e92a457a44e67a23cc79710bebdb6 +timeCreated: 1744862496 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/FishConfig.cs b/Assets/Scripts/Configs~/Mem/FishConfig.cs new file mode 100644 index 000000000..56470fffc --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/FishConfig.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; + +namespace NBF +{ + [Serializable] + public class AcceptFishBait + { + public string baitName; + + public int baitId; + + public float min; + + public float max; + } + + [TableName("gameFish")] + public partial class FishConfig : ConfigBase + { + public static FishConfig Get(FishSpecies fishSpecies) + { + return Get(t => t.speciesName == fishSpecies); + } + + public enum Type + { + WhiteFish = 0, + Predator = 1 + } + + public FishSpecies speciesName; + + public bool isEnabled = true; + + public Type type = Type.Predator; + + public float maxWeight = 10f; + + public float speciesCoins = 4f; + + public int rankingPoint = 1; + + public string[] modelPath; + + public string[] imagePath; + + public string[] modelTrophyPath; + + public Vector2[] weightLenghtValues; + + public AnimationCurve weightLengthCurve; + + public List acceptFishBaits; + + public List acceptFishLures; + + public Sprite GetIconImage(int index) + { + return Resources.Load("Icons/Fish/" + imagePath[index]); + } + + public float ConvertWeightFishToLength(float weight) + { + // return FishWeightToLength.Instance.ConvertWeightFishToLength(speciesName, weight); + return 1; + } + + public void SetupCurvesWeight() + { + weightLengthCurve.keys = null; + for (int i = 0; i < weightLenghtValues.Length; i++) + { + weightLengthCurve.AddKey(weightLenghtValues[i].x, weightLenghtValues[i].y); + } + } + + public Vector3 GetFishScale(float weight) + { + // if (!FishWeightToLength.Instance) + // { + // return Vector3.one; + // } + // + // var p = FishWeightToLength.Instance.ConvertWeightFishToLength(speciesName, weight); + // float num = FishWeightToLength.Instance.ConvertWeightFishToLength(speciesName, weight) * 0.0185f; + // return Vector3.one * num; + return Vector3.one; + } + + public GameObject GetModelPrefab(string _modelPath) + { + return Resources.Load("GameItemsPrefabs/Fish/" + _modelPath) as GameObject; + } + + public GameObject GetTrophyModelPrefab(float weight) + { + if (weight > maxWeight) + { + weight = maxWeight; + } + + float num = maxWeight / (float)modelTrophyPath.Length; + int num2 = (int)(weight / num); + if (num2 >= modelTrophyPath.Length) + { + num2 = modelTrophyPath.Length - 1; + } + + return Resources.Load("GameItemsPrefabs/Fish Trophies/" + modelTrophyPath[num2]) as GameObject; + } + + public GameObject GetFishModel(float weight) + { + if (weight > maxWeight) + { + weight = maxWeight; + } + + float num = maxWeight / (float)modelPath.Length; + int num2 = (int)(weight / num); + if (num2 >= modelPath.Length) + { + num2 = modelPath.Length - 1; + } + + return GetModelPrefab(modelPath[num2]); + } + + + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/FishConfig.cs.meta b/Assets/Scripts/Configs~/Mem/FishConfig.cs.meta new file mode 100644 index 000000000..74a9d502f --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/FishConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 036e4898008747fda0a473707565667b +timeCreated: 1742999445 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/HookConfig.cs b/Assets/Scripts/Configs~/Mem/HookConfig.cs new file mode 100644 index 000000000..1c340ab28 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/HookConfig.cs @@ -0,0 +1,167 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameHooks")] + public partial class HookConfig : ConfigGearBase + { + public enum Type + { + Aberdeen = 0, + Bait = 1, + Circle = 2, + Treble = 3, + Octopus = 4, + Carp = 5, + LiveBait = 6, + WideGap = 7 + } + + public enum Zadzior + { + None = 0, + Barbless = 1 + } + + public enum Size + { + _16 = 0, + _14 = 1, + _12 = 2, + _10 = 3, + _9 = 4, + _8 = 5, + _7 = 6, + _6 = 7, + _5 = 8, + _4 = 9, + _3 = 10, + _2 = 11, + _1 = 12, + _1x0 = 13, + _2x0 = 14, + _3x0 = 15, + _4x0 = 16, + _5x0 = 17, + _6x0 = 18, + _7x0 = 19, + _8x0 = 20, + _9x0 = 21, + _10x0 = 22, + _11x0 = 23, + _12x0 = 24, + _13x0 = 25, + _14x0 = 26 + } + + public string color = "Nickel"; + + public Type type; + + public Zadzior zadzior; + + public Size size; + + public int amount = 1; + + public int Level = 1; + + + public string GetSizetext() + { + return size.ToString().Replace("_", "#").Replace("x", "/"); + } + + public Vector2 GetFishAcceptWeightBySize() + { + Vector2 result = Vector2.zero; + switch (size) + { + case Size._16: + result = new Vector2(0f, 3.5f); + break; + case Size._14: + result = new Vector2(0.4f, 5.3f); + break; + case Size._12: + result = new Vector2(0.5f, 7.4f); + break; + case Size._10: + result = new Vector2(0.7f, 10.3f); + break; + case Size._9: + result = new Vector2(1f, 14.4f); + break; + case Size._8: + result = new Vector2(1.4f, 20.2f); + break; + case Size._7: + result = new Vector2(1.6f, 26.2f); + break; + case Size._6: + result = new Vector2(1.8f, 31.5f); + break; + case Size._5: + result = new Vector2(2.2f, 34.6f); + break; + case Size._4: + result = new Vector2(2.4f, 45f); + break; + case Size._3: + result = new Vector2(3.1f, 58.5f); + break; + case Size._2: + result = new Vector2(4.1f, 81.9f); + break; + case Size._1: + result = new Vector2(5.7f, 114.6f); + break; + case Size._1x0: + result = new Vector2(9.2f, 160.5f); + break; + case Size._2x0: + result = new Vector2(12.8f, 216.7f); + break; + case Size._3x0: + result = new Vector2(17.3f, 292.5f); + break; + case Size._4x0: + result = new Vector2(23.4f, 394.9f); + break; + case Size._5x0: + result = new Vector2(31.6f, 533.1f); + break; + case Size._6x0: + result = new Vector2(42.6f, 693f); + break; + case Size._7x0: + result = new Vector2(55.4f, 935f); + break; + case Size._8x0: + result = new Vector2(74.8f, 1122f); + break; + case Size._9x0: + result = new Vector2(89f, 1342f); + break; + case Size._10x0: + result = new Vector2(107f, 1616f); + break; + case Size._11x0: + result = new Vector2(129f, 1940f); + break; + case Size._12x0: + result = new Vector2(155f, 2328f); + break; + case Size._13x0: + result = new Vector2(186f, 2793f); + break; + case Size._14x0: + result = new Vector2(223f, 3352f); + break; + } + + return result; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/HookConfig.cs.meta b/Assets/Scripts/Configs~/Mem/HookConfig.cs.meta new file mode 100644 index 000000000..b67ac5c11 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/HookConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 163f314510a24a43b7f86e22854cde3b +timeCreated: 1742999185 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/LeadersConfig.cs b/Assets/Scripts/Configs~/Mem/LeadersConfig.cs new file mode 100644 index 000000000..6123c5244 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/LeadersConfig.cs @@ -0,0 +1,19 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameLeaders")] + public partial class LeadersConfig : ConfigGearBase + { + public enum Type + { + Mono = 0, + Wire = 1, + Steel = 2, + Titanium = 3 + } + + public Type type; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/LeadersConfig.cs.meta b/Assets/Scripts/Configs~/Mem/LeadersConfig.cs.meta new file mode 100644 index 000000000..196a20750 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/LeadersConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4a5ae0258ce84be1b6b2c2cb6a9921f9 +timeCreated: 1742998962 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/LineConfig.cs b/Assets/Scripts/Configs~/Mem/LineConfig.cs new file mode 100644 index 000000000..747a5b153 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/LineConfig.cs @@ -0,0 +1,28 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameLines")] + public partial class LineConfig : ConfigGearBase + { + protected override string ModelRoot => "GameItemsPrefabs/"; + + public enum Type + { + Mono = 0, + Braid = 1, + Fluro = 2 + } + + public Type type; + + public int length = 125; + + public float strength = 1f; + + public float size = 0.12f; + + public int Level = 1; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/LineConfig.cs.meta b/Assets/Scripts/Configs~/Mem/LineConfig.cs.meta new file mode 100644 index 000000000..dbda52553 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/LineConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8f09d37212e24ee2bb9f0b99ca69df42 +timeCreated: 1742998906 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/LureConfig.cs b/Assets/Scripts/Configs~/Mem/LureConfig.cs new file mode 100644 index 000000000..9a2b891da --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/LureConfig.cs @@ -0,0 +1,123 @@ +using UnityEngine; + +namespace NBF +{ + [TableName("gameLures")] + public partial class LureConfig : ConfigGearBase + { + public enum Type + { + Natural = 0, + Spinning = 1 + } + + + public Type type; + + public FishSpecies[] acceptFish; + + public Vector2 weightFishAccept = new Vector2(0f, 3f); + + public float weight = 10f; + + public float lenght; + + public int amount = 1; + + public int Level = 1; + + /// + /// 配的鱼钩 + /// + public int[] hook; + + private Vector2 startedbaitValues; + + private Vector2 _startedbaitValues; + + public bool CheckIsFishAccept(FishSpecies fishSpecies, float fishWeight = 0) + { + if (FishConfig.Get(fishSpecies).type == FishConfig.Type.Predator) + { + Vector2 vector = weightFishAccept; + Debug.Log("诱饵的初始值:" + vector.ToString()); + vector = _startedbaitValues; + Debug.Log("下一个诱饵值 1:" + vector.ToString()); + Vector2 vector2 = new Vector2(0f, 0f); + if (_startedbaitValues == vector2) + { + if (weightFishAccept.x > 0.01f && weightFishAccept.x <= 2.5f) + { + weightFishAccept.x = 0.01f; + } + else if (weightFishAccept.x > 2.5f && weightFishAccept.x <= 9.2f) + { + weightFishAccept.x = 2.5f; + } + else if (weightFishAccept.x > 9.2f && weightFishAccept.x <= 20f) + { + weightFishAccept.x = 8f; + } + else if (weightFishAccept.x > 20f && weightFishAccept.x <= 50f) + { + weightFishAccept.x = 14f; + } + else if (weightFishAccept.x > 50f && weightFishAccept.x <= 700f) + { + weightFishAccept.x = 22f; + } + else if (weightFishAccept.x > 700f) + { + weightFishAccept.x = 150f; + } + + if (weightFishAccept.y > 0.1f && weightFishAccept.y <= 3f) + { + weightFishAccept.y = 3f; + } + else if (weightFishAccept.y > 3f && weightFishAccept.y <= 9f) + { + weightFishAccept.y = 12f; + } + else if (weightFishAccept.y > 9f && weightFishAccept.y <= 24f) + { + weightFishAccept.y = 60f; + } + else if (weightFishAccept.y > 24f && weightFishAccept.y <= 50f) + { + weightFishAccept.y = 120f; + } + else if (weightFishAccept.y > 50f && weightFishAccept.y <= 105f) + { + weightFishAccept.y = 350f; + } + else if (weightFishAccept.y > 105f && weightFishAccept.y <= 170f) + { + weightFishAccept.y = 650f; + } + else if (weightFishAccept.y > 170f && weightFishAccept.y <= 500f) + { + weightFishAccept.y = 900f; + } + else if (weightFishAccept.y > 500f) + { + weightFishAccept.y = 1800f; + } + + _startedbaitValues = weightFishAccept; + vector = _startedbaitValues; + Debug.Log("另一个有价值的诱饵: 2" + vector.ToString()); + } + + if (fishWeight >= weightFishAccept.x && fishWeight <= weightFishAccept.y) + { + vector = weightFishAccept; + Debug.Log("Fish accept lure: " + vector.ToString() + " weight:" + fishWeight); + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/LureConfig.cs.meta b/Assets/Scripts/Configs~/Mem/LureConfig.cs.meta new file mode 100644 index 000000000..2ce12e541 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/LureConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 184995816e1944d2afc02384ef109693 +timeCreated: 1744898827 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/ReelConfig.cs b/Assets/Scripts/Configs~/Mem/ReelConfig.cs new file mode 100644 index 000000000..dab4e3b4e --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/ReelConfig.cs @@ -0,0 +1,30 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameReels")] + public partial class ReelConfig : ConfigGearBase + { + // protected override string ModelRoot => "GameItemsPrefabs/"; + + public enum Type + { + Universal = 0, + Spinning = 1, + Casting = 2, + Feeder = 3 + } + + + public Type type; + + public float strength = 1f; + + public Vector2 gearRatio; + + public int size = 2000; + + public int Level = 1; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/ReelConfig.cs.meta b/Assets/Scripts/Configs~/Mem/ReelConfig.cs.meta new file mode 100644 index 000000000..4f2cc54bc --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/ReelConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 13045659d27f4ee89aab30efb1740215 +timeCreated: 1742998847 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/RingConfig.cs b/Assets/Scripts/Configs~/Mem/RingConfig.cs new file mode 100644 index 000000000..f29cdfdb0 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/RingConfig.cs @@ -0,0 +1,7 @@ +namespace NBF +{ + [TableName("gameRings")] + public partial class RingConfig : ConfigGearBase + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/RingConfig.cs.meta b/Assets/Scripts/Configs~/Mem/RingConfig.cs.meta new file mode 100644 index 000000000..6d96a2839 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/RingConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 15f2ba6ac6404e9390d9cc2604f2016c +timeCreated: 1744861381 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/RodConfig.cs b/Assets/Scripts/Configs~/Mem/RodConfig.cs new file mode 100644 index 000000000..15e8976cb --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/RodConfig.cs @@ -0,0 +1,41 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameRods")] + public partial class RodConfig : ConfigGearBase + { + + public enum Type + { + Universal = 0, + Tele = 1, + SpinningFloat = 2, + Spinning = 3, + } + + public enum Action + { + Slow = 0, + Medium = 1, + Fast = 2 + } + + + public Type type; + + public string length; + + public string weight; + + public float strength = 2f; + + public int maxRange = 15; + + /// + /// 使用的圈id + /// + public int ring; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/RodConfig.cs.meta b/Assets/Scripts/Configs~/Mem/RodConfig.cs.meta new file mode 100644 index 000000000..7a1790a48 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/RodConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 01b7a315690b4a2d8f82aec56a3a3971 +timeCreated: 1742998702 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/UnitConfig.cs b/Assets/Scripts/Configs~/Mem/UnitConfig.cs new file mode 100644 index 000000000..7a39846f7 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/UnitConfig.cs @@ -0,0 +1,31 @@ +namespace NBF +{ + [TableName("gameUnit")] + public partial class UnitConfig : ConfigBase + { + public UnitType Type; + } + + public enum UnitType : byte + { + /// + /// 玩家 + /// + Player = 1, + + /// + /// 鱼 + /// + Fish = 2, + + /// + /// 船 + /// + Boat = 3, + + /// + /// 车 + /// + Car = 4, + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/UnitConfig.cs.meta b/Assets/Scripts/Configs~/Mem/UnitConfig.cs.meta new file mode 100644 index 000000000..daa9722a3 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/UnitConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 956ed7b067744c369fcff9a8baef77ee +timeCreated: 1756049614 \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/WeightConfig.cs b/Assets/Scripts/Configs~/Mem/WeightConfig.cs new file mode 100644 index 000000000..8d769f975 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/WeightConfig.cs @@ -0,0 +1,26 @@ +using System; +using UnityEngine; + +namespace NBF +{ + [TableName("gameWeights")] + public partial class WeightConfig : ConfigGearBase + { + protected override string ModelRoot => "GameItemsPrefabs/"; + + public enum Type + { + Ball = 0, + Teardrop = 1, + Olive = 2 + } + + public Type type; + + public float weight = 0.1f; + + public int Level = 1; + + public int amount = 1; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Configs~/Mem/WeightConfig.cs.meta b/Assets/Scripts/Configs~/Mem/WeightConfig.cs.meta new file mode 100644 index 000000000..113ec42c7 --- /dev/null +++ b/Assets/Scripts/Configs~/Mem/WeightConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6bfe88a3b2474031aa65c995baebf6f6 +timeCreated: 1742999355 \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs b/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs index 0922b3380..a00cd5621 100644 --- a/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs +++ b/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs @@ -24,7 +24,7 @@ namespace NBF.Fishing2 ret.Country = self.BaseInfo.Country; ret.Head = self.BaseInfo.Head; ret.Level = self.BaseInfo.Level; - ret.Vip = self.BaseInfo.Vip; + // ret.Vip = self.BaseInfo.Vip; return ret; } diff --git a/Assets/Scripts/Fishing2/Role/Role.cs b/Assets/Scripts/Fishing2/Role/Role.cs index 6227a4827..8d1ccce56 100644 --- a/Assets/Scripts/Fishing2/Role/Role.cs +++ b/Assets/Scripts/Fishing2/Role/Role.cs @@ -37,7 +37,7 @@ namespace NBF.Fishing2 Head = Info.BaseInfo.Head, Country = Info.BaseInfo.Country, Level = Info.BaseInfo.Level, - Vip = Info.BaseInfo.Vip + // Vip = Info.BaseInfo.Vip }; return mapUnit; diff --git a/Assets/Scripts/Generate/Config/BaitConfig.cs b/Assets/Scripts/Generate/Config/BaitConfig.cs index 612b61cc7..443bc78f3 100644 --- a/Assets/Scripts/Generate/Config/BaitConfig.cs +++ b/Assets/Scripts/Generate/Config/BaitConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class BaitConfigData : ASerialize, IConfigTable, IProto + public sealed partial class BaitConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static BaitConfigData _instance = null; - - public static BaitConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public BaitConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"BaitConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out BaitConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class BaitConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -106,5 +28,66 @@ namespace NBF public uint[] Arr { get; set; } = Array.Empty(); // 重量(克) [ProtoMember(7)] public string[] ArrStr { get; set; } = Array.Empty(); // 重量(克) - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static BaitConfig Get(uint key) + { + return Context.Get(key); + } + + public static BaitConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static BaitConfig Fist() + { + return Context.Fist(); + } + + public static BaitConfig Last() + { + return Context.Last(); + } + + public static BaitConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static BaitConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/BasicConfig.cs b/Assets/Scripts/Generate/Config/BasicConfig.cs new file mode 100644 index 000000000..6da196d61 --- /dev/null +++ b/Assets/Scripts/Generate/Config/BasicConfig.cs @@ -0,0 +1,85 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +using NBC; +using NBC.Serialize; + +namespace NBF +{ + [ProtoContract] + public sealed partial class BasicConfig : ASerialize, IProto, IConfigTable + { + + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Name { get; set; } // 参数名 + [ProtoMember(3)] + public string[] Val { get; set; } = Array.Empty(); // 参数值 + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static BasicConfig Get(uint key) + { + return Context.Get(key); + } + + public static BasicConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static BasicConfig Fist() + { + return Context.Fist(); + } + + public static BasicConfig Last() + { + return Context.Last(); + } + + public static BasicConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static BasicConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/BasicConfig.cs.meta b/Assets/Scripts/Generate/Config/BasicConfig.cs.meta new file mode 100644 index 000000000..7ef2cb87b --- /dev/null +++ b/Assets/Scripts/Generate/Config/BasicConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5c900c2cd8da41740a01b749b9c8d844 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/BobberConfig.cs b/Assets/Scripts/Generate/Config/BobberConfig.cs index b26f33a49..22e26e993 100644 --- a/Assets/Scripts/Generate/Config/BobberConfig.cs +++ b/Assets/Scripts/Generate/Config/BobberConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class BobberConfigData : ASerialize, IConfigTable, IProto + public sealed partial class BobberConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static BobberConfigData _instance = null; - - public static BobberConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public BobberConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"BobberConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out BobberConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class BobberConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -104,5 +26,66 @@ namespace NBF public uint Displacement { get; set; } // 位移 [ProtoMember(6)] public uint NightLight { get; set; } // 是否夜光 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static BobberConfig Get(uint key) + { + return Context.Get(key); + } + + public static BobberConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static BobberConfig Fist() + { + return Context.Fist(); + } + + public static BobberConfig Last() + { + return Context.Last(); + } + + public static BobberConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static BobberConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/FeederConfig.cs b/Assets/Scripts/Generate/Config/FeederConfig.cs index dfc491e21..3f9def404 100644 --- a/Assets/Scripts/Generate/Config/FeederConfig.cs +++ b/Assets/Scripts/Generate/Config/FeederConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class FeederConfigData : ASerialize, IConfigTable, IProto + public sealed partial class FeederConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static FeederConfigData _instance = null; - - public static FeederConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public FeederConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"FeederConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out FeederConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class FeederConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -102,5 +24,66 @@ namespace NBF public uint Capacity { get; set; } // 能力 [ProtoMember(5)] public uint Weight { get; set; } // 重量(克) - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static FeederConfig Get(uint key) + { + return Context.Get(key); + } + + public static FeederConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static FeederConfig Fist() + { + return Context.Fist(); + } + + public static FeederConfig Last() + { + return Context.Last(); + } + + public static FeederConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static FeederConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/FishConfig.cs b/Assets/Scripts/Generate/Config/FishConfig.cs index a221dfd04..160825b91 100644 --- a/Assets/Scripts/Generate/Config/FishConfig.cs +++ b/Assets/Scripts/Generate/Config/FishConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class FishConfigData : ASerialize, IConfigTable, IProto + public sealed partial class FishConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static FishConfigData _instance = null; - - public static FishConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public FishConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"FishConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out FishConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class FishConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -106,5 +28,66 @@ namespace NBF public uint MaxWeight { get; set; } // 最大重量(克) [ProtoMember(7)] public uint Accept { get; set; } // 接受饵 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static FishConfig Get(uint key) + { + return Context.Get(key); + } + + public static FishConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static FishConfig Fist() + { + return Context.Fist(); + } + + public static FishConfig Last() + { + return Context.Last(); + } + + public static FishConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static FishConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/HookConfig.cs b/Assets/Scripts/Generate/Config/HookConfig.cs index e523a7021..4b58d6da9 100644 --- a/Assets/Scripts/Generate/Config/HookConfig.cs +++ b/Assets/Scripts/Generate/Config/HookConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class HookConfigData : ASerialize, IConfigTable, IProto + public sealed partial class HookConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static HookConfigData _instance = null; - - public static HookConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public HookConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"HookConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out HookConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class HookConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -104,5 +26,66 @@ namespace NBF public uint Length { get; set; } // 长度(毫米) [ProtoMember(6)] public uint Weight { get; set; } // 重量(克) - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static HookConfig Get(uint key) + { + return Context.Get(key); + } + + public static HookConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static HookConfig Fist() + { + return Context.Fist(); + } + + public static HookConfig Last() + { + return Context.Last(); + } + + public static HookConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static HookConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/InitConfig.cs b/Assets/Scripts/Generate/Config/InitConfig.cs new file mode 100644 index 000000000..b409c69aa --- /dev/null +++ b/Assets/Scripts/Generate/Config/InitConfig.cs @@ -0,0 +1,85 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +using NBC; +using NBC.Serialize; + +namespace NBF +{ + [ProtoContract] + public sealed partial class InitConfig : ASerialize, IProto, IConfigTable + { + + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public uint ItemId { get; set; } // 物品Id + [ProtoMember(3)] + public int Amount { get; set; } // 数量 + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static InitConfig Get(uint key) + { + return Context.Get(key); + } + + public static InitConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static InitConfig Fist() + { + return Context.Fist(); + } + + public static InitConfig Last() + { + return Context.Last(); + } + + public static InitConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static InitConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/InitConfig.cs.meta b/Assets/Scripts/Generate/Config/InitConfig.cs.meta new file mode 100644 index 000000000..702b7732e --- /dev/null +++ b/Assets/Scripts/Generate/Config/InitConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 4b10beb37dfb5064593be4f13c7a4d29 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/ItemConfig.cs b/Assets/Scripts/Generate/Config/ItemConfig.cs new file mode 100644 index 000000000..df76a76ae --- /dev/null +++ b/Assets/Scripts/Generate/Config/ItemConfig.cs @@ -0,0 +1,89 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +using NBC; +using NBC.Serialize; + +namespace NBF +{ + [ProtoContract] + public sealed partial class ItemConfig : ASerialize, IProto, IConfigTable + { + + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Max { get; set; } // 最大堆叠数量 + [ProtoMember(5)] + public uint AutoUse { get; set; } // 获得自动使用 + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static ItemConfig Get(uint key) + { + return Context.Get(key); + } + + public static ItemConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static ItemConfig Fist() + { + return Context.Fist(); + } + + public static ItemConfig Last() + { + return Context.Last(); + } + + public static ItemConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static ItemConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/ItemConfig.cs.meta b/Assets/Scripts/Generate/Config/ItemConfig.cs.meta new file mode 100644 index 000000000..61c5ca698 --- /dev/null +++ b/Assets/Scripts/Generate/Config/ItemConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ab3487f65cb0c3b458c2ac0a75932642 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/LineConfig.cs b/Assets/Scripts/Generate/Config/LineConfig.cs index 5a13c7ea7..e764bf58b 100644 --- a/Assets/Scripts/Generate/Config/LineConfig.cs +++ b/Assets/Scripts/Generate/Config/LineConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class LineConfigData : ASerialize, IConfigTable, IProto + public sealed partial class LineConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static LineConfigData _instance = null; - - public static LineConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public LineConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"LineConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out LineConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class LineConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -104,5 +26,66 @@ namespace NBF public uint Strength { get; set; } // 强度 [ProtoMember(6)] public uint Size { get; set; } // 尺寸 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static LineConfig Get(uint key) + { + return Context.Get(key); + } + + public static LineConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static LineConfig Fist() + { + return Context.Fist(); + } + + public static LineConfig Last() + { + return Context.Last(); + } + + public static LineConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static LineConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/LureConfig.cs b/Assets/Scripts/Generate/Config/LureConfig.cs index e9feda92f..db656c3a5 100644 --- a/Assets/Scripts/Generate/Config/LureConfig.cs +++ b/Assets/Scripts/Generate/Config/LureConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class LureConfigData : ASerialize, IConfigTable, IProto + public sealed partial class LureConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static LureConfigData _instance = null; - - public static LureConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public LureConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"LureConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out LureConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class LureConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -104,5 +26,66 @@ namespace NBF public uint Length { get; set; } // 长度(毫米) [ProtoMember(6)] public uint Weight { get; set; } // 重量(克) - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static LureConfig Get(uint key) + { + return Context.Get(key); + } + + public static LureConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static LureConfig Fist() + { + return Context.Fist(); + } + + public static LureConfig Last() + { + return Context.Last(); + } + + public static LureConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static LureConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/ReelConfig.cs b/Assets/Scripts/Generate/Config/ReelConfig.cs index fa3a2a793..630d35e1f 100644 --- a/Assets/Scripts/Generate/Config/ReelConfig.cs +++ b/Assets/Scripts/Generate/Config/ReelConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class ReelConfigData : ASerialize, IConfigTable, IProto + public sealed partial class ReelConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static ReelConfigData _instance = null; - - public static ReelConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public ReelConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"ReelConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out ReelConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class ReelConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -104,5 +26,66 @@ namespace NBF public uint Size { get; set; } // 尺寸 [ProtoMember(6)] public uint Strength { get; set; } // 强度 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static ReelConfig Get(uint key) + { + return Context.Get(key); + } + + public static ReelConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static ReelConfig Fist() + { + return Context.Fist(); + } + + public static ReelConfig Last() + { + return Context.Last(); + } + + public static ReelConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static ReelConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/RingConfig.cs b/Assets/Scripts/Generate/Config/RingConfig.cs index 1dd9dbc84..9f3d61d31 100644 --- a/Assets/Scripts/Generate/Config/RingConfig.cs +++ b/Assets/Scripts/Generate/Config/RingConfig.cs @@ -5,96 +5,79 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class RingConfigData : ASerialize, IConfigTable, IProto + public sealed partial class RingConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static RingConfigData _instance = null; - - public static RingConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public RingConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"RingConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out RingConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class RingConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] public string Model { get; set; } // 模型 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static RingConfig Get(uint key) + { + return Context.Get(key); + } + + public static RingConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static RingConfig Fist() + { + return Context.Fist(); + } + + public static RingConfig Last() + { + return Context.Last(); + } + + public static RingConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static RingConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/RodConfig.cs b/Assets/Scripts/Generate/Config/RodConfig.cs index acadcef48..0c4d4fc12 100644 --- a/Assets/Scripts/Generate/Config/RodConfig.cs +++ b/Assets/Scripts/Generate/Config/RodConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class RodConfigData : ASerialize, IConfigTable, IProto + public sealed partial class RodConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static RodConfigData _instance = null; - - public static RodConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public RodConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"RodConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out RodConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class RodConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -110,5 +32,66 @@ namespace NBF public uint MaxRange { get; set; } // 最大范围 [ProtoMember(9)] public uint ConstructionType { get; set; } // 结构类型 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static RodConfig Get(uint key) + { + return Context.Get(key); + } + + public static RodConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static RodConfig Fist() + { + return Context.Fist(); + } + + public static RodConfig Last() + { + return Context.Last(); + } + + public static RodConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static RodConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/Unit2Config.cs b/Assets/Scripts/Generate/Config/Unit2Config.cs index 5e39bc1a7..39c7ae07c 100644 --- a/Assets/Scripts/Generate/Config/Unit2Config.cs +++ b/Assets/Scripts/Generate/Config/Unit2Config.cs @@ -5,98 +5,81 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class Unit2ConfigData : ASerialize, IConfigTable, IProto + public sealed partial class Unit2Config : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static Unit2ConfigData _instance = null; - - public static Unit2ConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public Unit2Config Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"Unit2Config not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out Unit2Config config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class Unit2Config : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] public string Name { get; set; } // 名称 [ProtoMember(3)] public string Model { get; set; } // 数据库类型 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static Unit2Config Get(uint key) + { + return Context.Get(key); + } + + public static Unit2Config Get(Predicate match) + { + return Context.Get(match); + } + + public static Unit2Config Fist() + { + return Context.Fist(); + } + + public static Unit2Config Last() + { + return Context.Last(); + } + + public static Unit2Config Fist(Predicate match) + { + return Context.Fist(match); + } + + public static Unit2Config Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/UnitConfig.cs b/Assets/Scripts/Generate/Config/UnitConfig.cs index ce42a9f12..79a2ef587 100644 --- a/Assets/Scripts/Generate/Config/UnitConfig.cs +++ b/Assets/Scripts/Generate/Config/UnitConfig.cs @@ -5,98 +5,81 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class UnitConfigData : ASerialize, IConfigTable, IProto + public sealed partial class UnitConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static UnitConfigData _instance = null; - - public static UnitConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public UnitConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"UnitConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out UnitConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class UnitConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] public string Name { get; set; } // 名称 [ProtoMember(3)] public string Model { get; set; } // 数据库类型 - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static UnitConfig Get(uint key) + { + return Context.Get(key); + } + + public static UnitConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static UnitConfig Fist() + { + return Context.Fist(); + } + + public static UnitConfig Last() + { + return Context.Last(); + } + + public static UnitConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static UnitConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Config/WeightConfig.cs b/Assets/Scripts/Generate/Config/WeightConfig.cs index 993973951..0c1431195 100644 --- a/Assets/Scripts/Generate/Config/WeightConfig.cs +++ b/Assets/Scripts/Generate/Config/WeightConfig.cs @@ -5,93 +5,15 @@ using System.Linq; using System.Reflection; using System.Collections.Generic; using System.Collections.Concurrent; -#if FANTASY_NET -using Fantasy.ConfigTable; -using Fantasy.Serialize; -#else using NBC; using NBC.Serialize; -#endif -// ReSharper disable CollectionNeverUpdated.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#pragma warning disable CS0169 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8603 namespace NBF { [ProtoContract] - public sealed partial class WeightConfigData : ASerialize, IConfigTable, IProto + public sealed partial class WeightConfig : ASerialize, IProto, IConfigTable { - [ProtoMember(1)] - public List List { get; set; } = new List(); -#if FANTASY_NET - [ProtoIgnore] - private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); -#else - [ProtoIgnore] - private readonly Dictionary _configs = new Dictionary(); -#endif - private static WeightConfigData _instance = null; - - public static WeightConfigData Instance - { - get { return _instance ??= ConfigTableHelper.Load(); } - private set => _instance = value; - } - - public WeightConfig Get(uint id, bool check = true) - { - if (_configs.ContainsKey(id)) - { - return _configs[id]; - } - if (check) - { - throw new Exception($"WeightConfig not find {id} Id"); - } - - return null; - } - public bool TryGet(uint id, out WeightConfig config) - { - config = null; - - if (!_configs.ContainsKey(id)) - { - return false; - } - - config = _configs[id]; - return true; - } - public override void AfterDeserialization() - { - foreach (var config in List) - { -#if FANTASY_NET - _configs.TryAdd(config.Id, config); -#else - _configs.Add(config.Id, config); -#endif - config.AfterDeserialization(); - } - - EndInit(); - } - - public override void Dispose() - { - Instance = null; - } - } - - [ProtoContract] - public sealed partial class WeightConfig : ASerialize, IProto - { [ProtoMember(1)] public uint Id { get; set; } // Id [ProtoMember(2)] @@ -100,5 +22,66 @@ namespace NBF public uint Type { get; set; } // 类型 [ProtoMember(4)] public uint Weight { get; set; } // 重量(克) - } -} \ No newline at end of file + [ProtoIgnore] + public uint Key => Id; + + #region Static + + private static ConfigContext Context => ConfigTableHelper.Table(); + + public static WeightConfig Get(uint key) + { + return Context.Get(key); + } + + public static WeightConfig Get(Predicate match) + { + return Context.Get(match); + } + + public static WeightConfig Fist() + { + return Context.Fist(); + } + + public static WeightConfig Last() + { + return Context.Last(); + } + + public static WeightConfig Fist(Predicate match) + { + return Context.Fist(match); + } + + public static WeightConfig Last(Predicate match) + { + return Context.Last(match); + } + + public static int Count() + { + return Context.Count(); + } + + public static int Count(Func predicate) + { + return Context.Count(predicate); + } + + public static List GetList() + { + return Context.GetList(); + } + + public static List GetList(Predicate match) + { + return Context.GetList(match); + } + public static void ParseJson(Newtonsoft.Json.Linq.JArray arr) + { + ConfigTableHelper.ParseLine(arr); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs b/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs index d0ec126b8..8d46b5c99 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs @@ -26,7 +26,6 @@ namespace NBC Country = default; Level = default; Exp = default; - Vip = default; VipInfo = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); @@ -43,8 +42,6 @@ namespace NBC [ProtoMember(5)] public int Exp { get; set; } [ProtoMember(6)] - public bool Vip { get; set; } - [ProtoMember(7)] public VipInfo VipInfo { get; set; } } [ProtoContract] @@ -148,7 +145,7 @@ namespace NBC [ProtoMember(5)] public int Level { get; set; } [ProtoMember(6)] - public bool Vip { get; set; } + public int Vip { get; set; } [ProtoMember(7)] public int MapId { get; set; } } @@ -164,6 +161,7 @@ namespace NBC } public override void Dispose() { + Level = default; OpenTime = default; ExpirationTime = default; #if FANTASY_NET || FANTASY_UNITY @@ -171,8 +169,10 @@ namespace NBC #endif } [ProtoMember(1)] - public long OpenTime { get; set; } + public int Level { get; set; } [ProtoMember(2)] + public long OpenTime { get; set; } + [ProtoMember(3)] public long ExpirationTime { get; set; } } /// diff --git a/Assets/Scripts/Init.cs b/Assets/Scripts/Init.cs index 4ec236387..0e4f0c9c6 100644 --- a/Assets/Scripts/Init.cs +++ b/Assets/Scripts/Init.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Threading.Tasks; using FairyGUI; using NBC; @@ -111,8 +112,12 @@ namespace NBF private void LoadData() { + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); var jsonAsset = Resources.Load("config/configs"); ConfigTableHelper.Initialize(jsonAsset.text); + stopwatch.Stop(); + Log.Info($"解析表格耗时={stopwatch.ElapsedMilliseconds}"); // ConfigAssets.Init(); } diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/ConfigContext.cs b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigContext.cs new file mode 100644 index 000000000..53c9ec1fe --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigContext.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace NBC +{ + public interface IConfigContext + { + // 定义非泛型接口 + } + + public class ConfigContext : IConfigContext where T : IConfigTable + { + private static List _cacheList = new List(); + + #region Cache + + public void Association(List list) + { + if (list != null) + { + _cacheList = list; + } + } + + #endregion + + public int Count() + { + return _cacheList.Count; + } + + public int Count(Func predicate) + { + return _cacheList.Count(predicate); + } + + public T Get(uint key) + { + return First(key); + } + + public T Fist() + { + return _cacheList.First(); + } + + public T Last() + { + return _cacheList.Last(); + } + + public T Fist(Predicate match) + { + return Get(match); + } + + public T Last(Predicate match) + { + return _cacheList.FindLast(match); + } + + public T Get(Predicate match) + { + return _cacheList.Find(match); + } + + public T GetRandom() + { + Random random = new Random(); + // 随机从列表中取一个对象 + return _cacheList[random.Next(_cacheList.Count)]; + } + + public List GetList() + { + return _cacheList; + } + + public List GetList(Predicate match) + { + return _cacheList.FindAll(match); + } + + private T First(uint key) + { + return _cacheList.Find(t => t.Key == key); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/ConfigContext.cs.meta b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigContext.cs.meta new file mode 100644 index 000000000..e0d9e3f4d --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigContext.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f916dd8f41b047068d570fc87f9163c2 +timeCreated: 1760064105 \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs index 447872f07..9f35d20ea 100644 --- a/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs +++ b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Reflection; using NBC.Serialize; using Newtonsoft.Json.Linq; @@ -11,23 +13,15 @@ namespace NBC /// public static class ConfigTableHelper { - // private static string _configTableBinaryDirectory; - // private static string _jsonData; - - private static readonly object Lock = new object(); - - // 配置表数据缓存字典 - private static readonly Dictionary ConfigDic = new(); - - private static readonly Dictionary Tokens = new(); - + private static readonly Dictionary _dictionary = new Dictionary(); + /// /// 初始化ConfigTableHelper /// public static void Initialize(string json) { - // _jsonData = json; var jsonObj = JObject.Parse(json); + Dictionary tokens = new(); foreach (var item in jsonObj) { try @@ -36,7 +30,7 @@ namespace NBC var value = item.Value; if (value is JArray jArray) { - Tokens[name] = jArray; + tokens[name] = jArray; } } catch (Exception e) @@ -44,44 +38,78 @@ namespace NBC Log.Error($"读表异常,请检查,name={item.Key} ex={e}"); } } - } - /// - /// 加载配置表数据 - /// - /// 配置表类型 - /// 配置表数据 - public static T Load() where T : ASerialize, new() - { - lock (Lock) + //反射获取所有IConfigTable的非抽象类 + var tableTypes = GetAllConfigTableTypes(); + foreach (var type in tableTypes) { - try + var name = type.Name; + if (tokens.TryGetValue(name, out var jArray)) { - var dataConfig = typeof(T).Name; - - if (ConfigDic.TryGetValue(dataConfig, out var aProto)) - { - return (T)aProto; - } - - var configName = typeof(T).Name; - if (!Tokens.TryGetValue(configName, out var jArray)) - { - // jArray.ToObject>() - // return new T(); - } - - // var configFile = GetConfigPath(dataConfig); - // var bytes = File.ReadAllBytes(configFile); - // var data = SerializerManager.GetSerializer(FantasySerializerType.ProtoBuf).Deserialize(bytes); - // ConfigDic[dataConfig] = data; - return new T(); - } - catch (Exception ex) - { - throw new Exception($"ConfigTableManage:{typeof(T).Name} 数据表加载之后反序列化时出错:{ex}"); + // 通过反射调用 ParseJson 方法 + var parseMethod = type.GetMethod("ParseJson", BindingFlags.Public | BindingFlags.Static); + parseMethod?.Invoke(null, new object[] { jArray }); } } + + } + + public static ConfigContext Table() where T : IConfigTable + { + var type = typeof(T); + if (_dictionary.TryGetValue(type, out var context)) + { + return context as ConfigContext; + } + + var jsonContext = new ConfigContext(); + _dictionary[type] = jsonContext; + return jsonContext; + } + + public static List ParseLine(JArray arr) where T : IConfigTable, new() + { + List list = new List(); + foreach (var jToken in arr) + { + T instance = jToken.ToObject(); + + if (instance != null) + { + list.Add(instance); + } + } + + var context = Table(); + context.Association(list); + + return list; + } + + + /// + /// 获取所有实现了 IConfigTable 接口的非抽象类 + /// + /// 所有非抽象的配置对象类 + private static List GetAllConfigTableTypes() + { + var types = new List(); + var interfaceType = typeof(IConfigTable); + + // 遍历当前程序集中的所有类型 + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + foreach (var type in assembly.GetTypes()) + { + // 检查是否实现了 IConfigTable 接口,并且不是抽象类 + if (interfaceType.IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface) + { + types.Add(type); + } + } + } + + return types; } } } \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs b/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs index a2160d2fe..bc708220d 100644 --- a/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs +++ b/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs @@ -3,5 +3,8 @@ /// /// 表示是一个配置文件 /// - public interface IConfigTable { } + public interface IConfigTable + { + public uint Key { get; } + } } \ No newline at end of file diff --git a/Config/BaitConfig.xlsx b/Config/BaitConfig.xlsx deleted file mode 100644 index 1f100b90a..000000000 Binary files a/Config/BaitConfig.xlsx and /dev/null differ diff --git a/Config/BasicConfig.xlsx b/Config/BasicConfig.xlsx new file mode 100644 index 000000000..3d55edd23 Binary files /dev/null and b/Config/BasicConfig.xlsx differ diff --git a/Config/BobberConfig.xlsx b/Config/BobberConfig.xlsx deleted file mode 100644 index 7d1cc15e9..000000000 Binary files a/Config/BobberConfig.xlsx and /dev/null differ diff --git a/Config/FeederConfig.xlsx b/Config/FeederConfig.xlsx deleted file mode 100644 index c253564fc..000000000 Binary files a/Config/FeederConfig.xlsx and /dev/null differ diff --git a/Config/FishConfig.xlsx b/Config/FishConfig.xlsx index ae840be99..608d6ec15 100644 Binary files a/Config/FishConfig.xlsx and b/Config/FishConfig.xlsx differ diff --git a/Config/Gear.xlsx b/Config/Gear.xlsx new file mode 100644 index 000000000..64c337bab Binary files /dev/null and b/Config/Gear.xlsx differ diff --git a/Config/HookConfig.xlsx b/Config/HookConfig.xlsx deleted file mode 100644 index 546c1759e..000000000 Binary files a/Config/HookConfig.xlsx and /dev/null differ diff --git a/Config/Item.xlsx b/Config/Item.xlsx new file mode 100644 index 000000000..64f00f7db Binary files /dev/null and b/Config/Item.xlsx differ diff --git a/Config/LineConfig.xlsx b/Config/LineConfig.xlsx deleted file mode 100644 index b8dcd5cf1..000000000 Binary files a/Config/LineConfig.xlsx and /dev/null differ diff --git a/Config/LureConfig.xlsx b/Config/LureConfig.xlsx deleted file mode 100644 index 97925e910..000000000 Binary files a/Config/LureConfig.xlsx and /dev/null differ diff --git a/Config/ReelConfig.xlsx b/Config/ReelConfig.xlsx deleted file mode 100644 index b52d8da87..000000000 Binary files a/Config/ReelConfig.xlsx and /dev/null differ diff --git a/Config/RingConfig.xlsx b/Config/RingConfig.xlsx deleted file mode 100644 index e457fc523..000000000 Binary files a/Config/RingConfig.xlsx and /dev/null differ diff --git a/Config/RodConfig.xlsx b/Config/RodConfig.xlsx deleted file mode 100644 index f62055ccb..000000000 Binary files a/Config/RodConfig.xlsx and /dev/null differ diff --git a/Config/UnitConfig.xlsx b/Config/UnitConfig.xlsx deleted file mode 100644 index 4cb4ee5a4..000000000 Binary files a/Config/UnitConfig.xlsx and /dev/null differ diff --git a/Config/WeightConfig.xlsx b/Config/WeightConfig.xlsx deleted file mode 100644 index 13782d911..000000000 Binary files a/Config/WeightConfig.xlsx and /dev/null differ diff --git a/Config/~$BasicConfig.xlsx b/Config/~$BasicConfig.xlsx new file mode 100644 index 000000000..e69de29bb diff --git a/Config/~$fishing gear-渔具.xlsx b/Config/~$fishing gear-渔具.xlsx deleted file mode 100644 index fd5ec1854..000000000 Binary files a/Config/~$fishing gear-渔具.xlsx and /dev/null differ diff --git a/Config/新建 文本文档.txt b/Config/新建 文本文档.txt new file mode 100644 index 000000000..e69de29bb diff --git a/Fishing2.sln.DotSettings.user b/Fishing2.sln.DotSettings.user index 0f7534b34..0b43a3c02 100644 --- a/Fishing2.sln.DotSettings.user +++ b/Fishing2.sln.DotSettings.user @@ -12,6 +12,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded