ModernUO/Projects/UOContent/Engines/Craft/Core/CraftRes.cs
Kamron Batman 9c374861d9
fix: Delays getting item id of craftables until they are needed (#1114)
- [X] Fixes world loading for multi.mul. It was taking 10-15s, now takes 1s or less.
- [X] Fixes loading the crafting system by offloading getting a label number to when the item needs it.
2022-07-10 22:44:24 -07:00

41 lines
930 B
C#

using System;
namespace Server.Engines.Craft;
public class CraftRes
{
private TextDefinition _name;
public CraftRes(Type type, TextDefinition name, int amount, TextDefinition message = null)
{
ItemType = type;
Amount = amount;
_name = name;
Message = message;
}
public Type ItemType { get; }
public TextDefinition Message { get; }
public TextDefinition Name => _name ??= CraftItem.LabelNumber(ItemType);
public int Amount { get; }
public void SendMessage(Mobile from)
{
if (Message?.Number > 0)
{
from.SendLocalizedMessage(Message.Number);
}
else if (!string.IsNullOrEmpty(Message?.String))
{
from.SendMessage(Message.String);
}
else
{
from.SendLocalizedMessage(502925); // You don't have the resources required to make that item.
}
}
}