91 lines
2.8 KiB
C#
91 lines
2.8 KiB
C#
using System;
|
|
using Server;
|
|
using Server.Multis;
|
|
|
|
namespace Server.Custom.InnRooms
|
|
{
|
|
public class InnRoomHouse : BaseHouse
|
|
{
|
|
private Rectangle2D m_CustomArea;
|
|
|
|
// Dynamically computes the relative coordinates for the core engine
|
|
public override Rectangle2D[] Area
|
|
{
|
|
get
|
|
{
|
|
return new Rectangle2D[] { new Rectangle2D(m_CustomArea.Start.X - this.X, m_CustomArea.Start.Y - this.Y, m_CustomArea.Width, m_CustomArea.Height) };
|
|
}
|
|
}
|
|
|
|
public override Point3D BaseBanLocation
|
|
{
|
|
get { return new Point3D(this.X, this.Y - 5, this.Z + 20); }
|
|
}
|
|
|
|
public override double BonusStorageScalar { get { return 1.0; } }
|
|
|
|
// Added the Rectangle2D area parameter to the constructor
|
|
public InnRoomHouse(Mobile owner, Rectangle2D area) : base(0xA26, owner, 250, 250)
|
|
{
|
|
RestrictDecay = true;
|
|
|
|
m_CustomArea = area;
|
|
|
|
MaxLockDowns = 250;
|
|
MaxSecures = 250;
|
|
|
|
// Stretches the internal physical footprint to match your .cfg
|
|
Components.Resize(area.Width, area.Height);
|
|
Components.Add(0x520, area.Width - 1, area.Height - 1, -5);
|
|
}
|
|
|
|
public InnRoomHouse(Serial serial) : base(serial)
|
|
{
|
|
}
|
|
|
|
public override int GetAosMaxLockdowns() { return 250; }
|
|
public override int GetAosMaxSecures() { return 250; }
|
|
|
|
public override bool IsInside(Point3D p, int height)
|
|
{
|
|
if (Deleted)
|
|
return false;
|
|
|
|
// Absolute map bounds check ensures exact precision and stops bleeding!
|
|
if (!m_CustomArea.Contains(new Point2D(p.X, p.Y)))
|
|
return false;
|
|
|
|
if (p.Z >= this.Z && (p.Z + height) <= this.Z + 40)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public override void Serialize(GenericWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
writer.Write((int)1); // Version bumped to 1
|
|
writer.Write(m_CustomArea);
|
|
}
|
|
|
|
public override void Deserialize(GenericReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
int version = reader.ReadInt();
|
|
|
|
if (version >= 1)
|
|
{
|
|
m_CustomArea = reader.ReadRect2D();
|
|
}
|
|
else
|
|
{
|
|
// Safety net for existing rooms using the old hardcoded offsets
|
|
m_CustomArea = new Rectangle2D(this.X - 5, this.Y - 5, 6, 5);
|
|
}
|
|
|
|
// Restores the stretched footprint on server restart
|
|
Components.Resize(m_CustomArea.Width, m_CustomArea.Height);
|
|
Components.Add(0x520, m_CustomArea.Width - 1, m_CustomArea.Height - 1, -5);
|
|
}
|
|
}
|
|
}
|