context: // **********
  // RpiUO - DecorateML.cs
  // Last Edit: 2015/12/24
  // Look for Rpi comment
  // **********
  
  using System;
  using System.IO;
  using System.Xml;
  using Server.Commands;
  using Server.Engines.InstancedPeerless;
  using Server.Engines.Quests;
  using Server.Gumps;
  using Server.Items;
  using Server.Mobiles;
  using Server.Network;
  
  namespace Server
  {
      public static class MondainsLegacyDecorate
      { 
          private static readonly Type[] m_PigmentList = new Type[]
          {
              typeof(RoyalZooLeatherLegs), typeof(RoyalZooLeatherGloves), typeof(RoyalZooLeatherGorget), typeof(RoyalZooLeatherArms),
              typeof(RoyalZooLeatherChest), typeof(RoyalZooLeatherFemaleChest), typeof(RoyalZooStuddedLegs), typeof(RoyalZooStuddedGloves),
              typeof(RoyalZooStuddedGorget), typeof(RoyalZooStuddedArms), typeof(RoyalZooStuddedChest), typeof(RoyalZooStuddedFemaleChest),
              typeof(RoyalZooPlateHelm), typeof(RoyalZooPlateFemaleChest), typeof(RoyalZooPlateChest), typeof(RoyalZooPlateArms),
              typeof(RoyalZooPlateGorget), typeof(RoyalZooPlateGloves), typeof(RoyalZooPlateLegs), typeof(MinaxsArmor),
              typeof(KeeoneansChainMail), typeof(VesperOrderShield), typeof(VesperChaosShield), typeof(ClaininsSpellbook),
              typeof(BlackthornsKryss), typeof(SwordOfJustice), typeof(GeoffreysAxe), typeof(TreatiseonAlchemyTalisman),
              typeof(PrimerOnArmsTalisman), typeof(MyBookTalisman), typeof(TalkingtoWispsTalisman), typeof(GrammarOfOrchishTalisman),
              typeof(BirdsofBritanniaTalisman), typeof(TheLifeOfTravelingMinstrelTalisman), typeof(MaceAndShieldGlasses), typeof(GlassesOfTheArts),
              typeof(FoldedSteelGlasses), typeof(TradesGlasses), typeof(LyricalGlasses), typeof(AnthropomorphistGlasses),
              typeof(LightOfWayGlasses), typeof(NecromanticGlasses), typeof(WizardsCrystalGlasses), typeof(MaritimeGlasses),
              typeof(TreasuresAndTrinketsGlasses), typeof(PoisonedGlasses), typeof(GypsyHeaddress), typeof(NystulsWizardsHat),
              typeof(JesterHatOfChuckles)
          };
          // true - dungeon is enabled, false - dungeon is disabled
          private static bool m_PalaceOfParoxysmus;
          private static bool m_TwistedWeald;
          private static bool m_BlightedGrove;
          private static bool m_Bedlam;
          private static bool m_PrismOfLight;
          private static bool m_Citadel;
          private static bool m_PaintedCaves;
          private static bool m_Labyrinth;
          private static bool m_Sanctuary;
          private static bool m_StygianDragonLair;
          private static bool m_MedusasLair;
          private static bool m_Spellweaving;
          private static bool m_PublicDonations;
          public static bool PalaceOfParoxysmus
          {
              get
              {
                  return m_PalaceOfParoxysmus;
              }
              set
              {
                  m_PalaceOfParoxysmus = value;
              }
          }
          public static bool TwistedWeald
          {
              get
              {
                  return m_TwistedWeald;
              }
              set
              {
                  m_TwistedWeald = value;
              }
          }
          public static bool BlightedGrove
          {
              get
              {
                  return m_BlightedGrove;
              }
              set
              {
                  m_BlightedGrove = value;
              }
          }
          public static bool Bedlam
          {
              get
              {
                  return m_Bedlam;
              }
              set
              {
                  m_Bedlam = value;
              }
          }
          public static bool PrismOfLight
          {
              get
              {
                  return m_PrismOfLight;
              }
              set
              {
                  m_PrismOfLight = value;
              }
          }
          public static bool Citadel
          {
              get
              {
                  return m_Citadel;
              }
              set
              {
                  m_Citadel = value;
              }
          }
          public static bool PaintedCaves
          {
              get
              {
                  return m_PaintedCaves;
              }
              set
              {
                  m_PaintedCaves = value;
              }
          }
          public static bool Labyrinth
          {
              get
              {
                  return m_Labyrinth;
              }
              set
              {
                  m_Labyrinth = value;
              }
          }
          public static bool Sanctuary
          {
              get
              {
                  return m_Sanctuary;
              }
              set
              {
                  m_Sanctuary = value;
              }
          }
          public static bool StygianDragonLair
          {
              get
              {
                  return m_StygianDragonLair;
              }
              set
              {
                  m_StygianDragonLair = value;
              }
          }
          public static bool MedusasLair
          {
              get
              {
                  return m_MedusasLair;
              }
              set
              {
                  m_MedusasLair = value;
              }
          }
          public static bool Spellweaving
          {
              get
              {
                  return m_Spellweaving;
              }
              set
              {
                  m_Spellweaving = value;
              }
          }
          public static bool PublicDonations
          {
              get
              {
                  return m_PublicDonations;
              }
              set
              {
                  m_PublicDonations = value;
              }
          }
          public static Type[] PigmentList
          {
              get
              {
                  return m_PigmentList;
              }
          }
          public static void Initialize()
          {
              CommandSystem.Register("DecorateML", AccessLevel.Administrator, new CommandEventHandler(DecorateML_OnCommand));
              CommandSystem.Register("SettingsML", AccessLevel.Administrator, new CommandEventHandler(SettingsML_OnCommand));
              CommandSystem.Register("Quests", AccessLevel.GameMaster, new CommandEventHandler(Quests_OnCommand));
  			
              LoadSettings();
          }
  
          public static bool FindItem(int x, int y, int z, Map map, Item test)
          {
              return FindItem(new Point3D(x, y, z), map, test);
          }
  
          public static bool FindItem(Point3D p, Map map, Item test)
          {
              IPooledEnumerable eable = map.GetItemsInRange(p);
  
              foreach (Item item in eable)
              {
                  if (item.Z == p.Z && item.ItemID == test.ItemID)
                  {
                      eable.Free();
                      return true;
                  }
              }
  			
              eable.Free();
              return false;
          }
  
          public static void LoadSettings()
          {
              if (!Directory.Exists("Data/Mondain's Legacy"))
                  Directory.CreateDirectory("Data/Mondain's Legacy");
  				
              if (!File.Exists("Data/Mondain's Legacy/Settings.xml"))
                  File.Create("Data/Mondain's Legacy/Settings.xml");
  				
              try
              {
                  XmlDocument doc = new XmlDocument();
                  doc.Load(Path.Combine(Core.BaseDirectory, "Data/Mondain's Legacy/Settings.xml"));
  				
                  XmlElement root = doc["Settings"];
  				
                  if (root == null)
                      return;
  					
                  ReadNode(root, "PalaceOfParoxysmus", ref m_PalaceOfParoxysmus);
                  ReadNode(root, "TwistedWeald", ref m_TwistedWeald);
                  ReadNode(root, "BlightedGrove", ref m_BlightedGrove);
                  ReadNode(root, "Bedlam", ref m_Bedlam);
                  ReadNode(root, "PrismOfLight", ref m_PrismOfLight);
                  ReadNode(root, "Citadel", ref m_Citadel);
                  ReadNode(root, "PaintedCaves", ref m_PaintedCaves);
                  ReadNode(root, "Labyrinth", ref m_Labyrinth);
                  ReadNode(root, "Sanctuary", ref m_Sanctuary);
                  ReadNode(root, "StygianDragonLair", ref m_StygianDragonLair);
                  ReadNode(root, "MedusasLair", ref m_MedusasLair);
                  ReadNode(root, "Spellweaving", ref m_Spellweaving);
                  ReadNode(root, "PublicDonations", ref m_PublicDonations);
              }
              catch
              {
              }
          }
  
          public static void SaveSetings()
          {
              if (!Directory.Exists("Data/Mondain's Legacy"))
                  Directory.CreateDirectory("Data/Mondain's Legacy");
  				
              if (!File.Exists("Data/Mondain's Legacy/Settings.xml"))
                  File.Create("Data/Mondain's Legacy/Settings.xml");
  			
              try
              { 
                  XmlDocument doc = new XmlDocument();
                  doc.Load(Path.Combine(Core.BaseDirectory, "Data/Mondain's Legacy/Settings.xml"));
  				
                  XmlElement root = doc["Settings"];
  				
                  if (root == null)
                      return;
  				
                  UpdateNode(root, "PalaceOfParoxysmus", m_PalaceOfParoxysmus);
                  UpdateNode(root, "TwistedWeald", m_TwistedWeald);
                  UpdateNode(root, "BlightedGrove", m_BlightedGrove);
                  UpdateNode(root, "Bedlam", m_Bedlam);
                  UpdateNode(root, "PrismOfLight", m_PrismOfLight);
  
gt:                 UpdateNode(root, "Citadel", m_Citadel);