75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using SepCore.Definition;
|
|
using Entity;
|
|
using CustomUtility;
|
|
using Entity.Weapon;
|
|
|
|
namespace SepCore.UI
|
|
{
|
|
public class DisplayItemInfoUseCase : IUIUseCase
|
|
{
|
|
private readonly Player _player;
|
|
|
|
private Player Player => _player;
|
|
|
|
public DisplayItemInfoUseCase(Player player)
|
|
{
|
|
_player = player;
|
|
}
|
|
|
|
public DisplayItemInfoRawData CreateModel(int index, bool isWeapon)
|
|
{
|
|
if (index < 0 || Player == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (isWeapon)
|
|
{
|
|
var weapons = Player.Weapons;
|
|
if (weapons == null || index >= weapons.Count)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
WeaponBase weapon = weapons[index];
|
|
if (weapon == null || weapon.WeaponData == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new DisplayItemInfoRawData
|
|
{
|
|
IconAssetName = weapon.WeaponData.IconAssetName,
|
|
Title = weapon.WeaponData.Title,
|
|
TypeText = "Weapon",
|
|
Description = ItemDescUtility.CreateWeaponDescription(weapon),
|
|
Price = 0,
|
|
IsWeapon = true
|
|
};
|
|
}
|
|
|
|
var props = Player.Props;
|
|
if (props == null || index >= props.Count)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
PropItem prop = props[index];
|
|
if (prop == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new DisplayItemInfoRawData
|
|
{
|
|
IconAssetName = prop.IconAssetName,
|
|
Title = prop.Title,
|
|
TypeText = "Prop",
|
|
Description = ItemDescUtility.CreatePropDescription(prop),
|
|
Price = 0,
|
|
IsWeapon = false
|
|
};
|
|
}
|
|
}
|
|
}
|