Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,153 +1,150 @@
using Server.Targeting;
using Server.Commands;
using Server.Targeting;
namespace Server.Items
{
[FlippableAttribute( 0x1f14, 0x1f15, 0x1f16, 0x1f17 )]
public class WayPoint : Item
{
public static void Initialize()
{
CommandSystem.Register( "WayPointSeq", AccessLevel.GameMaster, WayPointSeq_OnCommand );
}
[Flippable(0x1f14, 0x1f15, 0x1f16, 0x1f17)]
public class WayPoint : Item
{
private WayPoint m_Next;
public static void WayPointSeq_OnCommand( CommandEventArgs arg )
{
arg.Mobile.SendMessage( "Target the position of the first way point." );
arg.Mobile.Target = new WayPointSeqTarget( null );
}
[Constructible]
public WayPoint() : base(0x1f14)
{
Hue = 0x498;
Visible = false;
//this.Movable = false;
}
private WayPoint m_Next;
public WayPoint(WayPoint prev) : this()
{
if (prev != null)
prev.NextPoint = this;
}
public override string DefaultName => "AI Way Point";
public WayPoint(Serial serial) : base(serial)
{
}
[Constructible]
public WayPoint() : base( 0x1f14 )
{
Hue = 0x498;
Visible = false;
//this.Movable = false;
}
public override string DefaultName => "AI Way Point";
public WayPoint( WayPoint prev ) : this()
{
if ( prev != null )
prev.NextPoint = this;
}
[CommandProperty(AccessLevel.GameMaster)]
public WayPoint NextPoint
{
get => m_Next;
set
{
if (m_Next != this)
m_Next = value;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public WayPoint NextPoint
{
get => m_Next;
set
{
if ( m_Next != this )
m_Next = value;
}
}
public static void Initialize()
{
CommandSystem.Register("WayPointSeq", AccessLevel.GameMaster, WayPointSeq_OnCommand);
}
public override void OnDoubleClick( Mobile from )
{
if ( from.AccessLevel >= AccessLevel.GameMaster )
{
from.SendMessage( "Target the next way point in the sequence." );
public static void WayPointSeq_OnCommand(CommandEventArgs arg)
{
arg.Mobile.SendMessage("Target the position of the first way point.");
arg.Mobile.Target = new WayPointSeqTarget(null);
}
from.Target = new NextPointTarget( this );
}
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendMessage("Target the next way point in the sequence.");
public override void OnSingleClick( Mobile from )
{
base.OnSingleClick( from );
from.Target = new NextPointTarget(this);
}
}
if ( m_Next == null )
LabelTo( from, "(Unlinked)" );
else
LabelTo( from, "(Linked: {0})", m_Next.Location );
}
public override void OnSingleClick(Mobile from)
{
base.OnSingleClick(from);
public WayPoint( Serial serial ) : base( serial )
{
}
if (m_Next == null)
LabelTo(from, "(Unlinked)");
else
LabelTo(from, "(Linked: {0})", m_Next.Location);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int version = reader.ReadInt();
switch( version )
{
case 0:
{
m_Next = reader.ReadItem() as WayPoint;
break;
}
}
}
switch (version)
{
case 0:
{
m_Next = reader.ReadItem() as WayPoint;
break;
}
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 );
writer.Write(0);
writer.Write( m_Next );
}
}
writer.Write(m_Next);
}
}
public class NextPointTarget : Target
{
private WayPoint m_Point;
public class NextPointTarget : Target
{
private WayPoint m_Point;
public NextPointTarget( WayPoint pt ) : base( -1, false, TargetFlags.None )
{
m_Point = pt;
}
public NextPointTarget(WayPoint pt) : base(-1, false, TargetFlags.None)
{
m_Point = pt;
}
protected override void OnTarget( Mobile from, object target )
{
if ( target is WayPoint point && m_Point != null )
{
m_Point.NextPoint = point;
}
else
{
from.SendMessage( "Target a way point." );
}
}
}
protected override void OnTarget(Mobile from, object target)
{
if (target is WayPoint point && m_Point != null)
m_Point.NextPoint = point;
else
from.SendMessage("Target a way point.");
}
}
public class WayPointSeqTarget : Target
{
private WayPoint m_Last;
public class WayPointSeqTarget : Target
{
private WayPoint m_Last;
public WayPointSeqTarget( WayPoint last ) : base( -1, true, TargetFlags.None )
{
m_Last = last;
}
public WayPointSeqTarget(WayPoint last) : base(-1, true, TargetFlags.None)
{
m_Last = last;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is WayPoint wayPoint )
{
if ( m_Last != null )
m_Last.NextPoint = wayPoint;
}
else if ( targeted is IPoint3D d )
{
Point3D p = new Point3D( d );
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is WayPoint wayPoint)
{
if (m_Last != null)
m_Last.NextPoint = wayPoint;
}
else if (targeted is IPoint3D d)
{
Point3D p = new Point3D(d);
WayPoint point = new WayPoint( m_Last );
point.MoveToWorld( p, from.Map );
WayPoint point = new WayPoint(m_Last);
point.MoveToWorld(p, from.Map);
from.Target = new WayPointSeqTarget( point );
from.SendMessage( "Target the position of the next way point in the sequence, or target a way point link the newest way point to." );
}
else
{
from.SendMessage( "Target a position, or another way point." );
}
}
}
}
from.Target = new WayPointSeqTarget(point);
from.SendMessage(
"Target the position of the next way point in the sequence, or target a way point link the newest way point to.");
}
else
{
from.SendMessage("Target a position, or another way point.");
}
}
}
}