Skip to content

Commit

Permalink
Fix debris in MoC
Browse files Browse the repository at this point in the history
  • Loading branch information
Melledy committed Dec 31, 2023
1 parent 58c051f commit 32e378b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/main/java/emu/lunarcore/data/config/MonsterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public class MonsterInfo extends ObjectInfo {
private int NPCMonsterID;
private int EventID;
private int FarmElementID;
private boolean IsClientOnly;
}
1 change: 1 addition & 0 deletions src/main/java/emu/lunarcore/data/config/NpcInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
@Getter
public class NpcInfo extends ObjectInfo {
private int NPCID;
private boolean IsClientOnly;
}
1 change: 1 addition & 0 deletions src/main/java/emu/lunarcore/data/config/PropInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
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 {
Expand All @@ -24,6 +23,19 @@ public void onSceneLoad(Scene scene) {

// 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
Expand Down Expand Up @@ -58,11 +70,6 @@ public EntityMonster loadMonster(Scene scene, GroupInfo group, MonsterInfo monst
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;
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/emu/lunarcore/game/scene/SceneEntityLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public void onSceneLoad(Scene scene) {
}

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());
Expand All @@ -46,8 +48,10 @@ public EntityMonster loadMonster(Scene scene, GroupInfo group, MonsterInfo monst
}

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());
Expand Down Expand Up @@ -84,20 +88,25 @@ public EntityProp loadProp(Scene scene, GroupInfo group, PropInfo propInfo) {
}

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);
Expand Down

0 comments on commit 32e378b

Please sign in to comment.