public Task TeleportSubCommandHandler(CommandContext context, string command, string[] parameters)
        {
            string name = parameters.Length == 0 ? context.Session.Player.Name : string.Join(" ", parameters);

            Residence residence = ResidenceManager.GetResidence(name).GetAwaiter().GetResult();

            if (residence == null)
            {
                if (parameters.Length == 0)
                {
                    residence = ResidenceManager.CreateResidence(context.Session.Player);
                }
                else
                {
                    context.SendMessageAsync("A residence for that character doesn't exist!");
                    return(Task.CompletedTask);
                }
            }

            ResidenceEntrance entrance = ResidenceManager.GetResidenceEntrance(residence);

            context.Session.Player.TeleportTo(entrance.Entry, entrance.Position, 0u, residence.Id);

            return(Task.CompletedTask);
        }
Beispiel #2
0
        public static void HandleItemUseDecor(WorldSession session, ClientItemUseDecor itemUseDecor)
        {
            Item item = session.Player.Inventory.GetItem(itemUseDecor.ItemGuid);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            HousingDecorInfoEntry entry = GameTableManager.HousingDecorInfo.GetEntry(item.Entry.HousingDecorInfoId);

            if (entry == null)
            {
                throw new InvalidPacketValueException();
            }

            Task <Residence> task = ResidenceManager.GetResidence(session.Player.Name);

            session.EnqueueEvent(new TaskGenericEvent <Residence>(task,
                                                                  residence =>
            {
                if (residence == null)
                {
                    residence = ResidenceManager.CreateResidence(session.Player);
                }

                if (session.Player.Inventory.ItemUse(item))
                {
                    residence.DecorCreate(entry);
                }
            }));
        }
        public static void HandleCharacterSelect(WorldSession session, ClientCharacterSelect characterSelect)
        {
            Character character = session.Characters.SingleOrDefault(c => c.Id == characterSelect.CharacterId);

            if (character == null)
            {
                session.EnqueueMessageEncrypted(new ServerCharacterSelectFail
                {
                    Result = CharacterSelectResult.Failed
                });
                return;
            }

            session.Player = new Player(session, character);

            WorldEntry entry = GameTableManager.World.GetEntry(character.WorldId);

            if (entry == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            switch (entry.Type)
            {
            // housing map
            case 5:
            {
                // characters logging in to a housing map are returned to their own residence
                session.EnqueueEvent(new TaskGenericEvent <Residence>(ResidenceManager.GetResidence(session.Player.Name),
                                                                      residence =>
                    {
                        if (residence == null)
                        {
                            residence = ResidenceManager.CreateResidence(session.Player);
                        }

                        ResidenceEntrance entrance = ResidenceManager.GetResidenceEntrance(residence);
                        var mapInfo = new MapInfo(entrance.Entry, 0u, residence.Id);
                        MapManager.AddToMap(session.Player, mapInfo, entrance.Position);
                    }));

                break;
            }

            default:
            {
                var mapInfo = new MapInfo(entry);
                var vector3 = new Vector3(character.LocationX, character.LocationY, character.LocationZ);
                MapManager.AddToMap(session.Player, mapInfo, vector3);
                break;
            }
            }
        }
Beispiel #4
0
        public override void Initialise(MapInfo info, Player player)
        {
            base.Initialise(info, player);

            if (info.ResidenceId != 0u)
            {
                residence = ResidenceManager.GetCachedResidence(info.ResidenceId);
                if (residence == null)
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                residence = ResidenceManager.CreateResidence(player);
            }

            // initialise plug entities
            foreach (Plot plot in residence.GetPlots().Where(p => p.PlugEntry != null))
            {
                var plug = new Plug(plot.PlotEntry, plot.PlugEntry);
                EnqueueAdd(plug, Vector3.Zero);
            }
        }