添加 SepCore.Runtime 和 SepCore.Base 程序集

- 暂时将 Entity 全部归进 Runtime 程序集里
- 调整部分 UI 的 UseCase/RawData/Context 之间的关系,让 RawData 更接近业务原始数据,Context 更接近 UI 直接可读的数据
- 调整其他程序集的引用关系
This commit is contained in:
SepComet 2026-06-03 11:15:58 +08:00
parent d5893ac52b
commit 91f70dd783
176 changed files with 245 additions and 231 deletions

View File

@ -0,0 +1,16 @@
{
"name": "SepCore.Base",
"rootNamespace": "SepCore.Base",
"references": [
"GUID:363c5eb08ff8e6a439b85e37b8c20d96"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -14,12 +14,6 @@ namespace CustomUtility
return Text.Format("Assets/GameMain/DataTables/{0}.{1}", assetName, fromBytes ? "bytes" : "txt");
}
public static string GetDictionaryAsset(string assetName, bool fromBytes)
{
return Text.Format("Assets/GameMain/Localization/{0}/Dictionaries/{1}.{2}",
GameEntry.Localization.Language, assetName, fromBytes ? "bytes" : "xml");
}
public static string GetFontAsset(string assetName)
{
return Text.Format("Assets/GameMain/Fonts/{0}.ttf", assetName);

View File

@ -1,79 +0,0 @@
using SepCore.Definition;
using GameFramework.Debugger;
using GameFramework.Localization;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.Editor
{
public class ChangeLanguageDebuggerWindow : IDebuggerWindow
{
private Vector2 m_ScrollPosition = Vector2.zero;
private bool m_NeedRestart = false;
public void Initialize(params object[] args)
{
}
public void Shutdown()
{
}
public void OnEnter()
{
}
public void OnLeave()
{
}
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
if (m_NeedRestart)
{
m_NeedRestart = false;
UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Restart);
}
}
public void OnDraw()
{
m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
{
DrawSectionChangeLanguage();
}
GUILayout.EndScrollView();
}
private void DrawSectionChangeLanguage()
{
GUILayout.Label("<b>Change Language</b>");
GUILayout.BeginHorizontal("box");
{
if (GUILayout.Button("Chinese Simplified", GUILayout.Height(30)))
{
GameEntry.Localization.Language = Language.ChineseSimplified;
SaveLanguage();
}
if (GUILayout.Button("Chinese Traditional", GUILayout.Height(30)))
{
GameEntry.Localization.Language = Language.ChineseTraditional;
SaveLanguage();
}
if (GUILayout.Button("English", GUILayout.Height(30)))
{
GameEntry.Localization.Language = Language.English;
SaveLanguage();
}
}
GUILayout.EndHorizontal();
}
private void SaveLanguage()
{
GameEntry.Setting.SetString(Constant.Setting.Language, GameEntry.Localization.Language.ToString());
GameEntry.Setting.Save();
m_NeedRestart = true;
}
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 278a7992e66d1ea4081597614f912f3d
timeCreated: 1528026148
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,11 +2,12 @@
"name": "SepCore.Editor",
"rootNamespace": "SepCore.Editor",
"references": [
"GUID:47a82ffa13c291447ab895cd0bc251cd",
"GUID:363c5eb08ff8e6a439b85e37b8c20d96",
"GUID:a2d8a19598eca814496b089021d08d60",
"GUID:6f6ea874d7669044095abb01ec4c2f8d",
"GUID:0e1d182005e0ae647ab3fa40f5492dbb"
"GUID:363c5eb08ff8e6a439b85e37b8c20d96",
"GUID:47a82ffa13c291447ab895cd0bc251cd",
"GUID:436e23dbdc31e7d4fb5c3f804548b2df",
"GUID:0e1d182005e0ae647ab3fa40f5492dbb",
"GUID:6f6ea874d7669044095abb01ec4c2f8d"
],
"includePlatforms": [
"Editor"

View File

@ -1,3 +1,5 @@
using CustomUtility;
using SepCore.DataTable;
using SepCore.Definition;
using UnityEngine;
@ -7,19 +9,46 @@ namespace SepCore.UI
{
public string Title;
public ItemRarity Rarity;
public string Type;
public Sprite Icon;
public ItemType ItemType;
public string Description;
public int Price;
public GoodsItemContext()
{
Title = string.Empty;
Description = string.Empty;
Rarity = ItemRarity.White;
Price = 0;
Icon = null;
ItemType = ItemType.None;
}
public GoodsItemContext(GoodsItemRawData rawData)
{
Title = rawData.Title;
Description = rawData.Description;
Price = rawData.Price;
Rarity = rawData.Rarity;
Type = rawData.Type;
Icon = rawData.Icon;
ItemType = rawData.ItemType;
if (ItemType == ItemType.None)
{
Description = string.Empty;
Icon = null;
Title = string.Empty;
}
else if (ItemType == ItemType.Weapon)
{
var weapon = (DRWeapon)rawData.DataRow;
Title = weapon.Title;
Description = ItemDescUtility.CreateWeaponDescription(weapon);
GameEntry.SpriteCache.GetSprite(weapon.IconAssetName, sprite => Icon = sprite);
}
else
{
var prop = (DRProp)rawData.DataRow;
Title = prop.Title;
Description = ItemDescUtility.CreatePropDescription(prop.Modifiers);
GameEntry.SpriteCache.GetSprite(prop.IconAssetName, sprite => Icon = sprite);
}
}
}
}

View File

@ -1,3 +1,8 @@
using System;
using System.Drawing;
using CustomUtility;
using Entity.EntityData;
using Entity.Weapon;
using SepCore.Definition;
using UnityEngine;
@ -8,11 +13,50 @@ namespace SepCore.UI
public int Index;
public string IconAssetName;
public string Title;
public string TypeText;
public ItemType ItemType;
public ItemRarity Rarity;
public string Description;
public int Price;
public bool IsWeapon;
public Vector3 TargetPos;
public DisplayItemInfoContext()
{
Index = -1;
IconAssetName = string.Empty;
Title = string.Empty;
ItemType = ItemType.None;
Rarity = ItemRarity.White;
Description = string.Empty;
Price = 0;
TargetPos = Vector3.zero;
}
public DisplayItemInfoContext(DisplayItemInfoRawData rawData)
{
Index = rawData.Index;
ItemType = rawData.ItemType;
Rarity = rawData.Rarity;
Price = rawData.Price;
TargetPos = rawData.TargetPos;
if (ItemType == ItemType.None)
{
IconAssetName = string.Empty;
Title = string.Empty;
}
else if (ItemType == ItemType.Weapon)
{
var data = (WeaponData)rawData.Data;
IconAssetName = data.IconAssetName;
Title = data.Title;
Description = ItemDescUtility.CreateWeaponDescription(data);
}
else
{
var data = (PropItem)rawData.Data;
IconAssetName = data.IconAssetName;
Title = data.Title;
Description = ItemDescUtility.CreatePropDescription(data);
}
}
}
}

