public virtual void Deserialize(GenericReader reader) { DeserializeDefaults(reader); MobileSpawns.ForEach(m => m.BeginAction(InstanceMap.KickPreventionLock)); var version = reader.GetVersion(); switch (version) { case 1: { ActiveLeader = reader.ReadMobile <PlayerMobile>(); LootMode = reader.ReadFlag <DungeonLootMode>(); } goto case 0; case 0: { Deadline = reader.ReadDeltaTime(); SubCommandPrefix = reader.ReadChar(); ExitPortal2 = reader.ReadItem <DungeonPortal>(); } break; } }
public void Kick(Mobile m) { if (m == null || m.Deleted || m.Map != Map || MobileSpawns.Contains(m) || !m.CanBeginAction(InstanceMap.KickPreventionLock)) { return; } if ((m.Player || m.IsDeadBondedPet) && !m.Alive) { m.Resurrect(); } var z = Zones.Find(m.InRegion); if (z != null && !z.Deleted) { z.Kick(m); } else if (Map != null && Instances.GetDungeon(m) == null) { Map.Kick(m); } OnExitDungeon(m); }
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 virtual bool OnCombatantChange(DungeonZone zone, Mobile m, Mobile oldMob, Mobile newMob) #endif { if (m != null && !m.Deleted && m.Alive && MobileSpawns.Contains(m)) { if (oldMob == null && newMob != null) { OnSpawnActivate(m); } else if (oldMob != null && newMob == null) { OnSpawnDeactivate(m); } } return(true); }
public virtual void OnExitDungeon(Mobile m) { if (m == null) { return; } if (MobileSpawns.Remove(m)) { OnSpawnDeactivate(m); } if (m.Deleted) { return; } if (m is PlayerMobile) { var pm = (PlayerMobile)m; ActiveGroup.Remove(pm); if (ActiveGroup.Count > 0 && ActiveLeader == pm) { ActiveLeader = ActiveGroup[0]; } pm.CloseGump(typeof(DungeonUI)); pm.CloseGump(typeof(DungeonLootUI)); if (pm.Map == null || pm.Map == Server.Map.Internal) { StablePets(pm); } else { SummonPets(pm); } } m.Delta(MobileDelta.Noto); m.ProcessDelta(); }
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 virtual Mobile CreateMobile(Type type, Point3D p, bool replacePack, bool scale, double factor, object[] args) { var m = type.CreateInstanceSafe <Mobile>(args); if (m == null) { return(null); } MobileSpawns.Add(m); m.BeginAction(InstanceMap.KickPreventionLock); if (replacePack) { var dp = new DungeonPack(m); var cp = m.Backpack; if (cp != null && !cp.Deleted) { cp.Items.ForEachReverse( i => { var l = i.Location; dp.DropItem(i); i.Location = l; }); cp.Delete(); } m.AddItem(dp); } m.OnBeforeSpawn(p, Map); if (scale) { ScaleMobile(m, factor); } if (m is BaseCreature) { var c = (BaseCreature)m; c.Home = p; c.RangeHome = 0; c.Team = (int)ID; c.ApproachWait = true; c.ApproachRange = 8; } m.Direction = Entrance != Point3D.Zero ? p.GetDirection(Entrance) : (Direction)Utility.Random(8); if (Map != null) { m.MoveToWorld(p, Map); } m.OnAfterSpawn(); return(m); }
public bool IsSpawn(Mobile m) { return(m != null && MobileSpawns.Contains(m)); }