fix: Moves ContextMenu out of core, streamlines code, fixes bugs (#1873)
## Summary - Removes allocation of a `List<ContextMenuEntry>` every time a context menu is created. - Moves packet/context menu creation logic out of the core - Fixes tame entry ## BREAKING CHANGE > [!Important] > **Developer Note** > ```cs > public virtual void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list) > ``` > and similar functions changed to > ```cs > public virtual void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list) > ```
This commit is contained in:
parent
bb24b330e1
commit
f58117a877
88 changed files with 1206 additions and 1483 deletions
|
|
@ -160,40 +160,44 @@ public abstract class BaseAI
|
|||
return name != null && speech.InsensitiveStartsWith(name);
|
||||
}
|
||||
|
||||
public virtual void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public virtual void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from.Alive && m_Mobile.Controlled && from.InRange(m_Mobile, 14))
|
||||
if (!from.Alive || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14))
|
||||
{
|
||||
if (from == m_Mobile.ControlMaster)
|
||||
return;
|
||||
}
|
||||
|
||||
var isDeadPet = m_Mobile.IsDeadPet;
|
||||
|
||||
if (from == m_Mobile.ControlMaster)
|
||||
{
|
||||
list.Add(new InternalEntry(6107, 14, OrderType.Guard, !isDeadPet)); // Command: Guard
|
||||
list.Add(new InternalEntry(6108, 14, OrderType.Follow, true)); // Command: Follow
|
||||
|
||||
if (m_Mobile.CanDrop)
|
||||
{
|
||||
list.Add(new InternalEntry(from, 6107, 14, m_Mobile, this, OrderType.Guard)); // Command: Guard
|
||||
list.Add(new InternalEntry(from, 6108, 14, m_Mobile, this, OrderType.Follow)); // Command: Follow
|
||||
|
||||
if (m_Mobile.CanDrop)
|
||||
{
|
||||
list.Add(new InternalEntry(from, 6109, 14, m_Mobile, this, OrderType.Drop)); // Command: Drop
|
||||
}
|
||||
|
||||
list.Add(new InternalEntry(from, 6111, 14, m_Mobile, this, OrderType.Attack)); // Command: Kill
|
||||
|
||||
list.Add(new InternalEntry(from, 6112, 14, m_Mobile, this, OrderType.Stop)); // Command: Stop
|
||||
list.Add(new InternalEntry(from, 6114, 14, m_Mobile, this, OrderType.Stay)); // Command: Stay
|
||||
|
||||
if (!m_Mobile.Summoned && m_Mobile is not GrizzledMare)
|
||||
{
|
||||
list.Add(new InternalEntry(from, 6110, 14, m_Mobile, this, OrderType.Friend)); // Add Friend
|
||||
list.Add(new InternalEntry(from, 6099, 14, m_Mobile, this, OrderType.Unfriend)); // Remove Friend
|
||||
list.Add(new InternalEntry(from, 6113, 14, m_Mobile, this, OrderType.Transfer)); // Transfer
|
||||
}
|
||||
|
||||
list.Add(new InternalEntry(from, 6118, 14, m_Mobile, this, OrderType.Release)); // Release
|
||||
list.Add(new InternalEntry(6109, 14, OrderType.Drop, !isDeadPet)); // Command: Drop
|
||||
}
|
||||
else if (m_Mobile.IsPetFriend(from))
|
||||
|
||||
list.Add(new InternalEntry(6111, 14, OrderType.Attack, !isDeadPet)); // Command: Kill
|
||||
|
||||
list.Add(new InternalEntry(6112, 14, OrderType.Stop, true)); // Command: Stop
|
||||
list.Add(new InternalEntry(6114, 14, OrderType.Stay, true)); // Command: Stay
|
||||
|
||||
if (!m_Mobile.Summoned && m_Mobile is not GrizzledMare)
|
||||
{
|
||||
list.Add(new InternalEntry(from, 6108, 14, m_Mobile, this, OrderType.Follow)); // Command: Follow
|
||||
list.Add(new InternalEntry(from, 6112, 14, m_Mobile, this, OrderType.Stop)); // Command: Stop
|
||||
list.Add(new InternalEntry(from, 6114, 14, m_Mobile, this, OrderType.Stay)); // Command: Stay
|
||||
list.Add(new InternalEntry(6110, 14, OrderType.Friend, true)); // Add Friend
|
||||
list.Add(new InternalEntry(6099, 14, OrderType.Unfriend, true)); // Remove Friend
|
||||
list.Add(new InternalEntry(6113, 14, OrderType.Transfer, !isDeadPet)); // Transfer
|
||||
}
|
||||
|
||||
list.Add(new InternalEntry(6118, 14, OrderType.Release, true)); // Release
|
||||
}
|
||||
else if (m_Mobile.IsPetFriend(from))
|
||||
{
|
||||
list.Add(new InternalEntry(6108, 14, OrderType.Follow, true)); // Command: Follow
|
||||
list.Add(new InternalEntry(6112, 14, OrderType.Stop, !isDeadPet)); // Command: Stop
|
||||
list.Add(new InternalEntry(6114, 14, OrderType.Stay, true)); // Command: Stay
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2910,51 +2914,41 @@ public abstract class BaseAI
|
|||
|
||||
private class InternalEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseAI m_AI;
|
||||
private readonly Mobile m_From;
|
||||
private readonly BaseCreature m_Mobile;
|
||||
private readonly OrderType m_Order;
|
||||
private readonly OrderType _order;
|
||||
|
||||
public InternalEntry(Mobile from, int number, int range, BaseCreature mobile, BaseAI ai, OrderType order)
|
||||
: base(number, range)
|
||||
public InternalEntry(int number, int range, OrderType order, bool enabled) : base(number, range)
|
||||
{
|
||||
m_From = from;
|
||||
m_Mobile = mobile;
|
||||
m_AI = ai;
|
||||
m_Order = order;
|
||||
|
||||
if (mobile.IsDeadPet && order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop)
|
||||
{
|
||||
Enabled = false;
|
||||
}
|
||||
_order = order;
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (m_Mobile.Deleted || !m_Mobile.Controlled || !m_From.CheckAlive())
|
||||
if (!from.CheckAlive() || target is not BaseCreature { Deleted: not true, Controlled: true } bc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Mobile.IsDeadPet && m_Order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop)
|
||||
// Just in case
|
||||
if (bc.IsDeadPet && _order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var isOwner = m_From == m_Mobile.ControlMaster;
|
||||
var isFriend = !isOwner && m_Mobile.IsPetFriend(m_From);
|
||||
var isOwner = from == bc.ControlMaster;
|
||||
var isFriend = !isOwner && bc.IsPetFriend(from);
|
||||
|
||||
if (!isOwner && !isFriend)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFriend && m_Order != OrderType.Follow && m_Order != OrderType.Stay && m_Order != OrderType.Stop)
|
||||
if (isFriend && _order != OrderType.Follow && _order != OrderType.Stay && _order != OrderType.Stop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (m_Order)
|
||||
switch (_order)
|
||||
{
|
||||
case OrderType.Follow:
|
||||
case OrderType.Attack:
|
||||
|
|
@ -2962,37 +2956,37 @@ public abstract class BaseAI
|
|||
case OrderType.Friend:
|
||||
case OrderType.Unfriend:
|
||||
{
|
||||
if (m_Order == OrderType.Transfer && m_From.HasTrade)
|
||||
if (_order == OrderType.Transfer && from.HasTrade)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending
|
||||
from.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending
|
||||
}
|
||||
else if (m_Order == OrderType.Friend && m_From.HasTrade)
|
||||
else if (_order == OrderType.Friend && from.HasTrade)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending
|
||||
from.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AI.BeginPickTarget(m_From, m_Order);
|
||||
bc.AIObject.BeginPickTarget(from, _order);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case OrderType.Release:
|
||||
{
|
||||
if (m_Mobile.Summoned)
|
||||
if (bc.Summoned)
|
||||
{
|
||||
goto default;
|
||||
}
|
||||
|
||||
m_From.SendGump(new ConfirmReleaseGump(m_From, m_Mobile));
|
||||
from.SendGump(new ConfirmReleaseGump(from, bc));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (m_Mobile.CheckControlChance(m_From))
|
||||
if (bc.CheckControlChance(from))
|
||||
{
|
||||
m_Mobile.ControlOrder = m_Order;
|
||||
bc.ControlOrder = _order;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using ModernUO.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -103,43 +103,34 @@ namespace Server.Mobiles
|
|||
PackAnimal.TryPackOpen(this, from);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
PackAnimal.GetContextMenuEntries(this, from, list);
|
||||
PackAnimal.GetContextMenuEntries(this, from, ref list);
|
||||
}
|
||||
}
|
||||
|
||||
public class PackAnimalBackpackEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseCreature m_Animal;
|
||||
private readonly Mobile m_From;
|
||||
public PackAnimalBackpackEntry(bool enabled) : base(6145, 3) => Enabled = enabled;
|
||||
|
||||
public PackAnimalBackpackEntry(BaseCreature animal, Mobile from) : base(6145, 3)
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Animal = animal;
|
||||
m_From = from;
|
||||
|
||||
if (animal.IsDeadPet)
|
||||
if (target is BaseCreature bc)
|
||||
{
|
||||
Enabled = false;
|
||||
PackAnimal.TryPackOpen(bc, from);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
PackAnimal.TryPackOpen(m_Animal, m_From);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PackAnimal
|
||||
{
|
||||
public static void GetContextMenuEntries(BaseCreature animal, Mobile from, List<ContextMenuEntry> list)
|
||||
public static void GetContextMenuEntries(BaseCreature animal, Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (CheckAccess(animal, from))
|
||||
{
|
||||
list.Add(new PackAnimalBackpackEntry(animal, from));
|
||||
list.Add(new PackAnimalBackpackEntry(!animal.IsDeadPet));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using ModernUO.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -110,11 +110,11 @@ namespace Server.Mobiles
|
|||
PackAnimal.TryPackOpen(this, from);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
PackAnimal.GetContextMenuEntries(this, from, list);
|
||||
PackAnimal.GetContextMenuEntries(this, from, ref list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using ModernUO.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -129,11 +129,11 @@ namespace Server.Mobiles
|
|||
|
||||
public override bool CheckNonlocalLift(Mobile from, Item item) => PackAnimal.CheckAccess(this, from);
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
PackAnimal.GetContextMenuEntries(this, from, list);
|
||||
PackAnimal.GetContextMenuEntries(this, from, ref list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2546,25 +2546,25 @@ namespace Server.Mobiles
|
|||
return base.OnMoveOver(m);
|
||||
}
|
||||
|
||||
public virtual void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public virtual void AddCustomContextEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
if (Commandable)
|
||||
{
|
||||
AIObject?.GetContextMenuEntries(from, list);
|
||||
AIObject?.GetContextMenuEntries(from, ref list);
|
||||
}
|
||||
|
||||
if (m_bTamable && !m_Controlled && from.Alive)
|
||||
{
|
||||
list.Add(new TameEntry(from, this));
|
||||
list.Add(new TameEntry(from.Female ? AllowFemaleTamer : AllowMaleTamer));
|
||||
}
|
||||
|
||||
AddCustomContextEntries(from, list);
|
||||
AddCustomContextEntries(from, ref list);
|
||||
|
||||
if (CanTeach && from.Alive)
|
||||
{
|
||||
|
|
@ -2585,7 +2585,7 @@ namespace Server.Mobiles
|
|||
toTeach = 420;
|
||||
}
|
||||
|
||||
list.Add(new TeachEntry((SkillName)i, this, from, toTeach > theirSkill.BaseFixedPoint));
|
||||
list.Add(new TeachEntry((SkillName)i, toTeach > theirSkill.BaseFixedPoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5505,32 +5505,25 @@ namespace Server.Mobiles
|
|||
|
||||
private class TameEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseCreature m_Mobile;
|
||||
public TameEntry(bool enabled) : base(6130, 6) => Enabled = enabled;
|
||||
|
||||
public TameEntry(Mobile from, BaseCreature creature) : base(6130, 6)
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Mobile = creature;
|
||||
|
||||
Enabled = Enabled && (from.Female ? creature.AllowFemaleTamer : creature.AllowMaleTamer);
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
if (!Owner.From.CheckAlive())
|
||||
if (!from.CheckAlive() || target is not BaseCreature bc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Owner.From.TargetLocked = true;
|
||||
from.TargetLocked = true;
|
||||
AnimalTaming.DisableMessage = true;
|
||||
|
||||
if (Owner.From.UseSkill(SkillName.AnimalTaming))
|
||||
if (from.UseSkill(SkillName.AnimalTaming))
|
||||
{
|
||||
Owner.From.Target.Invoke(Owner.From, m_Mobile);
|
||||
from.Target.Invoke(from, bc);
|
||||
}
|
||||
|
||||
AnimalTaming.DisableMessage = false;
|
||||
Owner.From.TargetLocked = false;
|
||||
from.TargetLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -108,13 +109,13 @@ public abstract partial class BaseFamiliar : BaseCreature
|
|||
}
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
if (from.Alive && Controlled && from == ControlMaster && from.InRange(this, 14))
|
||||
{
|
||||
list.Add(new ReleaseEntry(from, this));
|
||||
list.Add(new ReleaseEntry());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,21 +171,16 @@ public abstract partial class BaseFamiliar : BaseCreature
|
|||
|
||||
private class ReleaseEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseFamiliar m_Familiar;
|
||||
private readonly Mobile m_From;
|
||||
|
||||
public ReleaseEntry(Mobile from, BaseFamiliar familiar) : base(6118, 14)
|
||||
public ReleaseEntry() : base(6118, 14)
|
||||
{
|
||||
m_From = from;
|
||||
m_Familiar = familiar;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (!m_Familiar.Deleted && m_Familiar.Controlled && m_From == m_Familiar.ControlMaster &&
|
||||
m_From.CheckAlive())
|
||||
if (from.CheckAlive() && target is BaseFamiliar { Deleted: false, Controlled: true } familiar &&
|
||||
from == familiar.ControlMaster)
|
||||
{
|
||||
m_Familiar.BeginRelease(m_From);
|
||||
familiar.BeginRelease(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
|
|
@ -179,11 +178,11 @@ public partial class HordeMinionFamiliar : BaseFamiliar
|
|||
PackAnimal.TryPackOpen(this, from);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
PackAnimal.GetContextMenuEntries(this, from, list);
|
||||
PackAnimal.GetContextMenuEntries(this, from, ref list);
|
||||
}
|
||||
|
||||
private class ReleaseFamiliarWarningGump : StaticWarningGump<ReleaseFamiliarWarningGump>
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ public partial class BaseHire : BaseCreature
|
|||
base.OnSpeech(e);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (Deleted)
|
||||
{
|
||||
|
|
@ -230,14 +230,14 @@ public partial class BaseHire : BaseCreature
|
|||
{
|
||||
if (CanPaperdollBeOpenedBy(from))
|
||||
{
|
||||
list.Add(new PaperdollEntry(this));
|
||||
list.Add(new PaperdollEntry());
|
||||
}
|
||||
|
||||
list.Add(new HireEntry(this));
|
||||
list.Add(new HireEntry());
|
||||
}
|
||||
else
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -309,13 +309,13 @@ public partial class BaseHire : BaseCreature
|
|||
|
||||
public class HireEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseHire _hire;
|
||||
|
||||
public HireEntry(BaseHire hire) : base(6120, 3) => _hire = hire;
|
||||
|
||||
public override void OnClick()
|
||||
public HireEntry() : base(6120, 3)
|
||||
{
|
||||
_hire.SayHireCost();
|
||||
}
|
||||
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
(target as BaseHire)?.SayHireCost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using ModernUO.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.Quests.Haven;
|
||||
|
||||
|
|
@ -56,9 +56,9 @@ namespace Server.Mobiles
|
|||
{
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using ModernUO.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Mobiles
|
||||
|
|
@ -85,9 +85,9 @@ namespace Server.Mobiles
|
|||
{
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1855,13 +1855,18 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
if (from == this)
|
||||
{
|
||||
Quest?.GetContextMenuEntries(list);
|
||||
if (Alive && Backpack != null && CanSee(Backpack))
|
||||
{
|
||||
list.Add(new OpenBackpackEntry());
|
||||
}
|
||||
|
||||
Quest?.GetContextMenuEntries(ref list);
|
||||
|
||||
if (Alive)
|
||||
{
|
||||
|
|
@ -1945,17 +1950,17 @@ namespace Server.Mobiles
|
|||
|
||||
if (theirParty == null && ourParty == null)
|
||||
{
|
||||
list.Add(new AddToPartyEntry(from, this));
|
||||
list.Add(new AddToPartyEntry());
|
||||
}
|
||||
else if (theirParty != null && theirParty.Leader == from)
|
||||
{
|
||||
if (ourParty == null)
|
||||
{
|
||||
list.Add(new AddToPartyEntry(from, this));
|
||||
list.Add(new AddToPartyEntry());
|
||||
}
|
||||
else if (ourParty == theirParty)
|
||||
{
|
||||
list.Add(new RemoveFromPartyEntry(from, this));
|
||||
list.Add(new RemoveFromPartyEntry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1965,7 +1970,7 @@ namespace Server.Mobiles
|
|||
if (curhouse != null && Alive && Core.Expansion >= Expansion.AOS && curhouse.IsAosRules &&
|
||||
curhouse.IsFriend(from))
|
||||
{
|
||||
list.Add(new EjectPlayerEntry(from, this));
|
||||
list.Add(new EjectPlayerEntry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4649,7 +4654,7 @@ namespace Server.Mobiles
|
|||
public CallbackEntry(int number, int range, ContextCallback callback) : base(number, range) =>
|
||||
m_Callback = callback;
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Callback?.Invoke();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public partial class Banker : BaseVendor
|
|||
}
|
||||
|
||||
checks = PooledRefList<BankCheck>.Create();
|
||||
|
||||
|
||||
foreach (var bc in bank.FindItemsByType<BankCheck>())
|
||||
{
|
||||
balance += bc.Worth;
|
||||
|
|
@ -507,13 +507,13 @@ public partial class Banker : BaseVendor
|
|||
base.OnSpeech(e);
|
||||
}
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void AddCustomContextEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from.Alive)
|
||||
{
|
||||
list.Add(new OpenBankEntry(this));
|
||||
list.Add(new OpenBankEntry());
|
||||
}
|
||||
|
||||
base.AddCustomContextEntries(from, list);
|
||||
base.AddCustomContextEntries(from, ref list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Buffers;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.MLQuests;
|
||||
using Server.Engines.MLQuests.Definitions;
|
||||
|
|
@ -738,7 +739,7 @@ public partial class BaseEscortable : BaseCreature
|
|||
|
||||
public override bool CanBeRenamedBy(Mobile from) => from.AccessLevel >= AccessLevel.GameMaster;
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void AddCustomContextEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from.Alive)
|
||||
{
|
||||
|
|
@ -748,22 +749,22 @@ public partial class BaseEscortable : BaseCreature
|
|||
{
|
||||
if (escorter == null || escorter == from)
|
||||
{
|
||||
list.Add(new AskDestinationEntry(this, from));
|
||||
list.Add(new AskDestinationEntry());
|
||||
}
|
||||
|
||||
if (escorter == null)
|
||||
{
|
||||
list.Add(new AcceptEscortEntry(this, from));
|
||||
list.Add(new AcceptEscortEntry());
|
||||
}
|
||||
}
|
||||
|
||||
if (escorter == from)
|
||||
{
|
||||
list.Add(new AbandonEscortEntry(this));
|
||||
list.Add(new AbandonEscortEntry());
|
||||
}
|
||||
}
|
||||
|
||||
base.AddCustomContextEntries(from, list);
|
||||
base.AddCustomContextEntries(from, ref list);
|
||||
}
|
||||
|
||||
public virtual string[] GetPossibleDestinations() => Core.ML ? MlTownNames : TownNames;
|
||||
|
|
@ -901,46 +902,36 @@ public class EscortDestinationInfo
|
|||
|
||||
public class AskDestinationEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Mobile _from;
|
||||
private readonly BaseEscortable _mobile;
|
||||
|
||||
public AskDestinationEntry(BaseEscortable m, Mobile from) : base(6100, 3)
|
||||
public AskDestinationEntry() : base(6100, 3)
|
||||
{
|
||||
_mobile = m;
|
||||
_from = from;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
_mobile.SayDestinationTo(_from);
|
||||
(target as BaseEscortable)?.SayDestinationTo(from);
|
||||
}
|
||||
}
|
||||
|
||||
public class AcceptEscortEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Mobile _from;
|
||||
private readonly BaseEscortable _mobile;
|
||||
|
||||
public AcceptEscortEntry(BaseEscortable m, Mobile from) : base(6101, 3)
|
||||
public AcceptEscortEntry() : base(6101, 3)
|
||||
{
|
||||
_mobile = m;
|
||||
_from = from;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
_mobile.AcceptEscorter(_from);
|
||||
(target as BaseEscortable)?.AcceptEscorter(from);
|
||||
}
|
||||
}
|
||||
|
||||
public class AbandonEscortEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseEscortable _mobile;
|
||||
|
||||
public AbandonEscortEntry(BaseEscortable m) : base(6102, 3) => _mobile = m;
|
||||
|
||||
public override void OnClick()
|
||||
public AbandonEscortEntry() : base(6102, 3)
|
||||
{
|
||||
_mobile.Delete(); // OSI just seems to delete instantly
|
||||
}
|
||||
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
(target as BaseEscortable)?.Delete(); // OSI just seems to delete instantly
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1398,27 +1398,27 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void AddCustomContextEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from.Alive && IsActiveVendor)
|
||||
{
|
||||
if (SupportsBulkOrders(from))
|
||||
{
|
||||
list.Add(new BulkOrderInfoEntry(from, this));
|
||||
list.Add(new BulkOrderInfoEntry());
|
||||
}
|
||||
|
||||
if (IsActiveSeller)
|
||||
{
|
||||
list.Add(new VendorBuyEntry(from, this));
|
||||
list.Add(new VendorBuyEntry(CheckVendorAccess(from)));
|
||||
}
|
||||
|
||||
if (IsActiveBuyer)
|
||||
{
|
||||
list.Add(new VendorSellEntry(from, this));
|
||||
list.Add(new VendorSellEntry(CheckVendorAccess(from)));
|
||||
}
|
||||
}
|
||||
|
||||
base.AddCustomContextEntries(from, list);
|
||||
base.AddCustomContextEntries(from, ref list);
|
||||
}
|
||||
|
||||
public virtual IShopSellInfo[] GetSellInfo() => _sellInfo.ToArray();
|
||||
|
|
@ -1439,63 +1439,57 @@ namespace Server.Mobiles
|
|||
|
||||
private class BulkOrderInfoEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly BaseVendor m_Vendor;
|
||||
|
||||
public BulkOrderInfoEntry(Mobile from, BaseVendor vendor)
|
||||
: base(6152)
|
||||
public BulkOrderInfoEntry() : base(6152)
|
||||
{
|
||||
m_From = from;
|
||||
m_Vendor = vendor;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (!m_Vendor.SupportsBulkOrders(m_From))
|
||||
if (target is not BaseVendor vendor || !vendor.SupportsBulkOrders(from))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ts = m_Vendor.GetNextBulkOrder(m_From);
|
||||
var ts = vendor.GetNextBulkOrder(from);
|
||||
|
||||
var totalSeconds = ts.TotalSeconds;
|
||||
|
||||
// Let them get a bulk order if they are within 1 second.
|
||||
if (totalSeconds < 1)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1049038); // You can get an order now.
|
||||
from.SendLocalizedMessage(1049038); // You can get an order now.
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
var bulkOrder = m_Vendor.CreateBulkOrder(m_From, true);
|
||||
var bulkOrder = vendor.CreateBulkOrder(from, true);
|
||||
|
||||
if (bulkOrder is LargeBOD bod)
|
||||
{
|
||||
m_From.SendGump(new LargeBODAcceptGump(m_From, bod));
|
||||
from.SendGump(new LargeBODAcceptGump(from, bod));
|
||||
}
|
||||
else if (bulkOrder is SmallBOD smallBod)
|
||||
{
|
||||
m_From.SendGump(new SmallBODAcceptGump(m_From, smallBod));
|
||||
from.SendGump(new SmallBODAcceptGump(from, smallBod));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldSpeechHue = m_Vendor.SpeechHue;
|
||||
m_Vendor.SpeechHue = 0x3B2;
|
||||
var oldSpeechHue = vendor.SpeechHue;
|
||||
vendor.SpeechHue = 0x3B2;
|
||||
|
||||
if (Core.SE)
|
||||
{
|
||||
// An offer may be available in about ~1_minutes~ minutes.
|
||||
m_Vendor.SayTo(m_From, 1072058, $"{Math.Ceiling(totalSeconds / 60):F0}");
|
||||
vendor.SayTo(from, 1072058, $"{Math.Ceiling(totalSeconds / 60):F0}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// An offer may be available in about ~1_hours~ hours.
|
||||
m_Vendor.SayTo(m_From, 1049039, $"{Math.Ceiling(totalSeconds / 3600):F0}");
|
||||
vendor.SayTo(vendor, 1049039, $"{Math.Ceiling(totalSeconds / 3600):F0}");
|
||||
}
|
||||
|
||||
m_Vendor.SpeechHue = oldSpeechHue;
|
||||
vendor.SpeechHue = oldSpeechHue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1506,35 +1500,21 @@ namespace Server.ContextMenus
|
|||
{
|
||||
public class VendorBuyEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseVendor m_Vendor;
|
||||
public VendorBuyEntry(bool enabled) : base(6103, 8) => Enabled = enabled;
|
||||
|
||||
public VendorBuyEntry(Mobile from, BaseVendor vendor)
|
||||
: base(6103, 8)
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
Enabled = vendor.CheckVendorAccess(from);
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
m_Vendor.VendorBuy(Owner.From);
|
||||
(target as BaseVendor)?.VendorBuy(from);
|
||||
}
|
||||
}
|
||||
|
||||
public class VendorSellEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly BaseVendor m_Vendor;
|
||||
public VendorSellEntry(bool enabled) : base(6104, 8) => Enabled = enabled;
|
||||
|
||||
public VendorSellEntry(Mobile from, BaseVendor vendor)
|
||||
: base(6104, 8)
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Vendor = vendor;
|
||||
Enabled = vendor.CheckVendorAccess(from);
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
m_Vendor.VendorSell(Owner.From);
|
||||
(target as BaseVendor)?.VendorSell(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,19 +40,19 @@ namespace Server.Mobiles
|
|||
AddItem(Utility.RandomBool() ? new QuarterStaff() : new ShepherdsCrook());
|
||||
}
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void AddCustomContextEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from is PlayerMobile { Alive: true } pm)
|
||||
{
|
||||
list.Add(new StableEntry(this, from));
|
||||
list.Add(new StableEntry());
|
||||
|
||||
if (pm.Stabled?.Count > 0)
|
||||
{
|
||||
list.Add(new ClaimAllEntry(this, from));
|
||||
list.Add(new ClaimAllEntry());
|
||||
}
|
||||
}
|
||||
|
||||
base.AddCustomContextEntries(from, list);
|
||||
base.AddCustomContextEntries(from, ref list);
|
||||
}
|
||||
|
||||
public static int GetMaxStabled(Mobile from)
|
||||
|
|
@ -411,18 +411,13 @@ namespace Server.Mobiles
|
|||
|
||||
private class StableEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly AnimalTrainer m_Trainer;
|
||||
|
||||
public StableEntry(AnimalTrainer trainer, Mobile from) : base(6126, 12)
|
||||
public StableEntry() : base(6126, 12)
|
||||
{
|
||||
m_Trainer = trainer;
|
||||
m_From = from;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Trainer.BeginStable(m_From);
|
||||
(target as AnimalTrainer)?.BeginStable(from);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -474,18 +469,13 @@ namespace Server.Mobiles
|
|||
|
||||
private class ClaimAllEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly AnimalTrainer m_Trainer;
|
||||
|
||||
public ClaimAllEntry(AnimalTrainer trainer, Mobile from) : base(6127, 12)
|
||||
public ClaimAllEntry() : base(6127, 12)
|
||||
{
|
||||
m_Trainer = trainer;
|
||||
m_From = from;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Trainer.Claim(m_From);
|
||||
(target as AnimalTrainer)?.Claim(from);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using ModernUO.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -18,11 +18,11 @@ namespace Server.Mobiles
|
|||
|
||||
public override NpcGuild NpcGuild => NpcGuild.TinkersGuild;
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void AddCustomContextEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (Core.ML && from.Alive)
|
||||
{
|
||||
var entry = new RechargeEntry(from, this);
|
||||
var entry = new RechargeEntry();
|
||||
|
||||
if (WeaponEngravingTool.Find(from) == null)
|
||||
{
|
||||
|
|
@ -32,45 +32,38 @@ namespace Server.Mobiles
|
|||
list.Add(entry);
|
||||
}
|
||||
|
||||
base.AddCustomContextEntries(from, list);
|
||||
base.AddCustomContextEntries(from, ref list);
|
||||
}
|
||||
|
||||
private class RechargeEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Mobile m_From;
|
||||
private readonly Mobile m_Vendor;
|
||||
|
||||
public RechargeEntry(Mobile from, Mobile vendor) : base(6271, 6)
|
||||
public RechargeEntry() : base(6271, 6)
|
||||
{
|
||||
m_From = from;
|
||||
m_Vendor = vendor;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (!Core.ML || m_Vendor?.Deleted != false)
|
||||
if (!Core.ML || target is not Mobile vendor || vendor.Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tool = WeaponEngravingTool.Find(m_From);
|
||||
var tool = WeaponEngravingTool.Find(from);
|
||||
|
||||
if (tool?.UsesRemaining <= 0)
|
||||
if (!(tool?.UsesRemaining <= 0))
|
||||
{
|
||||
if (Banker.GetBalance(m_From) >= 100000)
|
||||
{
|
||||
m_From.SendGump(new WeaponEngravingTool.ConfirmGump(tool, m_Vendor));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Vendor.Say(1076167); // You need a 100,000 gold and a blue diamond to recharge the weapon engraver.
|
||||
}
|
||||
// I can only help with this if you are carrying an engraving tool that needs repair.
|
||||
vendor.Say(1076164);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Banker.GetBalance(from) >= 100000)
|
||||
{
|
||||
from.SendGump(new WeaponEngravingTool.ConfirmGump(tool, vendor));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Vendor.Say(
|
||||
1076164
|
||||
); // I can only help with this if you are carrying an engraving tool that needs repair.
|
||||
vendor.Say(1076167); // You need a 100,000 gold and a blue diamond to recharge the weapon engraver.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
|
@ -124,18 +125,13 @@ namespace Server.Mobiles
|
|||
|
||||
public class ManageBarkeeperEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly PlayerBarkeeper m_Barkeeper;
|
||||
private readonly Mobile m_From;
|
||||
|
||||
public ManageBarkeeperEntry(Mobile from, PlayerBarkeeper barkeeper) : base(6151, 12)
|
||||
public ManageBarkeeperEntry() : base(6151, 12)
|
||||
{
|
||||
m_From = from;
|
||||
m_Barkeeper = barkeeper;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
m_Barkeeper.BeginManagement(m_From);
|
||||
(target as PlayerBarkeeper)?.BeginManagement(from);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -372,13 +368,13 @@ namespace Server.Mobiles
|
|||
return Owner == from;
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
|
||||
if (IsOwner(from) && from.InLOS(this))
|
||||
{
|
||||
list.Add(new ManageBarkeeperEntry(from, this));
|
||||
list.Add(new ManageBarkeeperEntry());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.BulkOrders;
|
||||
using Server.Gumps;
|
||||
|
|
@ -869,14 +870,14 @@ public partial class PlayerVendor : Mobile
|
|||
Placeholder?.Delete();
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from.Alive && Placeholder != null && IsOwner(from))
|
||||
{
|
||||
list.Add(new ReturnVendorEntry(this));
|
||||
list.Add(new ReturnVendorEntry());
|
||||
}
|
||||
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
}
|
||||
|
||||
public override bool HandlesOnSpeech(Mobile from) => from.Alive && from.GetDistanceToSqrt(this) <= 3;
|
||||
|
|
@ -978,17 +979,15 @@ public partial class PlayerVendor : Mobile
|
|||
|
||||
private class ReturnVendorEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly PlayerVendor m_Vendor;
|
||||
|
||||
public ReturnVendorEntry(PlayerVendor vendor) : base(6214) => m_Vendor = vendor;
|
||||
|
||||
public override void OnClick()
|
||||
public ReturnVendorEntry() : base(6214)
|
||||
{
|
||||
var from = Owner.From;
|
||||
}
|
||||
|
||||
if (!m_Vendor.Deleted && m_Vendor.IsOwner(from) && from.CheckAlive())
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (from.CheckAlive() && target is PlayerVendor { Deleted: false } vendor && vendor.IsOwner(from))
|
||||
{
|
||||
m_Vendor.Return();
|
||||
vendor.Return();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Gumps;
|
||||
using Server.Misc;
|
||||
|
|
@ -155,27 +155,27 @@ public partial class RentedVendor : PlayerVendor
|
|||
base.Destroy(toBackpack);
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
public override void GetContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list)
|
||||
{
|
||||
if (from.Alive)
|
||||
{
|
||||
if (IsOwner(from))
|
||||
{
|
||||
list.Add(new ContractOptionsEntry(this));
|
||||
list.Add(new ContractOptionsEntry());
|
||||
}
|
||||
else if (IsLandlord(from))
|
||||
{
|
||||
if (RentalGold > 0)
|
||||
{
|
||||
list.Add(new CollectRentEntry(this));
|
||||
list.Add(new CollectRentEntry());
|
||||
}
|
||||
|
||||
list.Add(new TerminateContractEntry(this));
|
||||
list.Add(new ContractOptionsEntry(this));
|
||||
list.Add(new TerminateContractEntry());
|
||||
list.Add(new ContractOptionsEntry());
|
||||
}
|
||||
}
|
||||
|
||||
base.GetContextMenuEntries(from, list);
|
||||
base.GetContextMenuEntries(from, ref list);
|
||||
}
|
||||
|
||||
[AfterDeserialization]
|
||||
|
|
@ -190,65 +190,59 @@ public partial class RentedVendor : PlayerVendor
|
|||
|
||||
private class ContractOptionsEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly RentedVendor m_Vendor;
|
||||
|
||||
public ContractOptionsEntry(RentedVendor vendor) : base(6209) => m_Vendor = vendor;
|
||||
|
||||
public override void OnClick()
|
||||
public ContractOptionsEntry() : base(6209)
|
||||
{
|
||||
var from = Owner.From;
|
||||
}
|
||||
|
||||
if (m_Vendor.Deleted || !from.CheckAlive())
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (!from.CheckAlive() || target is not RentedVendor vendor || vendor.Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Vendor.IsOwner(from))
|
||||
if (vendor.IsOwner(from))
|
||||
{
|
||||
from.CloseGump<RenterVendorRentalGump>();
|
||||
from.SendGump(new RenterVendorRentalGump(m_Vendor));
|
||||
from.SendGump(new RenterVendorRentalGump(vendor));
|
||||
|
||||
m_Vendor.SendRentalExpireMessage(from);
|
||||
vendor.SendRentalExpireMessage(from);
|
||||
}
|
||||
else if (m_Vendor.IsLandlord(from))
|
||||
else if (vendor.IsLandlord(from))
|
||||
{
|
||||
from.CloseGump<LandlordVendorRentalGump>();
|
||||
from.SendGump(new LandlordVendorRentalGump(m_Vendor));
|
||||
from.SendGump(new LandlordVendorRentalGump(vendor));
|
||||
|
||||
m_Vendor.SendRentalExpireMessage(from);
|
||||
vendor.SendRentalExpireMessage(from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CollectRentEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly RentedVendor m_Vendor;
|
||||
|
||||
public CollectRentEntry(RentedVendor vendor) : base(6212) => m_Vendor = vendor;
|
||||
|
||||
public override void OnClick()
|
||||
public CollectRentEntry() : base(6212)
|
||||
{
|
||||
var from = Owner.From;
|
||||
}
|
||||
|
||||
if (m_Vendor.Deleted || !from.CheckAlive() || !m_Vendor.IsLandlord(from))
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (!from.CheckAlive() || target is not RentedVendor vendor || vendor.Deleted || !vendor.IsLandlord(from))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Vendor.RentalGold > 0)
|
||||
if (vendor.RentalGold > 0)
|
||||
{
|
||||
var depositedGold = Banker.DepositUpTo(from, m_Vendor.RentalGold);
|
||||
m_Vendor.RentalGold -= depositedGold;
|
||||
var depositedGold = Banker.DepositUpTo(from, vendor.RentalGold);
|
||||
vendor.RentalGold -= depositedGold;
|
||||
|
||||
if (depositedGold > 0)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1060397,
|
||||
depositedGold.ToString()
|
||||
); // ~1_AMOUNT~ gold has been deposited into your bank box.
|
||||
// ~1_AMOUNT~ gold has been deposited into your bank box.
|
||||
from.SendLocalizedMessage(1060397, depositedGold.ToString());
|
||||
}
|
||||
|
||||
if (m_Vendor.RentalGold > 0)
|
||||
if (vendor.RentalGold > 0)
|
||||
{
|
||||
from.SendLocalizedMessage(500390); // Your bank box is full.
|
||||
}
|
||||
|
|
@ -258,23 +252,20 @@ public partial class RentedVendor : PlayerVendor
|
|||
|
||||
private class TerminateContractEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly RentedVendor m_Vendor;
|
||||
|
||||
public TerminateContractEntry(RentedVendor vendor) : base(6218) => m_Vendor = vendor;
|
||||
|
||||
public override void OnClick()
|
||||
public TerminateContractEntry() : base(6218)
|
||||
{
|
||||
var from = Owner.From;
|
||||
}
|
||||
|
||||
if (m_Vendor.Deleted || !from.CheckAlive() || !m_Vendor.IsLandlord(from))
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (!from.CheckAlive() || target is not RentedVendor vendor || vendor.Deleted || !vendor.IsLandlord(from))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendLocalizedMessage(
|
||||
1062503
|
||||
); // Enter the amount of gold you wish to offer the renter in exchange for immediate termination of this contract?
|
||||
from.Prompt = new RefundOfferPrompt(m_Vendor);
|
||||
// Enter the amount of gold you wish to offer the renter in exchange for immediate termination of this contract?
|
||||
from.SendLocalizedMessage(1062503);
|
||||
from.Prompt = new RefundOfferPrompt(vendor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.ContextMenus;
|
||||
using Server.Engines.BulkOrders;
|
||||
using Server.Ethics;
|
||||
|
|
@ -78,9 +78,9 @@ public partial class VendorBackpack : Backpack
|
|||
(from.AccessLevel >= AccessLevel.GameMaster ||
|
||||
targ.GetType().IsDefined(typeof(PlayerVendorTargetAttribute), false));
|
||||
|
||||
public override void GetChildContextMenuEntries(Mobile from, List<ContextMenuEntry> list, Item item)
|
||||
public override void GetChildContextMenuEntries(Mobile from, ref PooledRefList<ContextMenuEntry> list, Item item)
|
||||
{
|
||||
base.GetChildContextMenuEntries(from, list, item);
|
||||
base.GetChildContextMenuEntries(from, ref list, item);
|
||||
|
||||
if (RootParent is not PlayerVendor pv || pv.IsOwner(from))
|
||||
{
|
||||
|
|
@ -91,7 +91,7 @@ public partial class VendorBackpack : Backpack
|
|||
|
||||
if (vi != null)
|
||||
{
|
||||
list.Add(new BuyEntry(item));
|
||||
list.Add(new BuyEntry());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -169,20 +169,18 @@ public partial class VendorBackpack : Backpack
|
|||
|
||||
private class BuyEntry : ContextMenuEntry
|
||||
{
|
||||
private readonly Item m_Item;
|
||||
|
||||
public BuyEntry(Item item) : base(6103) => m_Item = item;
|
||||
public BuyEntry() : base(6103)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool NonLocalUse => true;
|
||||
|
||||
public override void OnClick()
|
||||
public override void OnClick(Mobile from, IEntity target)
|
||||
{
|
||||
if (m_Item.Deleted)
|
||||
if (target is Item { Deleted: false } item)
|
||||
{
|
||||
return;
|
||||
PlayerVendor.TryToBuy(item, from);
|
||||
}
|
||||
|
||||
PlayerVendor.TryToBuy(m_Item, Owner.From);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue