Example #1
0
        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);
            }
        }
Example #2
0
 void Start()
 {
     //ヒエラルキーからFindでDoorMgrを探す
     doormgr_obj = GameObject.Find("DoorManager");
     doormgr     = doormgr_obj.GetComponent <DoorMgr>();
     audio       = GameObject.Find("AudioList").GetComponent <AudioPlayer>();
 }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <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;
        }
Example #5
0
        /// <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);
        }
        public void AddingDoor(GamePlayer player, byte response)
        {
            if (response != 0x01)
            {
                return;
            }

            int doorType = HandlerDoorId / 100000000;

            if (doorType == 7)
            {
                PositionMgr.CreateDoor(HandlerDoorId, player);
            }
            else
            {
                var door = new DBDoor
                {
                    ObjectId   = null,
                    InternalID = HandlerDoorId,
                    Name       = "door",
                    Type       = HandlerDoorId / 100000000,
                    Level      = 20,
                    Realm      = 6,
                    MaxHealth  = 2545,
                    Health     = 2545,
                    Locked     = 0,
                    X          = player.X,
                    Y          = player.Y,
                    Z          = player.Z,
                    Heading    = player.Heading
                };

                GameServer.Database.AddObject(door);

                player.Out.SendMessage($"Added door {HandlerDoorId} to the database!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                DoorMgr.Init();
            }
        }
Example #7
0
        public void AddingDoor(GamePlayer player, byte response)
        {
            if (response != 0x01)
            {
                return;
            }

            int doorType = m_handlerDoorID / 100000000;

            if (doorType == 7)
            {
                PositionMgr.CreateDoor(m_handlerDoorID, player);
            }
            else
            {
                var door = new DBDoor();
                door.ObjectId   = null;
                door.InternalID = m_handlerDoorID;
                door.Name       = "door";
                door.Type       = m_handlerDoorID / 100000000;
                door.Level      = 20;
                door.Realm      = 6;
                door.MaxHealth  = 2545;
                door.Health     = 2545;
                door.Locked     = 0;
                door.X          = (int)player.Position.X;
                door.Y          = (int)player.Position.Y;
                door.Z          = (int)player.Position.Z;
                door.Heading    = player.Heading;
                GameServer.Database.AddObject(door);

                player.Out.SendMessage("Added door " + m_handlerDoorID + " to the database!", eChatType.CT_Important,
                                       eChatLoc.CL_SystemWindow);
                DoorMgr.Init();
            }
        }
Example #8
0
            /// <summary>
            /// Called on every timer tick
            /// </summary>
            protected override void OnTick()
            {
                var          player   = (GamePlayer)m_actionSource;
                List <IDoor> doorList = DoorMgr.getDoorByID(m_doorId);

                if (doorList.Count > 0)
                {
                    bool success = false;
                    foreach (IDoor mydoor in doorList)
                    {
                        if (success)
                        {
                            break;
                        }
                        if (mydoor is GameKeepDoor)
                        {
                            var door = mydoor as GameKeepDoor;
                            //portal keeps left click = right click
                            if (door.Component.Keep is GameKeepTower && door.Component.Keep.KeepComponents.Count > 1)
                            {
                                door.Interact(player);
                            }
                            success = true;
                        }
                        else
                        {
                            if (player.IsWithinRadius(mydoor.Position, m_radius))
                            {
                                if (m_doorState == 0x01)
                                {
                                    mydoor.Open(player);
                                }
                                else
                                {
                                    mydoor.Close(player);
                                }
                                success = true;
                            }
                        }
                    }

                    if (!success)
                    {
                        player.Out.SendMessage(
                            LanguageMgr.GetTranslation(player.Client.Account.Language, "DoorRequestHandler.OnTick.TooFarAway", doorList[0].Name),
                            eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
                else
                {
                    //new frontiers we don't want this, i.e. relic gates etc
                    if (player.CurrentRegionID == 163 && player.Client.Account.PrivLevel == 1)
                    {
                        return;
                    }

                    /*
                     * //create a bug report
                     * BugReport report = new BugReport();
                     * report.DateSubmitted = DateTime.Now;
                     * report.ID = GameServer.Database.GetObjectCount<BugReport>() + 1;
                     * report.Message = "There is a missing door at location Region: " + player.CurrentRegionID + " X:" + player.X + " Y: " + player.Y + " Z: " + player.Z;
                     * report.Submitter = player.Name;
                     * GameServer.Database.AddObject(report);
                     */

                    player.Out.SendDebugMessage("Door {0} not found in door list, opening via GM door hack.", m_doorId);

                    //else basic quick hack
                    var door = new GameDoor();
                    door.DoorID        = m_doorId;
                    door.Position      = player.Position;
                    door.Realm         = eRealm.Door;
                    door.CurrentRegion = player.CurrentRegion;
                    door.Open(player);
                }
            }
            /// <summary>
            /// Called on every timer tick
            /// </summary>
            protected override void OnTick()
            {
                var          player   = (GamePlayer)m_actionSource;
                List <IDoor> doorList = DoorMgr.getDoorByID(_doorId);

                if (doorList.Count > 0)
                {
                    bool success = false;
                    foreach (IDoor mydoor in doorList)
                    {
                        if (success)
                        {
                            break;
                        }

                        if (mydoor is GameKeepDoor)
                        {
                            var door = mydoor as GameKeepDoor;

                            // portal keeps left click = right click
                            if (door.Component.AbstractKeep is GameKeepTower && door.Component.AbstractKeep.KeepComponents.Count > 1)
                            {
                                door.Interact(player);
                            }

                            success = true;
                        }
                        else
                        {
                            if (player.IsWithinRadius(mydoor, _radius))
                            {
                                if (_doorState == 0x01)
                                {
                                    mydoor.Open(player);
                                }
                                else
                                {
                                    mydoor.Close(player);
                                }

                                success = true;
                            }
                        }
                    }

                    if (!success)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "DoorRequestHandler.OnTick.TooFarAway", doorList[0].Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
                else
                {
                    // new frontiers we don't want this, i.e. relic gates etc
                    if (player.CurrentRegionID == 163 && player.Client.Account.PrivLevel == 1)
                    {
                        return;
                    }

                    player.Out.SendDebugMessage($"Door {_doorId} not found in door list, opening via GM door hack.");

                    // else basic quick hack
                    var door = new GameDoor
                    {
                        DoorID        = _doorId,
                        X             = player.X,
                        Y             = player.Y,
                        Z             = player.Z,
                        Realm         = eRealm.Door,
                        CurrentRegion = player.CurrentRegion
                    };

                    door.Open(player);
                }
            }
Example #10
0
 void Start()
 {
     //ヒエラルキーからFindでDoorMgrを探す
     doormgr_obj = GameObject.Find("DoorManager");
     doormgr     = doormgr_obj.GetComponent <DoorMgr>();
 }