2020-08-25 18:53:35 -07:00
|
|
|
using Server.Accounting;
|
|
|
|
|
using Server.Network;
|
|
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
namespace Server.Items;
|
|
|
|
|
|
|
|
|
|
public class BankBox : Container
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
public BankBox(Serial serial) : base(serial)
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public BankBox(Mobile owner) : base(0xE7C)
|
|
|
|
|
{
|
|
|
|
|
Layer = Layer.Bank;
|
|
|
|
|
Movable = false;
|
|
|
|
|
Owner = owner;
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override int DefaultMaxWeight => 0;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override bool IsVirtualItem => true;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public Mobile Owner { get; private set; }
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public bool Opened { get; private set; }
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public static bool SendDeleteOnClose { get; set; }
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public void Open()
|
|
|
|
|
{
|
|
|
|
|
Opened = true;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
if (Owner != null)
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
Owner.PrivateOverheadMessage(
|
|
|
|
|
MessageType.Regular,
|
|
|
|
|
0x3B2,
|
|
|
|
|
true,
|
|
|
|
|
$"Bank container has {TotalItems} items, {TotalWeight} stones",
|
|
|
|
|
Owner.NetState
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Owner.NetState?.SendEquipUpdate(this);
|
|
|
|
|
DisplayTo(Owner);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override void Serialize(IGenericWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
writer.Write(0); // version
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
writer.Write(Owner);
|
|
|
|
|
writer.Write(Opened);
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override void Deserialize(IGenericReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
var version = reader.ReadInt();
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
switch (version)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
Owner = reader.ReadEntity<Mobile>();
|
|
|
|
|
Opened = reader.ReadBool();
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
}
|
|
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
if (ItemID == 0xE41)
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
ItemID = 0xE7C;
|
2020-08-25 18:53:35 -07:00
|
|
|
}
|
2022-11-13 15:54:58 -08:00
|
|
|
|
|
|
|
|
if (Owner == null)
|
|
|
|
|
{
|
|
|
|
|
Timer.DelayCall(Delete);
|
|
|
|
|
}
|
2022-10-10 21:47:08 -07:00
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public void Close()
|
|
|
|
|
{
|
|
|
|
|
Opened = false;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
if (SendDeleteOnClose)
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
Owner?.NetState.SendRemoveEntity(Serial);
|
2020-08-25 18:53:35 -07:00
|
|
|
}
|
2022-10-10 21:47:08 -07:00
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override void OnSingleClick(Mobile from)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override void OnDoubleClick(Mobile from)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override DeathMoveResult OnParentDeath(Mobile parent) => DeathMoveResult.RemainEquipped;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override bool IsAccessibleTo(Mobile check) =>
|
|
|
|
|
(check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check);
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override bool OnDragDrop(Mobile from, Item dropped) =>
|
|
|
|
|
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped);
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override bool OnDragDropInto(Mobile from, Item item, Point3D p) =>
|
|
|
|
|
(from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) &&
|
|
|
|
|
base.OnDragDropInto(from, item, p);
|
|
|
|
|
|
2025-01-01 16:47:32 -08:00
|
|
|
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
|
|
|
|
|
{
|
|
|
|
|
// This is a horrible hack.
|
|
|
|
|
// TODO: Refactor this by moving BankBox out of the core.
|
|
|
|
|
if (AccountGold.Enabled && AccountGold.ConvertOnBank && item.GetType().Name is "Gold" or "BankCheck")
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.CheckHold(m, item, message, checkItems, plusItems, plusWeight);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public override int GetTotal(TotalType type)
|
|
|
|
|
{
|
|
|
|
|
if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold)
|
|
|
|
|
{
|
|
|
|
|
return Owner.Account.TotalGold;
|
2020-08-25 18:53:35 -07:00
|
|
|
}
|
2022-10-10 21:47:08 -07:00
|
|
|
|
|
|
|
|
return base.GetTotal(type);
|
2020-08-25 18:53:35 -07:00
|
|
|
}
|
|
|
|
|
}
|