private void btlCleanDeadMinions_Click(object sender, EventArgs ex) { DialogResult res = MessageBox.Show("Do you want to try clean hidden dead minions? If so, make sure you do not save to the same map file OR have made a backup!", "Confirm fix", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (res == DialogResult.Cancel) { return; } int fixedMinions = 0; LayFile lay = SaveGamePlugin.LayFile; List <LayEntity> entities = new List <LayEntity>(); for (int i = 100; i < 113; i++) { entities = lay.FindEntities(i.ToString()); for (int e = 0; e < entities.Count; e++) { LayEntity minion = entities[e]; if (minion.Stats.Health.ToInteger() < 1) { if ((minion.GetProperty("IsDead") != null) && (minion.GetProperty("IsUnconscious") != null) && (minion.GetProperty("IsIncapacitated") != null) && (minion.GetProperty("Destroyed") != null) && (minion.GetProperty("NotInGame") == null)) { int cnt = 0; List <LayProperty> props = lay.FindProperties("EntityID"); foreach (LayProperty prop in props) { if (prop.Value == minion.EntityID) { cnt++; } } if (cnt == 1) { minion.Delete(); fixedMinions++; } } } } } MessageBox.Show("Cleaned " + fixedMinions.ToString() + " dead hidden minion(s). Be sure to test out if the fix worked!", "Fix applied.", MessageBoxButtons.OK, MessageBoxIcon.Information); }
void frmMapEditor_Click(object sender, EventArgs e) { LayEntity obj = (LayEntity)((ToolStripMenuItem)sender).OwnerItem.Tag; obj.Delete(); }