mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 11:03:38 +00:00
tp
to move directly in the same scene (#2375)
This commit is contained in:
parent
ff6a51db30
commit
43db7eba8f
@ -385,7 +385,7 @@ public class World implements Iterable<Player> {
|
|||||||
|
|
||||||
// Call player teleport event.
|
// Call player teleport event.
|
||||||
PlayerTeleportEvent event =
|
PlayerTeleportEvent event =
|
||||||
new PlayerTeleportEvent(player, teleportProperties, player.getPosition());
|
new PlayerTeleportEvent(player, teleportProperties, player.getPosition());
|
||||||
// Call event and check if it was canceled.
|
// Call event and check if it was canceled.
|
||||||
event.call();
|
event.call();
|
||||||
if (event.isCanceled()) {
|
if (event.isCanceled()) {
|
||||||
@ -396,40 +396,54 @@ public class World implements Iterable<Player> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene oldScene = null;
|
Scene oldScene = player.getScene();
|
||||||
if (player.getScene() != null) {
|
var newScene = this.getSceneById(teleportProperties.getSceneId());
|
||||||
oldScene = player.getScene();
|
|
||||||
|
|
||||||
|
// Move directly in the same scene.
|
||||||
|
if (newScene == oldScene && teleportProperties.getTeleportType() == TeleportType.COMMAND) {
|
||||||
|
// Set player position and rotation
|
||||||
|
if (teleportProperties.getTeleportTo() != null) {
|
||||||
|
player.getPosition().set(teleportProperties.getTeleportTo());
|
||||||
|
}
|
||||||
|
if (teleportProperties.getTeleportRot() != null) {
|
||||||
|
player.getRotation().set(teleportProperties.getTeleportRot());
|
||||||
|
}
|
||||||
|
player.sendPacket(new PacketSceneEntityAppearNotify(player));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldScene != null) {
|
||||||
// Don't deregister scenes if the player is going to tp back into them
|
// Don't deregister scenes if the player is going to tp back into them
|
||||||
if (oldScene.getId() == teleportProperties.getSceneId()) {
|
if (oldScene == newScene) {
|
||||||
oldScene.setDontDestroyWhenEmpty(true);
|
oldScene.setDontDestroyWhenEmpty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldScene.removePlayer(player);
|
oldScene.removePlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newScene = this.getSceneById(teleportProperties.getSceneId());
|
if (newScene != null) {
|
||||||
newScene.addPlayer(player);
|
newScene.addPlayer(player);
|
||||||
|
|
||||||
player.getTeamManager().applyAbilities(newScene);
|
player.getTeamManager().applyAbilities(newScene);
|
||||||
|
|
||||||
// Dungeon
|
// Dungeon
|
||||||
// Dungeon system is handling this already
|
// Dungeon system is handling this already
|
||||||
// if(dungeonData!=null){
|
// if(dungeonData!=null){
|
||||||
// var dungeonManager = new DungeonManager(newScene, dungeonData);
|
// var dungeonManager = new DungeonManager(newScene, dungeonData);
|
||||||
// dungeonManager.startDungeon();
|
// dungeonManager.startDungeon();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
SceneConfig config = newScene.getScriptManager().getConfig();
|
SceneConfig config = newScene.getScriptManager().getConfig();
|
||||||
if (teleportProperties.getTeleportTo() == null && config != null) {
|
if (teleportProperties.getTeleportTo() == null && config != null) {
|
||||||
if (config.born_pos != null) {
|
if (config.born_pos != null) {
|
||||||
teleportProperties.setTeleportTo(config.born_pos);
|
teleportProperties.setTeleportTo(config.born_pos);
|
||||||
}
|
}
|
||||||
if (config.born_rot != null) {
|
if (config.born_rot != null) {
|
||||||
teleportProperties.setTeleportRot(config.born_rot);
|
teleportProperties.setTeleportRot(config.born_rot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set player position and rotation
|
// Set player position and rotation
|
||||||
if (teleportProperties.getTeleportTo() != null) {
|
if (teleportProperties.getTeleportTo() != null) {
|
||||||
player.getPosition().set(teleportProperties.getTeleportTo());
|
player.getPosition().set(teleportProperties.getTeleportTo());
|
||||||
@ -438,7 +452,7 @@ public class World implements Iterable<Player> {
|
|||||||
player.getRotation().set(teleportProperties.getTeleportRot());
|
player.getRotation().set(teleportProperties.getTeleportRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldScene != null && newScene != oldScene) {
|
if (oldScene != null && newScene != null && newScene != oldScene) {
|
||||||
newScene.setPrevScenePoint(oldScene.getPrevScenePoint());
|
newScene.setPrevScenePoint(oldScene.getPrevScenePoint());
|
||||||
oldScene.setDontDestroyWhenEmpty(false);
|
oldScene.setDontDestroyWhenEmpty(false);
|
||||||
}
|
}
|
||||||
@ -447,7 +461,7 @@ public class World implements Iterable<Player> {
|
|||||||
player.sendPacket(new PacketPlayerEnterSceneNotify(player, teleportProperties));
|
player.sendPacket(new PacketPlayerEnterSceneNotify(player, teleportProperties));
|
||||||
|
|
||||||
if (teleportProperties.getTeleportType() != TeleportType.INTERNAL
|
if (teleportProperties.getTeleportType() != TeleportType.INTERNAL
|
||||||
&& teleportProperties.getTeleportType() != SCRIPT) {
|
&& teleportProperties.getTeleportType() != SCRIPT) {
|
||||||
player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_ANY_MANUAL_TRANSPORT);
|
player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_ANY_MANUAL_TRANSPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user