View File

@ -43,18 +43,7 @@ namespace SepCore.UI
return null;
}
return new DisplayItemInfoContext
{
Index = rawData.Index,
IconAssetName = rawData.IconAssetName,
Title = rawData.Title,
Rarity = rawData.Rarity,
TypeText = rawData.TypeText,
Description = rawData.Description,
Price = rawData.Price,
IsWeapon = rawData.IsWeapon,
TargetPos = rawData.TargetPos
};
return new DisplayItemInfoContext(rawData);
}
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)

View File

@ -1,3 +1,4 @@
using System;
using SepCore.Event;
using TMPro;
using UnityEngine;
@ -32,6 +33,7 @@ namespace SepCore.UI
[SerializeField] private float _screenEdgePadding = 0f;
private DisplayItemInfoContext _context;
private Vector3 _targetPos;
public void RefreshUI(DisplayItemInfoContext context)
@ -53,13 +55,13 @@ namespace SepCore.UI
}
if (_itemTitle != null) _itemTitle.text = _context.Title ?? string.Empty;
if (_itemTypeText != null) _itemTypeText.text = _context.TypeText ?? string.Empty;
if (_itemTypeText != null) _itemTypeText.text = BuildTypeText(_context.ItemType) ?? string.Empty;
if (_itemDescription != null) _itemDescription.text = _context.Description ?? string.Empty;
if (_itemPrice != null) _itemPrice.text = $"{_context.Price} <sprite name=\"coin\" index=0>";
if (_recycleButton != null)
{
_recycleButton.gameObject.SetActive(_context.IsWeapon);
_recycleButton.gameObject.SetActive(_context.ItemType == ItemType.Weapon);
}
if (_iconArea != null)
@ -193,7 +195,7 @@ namespace SepCore.UI
public void OnRecycleButtonClick()
{
if (_context == null || !_context.IsWeapon) return;
if (_context == null || _context.ItemType != ItemType.Weapon) return;
GameEntry.Event.Fire(this, ShopWeaponRecycleEventArgs.Create(_context.Index, _context.Price));
}
@ -201,5 +203,16 @@ namespace SepCore.UI
{
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
}
private string BuildTypeText(ItemType type)
{
return type switch
{
ItemType.None => "error",
ItemType.Weapon => "武器",
ItemType.Prop => "道具",
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
};
}
}
}

