mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-12-05 03:03:31 +00:00
f139818224
* feature(2.7 version): support 2.7 version & upload new protos 1. Support GC in GI 2.7.0; 2. Upload new protos; 3. Fix some bugs cuz by new protos. BREAKING CHANGE: all * fix(database helper): fix player uid issues * fix(ability embryo): uint32 to fixed32 * fix(proto): map mark rename MAP_MARK_FROM_TYPE_NOE to MAP_MARK_FROM_TYPE_NONE * fix(game version): change game version to 2.7.0 * perf(proto): remove unused protos 1. Remove unused protos; 2. Temporarily commented out some of the proto fields. * fix(proto): uint32 to fixed32
67 lines
2.6 KiB
Java
67 lines
2.6 KiB
Java
package emu.grasscutter.server.packet.send;
|
|
|
|
import emu.grasscutter.game.player.Player;
|
|
import emu.grasscutter.game.entity.EntityVehicle;
|
|
import emu.grasscutter.game.props.FightProperty;
|
|
import emu.grasscutter.game.entity.GameEntity;
|
|
|
|
import emu.grasscutter.net.packet.BasePacket;
|
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
|
|
|
import emu.grasscutter.net.proto.VehicleInteractTypeOuterClass;
|
|
import emu.grasscutter.net.proto.VehicleMemberOuterClass.VehicleMember;
|
|
import emu.grasscutter.net.proto.CreateVehicleRspOuterClass.CreateVehicleRsp;
|
|
|
|
import emu.grasscutter.utils.Position;
|
|
|
|
import java.util.List;
|
|
|
|
public class PacketCreateVehicleRsp extends BasePacket {
|
|
|
|
public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) {
|
|
super(PacketOpcodes.CreateVehicleRsp);
|
|
CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder();
|
|
|
|
// Eject vehicle members and Kill previous vehicles if there are any
|
|
List<GameEntity> previousVehicles = player.getScene().getEntities().values().stream()
|
|
.filter(entity -> entity instanceof EntityVehicle
|
|
&& ((EntityVehicle) entity).getGadgetId() == vehicleId
|
|
&& ((EntityVehicle) entity).getOwner().equals(player))
|
|
.toList();
|
|
|
|
previousVehicles.stream().forEach(entity -> {
|
|
List<VehicleMember> vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList();
|
|
|
|
vehicleMembers.stream().forEach(vehicleMember -> {
|
|
player.getScene().broadcastPacket(new PacketVehicleInteractRsp(((EntityVehicle) entity), vehicleMember, VehicleInteractTypeOuterClass.VehicleInteractType.VEHICLE_INTERACT_TYPE_OUT));
|
|
});
|
|
|
|
player.getScene().killEntity(entity, 0);
|
|
});
|
|
|
|
EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot);
|
|
|
|
switch (vehicleId) {
|
|
// TODO: Not hardcode this. Waverider (skiff)
|
|
case 45001001,45001002 -> {
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_BASE_HP, 10000);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, 100);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, 100);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 10000);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, 0);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_SPEED, 0);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 0);
|
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_MAX_HP, 10000);
|
|
}
|
|
default -> {}
|
|
}
|
|
|
|
player.getScene().addEntity(vehicle);
|
|
|
|
proto.setVehicleId(vehicleId);
|
|
proto.setEntityId(vehicle.getId());
|
|
|
|
this.setData(proto.build());
|
|
}
|
|
}
|