* Fixes pooled timer leaking * Fixes `[dumptimers` command so it outputs properly, adds spacing, and stacktraces * Adds `[Tidy]` for serializing Lists. This will remove deleted entities during world save before serializing the list. * Adds helpers for managing Lists/Sets/Dictionaries ### New API ```cs // Creates the list if it is null, then adds Utility.Add(ref list, value); Utility.Add(ref set, value); Utility.Add(ref dict, key, value); // Nulls the variable if the count is zero Utility.Remove(ref list, value); Utility.Remove(ref set, value); Utility.Remove(ref dict, key); // Marks entity as dirty in addition to doing the action entity.Add(list, value); // Marks entity as dirty, and will create list if it doesn't exist entity.Add(ref list, value); // Marks entity as dirty in addition to doing the action entity.Remove(list, value); // Marks entity as dirty, and will null the list count is zero entity.Remove(ref list, value); ``` ### Updates to [dumptimers <img width="825" alt="Screen Shot 2021-08-14 at 2 55 10 AM" src="https://user-images.githubusercontent.com/3953314/129442449-ccf7fe14-29d6-4f3f-9366-c8eb7b9828a7.png">
107 lines
2.9 KiB
C#
107 lines
2.9 KiB
C#
using Server.Targeting;
|
|
|
|
namespace Server.Items
|
|
{
|
|
[Serializable(0, false)]
|
|
public partial class CupidsArrow : Item
|
|
{
|
|
[InternString]
|
|
[InvalidateProperties]
|
|
[SerializableField(0)]
|
|
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
|
private string _from;
|
|
|
|
[InternString]
|
|
[InvalidateProperties]
|
|
[SerializableField(1)]
|
|
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
|
private string _to;
|
|
|
|
[Constructible]
|
|
public CupidsArrow() : base(0x4F7F) => LootType = LootType.Blessed;
|
|
|
|
// TODO: Check messages
|
|
|
|
public override int LabelNumber => 1152270; // Cupid's Arrow 2012
|
|
|
|
public bool IsSigned => _from != null && _to != null;
|
|
|
|
public override void AddNameProperty(ObjectPropertyList list)
|
|
{
|
|
base.AddNameProperty(list);
|
|
|
|
if (IsSigned)
|
|
{
|
|
list.Add(1152273, $"{_from}\t{_to}"); // ~1_val~ is madly in love with ~2_val~
|
|
}
|
|
}
|
|
|
|
public static bool CheckSeason(Mobile from)
|
|
{
|
|
if (Core.Now.Month == 2)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
from.SendLocalizedMessage(1152318); // You may not use this item out of season.
|
|
return false;
|
|
}
|
|
|
|
public override void OnSingleClick(Mobile from)
|
|
{
|
|
base.OnSingleClick(from);
|
|
|
|
if (IsSigned)
|
|
{
|
|
LabelTo(from, 1152273, $"{_from}\t{_to}"); // ~1_val~ is madly in love with ~2_val~
|
|
}
|
|
}
|
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
{
|
|
if (IsSigned || !CheckSeason(from))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!IsChildOf(from.Backpack))
|
|
{
|
|
from.SendLocalizedMessage(1080063); // This must be in your backpack to use it.
|
|
return;
|
|
}
|
|
|
|
from.BeginTarget(10, false, TargetFlags.None, OnTarget);
|
|
from.SendMessage("Who do you wish to use this on?");
|
|
}
|
|
|
|
private void OnTarget(Mobile from, object targeted)
|
|
{
|
|
if (IsSigned || !IsChildOf(from.Backpack))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (targeted is Mobile m)
|
|
{
|
|
if (!m.Alive)
|
|
{
|
|
from.SendLocalizedMessage(
|
|
1152269
|
|
); // That target is dead and even Cupid's arrow won't make them love you.
|
|
return;
|
|
}
|
|
|
|
From = from.Name;
|
|
To = m.Name;
|
|
|
|
InvalidateProperties();
|
|
|
|
from.SendMessage("You inscribe the arrow.");
|
|
}
|
|
else
|
|
{
|
|
from.SendMessage("That is not a person.");
|
|
}
|
|
}
|
|
}
|
|
}
|