context: using System;
  using Server.Mobiles;
  using Server.Multis;
  using Server.Spells;
  using Server.Targeting;
  
  namespace Server.Items
  {
      public class SpecialFishingNet : Item
      {
          private static readonly int[] m_Hues = new int[]
          {
              0x09B,
              0x0CD,
              0x0D3,
              0x14D,
              0x1DD,
              0x1E9,
              0x1F4,
              0x373,
              0x451,
              0x47F,
              0x489,
              0x492,
              0x4B5,
              0x8AA
          };
          private static readonly int[] m_WaterTiles = new int[]
          {
              0x00A8, 0x00AB,
              0x0136, 0x0137
          };
          private static readonly int[] m_UndeepWaterTiles = new int[]
          {
              0x1797, 0x179C
          };
  
          private bool m_InUse;
  
          [Constructable]
          public SpecialFishingNet()
              : base(0x0DCA)
          {
              this.Weight = 15.0;
  
              if (0.01 > Utility.RandomDouble())
                  this.Hue = Utility.RandomList(m_Hues);
              else
                  this.Hue = 0x8A0;
          }
  
          public SpecialFishingNet(Serial serial)
              : base(serial)
          {
          }
  
          public override int LabelNumber
          {
              get
              {
                  return 1041079;
              }
          }// a special fishing net
          [CommandProperty(AccessLevel.GameMaster)]
          public bool InUse
          {
              get
              {
                  return this.m_InUse;
              }
              set
              {
                  this.m_InUse = value;
              }
          }
          public virtual bool RequireDeepWater
          {
              get
              {
                  return true;
              }
          }
          public static bool FullValidation(Map map, int x, int y)
          {
              bool valid = ValidateDeepWater(map, x, y);
  
              for (int j = 1, offset = 5; valid && j <= 5; ++j, offset += 5)
              {
                  if (!ValidateDeepWater(map, x + offset, y + offset))
                      valid = false;
                  else if (!ValidateDeepWater(map, x + offset, y - offset))
                      valid = false;
                  else if (!ValidateDeepWater(map, x - offset, y + offset))
                      valid = false;
                  else if (!ValidateDeepWater(map, x - offset, y - offset))
                      valid = false;
              }
  
              return valid;
          }
  
          public override void GetProperties(ObjectPropertyList list)
          {
              base.GetProperties(list);
  
              this.AddNetProperties(list);
          }
  
          public override void Serialize(GenericWriter writer)
          {
              base.Serialize(writer);
  
              writer.Write((int)1); // version
  
              writer.Write(this.m_InUse);
          }
  
          public override void Deserialize(GenericReader reader)
          {
              base.Deserialize(reader);
  
              int version = reader.ReadInt();
  
              switch ( version )
              {
                  case 1:
                      {
                          this.m_InUse = reader.ReadBool();
  
                          if (this.m_InUse)
                              this.Delete();
  
                          break;
                      }
              }
  
              this.Stackable = false;
          }
  
          public override void OnDoubleClick(Mobile from)
          {
              if (this.m_InUse)
              {
                  from.SendLocalizedMessage(1010483); // Someone is already using that net!
              }
              else if (this.IsChildOf(from.Backpack))
              {
                  from.SendLocalizedMessage(1010484); // Where do you wish to use the net?
                  from.BeginTarget(-1, true, TargetFlags.None, new TargetCallback(OnTarget));
              }
              else
              {
                  from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
              }
          }
  
          public void OnTarget(Mobile from, object obj)
          {
              if (this.Deleted || this.m_InUse)
                  return;
  
              IPoint3D p3D = obj as IPoint3D;
  
              if (p3D == null)
                  return;
  
              Map map = from.Map;
  
              if (map == null || map == Map.Internal)
                  return;
  
              int x = p3D.X, y = p3D.Y, z = map.GetAverageZ(x, y); // OSI just takes the targeted Z
  
              if (!from.InRange(p3D, 6))
              {
                  from.SendLocalizedMessage(500976); // You need to be closer to the water to fish!
              }
              else if (!from.InLOS(obj))
              {
                  from.SendLocalizedMessage(500979); // You cannot see that location.
              }
              else if (this.RequireDeepWater ? FullValidation(map, x, y) : (ValidateDeepWater(map, x, y) || ValidateUndeepWater(map, obj, ref z)))
              {
                  Point3D p = new Point3D(x, y, z);
  
                  if (this.GetType() == typeof(SpecialFishingNet))
                  {
                      for (int i = 1; i < this.Amount; ++i) // these were stackable before, doh
                          from.AddToBackpack(new SpecialFishingNet());
                  }
  
                  this.m_InUse = true;
                  this.Movable = false;
                  this.MoveToWorld(p, map);
  
                  SpellHelper.Turn(from, p);
  
                  if (Core.SA)
                  {
                      from.Animate(AnimationType.Attack, 6);
                  }
                  else
                  {
  
gt:                     from.Animate(12, 5, 1, true, false, 0);