context: using System;
  using System.Collections;
  
  namespace Server.Mobiles
  {
      public enum BlockMountType
      {
          None = -1,
          Dazed,
          BolaRecovery,
          DismountRecovery
      }
  
      public abstract class BaseMount : BaseCreature, IMount
      {
          private static readonly Hashtable m_Table = new Hashtable();
          private Mobile m_Rider;
          private Item m_InternalItem;
          private DateTime m_NextMountAbility;
          public BaseMount(string name, int bodyID, int itemID, AIType aiType, FightMode fightMode, int rangePerception, int rangeFight, double activeSpeed, double passiveSpeed)
              : base(aiType, fightMode, rangePerception, rangeFight, activeSpeed, passiveSpeed)
          {
              this.Name = name;
              this.Body = bodyID;
  
              this.m_InternalItem = new MountItem(this, itemID);
          }
  
          public BaseMount(Serial serial)
              : base(serial)
          {
          }
  
          public virtual TimeSpan MountAbilityDelay
          {
              get
              {
                  return TimeSpan.Zero;
              }
          }
          [CommandProperty(AccessLevel.GameMaster)]
          public DateTime NextMountAbility
          {
              get
              {
                  return this.m_NextMountAbility;
              }
              set
              {
                  this.m_NextMountAbility = value;
              }
          }
          public virtual bool AllowMaleRider
          {
              get
              {
                  return true;
              }
          }
          public virtual bool AllowFemaleRider
          {
              get
              {
                  return true;
              }
          }
          [Hue, CommandProperty(AccessLevel.GameMaster)]
          public override int Hue
          {
              get
              {
                  return base.Hue;
              }
              set
              {
                  base.Hue = value;
  
                  if (this.m_InternalItem != null)
                      this.m_InternalItem.Hue = value;
              }
          }
          [CommandProperty(AccessLevel.GameMaster)]
          public int ItemID
          {
              get
              {
                  if (this.m_InternalItem != null)
                      return this.m_InternalItem.ItemID;
                  else
                      return 0;
              }
              set
              {
                  if (this.m_InternalItem != null)
                      this.m_InternalItem.ItemID = value;
              }
          }
          [CommandProperty(AccessLevel.GameMaster)]
          public Mobile Rider
          {
              get
              {
                  return this.m_Rider;
              }
              set
              {
                  if (this.m_Rider != value)
                  {
                      if (value == null)
                      {
                          Point3D loc = this.m_Rider.Location;
                          Map map = this.m_Rider.Map;
  
                          if (map == null || map == Map.Internal)
                          {
                              loc = this.m_Rider.LogoutLocation;
                              map = this.m_Rider.LogoutMap;
                          }
  
                          this.Direction = this.m_Rider.Direction;
                          this.Location = loc;
                          this.Map = map;
  
                          if (this.m_InternalItem != null)
                              this.m_InternalItem.Internalize();
                      }
                      else
                      {
                          if (this.m_Rider != null)
                              Dismount(this.m_Rider);
  
                          Dismount(value);
  
                          if (this.m_InternalItem != null)
                              value.AddItem(this.m_InternalItem);
  
                          value.Direction = this.Direction;
  
                          this.Internalize();
                      }
  
                      this.m_Rider = value;
                  }
              }
          }
  
          protected Item InternalItem
          {
              get
              {
                  return this.m_InternalItem;
              }
          }
  
          public static void Dismount(Mobile dismounted)
          {
              Dismount(dismounted, dismounted, BlockMountType.None, TimeSpan.FromSeconds(0), false);
          }
  
          public static void Dismount(Mobile dismounter, Mobile dismounted, BlockMountType blockmounttype, TimeSpan delay)
          {
              Dismount(dismounter, dismounted, blockmounttype, TimeSpan.FromSeconds(0), true);
          }
  
          public static void Dismount(Mobile dismounter, Mobile dismounted, BlockMountType blockmounttype, TimeSpan delay, bool message)
          {
              if (!dismounted.Mounted)
                  return;
  
              if (dismounted is ChaosDragoonElite)
              {
                  dismounter.SendLocalizedMessage(1042047); // You fail to knock the rider from its mount.
              }
  
              IMount mount = dismounted.Mount;
  
              if (mount != null)
              {
                  mount.Rider = null;
                  BaseMount.SetMountPrevention(dismounted, blockmounttype, delay);
  
                  if (message)
                      dismounted.SendLocalizedMessage(1040023); // You have been knocked off of your mount!
              }
              else if (dismounted.Flying)
              {
                  if (!OnFlightPath(dismounted))
                  {
                      dismounted.Flying = false;
                      dismounted.Freeze(TimeSpan.FromSeconds(1));
                      dismounted.Animate(61, 10, 1, true, false, 0);
                  }
              }
          }
  
          public static bool OnFlightPath(Mobile m)
          {
              if (!m.Flying)
                  return false;
  
              StaticTile[] tiles = m.Map.Tiles.GetStaticTiles(m.X, m.Y, true);
              ItemData itemData;
              bool onpath = false;
  
  
gt:             for (int i = 0; i < tiles.Length && !onpath; ++i)