Reorganizes Project (#41)

This commit is contained in:
Kamron Batman 2019-08-02 18:13:40 -07:00 committed by GitHub
parent 08bf44af9a
commit 3614a66aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3499 changed files with 79 additions and 55 deletions

View file

@ -0,0 +1,9 @@
namespace Server.Spells
{
public interface IRecallSpell
{
Mobile Caster{ get; }
void Effect(Point3D loc, Map map, bool checkMulti);
void FinishSequence();
}
}

View file

@ -0,0 +1,7 @@
namespace Server.Spells
{
public interface ISpellTarget
{
ISpell Spell{ get; }
}
}

View file

@ -0,0 +1,66 @@
using Server.Items;
using Server.Multis;
using Server.Network;
using Server.Targeting;
namespace Server.Spells
{
public class RecallSpellTarget : Target
{
private IRecallSpell m_Spell;
private bool m_ToBoat;
public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None)
{
m_Spell = spell;
m_ToBoat = toBoat;
m_Spell.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
protected override void OnTarget(Mobile from, object o)
{
if (o is RecallRune rune)
{
if (rune.Marked)
m_Spell.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501805); // That rune is not yet marked.
}
else if (o is Runebook runebook)
{
RunebookEntry e = runebook.Default;
if (e != null)
m_Spell.Effect(e.Location, e.Map, true);
else
from.SendLocalizedMessage(502354); // Target is not marked.
}
else if (m_ToBoat && o is Key key && key.KeyValue != 0 && key.Link is BaseBoat boat)
{
if (!boat.Deleted && boat.CheckKey(key.KeyValue))
m_Spell.Effect(boat.GetMarkedLocation(), boat.Map, false);
else
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357,
from.Name, "")); // I can not recall from that object.
}
else if (o is HouseRaffleDeed deed && deed.ValidLocation())
{
m_Spell.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name,
"")); // I can not recall from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
}
}
}

View file

@ -0,0 +1,31 @@
using Server.Targeting;
namespace Server.Spells
{
public interface ISpellTargetingItem : ISpell
{
void Target(Item item);
}
public class SpellTargetItem : Target, ISpellTarget
{
private ISpellTargetingItem m_Spell;
public ISpell Spell => m_Spell;
public SpellTargetItem(ISpellTargetingItem spell, TargetFlags flags, int range = 12) : base(range, false, flags)
{
m_Spell = spell;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is Item item)
m_Spell.Target(item);
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
}
}
}

View file

@ -0,0 +1,30 @@
using Server.Targeting;
namespace Server.Spells
{
public interface ISpellTargetingMobile : ISpell
{
void Target(Mobile from);
}
public class SpellTargetMobile : Target, ISpellTarget
{
private ISpellTargetingMobile m_Spell;
public ISpell Spell => m_Spell;
public SpellTargetMobile(ISpellTargetingMobile spell, TargetFlags flags, int range = 12) : base(range, false, flags)
{
m_Spell = spell;
}
protected override void OnTarget(Mobile from, object o)
{
m_Spell.Target(o as Mobile);
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
}
}
}

View file

@ -0,0 +1,46 @@
using System;
using Server.Targeting;
namespace Server.Spells
{
public interface ISpellTargetingPoint3D : ISpell
{
void Target(IPoint3D p);
}
public class SpellTargetPoint3D : Target
{
private ISpellTargetingPoint3D m_Spell;
public ISpell Spell => m_Spell;
private bool m_CheckLOS;
public SpellTargetPoint3D(ISpellTargetingPoint3D spell, TargetFlags flags = TargetFlags.None, int range = 12, bool checkLOS = true) : base(range, true, flags)
{
m_Spell = spell;
m_CheckLOS = checkLOS;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is IPoint3D p)
m_Spell.Target(p);
}
protected override void OnTargetOutOfLOS(Mobile from, object o)
{
if (!m_CheckLOS)
return;
from.SendLocalizedMessage(501943); // Target cannot be seen. Try again.
from.Target = new SpellTargetPoint3D(m_Spell);
from.Target.BeginTimeout(from, TimeoutTime - DateTime.UtcNow);
m_Spell = null; // Needed?
}
protected override void OnTargetFinish(Mobile from)
{
m_Spell?.FinishSequence();
}
}
}