public static StatueConfig FromXmlElement(XmlElement xmlData)
        {
            StatueConfig resultingStatueConfig = new StatueConfig();

            if (xmlData["PlayerCheckRange"] != null)
            {
                resultingStatueConfig.PlayerCheckRange = int.Parse(xmlData["PlayerCheckRange"].InnerText);
            }
            resultingStatueConfig.Cooldown = int.Parse(xmlData["Cooldown"].InnerText);
            if (xmlData["TriggerPermission"] != null)
            {
                resultingStatueConfig.TriggerPermission = xmlData["TriggerPermission"].InnerText;
            }
            if (xmlData["WirePermission"] != null)
            {
                resultingStatueConfig.WirePermission = xmlData["WirePermission"].InnerText;
            }

            XmlElement actionListNode = xmlData["Actions"];

            resultingStatueConfig.ActionsProcessingMethod = (ActionListProcessingMethod)Enum.Parse(
                typeof(ActionListProcessingMethod), actionListNode.Attributes["ProcessingMethod"].Value
                );
            foreach (XmlElement actionNode in actionListNode.ChildNodes)
            {
                switch (actionNode.LocalName)
                {
                case "NullAction":
                    resultingStatueConfig.Actions.Add(NullStatueAction.FromXmlElement(actionNode));
                    break;

                case "MoveNpcAction":
                    resultingStatueConfig.Actions.Add(MoveNpcStatueAction.FromXmlElement(actionNode));
                    break;

                case "SpawnNpcAction":
                    resultingStatueConfig.Actions.Add(SpawnNpcStatueAction.FromXmlElement(actionNode));
                    break;

                case "SpawnItemAction":
                    resultingStatueConfig.Actions.Add(SpawnItemStatueAction.FromXmlElement(actionNode));
                    break;

                case "BuffPlayerAction":
                    resultingStatueConfig.Actions.Add(BuffPlayerStatueAction.FromXmlElement(actionNode));
                    break;
                }
            }

            return(resultingStatueConfig);
        }
        private void ExecuteStatueAction(DPoint statueLocation, NullStatueAction statueAction)
        {
            MoveNpcStatueAction moveNpcAction = (statueAction as MoveNpcStatueAction);
              SpawnNpcStatueAction spawnNpcAction = (statueAction as SpawnNpcStatueAction);
              SpawnItemStatueAction spawnItemAction = (statueAction as SpawnItemStatueAction);
              BuffPlayerStatueAction buffPlayerAction = (statueAction as BuffPlayerStatueAction);

              DPoint spawnLocation = new DPoint((statueLocation.X + 1) * 16, (statueLocation.Y + 1) * 16);
              if (moveNpcAction != null) {
            int npcIndex = -1;
            for (int i = 0; i < 200; i++) {
              NPC npc = Main.npc[i];
              if (!npc.active || npc.type != moveNpcAction.NpcType)
            continue;

              npcIndex = i;
              break;
            }

            if (npcIndex == -1) {
              if (!moveNpcAction.SpawnIfNotExistent)
            return;

              TerrariaUtils.Npcs.Spawn(moveNpcAction.NpcType, spawnLocation, noDrops: true);
            } else {
              TerrariaUtils.Npcs.Move(npcIndex, spawnLocation);
            }
              } else if (spawnNpcAction != null) {
            if (spawnNpcAction.CheckRange > 0 && spawnNpcAction.CheckAmount > 0) {
              int closeByNpcs = 0;
              foreach (NPC closeByNpc in TerrariaUtils.Npcs.EnumerateNPCsAroundPoint(spawnLocation, spawnNpcAction.CheckRange * TerrariaUtils.TileSize)) {
            if (closeByNpc.type == spawnNpcAction.NpcType)
              closeByNpcs++;
              }
              if (closeByNpcs >= spawnNpcAction.CheckAmount)
            return;
            }

            for (int i = 0; i < spawnNpcAction.Amount; i++)
              TerrariaUtils.Npcs.Spawn(spawnNpcAction.NpcType, spawnLocation, noDrops: true);
              } else if (spawnItemAction != null) {
            if (spawnItemAction.CheckRange > 0 && spawnItemAction.CheckAmount > 0) {
              int closeByItems = 0;
              foreach (Item closeByItem in TerrariaUtils.Items.EnumerateItemsAroundPoint(spawnLocation, spawnItemAction.CheckRange * TerrariaUtils.TileSize)) {
            if (closeByItem.type == (int)spawnItemAction.ItemType)
              closeByItems++;
              }
              if (closeByItems >= spawnItemAction.CheckAmount)
            return;
            }

            if (spawnItemAction.Amount <= 5) {
              for (int i = 0; i < spawnItemAction.Amount; i++)
            Item.NewItem(spawnLocation.X, spawnLocation.Y, 0, 0, (int)spawnItemAction.ItemType);
            } else {
              Item.NewItem(spawnLocation.X, spawnLocation.Y, 0, 0, (int)spawnItemAction.ItemType, spawnItemAction.Amount);
            }
              } else if (buffPlayerAction != null) {
            foreach (TSPlayer player in TShock.Players) {
              if (player == null || !player.Active)
            continue;

              if (Math.Sqrt(Math.Pow(player.TileX - statueLocation.X, 2) + Math.Pow(player.TileY - statueLocation.Y, 2)) <= buffPlayerAction.Radius)
            player.SetBuff(buffPlayerAction.BuffId, buffPlayerAction.BuffTime);
            }
              }
        }