mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-12 21:34:35 +01:00
Implement character ascension material bosses
This commit is contained in:
@@ -17,6 +17,7 @@ import emu.lunarcore.game.scene.entity.*;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.proto.SceneEntityGroupInfoOuterClass.SceneEntityGroupInfo;
|
||||
import emu.lunarcore.proto.SceneInfoOuterClass.SceneInfo;
|
||||
import emu.lunarcore.server.packet.send.PacketActivateFarmElementScRsp;
|
||||
import emu.lunarcore.server.packet.send.PacketSceneGroupRefreshScNotify;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
@@ -157,6 +158,10 @@ public class Scene {
|
||||
return ++lastEntityId;
|
||||
}
|
||||
|
||||
public GameEntity getEntityById(int id) {
|
||||
return this.entities.get(id);
|
||||
}
|
||||
|
||||
public void syncLineup() {
|
||||
// Get current lineup
|
||||
PlayerLineup lineup = getPlayer().getLineupManager().getCurrentLineup();
|
||||
@@ -198,6 +203,17 @@ public class Scene {
|
||||
getPlayer().sendPacket(new PacketSceneGroupRefreshScNotify(toAdd, toRemove));
|
||||
}
|
||||
|
||||
public boolean activateFarmElement(int entityId, int worldLevel) {
|
||||
GameEntity entity = this.getEntityById(entityId);
|
||||
if (entity == null) {
|
||||
player.sendPacket(new PacketActivateFarmElementScRsp());
|
||||
return false;
|
||||
}
|
||||
|
||||
player.sendPacket(new PacketActivateFarmElementScRsp(entityId, worldLevel));
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized void addEntity(GameEntity entity) {
|
||||
// Dont add if monster id already exists
|
||||
if (entity.getEntityId() != 0) return;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package emu.lunarcore.server.packet.recv;
|
||||
|
||||
import emu.lunarcore.proto.ActivateFarmElementCsReqOuterClass.ActivateFarmElementCsReq;
|
||||
import emu.lunarcore.server.game.GameSession;
|
||||
import emu.lunarcore.server.packet.CmdId;
|
||||
import emu.lunarcore.server.packet.Opcodes;
|
||||
import emu.lunarcore.server.packet.PacketHandler;
|
||||
|
||||
@Opcodes(CmdId.ActivateFarmElementCsReq)
|
||||
public class HandlerActivateFarmElementCsReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
|
||||
var req = ActivateFarmElementCsReq.parseFrom(data);
|
||||
|
||||
session.getPlayer().getScene().activateFarmElement(req.getEntityId(), req.getWorldLevel());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package emu.lunarcore.server.packet.send;
|
||||
|
||||
import emu.lunarcore.proto.ActivateFarmElementScRspOuterClass.ActivateFarmElementScRsp;
|
||||
import emu.lunarcore.server.packet.BasePacket;
|
||||
import emu.lunarcore.server.packet.CmdId;
|
||||
|
||||
public class PacketActivateFarmElementScRsp extends BasePacket {
|
||||
|
||||
public PacketActivateFarmElementScRsp() {
|
||||
super(CmdId.ActivateFarmElementScRsp);
|
||||
|
||||
var data = ActivateFarmElementScRsp.newInstance()
|
||||
.setRetcode(1);
|
||||
|
||||
this.setData(data);
|
||||
}
|
||||
|
||||
public PacketActivateFarmElementScRsp(int entityId, int worldLevel) {
|
||||
super(CmdId.ActivateFarmElementScRsp);
|
||||
|
||||
var data = ActivateFarmElementScRsp.newInstance()
|
||||
.setEntityId(entityId)
|
||||
.setWorldLevel(worldLevel);
|
||||
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user