Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
87
Projects/Scripts/Items/Misc/Scales.cs
Normal file
87
Projects/Scripts/Items/Misc/Scales.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using Server.Targeting;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class Scales : Item
|
||||
{
|
||||
[Constructible]
|
||||
public Scales() : base(0x1852)
|
||||
{
|
||||
Weight = 4.0;
|
||||
}
|
||||
|
||||
public Scales(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
from.SendLocalizedMessage(502431); // What would you like to weigh?
|
||||
from.Target = new InternalTarget(this);
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private Scales m_Item;
|
||||
|
||||
public InternalTarget(Scales item) : base(1, false, TargetFlags.None)
|
||||
{
|
||||
m_Item = item;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
string message;
|
||||
|
||||
if (targeted == m_Item)
|
||||
{
|
||||
message = "It cannot weight itself.";
|
||||
}
|
||||
else if (targeted is Item item)
|
||||
{
|
||||
IEntity root = item.RootParent;
|
||||
|
||||
if (root != null && root != from || item.Parent == from)
|
||||
{
|
||||
message = "You decide that item's current location is too awkward to get an accurate result.";
|
||||
}
|
||||
else if (item.Movable)
|
||||
{
|
||||
message = item.Amount > 1 ? "You place one item on the scale. " : "You place that item on the scale. ";
|
||||
|
||||
double weight = item.Weight;
|
||||
|
||||
if (weight <= 0.0)
|
||||
message += "It is lighter than a feather.";
|
||||
else
|
||||
message += $"It weighs {weight} stones.";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "You cannot weigh that object.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "You cannot weigh that object.";
|
||||
}
|
||||
|
||||
from.SendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue