60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|