mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 07:37:43 +00:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
34589d0128
@ -9,13 +9,12 @@ import emu.grasscutter.game.entity.EntityHomeAnimal;
|
|||||||
import emu.grasscutter.game.world.Position;
|
import emu.grasscutter.game.world.Position;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;
|
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
@ -84,17 +83,16 @@ public class HomeSceneItem {
|
|||||||
return mainHouse == null || mainHouse.getAsItem() == null;
|
return mainHouse == null || mainHouse.getAsItem() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public Position getTeleportPointPos(int guid) {
|
||||||
public Position getTeleportPointPos(int guid) {
|
|
||||||
var pos = new AtomicReference<Position>();
|
var pos = new AtomicReference<Position>();
|
||||||
|
|
||||||
this.getBlockItems().values().stream()
|
this.getBlockItems().values().stream()
|
||||||
.map(HomeBlockItem::getDeployFurnitureList)
|
.map(HomeBlockItem::getDeployFurnitureList)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid)
|
.filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid)
|
||||||
.map(HomeFurnitureItem::getSpawnPos)
|
.map(HomeFurnitureItem::getSpawnPos)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(pos::set);
|
.ifPresent(pos::set);
|
||||||
|
|
||||||
return pos.get();
|
return pos.get();
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,10 @@ public class HomeWorldMPSystem extends BaseGameSystem {
|
|||||||
int realmId = 2000 + owner.getCurrentRealmId();
|
int realmId = 2000 + owner.getCurrentRealmId();
|
||||||
var item = targetHome.getHomeSceneItem(realmId);
|
var item = targetHome.getHomeSceneItem(realmId);
|
||||||
targetHome.save();
|
targetHome.save();
|
||||||
var pos = toSafe ? world.getSceneById(realmId).getScriptManager().getConfig().born_pos : item.getBornPos();
|
var pos =
|
||||||
|
toSafe
|
||||||
|
? world.getSceneById(realmId).getScriptManager().getConfig().born_pos
|
||||||
|
: item.getBornPos();
|
||||||
|
|
||||||
if (teleportPoint != 0) {
|
if (teleportPoint != 0) {
|
||||||
var target = item.getTeleportPointPos(teleportPoint);
|
var target = item.getTeleportPointPos(teleportPoint);
|
||||||
@ -202,12 +205,23 @@ public class HomeWorldMPSystem extends BaseGameSystem {
|
|||||||
player.getPosition().set(pos);
|
player.getPosition().set(pos);
|
||||||
var world = new World(player);
|
var world = new World(player);
|
||||||
world.addPlayer(player, prevScene);
|
world.addPlayer(player, prevScene);
|
||||||
player.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(player, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
|
player
|
||||||
|
.getCurHomeWorld()
|
||||||
|
.sendPacketToHostIfOnline(
|
||||||
|
new PacketOtherPlayerEnterOrLeaveHomeNotify(
|
||||||
|
player,
|
||||||
|
OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
|
||||||
var myHome = this.server.getHomeWorldOrCreate(player);
|
var myHome = this.server.getHomeWorldOrCreate(player);
|
||||||
player.setCurHomeWorld(myHome);
|
player.setCurHomeWorld(myHome);
|
||||||
myHome.getHome().onOwnerLogin(player);
|
myHome.getHome().onOwnerLogin(player);
|
||||||
|
|
||||||
player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK, EnterReason.TeamBack, prevScene, pos));
|
player.sendPacket(
|
||||||
|
new PacketPlayerEnterSceneNotify(
|
||||||
|
player,
|
||||||
|
EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK,
|
||||||
|
EnterReason.TeamBack,
|
||||||
|
prevScene,
|
||||||
|
pos));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -239,7 +253,12 @@ public class HomeWorldMPSystem extends BaseGameSystem {
|
|||||||
victim.getPosition().set(victim.getPrevPosForHome());
|
victim.getPosition().set(victim.getPrevPosForHome());
|
||||||
var world = new World(victim);
|
var world = new World(victim);
|
||||||
world.addPlayer(victim, 3);
|
world.addPlayer(victim, 3);
|
||||||
victim.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(victim, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
|
victim
|
||||||
|
.getCurHomeWorld()
|
||||||
|
.sendPacketToHostIfOnline(
|
||||||
|
new PacketOtherPlayerEnterOrLeaveHomeNotify(
|
||||||
|
victim,
|
||||||
|
OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
|
||||||
var myHome = this.server.getHomeWorldOrCreate(victim);
|
var myHome = this.server.getHomeWorldOrCreate(victim);
|
||||||
victim.setCurHomeWorld(myHome);
|
victim.setCurHomeWorld(myHome);
|
||||||
myHome.getHome().onOwnerLogin(victim);
|
myHome.getHome().onOwnerLogin(victim);
|
||||||
|
@ -16,7 +16,15 @@ public class HandlerHomeTransferReq extends PacketHandler {
|
|||||||
var home = player.getCurHomeWorld().getHome();
|
var home = player.getCurHomeWorld().getHome();
|
||||||
var item = home.getHomeSceneItem(player.getSceneId());
|
var item = home.getHomeSceneItem(player.getSceneId());
|
||||||
|
|
||||||
var pos = req.getIsTransferToMainHousePoint() ? item.getBornPos() : player.getCurHomeWorld().getSceneById(player.getSceneId()).getScriptManager().getConfig().born_pos;
|
var pos =
|
||||||
|
req.getIsTransferToMainHousePoint()
|
||||||
|
? item.getBornPos()
|
||||||
|
: player
|
||||||
|
.getCurHomeWorld()
|
||||||
|
.getSceneById(player.getSceneId())
|
||||||
|
.getScriptManager()
|
||||||
|
.getConfig()
|
||||||
|
.born_pos;
|
||||||
if (req.getGuid() != 0) {
|
if (req.getGuid() != 0) {
|
||||||
var target = item.getTeleportPointPos(req.getGuid());
|
var target = item.getTeleportPointPos(req.getGuid());
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
@ -50,15 +50,29 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
|
|||||||
req.getTargetUid()));
|
req.getTargetUid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> {
|
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption
|
||||||
session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint());
|
.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> {
|
||||||
|
session
|
||||||
|
.getServer()
|
||||||
|
.getHomeWorldMPSystem()
|
||||||
|
.enterHome(
|
||||||
|
session.getPlayer(),
|
||||||
|
targetPlayer,
|
||||||
|
req.getTargetPoint(),
|
||||||
|
req.getIsTransferToSafePoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint());
|
session
|
||||||
|
.getServer()
|
||||||
|
.getHomeWorldMPSystem()
|
||||||
|
.enterHome(
|
||||||
|
session.getPlayer(),
|
||||||
|
targetPlayer,
|
||||||
|
req.getTargetPoint(),
|
||||||
|
req.getIsTransferToSafePoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user