调整部分数据表配置,优化 SpriteCache 功能
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
[Serializable]
|
||||
public class WeaponData : AccessoryObjectData
|
||||
{
|
||||
private readonly WeaponConfig _weaponConfig;
|
||||
|
||||
public WeaponData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
||||
: base(weaponConfig.Prefab, entityId, ownerId, ownerCamp)
|
||||
{
|
||||
_weaponConfig = weaponConfig;
|
||||
}
|
||||
|
||||
public WeaponConfig Config => _weaponConfig;
|
||||
|
||||
public WeaponType WeaponType => _weaponConfig.WeaponType;
|
||||
|
||||
public string LogicType => _weaponConfig.LogicType;
|
||||
|
||||
public int Attack => _weaponConfig.Attack;
|
||||
|
||||
public string Title => _weaponConfig.WeaponType.ToString();
|
||||
|
||||
public string IconAssetName => _weaponConfig.Sprite;
|
||||
|
||||
public Rarity Rarity => _weaponConfig.Rarity;
|
||||
|
||||
public int Price => _weaponConfig.Price;
|
||||
|
||||
public float Cooldown => _weaponConfig.Cooldown / 1000f;
|
||||
|
||||
public float AttackRange => _weaponConfig.AttackRange / 1000f;
|
||||
|
||||
public int AttackSoundId => _weaponConfig.AttackSoundId;
|
||||
|
||||
public IReadOnlyDictionary<ParamType, int> Parameters => _weaponConfig.Parameters;
|
||||
|
||||
public IReadOnlyList<modifier> Modifiers => _weaponConfig.Modifiers;
|
||||
|
||||
public int GetParam(ParamType paramType, int defaultValue = 0)
|
||||
{
|
||||
return _weaponConfig.Parameters.TryGetValue(paramType, out int value) ? value : defaultValue;
|
||||
}
|
||||
|
||||
public float GetParamFloat(ParamType paramType, float defaultValue = 0f)
|
||||
{
|
||||
if (_weaponConfig.Parameters.TryGetValue(paramType, out int val))
|
||||
{
|
||||
return paramType == ParamType.SectorAngle ? val : val / 1000f;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user