mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-23 10:44:36 +01:00
Implement rogue portals (cant enter yet)
This commit is contained in:
@@ -3,11 +3,16 @@ package emu.lunarcore.game.rogue;
|
||||
import emu.lunarcore.data.GameData;
|
||||
import emu.lunarcore.data.config.GroupInfo;
|
||||
import emu.lunarcore.data.config.MonsterInfo;
|
||||
import emu.lunarcore.data.config.PropInfo;
|
||||
import emu.lunarcore.data.excel.NpcMonsterExcel;
|
||||
import emu.lunarcore.data.excel.PropExcel;
|
||||
import emu.lunarcore.data.excel.RogueMonsterExcel;
|
||||
import emu.lunarcore.game.enums.PropState;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.game.scene.SceneEntityLoader;
|
||||
import emu.lunarcore.game.scene.entity.EntityMonster;
|
||||
import emu.lunarcore.game.scene.entity.EntityProp;
|
||||
import emu.lunarcore.game.scene.entity.extra.PropRogueData;
|
||||
|
||||
public class RogueEntityLoader extends SceneEntityLoader {
|
||||
|
||||
@@ -37,4 +42,65 @@ public class RogueEntityLoader extends SceneEntityLoader {
|
||||
|
||||
return monster;
|
||||
}
|
||||
|
||||
public EntityProp loadProp(Scene scene, GroupInfo group, PropInfo propInfo) {
|
||||
// Make sure player is in a rogue instance
|
||||
RogueInstance rogue = scene.getPlayer().getRogueInstance();
|
||||
if (rogue == null) return null;
|
||||
|
||||
// Set variables here so we can override them later if we need
|
||||
int propId = propInfo.getPropID();
|
||||
PropState state = propInfo.getState();
|
||||
PropRogueData propExtra = null;
|
||||
|
||||
// Rogue Door id is 1000
|
||||
if (propId == 1000) {
|
||||
// Site index
|
||||
int index = 0;
|
||||
|
||||
// Eww
|
||||
if (propInfo.getName().equals("Door2")) {
|
||||
index = 1;
|
||||
}
|
||||
|
||||
// Get portal data
|
||||
RogueRoomData room = rogue.getCurrentRoom();
|
||||
if (room.getNextSiteIds().length > 0) {
|
||||
int siteId = room.getNextSiteIds()[index];
|
||||
int roomId = rogue.getRooms().get(siteId).getRoomId();
|
||||
|
||||
propExtra = new PropRogueData(roomId, siteId);
|
||||
} else {
|
||||
// Exit portal?
|
||||
}
|
||||
|
||||
// Force rogue door to be open
|
||||
propId = 1021; // TODO get proper portal ids
|
||||
state = PropState.Open;
|
||||
}
|
||||
|
||||
// Get prop excel
|
||||
PropExcel propExcel = GameData.getPropExcelMap().get(propId);
|
||||
if (propExcel == null) return null;
|
||||
|
||||
// Create prop from prop info
|
||||
EntityProp prop = new EntityProp(scene, propExcel, propInfo.getPos());
|
||||
prop.getRot().set(propInfo.getRot());
|
||||
prop.setPropInfo(propInfo);
|
||||
prop.setGroupId(group.getId());
|
||||
prop.setInstId(propInfo.getID());
|
||||
prop.setState(state);
|
||||
|
||||
// Overrides
|
||||
if (propExtra != null) {
|
||||
prop.setRogueData(propExtra);
|
||||
}
|
||||
|
||||
// Add trigger
|
||||
if (propInfo.getTrigger() != null) {
|
||||
scene.getTriggers().add(propInfo.getTrigger());
|
||||
}
|
||||
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import emu.lunarcore.data.config.PropInfo;
|
||||
import emu.lunarcore.data.excel.PropExcel;
|
||||
import emu.lunarcore.game.enums.PropState;
|
||||
import emu.lunarcore.game.scene.Scene;
|
||||
import emu.lunarcore.game.scene.entity.extra.PropRogueData;
|
||||
import emu.lunarcore.proto.MotionInfoOuterClass.MotionInfo;
|
||||
import emu.lunarcore.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||
import emu.lunarcore.proto.ScenePropInfoOuterClass.ScenePropInfo;
|
||||
@@ -14,6 +15,8 @@ import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public class EntityProp implements GameEntity {
|
||||
@Setter private PropInfo propInfo;
|
||||
|
||||
@Setter private int entityId;
|
||||
@Setter private int groupId;
|
||||
@Setter private int instId;
|
||||
@@ -23,9 +26,8 @@ public class EntityProp implements GameEntity {
|
||||
private final PropExcel excel;
|
||||
private final Position pos;
|
||||
private final Position rot;
|
||||
|
||||
@Setter
|
||||
private PropInfo propInfo;
|
||||
|
||||
@Setter private PropRogueData rogueData;
|
||||
|
||||
public EntityProp(Scene scene, PropExcel excel, Position pos) {
|
||||
this.scene = scene;
|
||||
@@ -62,6 +64,10 @@ public class EntityProp implements GameEntity {
|
||||
var prop = ScenePropInfo.newInstance()
|
||||
.setPropId(this.getPropId())
|
||||
.setPropState(this.getState().getVal());
|
||||
|
||||
if (this.rogueData != null) {
|
||||
prop.setExtraInfo(this.rogueData.toProto());
|
||||
}
|
||||
|
||||
var proto = SceneEntityInfo.newInstance()
|
||||
.setEntityId(this.getEntityId())
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package emu.lunarcore.game.scene.entity.extra;
|
||||
|
||||
import emu.lunarcore.proto.PropExtraInfoOuterClass.PropExtraInfo;
|
||||
import emu.lunarcore.proto.PropRogueInfoOuterClass.PropRogueInfo;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class PropRogueData {
|
||||
private int roomId;
|
||||
private int siteId;
|
||||
|
||||
public PropRogueData(int roomId, int siteId) {
|
||||
this.roomId = roomId;
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public PropExtraInfo toProto() {
|
||||
var data = PropRogueInfo.newInstance()
|
||||
.setRoomId(this.getRoomId())
|
||||
.setSiteId(this.getSiteId());
|
||||
|
||||
return PropExtraInfo.newInstance().setRogueInfo(data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user