调整 convert.py 转换逻辑 + 规划后续开发
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using DataTable;
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using GameFramework;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
@@ -39,6 +40,26 @@ namespace Entity.EntityData
|
||||
return Params.TryGetValue(key.ToLower(), out value);
|
||||
}
|
||||
|
||||
protected TParams ParseParams<TParams>() where TParams : new()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_drWeapon.ParamsJson))
|
||||
{
|
||||
return new TParams();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
TParams parsed = Utility.Json.ToObject<TParams>(_drWeapon.ParamsJson);
|
||||
return parsed ?? new TParams();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Failed to parse weapon params, WeaponType='{WeaponType}', Json='{_drWeapon.ParamsJson}'.",
|
||||
exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 攻击力。
|
||||
/// </summary>
|
||||
@@ -80,9 +101,11 @@ namespace Entity.EntityData
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Params => _drWeapon.Pramas;
|
||||
|
||||
public string ParamsJson => _drWeapon.ParamsJson;
|
||||
|
||||
/// <summary>
|
||||
/// 额外属性。
|
||||
/// </summary>
|
||||
public StatModifier[] Modifiers => _drWeapon.Modifiers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
using System;
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponHandgunParamsData
|
||||
{
|
||||
}
|
||||
|
||||
public class WeaponHandgunData : WeaponData
|
||||
{
|
||||
public WeaponHandgunParamsData ParamsData { get; }
|
||||
|
||||
public WeaponHandgunData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponHandgun, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponHandgunParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
using System;
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponKnifeParamsData
|
||||
{
|
||||
public float HitRadius { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponKnifeData : WeaponData
|
||||
{
|
||||
public WeaponKnifeParamsData ParamsData { get; }
|
||||
|
||||
public WeaponKnifeData(int entityId, int ownerId, CampType ownerCamp) : base(entityId, WeaponType.WeaponKnife,
|
||||
ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponKnifeParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
using System;
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponLightningParamsData
|
||||
{
|
||||
public float HitRadius { get; set; }
|
||||
public float HoverHeight { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponLightningData : WeaponData
|
||||
{
|
||||
public WeaponLightningParamsData ParamsData { get; }
|
||||
|
||||
public WeaponLightningData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponLightning, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponLightningParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
using System;
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class WeaponSlashParamsData
|
||||
{
|
||||
public float SectorAngle { get; set; }
|
||||
}
|
||||
|
||||
public class WeaponSlashData : WeaponData
|
||||
{
|
||||
public WeaponSlashParamsData ParamsData { get; }
|
||||
|
||||
public WeaponSlashData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponSlash, ownerId, ownerCamp)
|
||||
{
|
||||
ParamsData = ParseParams<WeaponSlashParamsData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user