public virtual void LoadFromPosition(DBKeepPosition pos, GameKeepComponent component) { m_templateID = pos.TemplateID; m_component = component; PositionMgr.LoadKeepItemPosition(pos, this); component.AbstractKeep.Doors[m_templateID] = this; m_oldMaxHealth = MaxHealth; m_health = MaxHealth; m_name = "Keep Door"; m_oldHealthPercent = HealthPercent; m_doorID = GenerateDoorID(); m_model = 0xFFFF; m_state = eDoorState.Closed; if (AddToWorld()) { StartHealthRegeneration(); DoorMgr.RegisterDoor(this); } else { log.Error("Failed to load keep door from position! DoorID=" + m_doorID + ". Component SkinID=" + component.Skin + ". KeepID=" + component.AbstractKeep.KeepID); } }
/// <summary> /// load the keep door object from DB object /// </summary> /// <param name="obj"></param> public override void LoadFromDatabase(DataObject obj) { DBDoor door = obj as DBDoor; if (door == null) { return; } base.LoadFromDatabase(obj); Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000)); if (curZone == null) { return; } CurrentRegion = curZone.ZoneRegion; m_name = door.Name; m_Heading = (ushort)door.Heading; X = door.X; Y = door.Y; Z = door.Z; m_level = 0; m_model = 0xFFFF; m_doorID = door.InternalID; m_state = eDoorState.Closed; AddToWorld(); foreach (AbstractArea area in CurrentAreas) { if (area is KeepArea) { AbstractGameKeep keep = (area as KeepArea).Keep; if (!keep.Doors.Contains(door.InternalID)) { Component = new GameKeepComponent(); Component.AbstractKeep = keep; keep.Doors.Add(door.InternalID, this); } break; } } m_health = MaxHealth; StartHealthRegeneration(); DoorMgr.RegisterDoor(this); }
/// <summary> /// Remove a keep from the database /// </summary> /// <param name="area"></param> public virtual void Remove(KeepArea area) { Dictionary <string, GameKeepGuard> guards = new Dictionary <string, GameKeepGuard>(Guards); // Use a shallow copy foreach (GameKeepGuard guard in guards.Values) { guard.Delete(); guard.DeleteFromDatabase(); } Dictionary <string, GameKeepBanner> banners = new Dictionary <string, GameKeepBanner>(Banners); // Use a shallow copy foreach (GameKeepBanner banner in banners.Values) { banner.Delete(); banner.DeleteFromDatabase(); } Dictionary <string, GameKeepDoor> doors = new Dictionary <string, GameKeepDoor>(Doors); // Use a shallow copy foreach (GameKeepDoor door in doors.Values) { door.Delete(); GameDoor d = new GameDoor(); d.CurrentRegionID = door.CurrentRegionID; d.DoorID = door.DoorID; d.Heading = door.Heading; d.Level = door.Level; d.Model = door.Model; d.Name = "door"; d.Realm = door.Realm; d.State = eDoorState.Closed; d.X = door.X; d.Y = door.Y; d.Z = door.Z; DoorMgr.RegisterDoor(door); d.AddToWorld(); } UnloadTimers(); GameEventMgr.RemoveHandler(CurrentRegion, RegionEvent.PlayerEnter, new DOLEventHandler(SendKeepInit)); if (area != null) { CurrentRegion.RemoveArea(area); } RemoveFromDatabase(); GameServer.KeepManager.Keeps[KeepID] = null; }
/// <summary> /// load the keep door object from DB object /// </summary> /// <param name="obj"></param> public override void LoadFromDatabase(DataObject obj) { DBDoor door = obj as DBDoor; if (door == null) { return; } base.LoadFromDatabase(obj); Zone curZone = WorldMgr.GetZone((ushort)(door.InternalID / 1000000)); if (curZone == null) { return; } this.CurrentRegion = curZone.ZoneRegion; m_name = door.Name; m_Heading = (ushort)door.Heading; Position = new Vector3(door.X, door.Y, door.Z); m_level = 0; m_model = 0xFFFF; m_doorID = door.InternalID; m_state = eDoorState.Closed; this.AddToWorld(); foreach (AbstractArea area in this.CurrentAreas) { if (area is KeepArea keepArea) { string sKey = door.InternalID.ToString(); if (!keepArea.Keep.Doors.ContainsKey(sKey)) { Component = new GameKeepComponent(); Component.Keep = keepArea.Keep; keepArea.Keep.Doors.Add(sKey, this); } break; } } m_health = MaxHealth; StartHealthRegeneration(); DoorMgr.RegisterDoor(this); }