fix: Codegens house/vendors (#1767)
### Summary - Cleans up ShardPoller - Breaks up player vendor file - Codegens houses/vendors
This commit is contained in:
parent
8fd04ac5aa
commit
fb8563aa60
20 changed files with 4801 additions and 4858 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,311 +1,274 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Server.Multis
|
||||
namespace Server.Multis;
|
||||
|
||||
[SerializationGenerator(0, false)]
|
||||
public partial class HouseSign : Item
|
||||
{
|
||||
public class HouseSign : Item
|
||||
[SerializableField(0, setter: "private")]
|
||||
private BaseHouse _owner;
|
||||
|
||||
[SerializableField(1, setter: "private")]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private Mobile _originalOwner;
|
||||
|
||||
public HouseSign(BaseHouse owner) : base(0xBD2)
|
||||
{
|
||||
public HouseSign(BaseHouse owner) : base(0xBD2)
|
||||
{
|
||||
Owner = owner;
|
||||
OriginalOwner = Owner.Owner;
|
||||
Movable = false;
|
||||
}
|
||||
Owner = owner;
|
||||
OriginalOwner = Owner.Owner;
|
||||
Movable = false;
|
||||
}
|
||||
|
||||
public HouseSign(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public BaseHouse Owner { get; private set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool RestrictDecay
|
||||
{
|
||||
get => Owner?.RestrictDecay == true;
|
||||
set
|
||||
{
|
||||
if (Owner != null)
|
||||
{
|
||||
Owner.RestrictDecay = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile OriginalOwner { get; private set; }
|
||||
|
||||
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
|
||||
|
||||
public bool GettingProperties { get; private set; }
|
||||
|
||||
public string GetName() => Name ?? "An Unnamed House";
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (Owner?.Deleted == false)
|
||||
{
|
||||
Owner.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddNameProperty(IPropertyList list)
|
||||
{
|
||||
list.Add(1061638); // A House Sign
|
||||
}
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1061639, GetName().FixHtml()); // Name: ~1_NAME~
|
||||
list.Add(1061640, Owner?.Owner == null ? "nobody" : Owner.Owner.Name); // Owner: ~1_OWNER~
|
||||
|
||||
if (Owner != null)
|
||||
{
|
||||
list.Add(Owner.Public ? 1061641 : 1061642); // This House is Open to the Public : This is a Private Home
|
||||
|
||||
GettingProperties = true;
|
||||
var level = Owner.DecayLevel;
|
||||
GettingProperties = false;
|
||||
|
||||
if (level == DecayLevel.DemolitionPending)
|
||||
{
|
||||
list.Add(1062497); // Demolition Pending
|
||||
}
|
||||
else if (level != DecayLevel.Ageless)
|
||||
{
|
||||
if (level == DecayLevel.Collapsed)
|
||||
{
|
||||
level = DecayLevel.IDOC;
|
||||
}
|
||||
|
||||
list.AddLocalized(1062028, 1043009 + (int)level); // Condition: This structure is ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (BaseHouse.DecayEnabled && Owner != null && Owner.DecayPeriod != TimeSpan.Zero)
|
||||
{
|
||||
var message = Owner.DecayLevel switch
|
||||
{
|
||||
DecayLevel.Ageless => "ageless",
|
||||
DecayLevel.Fairly => "fairly worn",
|
||||
DecayLevel.Greatly => "greatly worn",
|
||||
DecayLevel.LikeNew => "like new",
|
||||
DecayLevel.Slightly => "slightly worn",
|
||||
DecayLevel.Somewhat => "somewhat worn",
|
||||
_ => "in danger of collapsing"
|
||||
};
|
||||
|
||||
LabelTo(from, $"This house is {message}.");
|
||||
}
|
||||
|
||||
base.OnSingleClick(from);
|
||||
}
|
||||
|
||||
public void ShowSign(Mobile m)
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool RestrictDecay
|
||||
{
|
||||
get => Owner?.RestrictDecay == true;
|
||||
set
|
||||
{
|
||||
if (Owner != null)
|
||||
{
|
||||
if (Owner.IsFriend(m) && m.AccessLevel < AccessLevel.GameMaster)
|
||||
{
|
||||
if (Core.ML && Owner.IsOwner(m) || !Core.ML)
|
||||
{
|
||||
Owner.RefreshDecay();
|
||||
}
|
||||
|
||||
if (!Core.AOS)
|
||||
{
|
||||
m.SendLocalizedMessage(501293); // Welcome back to the house, friend!
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner.IsAosRules)
|
||||
{
|
||||
m.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Information, m, Owner));
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendGump(new HouseGump(m, Owner));
|
||||
}
|
||||
Owner.RestrictDecay = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClaimGump_Callback(Mobile from, bool okay)
|
||||
public int LabelNumber => 1061638; // A House Sign
|
||||
|
||||
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
|
||||
|
||||
public bool GettingProperties { get; private set; }
|
||||
|
||||
public string GetName() => Name ?? "An Unnamed House";
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (Owner?.Deleted == false)
|
||||
{
|
||||
if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||
Owner.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(IPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1061639, GetName().FixHtml()); // Name: ~1_NAME~
|
||||
list.Add(1061640, Owner?.Owner?.Name ?? "nobody"); // Owner: ~1_OWNER~
|
||||
|
||||
if (Owner != null)
|
||||
{
|
||||
list.Add(Owner.Public ? 1061641 : 1061642); // This House is Open to the Public : This is a Private Home
|
||||
|
||||
GettingProperties = true;
|
||||
var level = Owner.DecayLevel;
|
||||
GettingProperties = false;
|
||||
|
||||
if (level == DecayLevel.DemolitionPending)
|
||||
{
|
||||
var canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from);
|
||||
|
||||
if (canClaim && !BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
Owner.Owner = from;
|
||||
Owner.LastTraded = Core.Now;
|
||||
}
|
||||
list.Add(1062497); // Demolition Pending
|
||||
}
|
||||
else if (level != DecayLevel.Ageless)
|
||||
{
|
||||
if (level == DecayLevel.Collapsed)
|
||||
{
|
||||
level = DecayLevel.IDOC;
|
||||
}
|
||||
|
||||
ShowSign(from);
|
||||
list.AddLocalized(1062028, 1043009 + (int)level); // Condition: This structure is ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (BaseHouse.DecayEnabled && Owner != null && Owner.DecayPeriod != TimeSpan.Zero)
|
||||
{
|
||||
var message = Owner.DecayLevel switch
|
||||
{
|
||||
DecayLevel.Ageless => "ageless",
|
||||
DecayLevel.Fairly => "fairly worn",
|
||||
DecayLevel.Greatly => "greatly worn",
|
||||
DecayLevel.LikeNew => "like new",
|
||||
DecayLevel.Slightly => "slightly worn",
|
||||
DecayLevel.Somewhat => "somewhat worn",
|
||||
_ => "in danger of collapsing"
|
||||
};
|
||||
|
||||
LabelTo(from, $"This house is {message}.");
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
base.OnSingleClick(from);
|
||||
}
|
||||
|
||||
public void ShowSign(Mobile m)
|
||||
{
|
||||
if (Owner == null)
|
||||
{
|
||||
if (Owner == null)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Owner.IsFriend(m) && m.AccessLevel < AccessLevel.GameMaster)
|
||||
{
|
||||
if (Core.ML && Owner.IsOwner(m) || !Core.ML)
|
||||
{
|
||||
Owner.RefreshDecay();
|
||||
}
|
||||
|
||||
if (!Core.AOS)
|
||||
{
|
||||
m.SendLocalizedMessage(501293); // Welcome back to the house, friend!
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner.IsAosRules)
|
||||
{
|
||||
m.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Information, m, Owner));
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendGump(new HouseGump(m, Owner));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClaimGump_Callback(Mobile from, bool okay)
|
||||
{
|
||||
if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||
{
|
||||
var canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from);
|
||||
|
||||
if (canClaim && !BaseHouse.HasAccountHouse(from))
|
||||
{
|
||||
Owner.Owner = from;
|
||||
Owner.LastTraded = Core.Now;
|
||||
}
|
||||
}
|
||||
|
||||
ShowSign(from);
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (Owner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null &&
|
||||
Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||
{
|
||||
var canClaim = Owner.IsCoOwner(m) || Owner.IsFriend(m);
|
||||
|
||||
if (canClaim && !BaseHouse.HasAccountHouse(m))
|
||||
{
|
||||
m.SendGump(
|
||||
new ClaimHouseWarningGump(okay => ClaimGump_Callback(m, okay))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ShowSign(m);
|
||||
}
|
||||
|
||||
private class ClaimHouseWarningGump : StaticWarningGump<ClaimHouseWarningGump>
|
||||
{
|
||||
public override int Header => 501036; // Claim house
|
||||
public override int HeaderColor => 0x7F00;
|
||||
|
||||
/*
|
||||
* You do not currently own any house on any shard with this account, and this house currently does not have an owner.
|
||||
* If you wish, you may choose to claim this house and become its rightful owner.
|
||||
* If you do this, it will become your Primary house and automatically refresh.
|
||||
* If you claim this house, you will be unable to place another house or have another house transferred to you for the next 7 days.
|
||||
* Do you wish to claim this house?
|
||||
*/
|
||||
public override int StaticLocalizedContent => 1049719;
|
||||
|
||||
public override int Width => 420;
|
||||
public override int Height => 280;
|
||||
|
||||
public ClaimHouseWarningGump(Action<bool> callback) : base(callback)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
|
||||
if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Owner.AreThereAvailableVendorsFor(from))
|
||||
{
|
||||
list.Add(new VendorsEntry(this));
|
||||
}
|
||||
|
||||
if (Owner.VendorInventories.Count > 0)
|
||||
{
|
||||
list.Add(new ReclaimVendorInventoryEntry(this));
|
||||
}
|
||||
}
|
||||
|
||||
private class VendorsEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly HouseSign m_Sign;
|
||||
|
||||
public VendorsEntry(HouseSign sign) : base(6211) => m_Sign = sign;
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
var from = Owner.From;
|
||||
|
||||
if (!from.CheckAlive() || m_Sign.Deleted || m_Sign.Owner?.AreThereAvailableVendorsFor(from) != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null &&
|
||||
Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
||||
{
|
||||
var canClaim = Owner.IsCoOwner(m) || Owner.IsFriend(m);
|
||||
|
||||
if (canClaim && !BaseHouse.HasAccountHouse(m))
|
||||
{
|
||||
m.SendGump(
|
||||
new ClaimHouseWarningGump(okay => ClaimGump_Callback(m, okay))
|
||||
);
|
||||
}
|
||||
// You must be within five paces of the house sign to use this option.
|
||||
from.SendLocalizedMessage(1062429);
|
||||
}
|
||||
|
||||
ShowSign(m);
|
||||
}
|
||||
|
||||
private class ClaimHouseWarningGump : StaticWarningGump<ClaimHouseWarningGump>
|
||||
{
|
||||
public override int Header => 501036; // Claim house
|
||||
public override int HeaderColor => 0x7F00;
|
||||
|
||||
/*
|
||||
* You do not currently own any house on any shard with this account, and this house currently does not have an owner.
|
||||
* If you wish, you may choose to claim this house and become its rightful owner.
|
||||
* If you do this, it will become your Primary house and automatically refresh.
|
||||
* If you claim this house, you will be unable to place another house or have another house transferred to you for the next 7 days.
|
||||
* Do you wish to claim this house?
|
||||
*/
|
||||
public override int StaticLocalizedContent => 1049719;
|
||||
|
||||
public override int Width => 420;
|
||||
public override int Height => 280;
|
||||
|
||||
public ClaimHouseWarningGump(Action<bool> callback) : base(callback)
|
||||
else
|
||||
{
|
||||
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Vendors, from, m_Sign.Owner));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
private class ReclaimVendorInventoryEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly HouseSign m_Sign;
|
||||
|
||||
public ReclaimVendorInventoryEntry(HouseSign sign) : base(6213) => m_Sign = sign;
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
var from = Owner.From;
|
||||
|
||||
if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true)
|
||||
if (m_Sign.Deleted || m_Sign.Owner == null || m_Sign.Owner.VendorInventories.Count == 0 ||
|
||||
!from.CheckAlive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Owner.AreThereAvailableVendorsFor(from))
|
||||
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
||||
{
|
||||
list.Add(new VendorsEntry(this));
|
||||
// You must be within five paces of the house sign to use this option.
|
||||
from.SendLocalizedMessage(1062429);
|
||||
}
|
||||
|
||||
if (Owner.VendorInventories.Count > 0)
|
||||
else
|
||||
{
|
||||
list.Add(new ReclaimVendorInventoryEntry(this));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(Owner);
|
||||
writer.Write(OriginalOwner);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Owner = reader.ReadEntity<BaseHouse>();
|
||||
OriginalOwner = reader.ReadEntity<Mobile>();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Name == "a house sign")
|
||||
{
|
||||
Name = null;
|
||||
}
|
||||
}
|
||||
|
||||
private class VendorsEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly HouseSign m_Sign;
|
||||
|
||||
public VendorsEntry(HouseSign sign) : base(6211) => m_Sign = sign;
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
var from = Owner.From;
|
||||
|
||||
if (!from.CheckAlive() || m_Sign.Deleted || m_Sign.Owner?.AreThereAvailableVendorsFor(from) != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062429
|
||||
); // You must be within five paces of the house sign to use this option.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Vendors, from, m_Sign.Owner));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ReclaimVendorInventoryEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly HouseSign m_Sign;
|
||||
|
||||
public ReclaimVendorInventoryEntry(HouseSign sign) : base(6213) => m_Sign = sign;
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
var from = Owner.From;
|
||||
|
||||
if (m_Sign.Deleted || m_Sign.Owner == null || m_Sign.Owner.VendorInventories.Count == 0 ||
|
||||
!from.CheckAlive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1062429
|
||||
); // You must be within five paces of the house sign to use this option.
|
||||
}
|
||||
else
|
||||
{
|
||||
from.CloseGump<VendorInventoryGump>();
|
||||
from.SendGump(new VendorInventoryGump(m_Sign.Owner, from));
|
||||
}
|
||||
from.CloseGump<VendorInventoryGump>();
|
||||
from.SendGump(new VendorInventoryGump(m_Sign.Owner, from));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,198 +1,163 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Mobiles;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[SerializationGenerator(2, false)]
|
||||
public partial class HouseTeleporter : Item, ISecurable
|
||||
{
|
||||
public class HouseTeleporter : Item, ISecurable
|
||||
[SerializableField(0)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private SecureLevel _level;
|
||||
|
||||
[SerializableField(1)]
|
||||
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||
private Item _target;
|
||||
|
||||
public HouseTeleporter(int itemID, Item target = null) : base(itemID)
|
||||
{
|
||||
public HouseTeleporter(int itemID, Item target = null) : base(itemID)
|
||||
Movable = false;
|
||||
_level = SecureLevel.Anyone;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public bool CheckAccess(Mobile m)
|
||||
{
|
||||
var house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) &&
|
||||
house?.HasSecureAccess(m, Level) == true;
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (Target?.Deleted != false)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
Level = SecureLevel.Anyone;
|
||||
|
||||
Target = target;
|
||||
}
|
||||
|
||||
public HouseTeleporter(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Item Target { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public SecureLevel Level { get; set; }
|
||||
|
||||
public bool CheckAccess(Mobile m)
|
||||
{
|
||||
var house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) &&
|
||||
house?.HasSecureAccess(m, Level) == true;
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
if (Target?.Deleted == false)
|
||||
{
|
||||
if (CheckAccess(m))
|
||||
{
|
||||
if (!m.Hidden || m.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
new EffectTimer(Location, Map, 2023, 0x1F0, TimeSpan.FromSeconds(0.4)).Start();
|
||||
}
|
||||
|
||||
new DelayTimer(this, m).Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendLocalizedMessage(1061637); // You are not allowed to access this.
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
if (!CheckAccess(m))
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
SetSecureLevelEntry.AddTo(from, this, list);
|
||||
m.SendLocalizedMessage(1061637); // You are not allowed to access this.
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
if (!m.Hidden || m.AccessLevel == AccessLevel.Player)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
writer.Write((int)Level);
|
||||
|
||||
writer.Write(Target);
|
||||
new EffectTimer(Location, Map, 2023, 0x1F0, TimeSpan.FromSeconds(0.4)).Start();
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
new DelayTimer(this, m).Start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
SetSecureLevelEntry.AddTo(from, this, list);
|
||||
}
|
||||
|
||||
private void Deserialize(IGenericReader reader, int version)
|
||||
{
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
Target = reader.ReadEntity<Item>();
|
||||
}
|
||||
|
||||
private class EffectTimer : Timer
|
||||
{
|
||||
private readonly int _effectId;
|
||||
private readonly Point3D _location;
|
||||
private readonly Map _map;
|
||||
private readonly int _soundId;
|
||||
|
||||
public EffectTimer(Point3D p, Map map, int effectID, int soundID, TimeSpan delay) : base(delay)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Level = (SecureLevel)reader.ReadInt();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Target = reader.ReadEntity<Item>();
|
||||
|
||||
if (version < 1)
|
||||
{
|
||||
Level = SecureLevel.Anyone;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
_location = p;
|
||||
_map = map;
|
||||
_effectId = effectID;
|
||||
_soundId = soundID;
|
||||
}
|
||||
|
||||
private class EffectTimer : Timer
|
||||
protected override void OnTick()
|
||||
{
|
||||
private readonly int m_EffectID;
|
||||
private readonly Point3D m_Location;
|
||||
private readonly Map m_Map;
|
||||
private readonly int m_SoundID;
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(_location, _map, EffectItem.DefaultDuration),
|
||||
0x3728,
|
||||
10,
|
||||
10,
|
||||
_effectId,
|
||||
0
|
||||
);
|
||||
|
||||
public EffectTimer(Point3D p, Map map, int effectID, int soundID, TimeSpan delay) : base(delay)
|
||||
if (_soundId != -1)
|
||||
{
|
||||
m_Location = p;
|
||||
m_Map = map;
|
||||
m_EffectID = effectID;
|
||||
m_SoundID = soundID;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(m_Location, m_Map, EffectItem.DefaultDuration),
|
||||
0x3728,
|
||||
10,
|
||||
10,
|
||||
m_EffectID,
|
||||
0
|
||||
);
|
||||
|
||||
if (m_SoundID != -1)
|
||||
{
|
||||
Effects.PlaySound(m_Location, m_Map, m_SoundID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DelayTimer : Timer
|
||||
{
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly HouseTeleporter m_Teleporter;
|
||||
|
||||
public DelayTimer(HouseTeleporter tp, Mobile m) : base(TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
m_Teleporter = tp;
|
||||
m_Mobile = m;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
var target = m_Teleporter.Target;
|
||||
|
||||
if (target?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Mobile.Location != m_Teleporter.Location || m_Mobile.Map != m_Teleporter.Map)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var p = target.GetWorldTop();
|
||||
var map = target.Map;
|
||||
|
||||
BaseCreature.TeleportPets(m_Mobile, p, map);
|
||||
|
||||
m_Mobile.MoveToWorld(p, map);
|
||||
|
||||
if (m_Mobile.Hidden && m_Mobile.AccessLevel != AccessLevel.Player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Effects.PlaySound(target.Location, target.Map, 0x1FE);
|
||||
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(m_Teleporter.Location, m_Teleporter.Map, EffectItem.DefaultDuration),
|
||||
0x3728,
|
||||
10,
|
||||
10,
|
||||
2023,
|
||||
0
|
||||
);
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration),
|
||||
0x3728,
|
||||
10,
|
||||
10,
|
||||
5023,
|
||||
0
|
||||
);
|
||||
|
||||
new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start();
|
||||
Effects.PlaySound(_location, _map, _soundId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DelayTimer : Timer
|
||||
{
|
||||
private readonly Mobile _mobile;
|
||||
private readonly HouseTeleporter _teleporter;
|
||||
|
||||
public DelayTimer(HouseTeleporter tp, Mobile m) : base(TimeSpan.FromSeconds(1.0))
|
||||
{
|
||||
_teleporter = tp;
|
||||
_mobile = m;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
var target = _teleporter.Target;
|
||||
|
||||
if (target?.Deleted != false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_mobile.Location != _teleporter.Location || _mobile.Map != _teleporter.Map)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var p = target.GetWorldTop();
|
||||
var map = target.Map;
|
||||
|
||||
BaseCreature.TeleportPets(_mobile, p, map);
|
||||
|
||||
_mobile.MoveToWorld(p, map);
|
||||
|
||||
if (_mobile.Hidden && _mobile.AccessLevel != AccessLevel.Player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Effects.PlaySound(target.Location, target.Map, 0x1FE);
|
||||
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(_teleporter.Location, _teleporter.Map, EffectItem.DefaultDuration),
|
||||
0x3728,
|
||||
10,
|
||||
10,
|
||||
2023,
|
||||
0
|
||||
);
|
||||
Effects.SendLocationParticles(
|
||||
EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration),
|
||||
0x3728,
|
||||
10,
|
||||
10,
|
||||
5023,
|
||||
0
|
||||
);
|
||||
|
||||
new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue