Fix debris in MoC

This commit is contained in:
Melledy
2023-12-31 03:28:37 -08:00
parent 58c051fd9e
commit 32e378b112
5 changed files with 35 additions and 16 deletions

View File

@@ -10,4 +10,5 @@ public class MonsterInfo extends ObjectInfo {
private int NPCMonsterID;
private int EventID;
private int FarmElementID;
private boolean IsClientOnly;
}

View File

@@ -8,4 +8,5 @@ import lombok.Getter;
@Getter
public class NpcInfo extends ObjectInfo {
private int NPCID;
private boolean IsClientOnly;
}

View File

@@ -24,6 +24,7 @@ public class PropInfo extends ObjectInfo {
private int EventID;
private int CocoonID;
private int FarmElementID;
private boolean IsClientOnly;
private PropValueSource ValueSource;
@Setter private String InitLevelGraph;

View File

@@ -4,14 +4,13 @@ import emu.lunarcore.data.GameData;
import emu.lunarcore.data.config.GroupInfo;
import emu.lunarcore.data.config.MonsterInfo;
import emu.lunarcore.data.config.NpcInfo;
import emu.lunarcore.data.config.PropInfo;
import emu.lunarcore.data.config.GroupInfo.GroupLoadSide;
import emu.lunarcore.data.excel.NpcMonsterExcel;
import emu.lunarcore.data.excel.ChallengeExcel.ChallengeMonsterInfo;
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.EntityNpc;
import emu.lunarcore.game.scene.entity.EntityProp;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
public class ChallengeEntityLoader extends SceneEntityLoader {
@@ -24,6 +23,19 @@ public class ChallengeEntityLoader extends SceneEntityLoader {
// Setup first stage
scene.loadGroup(instance.getExcel().getMazeGroupID1());
// Load all groups with props
for (var group : scene.getFloorInfo().getGroups().values()) {
// Skip non-server groups
if (group.getLoadSide() != GroupLoadSide.Server) {
continue;
}
// Dont load the groups that have monsters in them
if (group.getPropList().size() > 0 && group.getMonsterList().size() == 0) {
scene.loadGroup(group);
}
}
}
@Override
@@ -58,11 +70,6 @@ public class ChallengeEntityLoader extends SceneEntityLoader {
return monster;
}
@Override
public EntityProp loadProp(Scene scene, GroupInfo group, PropInfo propInfo) {
return null;
}
@Override
public EntityNpc loadNpc(Scene scene, GroupInfo group, NpcInfo npcInfo) {
return null;

View File

@@ -30,8 +30,10 @@ public class SceneEntityLoader {
}
public EntityMonster loadMonster(Scene scene, GroupInfo group, MonsterInfo monsterInfo) {
// Don't spawn entity if they have the IsDelete flag in group info
if (monsterInfo.isIsDelete()) return null;
// Don't spawn entity if they have certain flags in their info
if (monsterInfo.isIsDelete() || monsterInfo.isIsClientOnly()) {
return null;
}
// Get excels from game data
NpcMonsterExcel npcMonsterExcel = GameData.getNpcMonsterExcelMap().get(monsterInfo.getNPCMonsterID());
@@ -46,8 +48,10 @@ public class SceneEntityLoader {
}
public EntityProp loadProp(Scene scene, GroupInfo group, PropInfo propInfo) {
// Don't spawn entity if they have the IsDelete flag in group info
if (propInfo.isIsDelete()) return null;
// Don't spawn entity if they have certain flags in their info
if (propInfo.isIsDelete() || propInfo.isIsClientOnly()) {
return null;
}
// Get prop excel to make sure prop exists
PropExcel propExcel = GameData.getPropExcelMap().get(propInfo.getPropID());
@@ -84,20 +88,25 @@ public class SceneEntityLoader {
}
public EntityNpc loadNpc(Scene scene, GroupInfo group, NpcInfo npcInfo) {
// Don't spawn entity if they have the IsDelete flag in group info
if (npcInfo.isIsDelete() || !GameData.getNpcExcelMap().containsKey(npcInfo.getNPCID())) {
// Don't spawn entity if they have certain flags in their info
if (npcInfo.isIsDelete() || npcInfo.isIsClientOnly()) {
return null;
}
// Sanity check npc id
if (!GameData.getNpcExcelMap().containsKey(npcInfo.getNPCID())) {
return null;
}
// Dont spawn duplicate NPCs
boolean haseDuplicateNpcId = false;
boolean hasDuplicateNpcId = false;
for (GameEntity entity : scene.getEntities().values()) {
if (entity instanceof EntityNpc eNpc && eNpc.getNpcId() == npcInfo.getNPCID()) {
haseDuplicateNpcId = true;
hasDuplicateNpcId = true;
break;
}
}
if (haseDuplicateNpcId) return null;
if (hasDuplicateNpcId) return null;
// Create npc from group and npc info
return new EntityNpc(scene, group, npcInfo);