迁移数据表到 Luban,移除 JsonNet、EnumUtility

This commit is contained in:
2026-09-13 14:08:14 +08:00
parent 4003b3aaba
commit de53890de6
607 changed files with 18515 additions and 3257 deletions
@@ -1,42 +1,103 @@
using System;
using SepCore.DataTable;
using SepCore.Entity;
using SepCore.Definition;
using UnityGameFramework.Runtime;
namespace SepCore.CustomUtility
{
public static class EntityDataFactory
{
private static readonly string[] s_EnemyTypeNames =
{
null,
"近战敌人",
"远程敌人",
"蝙蝠",
"骷髅兵",
"骷髅巨人",
"幽灵",
"火焰法师"
};
public static EnemyConfig GetEnemyConfig(EnemyType enemyType)
{
int index = (int)enemyType;
if (index > 0 && index < s_EnemyTypeNames.Length)
{
string name = s_EnemyTypeNames[index];
return GameEntry.Luban.Get<EnemyConfig>(name);
}
Log.Error("Invalid enemy type '{0}'.", enemyType);
return null;
}
public static EnemyType GetEnemyType(string enemyName)
{
if (string.IsNullOrEmpty(enemyName))
{
Log.Error("Enemy name is invalid.");
return EnemyType.None;
}
for (int i = 1; i < s_EnemyTypeNames.Length; i++)
{
if (s_EnemyTypeNames[i] == enemyName)
{
return (EnemyType)i;
}
}
if (Enum.TryParse<EnemyType>(enemyName, true, out var enemyType))
{
return enemyType;
}
Log.Error("Can not find EnemyType for enemy name '{0}'.", enemyName);
return EnemyType.None;
}
public static EnemyData Create(int entityId, EnemyType enemyType, int level)
{
var dr = GameEntry.DataTable.GetDataTableRow<DREnemy>((int)enemyType);
return new EnemyData(entityId, dr, level);
EnemyConfig config = GetEnemyConfig(enemyType);
if (config == null)
{
Log.Error("Can not find EnemyConfig for enemy type '{0}'.", enemyType);
return null;
}
return new EnemyData(entityId, config, enemyType, level);
}
public static EnemyData Create(int entityId, EnemyConfig config, EnemyType enemyType, int level)
{
return new EnemyData(entityId, config, enemyType, level);
}
public static WeaponData Create(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
{
var dr = GameEntry.DataTable.GetDataTableRow<DRWeapon>((int)weaponType);
var config = GameEntry.Luban.Get<WeaponConfig>((int)weaponType);
return weaponType switch
{
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponSlash => new WeaponSlashData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLightning => new WeaponLightningData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLance => new WeaponLanceData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponSlash => new WeaponSlashData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponLightning => new WeaponLightningData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponLance => new WeaponLanceData(entityId, config, ownerId, ownerCamp),
_ => throw new NotImplementedException()
};
}
public static WeaponData Create(int entityId, DRWeapon dr, int ownerId, CampType ownerCamp)
public static WeaponData Create(int entityId, WeaponConfig config, int ownerId, CampType ownerCamp)
{
WeaponType type = (WeaponType)dr.Id;
WeaponType type = (WeaponType)config.Id;
return type switch
{
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponSlash => new WeaponSlashData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLightning => new WeaponLightningData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLance => new WeaponLanceData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponSlash => new WeaponSlashData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponLightning => new WeaponLightningData(entityId, config, ownerId, ownerCamp),
WeaponType.WeaponLance => new WeaponLanceData(entityId, config, ownerId, ownerCamp),
_ => throw new NotImplementedException()
};
}
@@ -0,0 +1,36 @@
using SepCore.Definition;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.CustomUtility
{
public static class RarityUtility
{
public static Rarity SelectRarityForLevel(int level)
{
int configId = level >= 1000 ? level : 1000 + level;
LevelDropConfig dropConfig = GameEntry.Luban.Get<LevelDropConfig>(configId);
return SelectRarity(dropConfig);
}
public static Rarity SelectRarity(LevelDropConfig dropConfig)
{
float total = dropConfig.WhiteWeight + dropConfig.GreenWeight + dropConfig.BlueWeight + dropConfig.PurpleWeight + dropConfig.RedWeight;
if (total <= 0f)
{
Log.Error("LevelDropConfig '{0}' has invalid total weight '{1}'.", dropConfig.Id, total);
return Rarity.White;
}
float roll = Random.Range(0f, total);
if (roll < dropConfig.WhiteWeight) return Rarity.White;
roll -= dropConfig.WhiteWeight;
if (roll < dropConfig.GreenWeight) return Rarity.Green;
roll -= dropConfig.GreenWeight;
if (roll < dropConfig.BlueWeight) return Rarity.Blue;
roll -= dropConfig.BlueWeight;
if (roll < dropConfig.PurpleWeight) return Rarity.Purple;
return Rarity.Red;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d9186261c82d4f0b8270048f08158b0f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: