RunUO/Scripts/Items/Houses/StaticHouse.cs

106 lines
3 KiB
C#

using System;
using Server;
using Server.Multis;
namespace Server.Custom.StaticHousing
{
public class StaticHouse : BaseHouse
{
private Rectangle2D m_CustomArea;
private int m_MinZ;
private int m_MaxZ;
private int m_CustomLockdowns;
private int m_CustomSecures;
public override Rectangle2D[] Area
{
get
{
return new Rectangle2D[] { new Rectangle2D(0, 0, m_CustomArea.Width, m_CustomArea.Height) };
}
}
public override Point3D BaseBanLocation
{
get
{
if (Sign != null)
return new Point3D(Sign.X, Sign.Y + 1, Sign.Z);
return Point3D.Zero;
}
}
public override double BonusStorageScalar { get { return 1.0; } }
public StaticHouse(Mobile owner, Rectangle2D area, int minZ, int maxZ, int locks, int secures, int price)
: base(0xA28, owner, locks, secures)
{
RestrictDecay = true;
m_CustomArea = area;
m_MinZ = minZ;
m_MaxZ = maxZ;
m_CustomLockdowns = locks;
m_CustomSecures = secures;
MaxLockDowns = locks;
MaxSecures = secures;
Price = price;
Components.Resize(area.Width, area.Height);
Components.Add(0x520, area.Width - 1, area.Height - 1, -5);
SetSign(0, 0, 0);
}
public StaticHouse(Serial serial) : base(serial)
{
}
public override int GetAosMaxLockdowns() { return m_CustomLockdowns; }
public override int GetAosMaxSecures() { return m_CustomSecures; }
public override bool IsInside(Point3D p, int height)
{
if (Deleted) return false;
if (!m_CustomArea.Contains(new Point2D(p.X, p.Y)))
return false;
if (p.Z >= m_MinZ && (p.Z + height) <= m_MaxZ)
return true;
return false;
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(m_CustomArea);
writer.Write(m_MinZ);
writer.Write(m_MaxZ);
writer.Write(m_CustomLockdowns);
writer.Write(m_CustomSecures);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_CustomArea = reader.ReadRect2D();
m_MinZ = reader.ReadInt();
m_MaxZ = reader.ReadInt();
m_CustomLockdowns = reader.ReadInt();
m_CustomSecures = reader.ReadInt();
Components.Resize(m_CustomArea.Width, m_CustomArea.Height);
Components.Add(0x520, m_CustomArea.Width - 1, m_CustomArea.Height - 1, -5);
}
}
}