wServer.realm.entities.player.Player.UsePortal C# (CSharp) Method

UsePortal() public method

public UsePortal ( RealmTime time, wServer.cliPackets.UsePortalPacket pkt ) : void
time RealmTime
pkt wServer.cliPackets.UsePortalPacket
return void
        public void UsePortal(RealmTime time, UsePortalPacket pkt)
        {
            var entity = Owner.GetEntity(pkt.ObjectId);
            if (entity == null || !entity.Usable) return;
            World world = null;
            var player = this;
            Portal p = null;
            if (entity is Portal)
            {
                p = entity as Portal;
                world = p.WorldInstance;
            }
            if (world == null)
            {
                if (p != null)
                {
                    var setWorldInstance = true;
                    var d = "";
                    if (XmlDatas.IdToDungeon.TryGetValue(entity.ObjectType, out d))
                    {
                        world = RealmManager.AddWorld(new XmlWorld(XmlDatas.DungeonDescs[d]));
                    }
                    else
                    {
                        switch (entity.ObjectType) //handling default case for not found. Add more as implemented
                        {
                            case 0x0703: //portal of cowardice
                                {
                                    if (RealmManager.PlayerWorldMapping.ContainsKey(AccountId))
                                        //may not be valid, realm recycled?
                                        world = RealmManager.PlayerWorldMapping[AccountId];
                                    //also reconnecting to vault is a little unexpected
                                    else if (world.Id == -5 || world.Id == -11)
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                    else
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                }
                                break;
                            case 0x0d40:
                                {
                                    if (RealmManager.PlayerWorldMapping.ContainsKey(AccountId))
                                        //may not be valid, realm recycled?
                                        world = RealmManager.PlayerWorldMapping[AccountId];
                                    //also reconnecting to vault is a little unexpected
                                    else if (world.Id == -5 || world.Id == -11)
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                    else
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                }
                                break;
                            case 0x0712:
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                                break;
                            case 0x071d:
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                                break;
                            case 0x071c:
                                world = RealmManager.Monitor.GetRandomRealm();
                                break;
                            case 0x0720:
                                world = RealmManager.PlayerVault(psr);
                                setWorldInstance = false;
                                break;
                            case 0x071e:
                                world = RealmManager.AddWorld(new Kitchen());
                                break;
                            case 0x0ffa: //these need to match IDs
                                //world = RealmManager.GetWorld(World.GauntletMap); break; //this creates a singleton dungeon
                                world = RealmManager.AddWorld(new Island());
                                break; //this allows each dungeon to be unique
                            case 0x0ffc:
                                world = RealmManager.AddWorld(new WineCellarMap());
                                break;
                            case 0x1900:
                                world = RealmManager.AddWorld(new ArenaMap());
                                break;
                            case 0x0730:
                                world = RealmManager.AddWorld(new OceanTrench());
                                break;
                            case 0x070c:
                                world = RealmManager.AddWorld(new SpriteWorld());
                                break;
                            case 0x071b:
                                world = RealmManager.AddWorld(new Abyss());
                                break;
                            case 0x071a:
                                world = RealmManager.AddWorld(new UndeadLair());
                                break;
                            case 0x1901:
                                world = RealmManager.AddWorld(new VoidWorld());
                                break;
                            case 0x072c:
                                world = RealmManager.AddWorld(new TombMap());
                                break;
                            case 0x1905:
                                {
                                    psr.SendPacket(new TextBoxPacket
                                    {
                                        Button1 = "Enter",
                                        Button2 = "Cancel",
                                        Message = "Join the arena at the price of 150 fame?",
                                        Title = "Arena Confirmation",
                                        Type = "EnterArena1"
                                    });
                                }
                                break;
                            case 0x1908:

                                psr.SendPacket(new TextBoxPacket
                                {
                                    Button1 = "Enter",
                                    Button2 = "Cancel",
                                    Message = "Join the free arena?",
                                    Title = "Arena Confirmation",
                                    Type = "EnterArena2"
                                });
                                break;
                            case 0x0742:
                                world = RealmManager.AddWorld(new BeachZone());
                                break;
                            case 0x0718:
                                world = RealmManager.AddWorld(new SnakePit());
                                break;
                            case 0x0890:
                                world = RealmManager.AddWorld(new MadLabMap());
                                break;
                            case 0x1919:
                                world = RealmManager.AddWorld(new Secret());
                                break;
                            case 0x1923:
                                world = RealmManager.AddWorld(new ZombieMap());
                                break;
                            default:
                                SendError("Portal Not Implemented!");
                                break;
                            case 0x195d:
                                world = RealmManager.AddWorld(new MarketMap());
                                break;
                            //case 0x268D:
                            //    world = RealmManager.PlayerHome(psr);
                            //    setWorldInstance = false;
                            //    break;

                            case 0x070d:
                                world = RealmManager.Monitor.GetRandomRealm();
                                break;
                            case 0x070e:
                                world = RealmManager.Monitor.GetRandomRealm();
                                break;
                            case 0x0704:
                                world = RealmManager.Monitor.GetRandomRealm();
                                break;
                            case 0x753E:
                                world = RealmManager.AddWorld(new LairofDraconis());
                                break;
                            case 0x7002:
                                world = RealmManager.AddWorld(new PartyCellarMap());
                                break;
                            case 0x701c:
                                {
                                    psr.SendPacket(new TextBoxPacket
                                    {
                                        Button1 = "Enter",
                                        Button2 = "Cancel",
                                        Message = "Join sheep herding at the price of 500 fame?",
                                        Title = "Sheep Herding",
                                        Type = "SheepHerding"
                                    });
                                }
                                break;
                            case 0x7024:
                                {
                                    psr.SendPacket(new TextBoxPacket
                                    {
                                        Button1 = "Yes",
                                        Button2 = "Cancel",
                                        Message = "Join zombies at the price of 100 fame?",
                                        Title = "Zombies",
                                        Type = "Zombies"
                                    });
                                }
                                break;
                            case 0x7025:
                                world = RealmManager.AddWorld(new ForestMap());
                                break;
                        }
                    }
                    if (setWorldInstance)
                        p.WorldInstance = world;
                }
                else
                {
                    switch (entity.ObjectType) // Special Portals that cannot be the portal class
                    {
                        case 0x072f:
                            world = RealmManager.GuildHallWorld(Guild);
                            break;
                        default:
                            psr.SendPacket(new TextPacket
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "",
                                Text = "Semi-Portal Not Implemented!"
                            });
                            break;
                    }
                }
            }

            //used to match up player to last realm they were in, to return them to it. Sometimes is odd, like from Vault back to Vault...

            if (RealmManager.PlayerWorldMapping.ContainsKey(AccountId))
            {
                World tempWorld;
                RealmManager.PlayerWorldMapping.TryRemove(AccountId, out tempWorld);
            }
            RealmManager.PlayerWorldMapping.TryAdd(AccountId, Owner);
            psr.Reconnect(new ReconnectPacket
            {
                Host = "",
                Port = 2050,
                GameId = world.Id,
                Name = world.Name,
                Key = Empty<byte>.Array,
            });
        }