### Summary Modifying a ValueLinkList using one of the methods will bump the "version". This field is used by iterators (foreach loops) to determine if the link list was modified while iterating. The sector.Items (and in the future other lists), will no longer be safe to modify while iterating. The server will _CRASH_ if the ValueLinkList is modified. Thanks to @stefanomerotta for help! ### Screenshots <img width="588" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/83ee0b6e-ff4f-4768-9e29-84456e04b1ec">
106 lines
2.8 KiB
C#
106 lines
2.8 KiB
C#
using ModernUO.Serialization;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Items;
|
|
|
|
[SerializationGenerator(0)]
|
|
public partial class OilFlask : Item
|
|
{
|
|
[Constructible]
|
|
public OilFlask(int amount = 1) : base(0x1C18)
|
|
{
|
|
Stackable = true;
|
|
Amount = amount;
|
|
}
|
|
|
|
public override int LabelNumber => 1027199; // oil flask
|
|
public virtual int FilledMessageNumber => 1150864; // You fill the lamp with oil.
|
|
public virtual double FillMultiplier => 1;
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
from.SendLocalizedMessage(501947); // Select lantern to refuel.
|
|
from.BeginTarget(2, true, TargetFlags.None, OnTargetPicked);
|
|
}
|
|
|
|
private void OnTargetPicked(Mobile from, object targeted)
|
|
{
|
|
if (targeted is Lantern lantern)
|
|
{
|
|
if (!lantern.Movable || lantern.Protected && from.AccessLevel == AccessLevel.Player)
|
|
{
|
|
from.SendLocalizedMessage(500685); // You can't use that, it belongs to someone else.
|
|
return;
|
|
}
|
|
|
|
var wasBurning = lantern.Burning;
|
|
lantern.Douse();
|
|
lantern.Duration = Lantern.FullDuration * FillMultiplier;
|
|
lantern.BurntOut = false;
|
|
|
|
if (wasBurning)
|
|
{
|
|
lantern.Ignite();
|
|
}
|
|
|
|
from.SendLocalizedMessage(FilledMessageNumber);
|
|
|
|
var emptyFlask = new EmptyOilFlask();
|
|
if (!from.PlaceInBackpack(emptyFlask))
|
|
{
|
|
var didStack = false;
|
|
|
|
foreach (var i in from.GetItemsAt())
|
|
{
|
|
if (i.StackWith(from, this, false))
|
|
{
|
|
didStack = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!didStack)
|
|
{
|
|
emptyFlask.MoveToWorld(Location, Map);
|
|
}
|
|
}
|
|
|
|
Consume(1);
|
|
}
|
|
else
|
|
{
|
|
from.SendLocalizedMessage(502218); // You cannot use that.
|
|
}
|
|
}
|
|
}
|
|
|
|
[SerializationGenerator(0)]
|
|
public partial class FishOilFlask : OilFlask
|
|
{
|
|
[Constructible]
|
|
public FishOilFlask(int amount = 1) : base(amount)
|
|
{
|
|
}
|
|
|
|
public override int LabelNumber => 1150863; // fish oil flask
|
|
public override int FilledMessageNumber => 1150865; // You fill the lamp with fish oil. It should burn for a nice long time.
|
|
public override double FillMultiplier => 2;
|
|
}
|
|
|
|
[SerializationGenerator(0)]
|
|
public partial class EmptyOilFlask : Item
|
|
{
|
|
[Constructible]
|
|
public EmptyOilFlask(int amount = 1) : base(0x1C18)
|
|
{
|
|
Stackable = true;
|
|
Amount = amount;
|
|
}
|
|
|
|
public override int LabelNumber => 1150866; // empty oil flask
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
from.SendLocalizedMessage(500318); // This flask is empty.
|
|
}
|
|
}
|