초기커밋
This commit is contained in:
154
UGQApiServer/Converter/UGQMetaDataConverter.cs
Normal file
154
UGQApiServer/Converter/UGQMetaDataConverter.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using UGQApiServer.Models;
|
||||
using UGQApiServer.UGQData;
|
||||
|
||||
|
||||
namespace UGQApiServer.Converter;
|
||||
|
||||
public static class UGQMetaDataConverter
|
||||
{
|
||||
public static UGQNpcMetaData ToNpcLocale(this UGQNpcMetaData npc, LangEnum langEnum)
|
||||
{
|
||||
if (npc.NpcId != null)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, npc.NpcName);
|
||||
if (text != null)
|
||||
npc.NpcName = text;
|
||||
|
||||
var titleText = UGQDataHelper.getText(langEnum, npc.NpcTitle);
|
||||
if (titleText != null)
|
||||
npc.NpcTitle = titleText;
|
||||
}
|
||||
|
||||
return npc;
|
||||
}
|
||||
|
||||
public static TaskAction ToTaskAction(this UGQTaskAction action, LangEnum langEnum)
|
||||
{
|
||||
string actionName = action.ActionName;
|
||||
if (action.TextId != string.Empty)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, action.TextId);
|
||||
if (text != null)
|
||||
actionName = text;
|
||||
}
|
||||
|
||||
return new TaskAction
|
||||
{
|
||||
ActionId = action.ActionId,
|
||||
ActionName = actionName,
|
||||
};
|
||||
}
|
||||
|
||||
public static TaskActionValue ToTaskActionValue(this UGQActionValue actionValue, LangEnum langEnum)
|
||||
{
|
||||
string valueName = actionValue.ValueName;
|
||||
if (actionValue.TextId != string.Empty)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, actionValue.TextId);
|
||||
if (text != null)
|
||||
valueName = text;
|
||||
}
|
||||
|
||||
return new TaskActionValue
|
||||
{
|
||||
ValueId = actionValue.ValueId,
|
||||
UgcValueGuid = actionValue.UgcValueGuid,
|
||||
ValueName = valueName,
|
||||
};
|
||||
}
|
||||
|
||||
public static DialogType ToDialogType(this UGQDialogType dialogType, LangEnum langEnum)
|
||||
{
|
||||
string typeName = dialogType.TypeName;
|
||||
if (dialogType.TextId != string.Empty)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, dialogType.TextId);
|
||||
if (text != null)
|
||||
typeName = text;
|
||||
}
|
||||
|
||||
return new DialogType
|
||||
{
|
||||
TypeId = dialogType.TypeId,
|
||||
TypeName = typeName,
|
||||
};
|
||||
}
|
||||
|
||||
public static DialogAction ToDialogAction(this UGQDialogCondition action, LangEnum langEnum)
|
||||
{
|
||||
string actionName = action.ConditionName;
|
||||
if (action.TextId != string.Empty)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, action.TextId);
|
||||
if (text != null)
|
||||
actionName = text;
|
||||
}
|
||||
|
||||
return new DialogAction
|
||||
{
|
||||
ActionId = action.ConditionId,
|
||||
ActionName = actionName,
|
||||
};
|
||||
}
|
||||
|
||||
public static DialogActionValue ToDialogActionValue(this UGQActionValue actionValue, LangEnum langEnum)
|
||||
{
|
||||
string valueName = actionValue.ValueName;
|
||||
if (actionValue.TextId != string.Empty)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, actionValue.TextId);
|
||||
if (text != null)
|
||||
valueName = text;
|
||||
}
|
||||
|
||||
return new DialogActionValue
|
||||
{
|
||||
ValueId = actionValue.ValueId,
|
||||
ValueName = valueName,
|
||||
};
|
||||
}
|
||||
public static NpcActionValue ToNpcActionValue(this UGQBeaconActionData npcAction, LangEnum langEnum)
|
||||
{
|
||||
string valueName = npcAction.Name;
|
||||
if (npcAction.Name != string.Empty)
|
||||
{
|
||||
var text = UGQDataHelper.getText(langEnum, npcAction.Name);
|
||||
if (text != null)
|
||||
valueName = text;
|
||||
}
|
||||
|
||||
return new NpcActionValue
|
||||
{
|
||||
Id = npcAction.Id,
|
||||
Name = valueName,
|
||||
FileName = npcAction.FileName,
|
||||
};
|
||||
}
|
||||
|
||||
public static MapDataValue ToMapDataValue(this ZoneMetaData zoneMetaData, LangEnum langEnum)
|
||||
{
|
||||
//string valueName = npcAction.zone_name;
|
||||
//if (npcAction.zone_name != string.Empty)
|
||||
//{
|
||||
// var text = UGQDataHelper.getText(langEnum, npcAction.zone_name);
|
||||
// if (text != null)
|
||||
// valueName = text;
|
||||
//}
|
||||
MetaData.Instance.UGQMapImageMetaDataListbyId.TryGetValue(zoneMetaData.Id, out var mapImageData);
|
||||
|
||||
return new MapDataValue
|
||||
{
|
||||
Id = zoneMetaData.Id,
|
||||
Name = zoneMetaData.zone_name,
|
||||
MapSize_X = zoneMetaData.mapDistance_x,
|
||||
MapSize_Y = zoneMetaData.mapDistance_y,
|
||||
ImageFileName = mapImageData == null ? string.Empty : mapImageData.FileName,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user