public virtual Item CreateItem(Type type, Point3D p, bool scale, double factor, object[] args) { var i = type.CreateInstanceSafe <Item>(args); if (i == null) { return(null); } ItemSpawns.Add(i); i.OnBeforeSpawn(p, Map); if (scale) { ScaleItem(i, factor); } if (Map != null) { i.MoveToWorld(p, Map); } i.OnAfterSpawn(); return(i); }
public void Defragment() { if (MobileSpawns != null) { MobileSpawns.RemoveAll(m => m == null || m.Deleted || m.Map != Map); } if (ItemSpawns != null) { ItemSpawns.RemoveAll(i => i == null || i.Deleted || i.Map != Map); } if (Zones != null) { Zones.RemoveAll(z => z == null || z.Deleted || z.Map != Map); Zones.ForEachReverse(z => z.Defragment()); } if (Logs != null && Logs.Count > 0) { Logs.RemoveRange( (c, l) => { if (l == null) { return(true); } l.RemoveAll(String.IsNullOrWhiteSpace); if (l.Count == 0) { l.Free(false); return(true); } if (String.IsNullOrWhiteSpace(c)) { l.Free(true); return(true); } return(false); }); } }
public Static CreateStatic(int itemID, Point3D p, bool checkExist) { Static s = null; if (checkExist) { s = ItemSpawns.OfType <Static>().FirstOrDefault(i => i.ItemID == itemID && i.GetWorldLocation() == p); } if (s == null || s.Deleted) { s = CreateItem <Static>(p, false); if (s != null) { s.ItemID = itemID; } } return(s); }
public void Delete() { if (Deleted || _Deleting) { return; } _Deleting = true; OnBeforeDelete(); KickAll(); EventSink.Shutdown -= InternalServerShutdown; EventSink.Logout -= InternalLogout; EventSink.Login -= InternalLogin; if (CoreTimer != null) { CoreTimer.Dispose(); CoreTimer = null; } Instances.Dungeons.Remove(Serial); OnDelete(); if (ExitPortal1 != null) { ExitPortal1.Delete(); ExitPortal1 = null; } if (ExitPortal2 != null) { ExitPortal2.Delete(); ExitPortal2 = null; } if (Loot != null) { Loot.ForEach(l => l.Free()); Loot.Free(true); } if (Zones != null) { Zones.ForEachReverse( z => { if (z != null) { z.Dungeon = null; z.Delete(); } }); Zones.Free(true); } if (MobileSpawns != null) { MobileSpawns.Where(m => m != null && !m.Deleted && !m.Player && m.Map == Map).ForEach(m => m.Delete()); MobileSpawns.Free(true); } if (ItemSpawns != null) { ItemSpawns.Where(m => m != null && !m.Deleted && m.Map == Map && m.Parent == null).ForEach(i => i.Delete()); ItemSpawns.Free(true); } if (Map != null) { if (Map.InstanceRegions.All(z => z == null || z.Deleted)) { Map.Delete(); } Map = null; } if (Logs != null) { Logs.Values.Free(true); Logs.Clear(); } if (ActiveGroup != null) { ActiveGroup.Free(true); } if (Group != null) { Group.Free(true); } if (SubCommands != null) { SubCommands.Clear(); } if (Options != null) { Options.Clear(); } Deleted = true; OnAfterDelete(); _Deleting = false; /* * Loot = null; * Zones = null; * MobileSpawns = null; * ItemSpawns = null; * Map = null; * Logs = null; * ActiveGroup = null; * Group = null; * SubCommands = null; * Options = null; */ }
public bool IsSpawn(Item i) { return(i != null && ItemSpawns.Contains(i)); }