示例#1
0
        static bool GotoLevel(Player p, Level lvl)
        {
            if (p.level == lvl)
            {
                p.Message("You are already in {0}%S.", lvl.ColoredName); return(false);
            }

            bool canJoin = lvl.CanJoin(p);

            OnJoiningLevelEvent.Call(p, lvl, ref canJoin);
            if (!canJoin)
            {
                return(false);
            }

            p.Loading = true;
            Entities.DespawnEntities(p);
            Level prev = p.level;

            p.level = lvl;

            p.SendRawMap(prev, lvl);
            PostSentMap(p, prev, lvl, true);
            p.Loading = false;
            return(true);
        }
示例#2
0
        static bool GotoLevel(Player p, Level lvl)
        {
            if (p.level == lvl)
            {
                Player.Message(p, "You are already in {0}%S.", lvl.ColoredName); return(false);
            }
            if (!lvl.CanJoin(p))
            {
                return(false);
            }

            p.Loading = true;
            Entities.DespawnEntities(p);
            Level oldLevel = p.level;

            p.level = lvl;
            p.SendMap(oldLevel);

            Position pos = lvl.SpawnPos;
            byte     yaw = lvl.rotx, pitch = lvl.roty;

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, false);
            Entities.SpawnEntities(p, pos, new Orientation(yaw, pitch));
            CheckGamesJoin(p, oldLevel);

            if (p.level.ShouldShowJoinMessage(oldLevel))
            {
                string msg = p.level.IsMuseum ? " %Swent to the " : " %Swent to ";
                Chat.MessageGlobal(p, p.ColoredName + msg + lvl.ColoredName, false, true);
                OnPlayerActionEvent.Call(p, PlayerAction.JoinWorld, lvl.name);
            }
            return(true);
        }
示例#3
0
        public static Level Load(Player p, string map, bool announce)
        {
            map = map.ToLower();
            if (!LevelInfo.MapExists(map))
            {
                p.Message("Level \"{0}\" does not exist", map); return(null);
            }

            Level cur = LevelInfo.FindExact(map);

            if (cur != null)
            {
                p.Message("%WLevel {0} %Wis already loaded.", cur.ColoredName); return(null);
            }

            try {
                Level lvl = ReadLevel(p, map);
                if (lvl == null || !lvl.CanJoin(p))
                {
                    return(null);
                }

                cur = LevelInfo.FindExact(map);
                if (cur != null)
                {
                    p.Message("%WLevel {0} %Wis already loaded.", cur.ColoredName); return(null);
                }

                LevelInfo.Add(lvl);
                if (!announce)
                {
                    return(lvl);
                }

                string autoloadMsg = "Level " + lvl.ColoredName + " %Sloaded.";
                Chat.Message(ChatScope.All, autoloadMsg, null, Chat.FilterVisible(p));
                return(lvl);
            } finally {
                Server.DoGC();
            }
        }
示例#4
0
        static bool GotoLevel(Player p, Level lvl)
        {
            if (p.level == lvl)
            {
                p.Message("You are already in {0}%S.", lvl.ColoredName); return(false);
            }
            if (!lvl.CanJoin(p))
            {
                return(false);
            }

            p.Loading = true;
            Entities.DespawnEntities(p);
            Level oldLevel = p.level;

            p.level = lvl;
            p.SendMap(oldLevel);

            PostSentMap(p, oldLevel, lvl, true);
            return(true);
        }
示例#5
0
        static bool GotoLevel(Player p, Level lvl, bool ignorePerms)
        {
            if (p.level == lvl)
            {
                Player.Message(p, "You are already in {0}%S.", lvl.ColoredName); return(false);
            }
            if (!lvl.CanJoin(p, ignorePerms))
            {
                return(false);
            }
            if (!Server.zombie.PlayerCanJoinLevel(p, lvl, p.level))
            {
                return(false);
            }

            p.Loading = true;
            Entities.DespawnEntities(p);
            Level oldLevel = p.level;

            p.level = lvl; p.SendUserMOTD(); p.SendMap(oldLevel);

            ushort x = (ushort)(lvl.spawnx * 32 + 16);
            ushort y = (ushort)(lvl.spawny * 32 + 32);
            ushort z = (ushort)(lvl.spawnz * 32 + 16);

            Entities.SpawnEntities(p, x, y, z, lvl.rotx, lvl.roty);
            p.Loading = false;
            CheckGamesJoin(p, oldLevel);
            p.prevMsg = "";

            if (!p.hidden && p.level.ShouldShowJoinMessage(oldLevel))
            {
                Player.SendChatFrom(p, p.ColoredName + " %Swent to " + lvl.ColoredName, false);
                Player.RaisePlayerAction(p, PlayerAction.JoinWorld, lvl.name);
            }
            return(true);
        }