using ColdMint.scripts.damage;
using ColdMint.scripts.utils;
using Godot;
namespace ColdMint.scripts.furniture;
///
/// FurnitureTemplate
/// 家具模板
///
public partial class Furniture : RigidBody2D
{
[Export] private int _initialDurability;
[Export] private int _maxDurability;
[Export]
private string? _furnitureName;
private Label? _tipLabel;
public override void _MouseEnter()
{
if (_tipLabel == null || string.IsNullOrEmpty(_furnitureName))
{
return;
}
var translation = TranslationServerUtils.Translate(_furnitureName);
if (string.IsNullOrEmpty(translation))
{
return;
}
_tipLabel.Visible = true;
_tipLabel.Text = translation;
//Vertical Centering Tip
//垂直居中提示
var oldPosition = _tipLabel.Position;
oldPosition.X = -_tipLabel.Size.X / 2;
_tipLabel.Rotation = -Rotation;
_tipLabel.Position = oldPosition;
}
public override void _MouseExit()
{
if (_tipLabel == null)
{
return;
}
_tipLabel.Visible = false;
}
///
///
/// 家具的耐久度
///
private int _durability;
public override void _Ready()
{
if (_maxDurability <= 0)
{
_maxDurability = Config.DefaultMaxDurability;
}
if (_initialDurability <= 0 || _initialDurability > _maxDurability)
{
_initialDurability = _maxDurability;
}
_tipLabel = GetNodeOrNull