69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using SepCore.Definition;
|
|
using UnityGameFramework.Runtime;
|
|
|
|
namespace SepCore.Entity
|
|
{
|
|
[Serializable]
|
|
public class WeaponData : AccessoryObjectData
|
|
{
|
|
public WeaponConfig Config { get; }
|
|
|
|
public WeaponData(int entityId, WeaponConfig weaponConfig, int ownerId, CampType ownerCamp)
|
|
: base(weaponConfig.Prefab, entityId, ownerId, ownerCamp)
|
|
{
|
|
Config = weaponConfig;
|
|
}
|
|
|
|
public WeaponType WeaponType => Config.WeaponType;
|
|
|
|
public string LogicType => Config.LogicType;
|
|
|
|
public int Attack => Config.Attack;
|
|
|
|
public DamageType DamageType => Config.DamageType;
|
|
|
|
public string Title => Config.WeaponType.ToString();
|
|
|
|
public string Sprite => Config.Sprite;
|
|
|
|
public Rarity Rarity => Config.Rarity;
|
|
|
|
public int Price => Config.Price;
|
|
|
|
public float Cooldown => Config.Cooldown / 1000f;
|
|
|
|
public float AttackRange => Config.AttackRange / 1000f;
|
|
|
|
public int AttackSoundId => Config.AttackSoundId;
|
|
|
|
public IReadOnlyDictionary<ParamType, int> Parameters => Config.Parameters;
|
|
|
|
public IReadOnlyList<StatModifierConfig> Modifiers => Config.StatModifierConfigs;
|
|
|
|
public int GetParam(ParamType paramType)
|
|
{
|
|
if (Config.Parameters.TryGetValue(paramType, out int value))
|
|
{
|
|
return value;
|
|
}
|
|
|
|
Log.Error("Weapon parameter '{0}' not found for weapon '{1}'.", paramType, Config.WeaponType);
|
|
return 0;
|
|
}
|
|
|
|
public float GetParamFloat(ParamType paramType)
|
|
{
|
|
if (Config.Parameters.TryGetValue(paramType, out int val))
|
|
{
|
|
return paramType == ParamType.SectorAngle ? val : val / 1000f;
|
|
}
|
|
|
|
Log.Error("Weapon parameter '{0}' not found for weapon '{1}'.", paramType, Config.WeaponType);
|
|
return 0f;
|
|
}
|
|
}
|
|
}
|
|
|