View File

@ -374,18 +374,14 @@ namespace SepCore.UI
return false;
}
var weaponData = weapon.WeaponData;
rawData = new DisplayItemInfoRawData
{
TargetPos = targetPos,
Index = index,
IconAssetName = weaponData.IconAssetName,
Title = weaponData.Title,
Rarity = weaponData.Rarity,
TypeText = "武器",
Description = ItemDescUtility.CreateWeaponDescription(weaponData),
Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate),
IsWeapon = true
Data = weapon.WeaponData,
Rarity = weapon.WeaponData.Rarity,
ItemType = ItemType.Weapon,
Price = Mathf.FloorToInt(weapon.WeaponData.Price * Context.WeaponRecycleRate),
};
return true;
}
@ -417,13 +413,10 @@ namespace SepCore.UI
{
TargetPos = targetPos,
Index = index,
IconAssetName = propItem.IconAssetName,
Title = propItem.Title,
Data = propItem,
Rarity = propItem.Rarity,
TypeText = "道具",
Description = ItemDescUtility.CreatePropDescription(propItem),
Price = 0,
IsWeapon = false
ItemType = ItemType.Prop,
Price = 0
};
return true;
}

View File

@ -1,3 +1,4 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@ -22,7 +23,13 @@ namespace SepCore.UI
{
_iconArea.OnInit(data.Icon, data.Rarity);
_titleText.text = data.Title;
_typeText.text = data.Type;
_typeText.text = data.ItemType switch
{
ItemType.None => "error",
ItemType.Weapon => "武器",
ItemType.Prop => "道具",
_ => throw new ArgumentOutOfRangeException()
};
_descriptionText.text = data.Description;
_costText.text = $"{data.Price} <sprite name=\"coin\" index=0>";
}

View File

@ -3,9 +3,10 @@
"rootNamespace": "SepCore.UI",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:47a82ffa13c291447ab895cd0bc251cd",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:363c5eb08ff8e6a439b85e37b8c20d96",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
"GUID:47a82ffa13c291447ab895cd0bc251cd",
"GUID:436e23dbdc31e7d4fb5c3f804548b2df"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 77816bb3deec31c4ba8881acdd951fea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -92,9 +92,6 @@ namespace Procedure
LoadDataTable(dataTableName);
}
// Preload dictionaries
LoadDictionary("Default");
// Preload fonts
LoadFont("MainFont");
LoadTMPFont("MainTMPFont");
@ -114,45 +111,40 @@ namespace Procedure
GameEntry.DataTable.LoadDataTable(dataTableName, dataTableAssetName, this);
}
private void LoadDictionary(string dictionaryName)
{
string dictionaryAssetName = AssetUtility.GetDictionaryAsset(dictionaryName, false);
_loadedFlag.Add(dictionaryAssetName, false);
GameEntry.Localization.ReadData(dictionaryAssetName, this);
}
private void LoadFont(string fontName)
{
_loadedFlag.Add(Utility.Text.Format("Font.{0}", fontName), false);
GameEntry.Resource.LoadAsset(AssetUtility.GetFontAsset(fontName), Constant.AssetPriority.FontAsset, new LoadAssetCallbacks(
(assetName, asset, duration, userData) =>
{
_loadedFlag[Utility.Text.Format("Font.{0}", fontName)] = true;
UGuiForm.SetMainFont((Font)asset);
Log.Info("Load font '{0}' OK.", fontName);
},
(assetName, status, errorMessage, userData) =>
{
Log.Error("Can not load font '{0}' from '{1}' with error message '{2}'.", fontName, assetName, errorMessage);
}));
GameEntry.Resource.LoadAsset(AssetUtility.GetFontAsset(fontName), Constant.AssetPriority.FontAsset,
new LoadAssetCallbacks(
(assetName, asset, duration, userData) =>
{
_loadedFlag[Utility.Text.Format("Font.{0}", fontName)] = true;
UGuiForm.SetMainFont((Font)asset);
Log.Info("Load font '{0}' OK.", fontName);
},
(assetName, status, errorMessage, userData) =>
{
Log.Error("Can not load font '{0}' from '{1}' with error message '{2}'.", fontName, assetName,
errorMessage);
}));
}
private void LoadTMPFont(string fontName)
{
_loadedFlag.Add(Utility.Text.Format("Font.{0}", fontName), false);
GameEntry.Resource.LoadAsset(AssetUtility.GetTMPFontAsset(fontName), Constant.AssetPriority.FontAsset, new LoadAssetCallbacks(
(assetName, asset, duration, userData) =>
{
_loadedFlag[Utility.Text.Format("Font.{0}", fontName)] = true;
UGuiForm.SetMainTMPFont((TMP_FontAsset)asset);
Log.Info("Load font '{0}' OK.", fontName);
},
(assetName, status, errorMessage, userData) =>
{
Log.Error("Can not load font '{0}' from '{1}' with error message '{2}'.", fontName, assetName, errorMessage);
}));
GameEntry.Resource.LoadAsset(AssetUtility.GetTMPFontAsset(fontName), Constant.AssetPriority.FontAsset,
new LoadAssetCallbacks(
(assetName, asset, duration, userData) =>
{
_loadedFlag[Utility.Text.Format("Font.{0}", fontName)] = true;
UGuiForm.SetMainTMPFont((TMP_FontAsset)asset);
Log.Info("Load font '{0}' OK.", fontName);
},
(assetName, status, errorMessage, userData) =>
{
Log.Error("Can not load font '{0}' from '{1}' with error message '{2}'.", fontName, assetName,
errorMessage);
}));
}
private void OnLoadConfigSuccess(object sender, GameEventArgs e)
@ -175,7 +167,8 @@ namespace Procedure
return;
}
Log.Error("Can not load config '{0}' from '{1}' with error message '{2}'.", ne.ConfigAssetName, ne.ConfigAssetName, ne.ErrorMessage);
Log.Error("Can not load config '{0}' from '{1}' with error message '{2}'.", ne.ConfigAssetName,
ne.ConfigAssetName, ne.ErrorMessage);
}
private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
@ -198,7 +191,8 @@ namespace Procedure
return;
}
Log.Error("Can not load data table '{0}' from '{1}' with error message '{2}'.", ne.DataTableAssetName, ne.DataTableAssetName, ne.ErrorMessage);
Log.Error("Can not load data table '{0}' from '{1}' with error message '{2}'.", ne.DataTableAssetName,
ne.DataTableAssetName, ne.ErrorMessage);
}
private void OnLoadDictionarySuccess(object sender, GameEventArgs e)
@ -221,7 +215,8 @@ namespace Procedure
return;
}
Log.Error("Can not load dictionary '{0}' from '{1}' with error message '{2}'.", ne.DictionaryAssetName, ne.DictionaryAssetName, ne.ErrorMessage);
Log.Error("Can not load dictionary '{0}' from '{1}' with error message '{2}'.", ne.DictionaryAssetName,
ne.DictionaryAssetName, ne.ErrorMessage);
}
}
}

View File

@ -2,11 +2,12 @@
"name": "SepCore.Procedure",
"rootNamespace": "SepCore.Procedure",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:363c5eb08ff8e6a439b85e37b8c20d96",
"GUID:47a82ffa13c291447ab895cd0bc251cd",
"GUID:0e1d182005e0ae647ab3fa40f5492dbb",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
"GUID:436e23dbdc31e7d4fb5c3f804548b2df",
"GUID:0e1d182005e0ae647ab3fa40f5492dbb"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: f7c4b051e63f0c2418a55e8817bf4ba9
guid: e185f5edf2aad9e47be7d8a4b4d04966
folderAsset: yes
timeCreated: 1528026151
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using SepCore.DataTable;
using SepCore.Definition;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace Entity.EntityData
{

Some files were not shown because too many files have changed in this diff Show More