Exemplo n.º 1
0
		public virtual void SpawnLevel(Level toLevel, PlayerLocation spawnPoint)
		{
			bool oldNoAi = NoAi;
			SetNoAi(true);

			// send teleport straight up, no chunk loading
			SetPosition(new PlayerLocation
			{
				X = KnownPosition.X, Y = 4000, Z = KnownPosition.Z, Yaw = 91, Pitch = 28, HeadYaw = 91,
			});

			//if (Level != null)
			{
				Level.RemovePlayer(this, true);
				Level.EntityManager.RemoveEntity(null, this);
			}

			Level = toLevel; // Change level
			SpawnPosition = spawnPoint;
			//Level.AddPlayer(this, "", false);
			// reset all health states
			HealthManager.ResetHealth();
			SendSetHealth();

			SendSetSpawnPosition();

			SendAdventureSettings();

			SendPlayerInventory();

			CleanCache();

			ForcedSendChunk(spawnPoint);

			// send teleport to spawn
			SetPosition(spawnPoint);

			SetNoAi(oldNoAi);

			Level.AddPlayer(this, true);

			Log.InfoFormat("Respawn player {0} on level {1}", Username, Level.LevelId);

			SendSetTime();

			ThreadPool.QueueUserWorkItem(delegate(object state) { ForcedSendChunks(); });
		}
Exemplo n.º 2
0
        public virtual void SpawnLevel(Level toLevel, PlayerLocation spawnPoint)
        {
            SetNoAi(true);

            // send teleport straight up, no chunk loading
            SetPosition(new PlayerLocation
            {
                X = KnownPosition.X,
                Y = 4000,
                Z = KnownPosition.Z,
                Yaw = 91,
                Pitch = 28,
                HeadYaw = 91,
            });

            Level.RemovePlayer(this, true);
            Level.EntityManager.RemoveEntity(null, this);

            Level = toLevel; // Change level
            SpawnPosition = spawnPoint;
            Level.AddPlayer(this, "", false);
            // reset all health states
            HealthManager.ResetHealth();
            SendSetHealth();

            SendSetSpawnPosition();

            SendAdventureSettings();

            SendPlayerInventory();

            lock (_chunksUsed)
            {
                _chunksUsed.Clear();
            }

            ForcedSendChunksForKnownPosition(spawnPoint);

            // send teleport to spawn
            SetPosition(spawnPoint);

            SetNoAi(false);

            Level.SpawnToAll(this);
            IsSpawned = true;

            Log.InfoFormat("Respawn player {0} on level {1}", Username, Level.LevelId);

            SendSetTime();
        }