调整部分数据表配置,优化 SpriteCache 功能

This commit is contained in:
2026-09-13 20:36:21 +08:00
parent de53890de6
commit 7dc529a840
520 changed files with 24231 additions and 967 deletions
@@ -1,23 +1,10 @@
using System;
using System.Collections.Generic;
using SepCore.Definition;
using UnityGameFramework.Runtime;
using SepCore.CustomUtility;
namespace SepCore.Entity
{
public static class EntityExtension
{
private static int s_SerialId = -10;
private static int _serialId = 0;
private const string EntityNamespace = "SepCore.Entity.";
private static readonly Dictionary<string, Type> _typeDict;
static EntityExtension()
{
_typeDict = new Dictionary<string, Type>();
}
public static EntityBase GetGameEntity(this EntityComponent entityComponent, int entityId)
{
@@ -41,116 +28,9 @@ namespace SepCore.Entity
entityComponent.AttachEntity(entityBase.Entity, ownerId, parentTransformPath, userData);
}
public static void ShowEntity<T>(this EntityComponent entityComponent, EntityDataBase data, string group,
int priority) where T : EntityBase
{
if (data == null)
{
Log.Warning("Data is invalid.");
return;
}
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
if (entityConfig == null)
{
Log.Warning("Can not load entity assetName '{0}' from data table.", data.AssetName);
return;
}
entityComponent.ShowEntity(data.Id, typeof(T), AssetUtility.GetEntityAsset(entityConfig.PrefabPath), group,
priority, data);
}
public static void ShowPlayer(this EntityComponent entityComponent, PlayerData data)
{
entityComponent.ShowEntity(typeof(Player), "Player", Constant.AssetPriority.PlayerAsset, data);
}
public static void ShowEnemy(this EntityComponent entityComponent, EnemyData data)
{
if (data == null)
{
Log.Warning("Enemy data is invalid.");
return;
}
var enemyType = TryGetType(data.EnemyType.ToString());
entityComponent.ShowEntity(enemyType, "Enemy", Constant.AssetPriority.EnemyAsset, data);
}
public static void ShowWeapon(this EntityComponent entityComponent, WeaponData data)
{
if (data == null)
{
Log.Warning("Weapon data is invalid.");
return;
}
var weaponType = TryGetType("Weapon." + data.WeaponType);
entityComponent.ShowEntity(weaponType, "Weapon", Constant.AssetPriority.WeaponAsset, data);
}
public static void ShowEffect(this EntityComponent entityComponent, EffectData data)
{
entityComponent.ShowEntity(typeof(Effect), "Effect", Constant.AssetPriority.EffectAsset, data);
}
public static void ShowCoin(this EntityComponent entityComponent, CoinData data)
{
entityComponent.ShowEntity(typeof(CoinEntity), "Drop", Constant.AssetPriority.EffectAsset, data);
}
public static void ShowExp(this EntityComponent entityComponent, ExpData data)
{
entityComponent.ShowEntity(typeof(ExpEntity), "Drop", Constant.AssetPriority.EffectAsset, data);
}
private static void ShowEntity(this EntityComponent entityComponent, Type logicType, string entityGroup,
int priority, EntityDataBase data)
{
if (data == null)
{
Log.Warning("Data is invalid.");
return;
}
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
if (entityConfig == null)
{
Log.Warning("Can not load entity assetName '{0}' from data table.", data.AssetName);
return;
}
entityComponent.ShowEntity(data.Id, logicType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), entityGroup,
priority, data);
}
private static Type TryGetType(string rawTypeName)
{
string typeName = EntityNamespace + rawTypeName;
if (!_typeDict.TryGetValue(typeName, out Type type))
{
type = Type.GetType(typeName);
if (type == null)
{
Log.Warning("Can not load entity type '{0}'.", typeName);
return null;
}
_typeDict.Add(typeName, type);
}
return type;
}
public static int NextId(this EntityComponent entityComponent)
{
return --s_SerialId;
}
public static int SerialId(this EntityComponent entityComponent)
{
return ++_serialId;
}
}
}