Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
121
Projects/Scripts/Engines/Quests/Core/BaseQuester.cs
Normal file
121
Projects/Scripts/Engines/Quests/Core/BaseQuester.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
using System.Collections.Generic;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Engines.Quests
|
||||
{
|
||||
public class TalkEntry : ContextMenuEntry
|
||||
{
|
||||
private BaseQuester m_Quester;
|
||||
|
||||
public TalkEntry(BaseQuester quester) : base(quester.TalkNumber)
|
||||
{
|
||||
m_Quester = quester;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
Mobile from = Owner.From;
|
||||
|
||||
if (from.CheckAlive() && from is PlayerMobile mobile && m_Quester.CanTalkTo(mobile))
|
||||
m_Quester.OnTalk(mobile, true);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseQuester : BaseVendor
|
||||
{
|
||||
protected List<SBInfo> m_SBInfos = new List<SBInfo>();
|
||||
|
||||
public BaseQuester(string title = null) : base(title)
|
||||
{
|
||||
}
|
||||
|
||||
public BaseQuester(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<SBInfo> SBInfos => m_SBInfos;
|
||||
|
||||
public override bool IsActiveVendor => false;
|
||||
public override bool IsInvulnerable => true;
|
||||
public override bool DisallowAllMoves => true;
|
||||
public override bool ClickTitle => false;
|
||||
public override bool CanTeach => false;
|
||||
|
||||
public virtual int TalkNumber // Talk
|
||||
=> 6146;
|
||||
|
||||
public override void InitSBInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void OnTalk(PlayerMobile player, bool contextMenu);
|
||||
|
||||
public virtual bool CanTalkTo(PlayerMobile to)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual int GetAutoTalkRange(PlayerMobile m)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override bool CanBeDamaged()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Item SetHue(Item item, int hue)
|
||||
{
|
||||
item.Hue = hue;
|
||||
return item;
|
||||
}
|
||||
|
||||
public override void AddCustomContextEntries(Mobile from, List<ContextMenuEntry> list)
|
||||
{
|
||||
base.AddCustomContextEntries(from, list);
|
||||
|
||||
if (from.Alive && from is PlayerMobile mobile && TalkNumber > 0 && CanTalkTo(mobile))
|
||||
list.Add(new TalkEntry(this));
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (m.Alive && m is PlayerMobile pm)
|
||||
{
|
||||
int range = GetAutoTalkRange(pm);
|
||||
|
||||
if (pm.Alive && range >= 0 && InRange(m, range) && !InRange(oldLocation, range) && CanTalkTo(pm))
|
||||
OnTalk(pm, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void FocusTo(Mobile to)
|
||||
{
|
||||
QuestSystem.FocusTo(this, to);
|
||||
}
|
||||
|
||||
public static Container GetNewContainer()
|
||||
{
|
||||
Bag bag = new Bag();
|
||||
bag.Hue = QuestSystem.RandomBrightHue();
|
||||
return bag;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue