using System; using Server; using Server.Mobiles; using Server.Gumps; using Server.Network; namespace Server.Custom.StaticHousing { public class StaticHouseSign : Item { private Rectangle2D m_HouseArea; private int m_MinZ; private int m_MaxZ; private int m_Price; private int m_CustomLockdowns; private int m_CustomSecures; public Rectangle2D HouseArea { get { return m_HouseArea; } } public int MinZ { get { return m_MinZ; } } public int MaxZ { get { return m_MaxZ; } } public int Price { get { return m_Price; } } public int CustomLockdowns { get { return m_CustomLockdowns; } } public int CustomSecures { get { return m_CustomSecures; } } [Constructable] public StaticHouseSign(int itemID, Rectangle2D area, int minZ, int maxZ, int price, int locks, int secures) : base(itemID) { Name = "A Vacant House For Sale"; Movable = false; m_HouseArea = area; m_MinZ = minZ; m_MaxZ = maxZ; m_Price = price; m_CustomLockdowns = locks; m_CustomSecures = secures; } public StaticHouseSign(Serial serial) : base(serial) { } public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); list.Add(1060658, "Price\t{0} Gold", m_Price); list.Add(1060659, "Lockdowns\t{0}", m_CustomLockdowns); list.Add(1060660, "Secures\t{0}", m_CustomSecures); } public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 3)) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } if (from is PlayerMobile) { from.SendGump(new StaticPurchaseGump((PlayerMobile)from, this)); } } public void Purchase(PlayerMobile pm) { if (Deleted) return; if (Banker.Withdraw(pm, m_Price)) { StaticHouse newHouse = new StaticHouse(pm, m_HouseArea, m_MinZ, m_MaxZ, m_CustomLockdowns, m_CustomSecures, m_Price); Point3D houseLoc = new Point3D(m_HouseArea.Start.X, m_HouseArea.Start.Y, m_MinZ); newHouse.MoveToWorld(houseLoc, this.Map); if (newHouse.Sign != null) newHouse.Sign.Location = this.Location; newHouse.BanLocation = new Point3D(this.X, this.Y + 1, this.Z); pm.PlaySound(0x249); pm.SendMessage(68, $"You have purchased this home for {m_Price} gold."); this.Delete(); } else { pm.SendMessage(33, $"You need {m_Price} gold in your bank to purchase this home."); } } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); writer.Write(m_HouseArea); writer.Write(m_MinZ); writer.Write(m_MaxZ); writer.Write(m_Price); writer.Write(m_CustomLockdowns); writer.Write(m_CustomSecures); } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_HouseArea = reader.ReadRect2D(); m_MinZ = reader.ReadInt(); m_MaxZ = reader.ReadInt(); m_Price = reader.ReadInt(); m_CustomLockdowns = reader.ReadInt(); m_CustomSecures = reader.ReadInt(); } private class StaticPurchaseGump : Gump { private PlayerMobile m_Player; private StaticHouseSign m_Sign; public StaticPurchaseGump(PlayerMobile pm, StaticHouseSign sign) : base(200, 200) { m_Player = pm; m_Sign = sign; AddPage(0); AddBackground(0, 0, 300, 150, 9270); AddHtml(0, 15, 300, 20, "