69 lines
1.6 KiB
C#
69 lines
1.6 KiB
C#
using SepCore.Definition;
|
|
using SepCore.Entity;
|
|
using SepCore.CustomUtility;
|
|
using SepCore.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
|
|
{
|
|
Data = weapon.WeaponData,
|
|
ItemType = ItemType.Weapon,
|
|
Price = 0,
|
|
};
|
|
}
|
|
|
|
var props = Player.Props;
|
|
if (props == null || index >= props.Count)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
PropItem prop = props[index];
|
|
if (prop == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new DisplayItemInfoRawData
|
|
{
|
|
Data = prop,
|
|
ItemType = ItemType.Prop,
|
|
Price = 0,
|
|
};
|
|
}
|
|
}
|
|
}
|