mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-10-21 19:53:29 +08:00
Update All Gadgets
Update Spawn filter
This commit is contained in:
@@ -17,10 +17,20 @@
|
||||
*
|
||||
**/
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace GrasscutterTools.Game.Data.Excels
|
||||
{
|
||||
[ResourceType("GadgetExcelConfigData.json")]
|
||||
internal class GadgetData
|
||||
internal class GadgetData : GameResource
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonProperty("jsonName")]
|
||||
public string JsonName { get; set; }
|
||||
|
||||
[JsonProperty("interactNameTextMapHash")]
|
||||
public long InteractNameTextMapHash { get; set; }
|
||||
}
|
||||
}
|
33
Source/GrasscutterTools/Game/Data/Excels/GatherData.cs
Normal file
33
Source/GrasscutterTools/Game/Data/Excels/GatherData.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Grasscutter Tools
|
||||
* Copyright (C) 2023 jie65535
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace GrasscutterTools.Game.Data.Excels
|
||||
{
|
||||
[ResourceType("GatherExcelConfigData.json")]
|
||||
internal class GatherData
|
||||
{
|
||||
[JsonProperty("gadgetId")]
|
||||
public int GadgetId { get; set; }
|
||||
|
||||
[JsonProperty("itemId")]
|
||||
public int ItemId { get; set; }
|
||||
}
|
||||
}
|
@@ -17,10 +17,14 @@
|
||||
*
|
||||
**/
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace GrasscutterTools.Game.Data.Excels
|
||||
{
|
||||
[ResourceType("HomeWorldFurnitureExcelConfigData.json")]
|
||||
internal class HomeWorldFurnitureData : GameResource
|
||||
{
|
||||
[JsonProperty("furnitureGadgetID")]
|
||||
public int[] FurnitureGadgetId { get; set; }
|
||||
}
|
||||
}
|
@@ -30,7 +30,7 @@ namespace GrasscutterTools.Game.Data
|
||||
public long NameTextMapHash { get; set; }
|
||||
|
||||
[JsonProperty("titleTextMapHash")]
|
||||
public string TitleTextMapHash { get; set; }
|
||||
public long TitleTextMapHash { get; set; }
|
||||
|
||||
[JsonProperty("descTextMapHash")]
|
||||
public long DescTextMapHash { get; set; }
|
||||
|
@@ -45,6 +45,10 @@ namespace GrasscutterTools.Game.Data
|
||||
|
||||
public Dictionary<int, DungeonData> DungeonData { get; set; }
|
||||
|
||||
public Dictionary<int, GadgetData> GadgetData { get; set; }
|
||||
|
||||
public List<GatherData> GatherData { get; set; }
|
||||
|
||||
public Dictionary<int, HomeWorldFurnitureData> HomeWorldFurnitureData { get; set; }
|
||||
|
||||
public Dictionary<int, MainQuestData> MainQuestData { get; set; }
|
||||
@@ -72,11 +76,18 @@ namespace GrasscutterTools.Game.Data
|
||||
{
|
||||
var type = property.PropertyType;
|
||||
if (!type.IsGenericType) continue;
|
||||
var gameResourceType = type.GetGenericArguments()[1];
|
||||
var attributes = (ResourceTypeAttribute[])gameResourceType.GetCustomAttributes(typeof(ResourceTypeAttribute), true);
|
||||
if (attributes.Length < 1) continue;
|
||||
var dataFile = Path.Combine(resourcesDirPath, "ExcelBinOutput", attributes[0].Name);
|
||||
var data = LoadDataFile(gameResourceType, dataFile);
|
||||
var genericArguments = type.GetGenericArguments();
|
||||
ResourceTypeAttribute attribute = null;
|
||||
foreach (var it in genericArguments)
|
||||
{
|
||||
var attributes = it.GetCustomAttributes(typeof(ResourceTypeAttribute), true);
|
||||
if (attributes.Length == 0) continue;
|
||||
attribute = (ResourceTypeAttribute)attributes[0];
|
||||
type = it;
|
||||
}
|
||||
if (attribute == null) continue;
|
||||
var dataFile = Path.Combine(resourcesDirPath, "ExcelBinOutput", attribute.Name);
|
||||
var data = LoadDataFile(type, dataFile);
|
||||
property.SetValue(this, data, null);
|
||||
}
|
||||
|
||||
@@ -115,6 +126,8 @@ namespace GrasscutterTools.Game.Data
|
||||
var list = (IList)JsonConvert.DeserializeObject(File.ReadAllText(path), typeof(List<>).MakeGenericType(type));
|
||||
if (list == null) return null;
|
||||
|
||||
if (!type.IsSubclassOf(typeof(GameResource))) return list;
|
||||
|
||||
var dicType = typeof(Dictionary<,>).MakeGenericType(typeof(int), type);
|
||||
var dic = (IDictionary)Activator.CreateInstance(dicType);
|
||||
foreach (GameResource gameResource in list)
|
||||
@@ -144,17 +157,30 @@ namespace GrasscutterTools.Game.Data
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo(language.Key);
|
||||
GameData.LoadResources();
|
||||
|
||||
#region Achievement
|
||||
|
||||
// Achievement
|
||||
File.WriteAllLines(
|
||||
Path.Combine(dir, "Achievement.txt"),
|
||||
AchievementData.Values.Where(it => it.IsUsed)
|
||||
.Select(it => $"{it.Id}:{TextMapData.GetText(it.TitleTextMapHash.ToString())} - {TextMapData.GetText(it.DescTextMapHash.ToString())}"),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Achievement
|
||||
|
||||
#region Artifact
|
||||
|
||||
// Artifact
|
||||
File.WriteAllLines(
|
||||
Path.Combine(dir, "Artifact.txt"),
|
||||
ReliquaryData.Values.OrderBy(it => it.Id).Select(it => $"{it.Id}:{TextMapData.GetText(it.NameTextMapHash.ToString())}"),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Artifact
|
||||
|
||||
#region Avatar
|
||||
|
||||
// Avatar
|
||||
File.WriteAllLines(
|
||||
Path.Combine(dir, "Avatar.txt"),
|
||||
MaterialData.Values
|
||||
@@ -162,11 +188,88 @@ namespace GrasscutterTools.Game.Data
|
||||
.Select(it => $"{it.Id}:{TextMapData.GetText(it.NameTextMapHash.ToString())}"),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Avatar
|
||||
|
||||
#region Dungeon
|
||||
|
||||
// Dungeon
|
||||
File.WriteAllLines(
|
||||
Path.Combine(dir, "Dungeon.txt"),
|
||||
DungeonData.Values.Select(it => $"{it.Id}:{TextMapData.GetText(it.NameTextMapHash.ToString())}"),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Dungeon
|
||||
|
||||
#region Gadget
|
||||
|
||||
// Gadget
|
||||
sb.Clear();
|
||||
var gatherMap = new Dictionary<int, int>(GatherData.Count);
|
||||
foreach (var it in GatherData.Where(it => !gatherMap.ContainsKey(it.GadgetId)))
|
||||
gatherMap.Add(it.GadgetId, it.ItemId);
|
||||
var furnitureMap = new Dictionary<int, long>(HomeWorldFurnitureData.Count);
|
||||
foreach (var it in HomeWorldFurnitureData.Values.Where(it => it.FurnitureGadgetId != null))
|
||||
foreach (var gadgetId in it.FurnitureGadgetId.Where(id => id > 0 && !furnitureMap.ContainsKey(id)))
|
||||
furnitureMap.Add(gadgetId, it.NameTextMapHash);
|
||||
var oldFirst = language.Key.StartsWith("zh");
|
||||
foreach (var gadgetTypes in GadgetData.Values.OrderBy(it => it.Id).GroupBy(it => it.Type))
|
||||
{
|
||||
sb.Append("// ").AppendLine(GadgetType.ToTranslatedString(gadgetTypes.Key, language.Key));
|
||||
foreach (var it in gadgetTypes)
|
||||
{
|
||||
var name = oldFirst ? GameData.Gadgets[it.Id] : ItemMap.EmptyName;
|
||||
|
||||
if (name == ItemMap.EmptyName)
|
||||
{
|
||||
if (!TextMapData.TryGetText(it.NameTextMapHash.ToString(), out name)
|
||||
&& !TextMapData.TryGetText(it.InteractNameTextMapHash.ToString(), out name))
|
||||
{
|
||||
if (gatherMap.TryGetValue(it.Id, out var itemId)
|
||||
&& MaterialData.TryGetValue(itemId, out var item))
|
||||
{
|
||||
name = TextMapData.GetText(item.NameTextMapHash.ToString());
|
||||
}
|
||||
else if (furnitureMap.TryGetValue(it.Id, out var hash))
|
||||
{
|
||||
name = TextMapData.GetText(hash.ToString());
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(it.JsonName))
|
||||
{
|
||||
name = it.JsonName;
|
||||
}
|
||||
else if (!oldFirst)
|
||||
{
|
||||
var temp = GameData.Gadgets[it.Id];
|
||||
if (temp != ItemMap.EmptyName)
|
||||
name = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendFormat("{0}:{1}", it.Id, name).AppendLine();
|
||||
}
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
// 旧的数据
|
||||
//var old = GameData.Gadgets.AllIds.Where(it => !GadgetData.ContainsKey(it));
|
||||
//if (old.Any())
|
||||
//{
|
||||
// sb.AppendLine("// Old lines");
|
||||
// foreach (var it in old)
|
||||
// sb.AppendFormat("{0}:{1}", it, GameData.Gadgets[it]).AppendLine();
|
||||
//}
|
||||
|
||||
File.WriteAllText(
|
||||
Path.Combine(dir, "Gadget.txt"),
|
||||
sb.ToString(),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Gadget
|
||||
|
||||
#region Item
|
||||
|
||||
// Item
|
||||
sb.Clear();
|
||||
foreach (var itemTypes in MaterialData.Values.GroupBy(it => it.ItemType))
|
||||
{
|
||||
@@ -211,6 +314,11 @@ namespace GrasscutterTools.Game.Data
|
||||
|
||||
File.WriteAllText(Path.Combine(dir, "Item.txt"), sb.ToString(), Encoding.UTF8);
|
||||
|
||||
#endregion Item
|
||||
|
||||
#region Monsters
|
||||
|
||||
// Monsters
|
||||
sb.Clear();
|
||||
foreach (var monsterType in MonsterData.Values.OrderBy(it => it.Id)
|
||||
.GroupBy(it => it.Type)
|
||||
@@ -240,6 +348,11 @@ namespace GrasscutterTools.Game.Data
|
||||
sb.ToString(),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Monsters
|
||||
|
||||
#region Quest
|
||||
|
||||
// Quest
|
||||
sb.Clear();
|
||||
foreach (var it in QuestData.Values.OrderBy(it => it.Id))
|
||||
{
|
||||
@@ -248,7 +361,7 @@ namespace GrasscutterTools.Game.Data
|
||||
{
|
||||
sb.AppendFormat("{0}:{1} - {2}",
|
||||
it.Id,
|
||||
TextMapData.GetText(MainQuestData[it.MainId].TitleTextMapHash),
|
||||
TextMapData.GetText(MainQuestData[it.MainId].TitleTextMapHash.ToString()),
|
||||
TextMapData.GetText(it.DescTextMapHash.ToString()));
|
||||
}
|
||||
else
|
||||
@@ -262,6 +375,11 @@ namespace GrasscutterTools.Game.Data
|
||||
sb.ToString(),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Quest
|
||||
|
||||
#region Scene
|
||||
|
||||
// Scene
|
||||
sb.Clear();
|
||||
foreach (var it in DungeonData.Values)
|
||||
{
|
||||
@@ -283,10 +401,17 @@ namespace GrasscutterTools.Game.Data
|
||||
sb.ToString(),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Scene
|
||||
|
||||
#region Weapon
|
||||
|
||||
// Weapon
|
||||
File.WriteAllLines(
|
||||
Path.Combine(dir, "Weapon.txt"),
|
||||
WeaponData.Values.Select(it => $"{it.Id}:{TextMapData.GetText(it.NameTextMapHash.ToString())}"),
|
||||
Encoding.UTF8);
|
||||
|
||||
#endregion Weapon
|
||||
}
|
||||
|
||||
File.WriteAllLines(
|
||||
|
@@ -64,6 +64,11 @@ namespace GrasscutterTools.Game
|
||||
/// </summary>
|
||||
public IEnumerable<string> AllLines => Values.SelectMany(it => it.Lines);
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有ID
|
||||
/// </summary>
|
||||
public IEnumerable<int> AllIds => Values.SelectMany(it => it.Ids);
|
||||
|
||||
private string[] lines;
|
||||
public string[] Lines => lines ?? (lines = AllLines.ToArray());
|
||||
|
||||
|
92
Source/GrasscutterTools/Game/Props/GadgetType.cs
Normal file
92
Source/GrasscutterTools/Game/Props/GadgetType.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Grasscutter Tools
|
||||
* Copyright (C) 2023 jie65535
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GrasscutterTools.Game.Props
|
||||
{
|
||||
internal static class GadgetType
|
||||
{
|
||||
private static readonly Dictionary<string, string> TextMapCHS = new Dictionary<string, string>
|
||||
{
|
||||
["Gear"] = "机关装置",
|
||||
["Field"] = "领域",
|
||||
["Bullet"] = "技能/飞弹",
|
||||
["Gadget"] = "Gadget",
|
||||
["AirflowField"] = "气流领域",
|
||||
["SpeedupField"] = "加速领域",
|
||||
["GatherObject"] = "采集物品",
|
||||
["Platform"] = "平台",
|
||||
["AmberWind"] = "风琥珀",
|
||||
["Vehicle"] = "载具",
|
||||
["MonsterEquip"] = "怪物装备",
|
||||
["Equip"] = "装备",
|
||||
["SubEquip"] = "副装备",
|
||||
["FishRod"] = "钓鱼竿",
|
||||
["Grass"] = "草",
|
||||
["Water"] = "水",
|
||||
["Tree"] = "树",
|
||||
["Bush"] = "灌木",
|
||||
["Lightning"] = "闪电",
|
||||
["CustomTile"] = "自定义贴图",
|
||||
["TransPointFirst"] = "传送点1",
|
||||
["TransPointSecond"] = "传送点2",
|
||||
["Chest"] = "宝箱",
|
||||
["GeneralRewardPoint"] = "通用奖励点",
|
||||
["OfferingGadget"] = "祭品Gadget",
|
||||
["Worktop"] = "工作台",
|
||||
["CustomGadget"] = "自定义Gadget",
|
||||
["BlackMud"] = "黑色泥浆",
|
||||
["DeshretObeliskGadget"] = "赤王方尖碑",
|
||||
["JourneyGearOperatorGadget"] = "旅途装备操作Gadget",
|
||||
["QuestGadget"] = "任务Gadget",
|
||||
["RoguelikeOperatorGadget"] = "肉鸽 操作台",
|
||||
["NightCrowGadget"] = "幽邃鸦眼",
|
||||
["MpPlayRewardPoint"] = "多人游戏奖励点",
|
||||
["CurveMoveGadget"] = "曲线移动Gadget",
|
||||
["RewardStatue"] = "地城奖励树",
|
||||
["RewardPoint"] = "循环地城奖励点",
|
||||
["Foundation"] = "底座",
|
||||
["Projector"] = "投影仪",
|
||||
["Screen"] = "屏幕",
|
||||
["CoinCollectLevelGadget"] = "金币收集等级Gadget",
|
||||
["EchoShell"] = "回声海螺",
|
||||
["UgcSpecialGadget"] = "UGC特殊Gadget",
|
||||
["UgcTowerLevelUpGadget"] = "UGC塔升级Gadget",
|
||||
["GatherPoint"] = "采集物挂接点",
|
||||
["MiracleRing"] = "奇迹之环",
|
||||
["EnvAnimal"] = "环境动物",
|
||||
["EnergyBall"] = "能量球",
|
||||
["SealGadget"] = "封印Gadget",
|
||||
["ViewPoint"] = "观景点",
|
||||
["FishPool"] = "钓鱼点",
|
||||
["ElemCrystal"] = "元素水晶",
|
||||
["Deprecated"] = "弃用",
|
||||
["WindSeed"] = "风种子",
|
||||
["UIInteractGadget"] = "界面交互Gadget",
|
||||
["Camera"] = "摄像机",
|
||||
};
|
||||
|
||||
public static string ToTranslatedString(string gadgetType, string language)
|
||||
{
|
||||
if (string.IsNullOrEmpty(gadgetType)) gadgetType = "Deprecated";
|
||||
return language.StartsWith("zh") ? TextMapCHS[gadgetType] : gadgetType;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user