mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 17:53:21 +08:00
Spawn the player at the scene's start position when sent to a dungeon
This commit is contained in:
parent
0de69cd1fa
commit
60eb62fa42
@ -6,6 +6,9 @@ import emu.grasscutter.data.ResourceType;
|
|||||||
import emu.grasscutter.data.excels.RewardPreviewData;
|
import emu.grasscutter.data.excels.RewardPreviewData;
|
||||||
import emu.grasscutter.game.dungeons.enums.*;
|
import emu.grasscutter.game.dungeons.enums.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import emu.grasscutter.scripts.data.SceneMeta;
|
||||||
|
import emu.grasscutter.utils.Position;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@ResourceType(name = "DungeonExcelConfigData.json")
|
@ResourceType(name = "DungeonExcelConfigData.json")
|
||||||
@ -62,6 +65,20 @@ public class DungeonData extends GameResource {
|
|||||||
return involveType;
|
return involveType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The position of the player when they enter the dungeon.
|
||||||
|
*/
|
||||||
|
public Position getStartPosition() {
|
||||||
|
return SceneMeta.of(this.getSceneId()).config.born_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The rotation of the player when they enter the dungeon.
|
||||||
|
*/
|
||||||
|
public Position getStartRotation() {
|
||||||
|
return SceneMeta.of(this.getSceneId()).config.born_rot;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
if (this.passRewardPreviewID > 0) {
|
if (this.passRewardPreviewID > 0) {
|
||||||
|
@ -279,17 +279,25 @@ public class World implements Iterable<Player> {
|
|||||||
|
|
||||||
val sceneData = GameData.getSceneDataMap().get(sceneId);
|
val sceneData = GameData.getSceneDataMap().get(sceneId);
|
||||||
if (dungeonData != null) {
|
if (dungeonData != null) {
|
||||||
teleportProps.enterType(EnterType.ENTER_TYPE_DUNGEON).enterReason(EnterReason.DungeonEnter);
|
teleportProps.teleportTo(dungeonData.getStartPosition())
|
||||||
|
.teleportRot(dungeonData.getStartRotation());
|
||||||
|
teleportProps.enterType(EnterType.ENTER_TYPE_DUNGEON)
|
||||||
|
.enterReason(EnterReason.DungeonEnter);
|
||||||
} else if (player.getSceneId() == sceneId) {
|
} else if (player.getSceneId() == sceneId) {
|
||||||
teleportProps.enterType(EnterType.ENTER_TYPE_GOTO);
|
teleportProps.enterType(EnterType.ENTER_TYPE_GOTO);
|
||||||
} else if (sceneData != null && sceneData.getSceneType() == SceneType.SCENE_HOME_WORLD) {
|
} else if (sceneData != null && sceneData.getSceneType() == SceneType.SCENE_HOME_WORLD) {
|
||||||
// Home
|
// Home
|
||||||
teleportProps.enterType(EnterType.ENTER_TYPE_SELF_HOME).enterReason(EnterReason.EnterHome);
|
teleportProps.enterType(EnterType.ENTER_TYPE_SELF_HOME).enterReason(EnterReason.EnterHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
return transferPlayerToScene(player, teleportProps.build());
|
return transferPlayerToScene(player, teleportProps.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean transferPlayerToScene(Player player, TeleportProperties teleportProperties) {
|
public boolean transferPlayerToScene(Player player, TeleportProperties teleportProperties) {
|
||||||
|
// Check if the teleport properties are valid.
|
||||||
|
if (teleportProperties.getTeleportTo() == null)
|
||||||
|
teleportProperties.setTeleportTo(player.getPosition());
|
||||||
|
|
||||||
// Call player teleport event.
|
// Call player teleport event.
|
||||||
PlayerTeleportEvent event =
|
PlayerTeleportEvent event =
|
||||||
new PlayerTeleportEvent(player, teleportProperties, player.getPosition());
|
new PlayerTeleportEvent(player, teleportProperties, player.getPosition());
|
||||||
|
Loading…
Reference in New Issue
Block a user