Cleanup and remove business_type filter

This commit is contained in:
Melledy 2022-05-18 05:33:00 -07:00
parent 9902ba381a
commit 2e24d77bc2
3 changed files with 17 additions and 20 deletions

View File

@ -531,12 +531,12 @@ public class Scene {
public List<SceneGroup> playerMeetGroups(Player player, SceneBlock block){ public List<SceneGroup> playerMeetGroups(Player player, SceneBlock block){
int RANGE = 100; int RANGE = 100;
var sceneGroups = SceneIndexManager.queryNeighbors(block.sceneGroupIndex, player.getPos(), RANGE); List<SceneGroup> sceneGroups = SceneIndexManager.queryNeighbors(block.sceneGroupIndex, player.getPos(), RANGE);
var groups = new ArrayList<>(sceneGroups.stream() List<SceneGroup> groups = sceneGroups.stream()
.filter(group -> !scriptManager.getLoadedGroupSetPerBlock().get(block.id).contains(group) && group.getBusinessType() == 0) .filter(group -> !scriptManager.getLoadedGroupSetPerBlock().get(block.id).contains(group))
.peek(group -> scriptManager.getLoadedGroupSetPerBlock().get(block.id).add(group)) .peek(group -> scriptManager.getLoadedGroupSetPerBlock().get(block.id).add(group))
.toList()); .toList();
if (groups.size() == 0) { if (groups.size() == 0) {
return List.of(); return List.of();

View File

@ -354,6 +354,9 @@ public class SceneScriptManager {
entity.setPointType(g.point_type); entity.setPointType(g.point_type);
entity.buildContent(); entity.buildContent();
// Lua event
this.callEvent(EventType.EVENT_GADGET_CREATE, new ScriptArgs(entity.getConfigId()));
return entity; return entity;
} }
@ -391,31 +394,22 @@ public class SceneScriptManager {
this.getScriptMonsterSpawnService() this.getScriptMonsterSpawnService()
.onMonsterCreatedListener.forEach(action -> action.onNotify(entity)); .onMonsterCreatedListener.forEach(action -> action.onNotify(entity));
// Lua event
callEvent(EventType.EVENT_ANY_MONSTER_LIVE, new ScriptArgs(entity.getConfigId()));
return entity; return entity;
} }
public void addEntity(GameEntity gameEntity){ public void addEntity(GameEntity gameEntity){
getScene().addEntity(gameEntity); getScene().addEntity(gameEntity);
callCreateEvent(gameEntity);
} }
public void meetEntities(List<? extends GameEntity> gameEntity){ public void meetEntities(List<? extends GameEntity> gameEntity){
getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_MEET); getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_MEET);
gameEntity.forEach(this::callCreateEvent);
} }
public void addEntities(List<? extends GameEntity> gameEntity){ public void addEntities(List<? extends GameEntity> gameEntity){
getScene().addEntities(gameEntity); getScene().addEntities(gameEntity);
gameEntity.forEach(this::callCreateEvent);
}
public void callCreateEvent(GameEntity gameEntity){
if(!isInit){
return;
}
if(gameEntity instanceof EntityMonster entityMonster){
callEvent(EventType.EVENT_ANY_MONSTER_LIVE, new ScriptArgs(entityMonster.getConfigId()));
}
if(gameEntity instanceof EntityGadget entityGadget){
this.callEvent(EventType.EVENT_GADGET_CREATE, new ScriptArgs(entityGadget.getConfigId()));
}
} }
public PhTree<SceneBlock> getBlocksIndex() { public PhTree<SceneBlock> getBlocksIndex() {

View File

@ -376,11 +376,14 @@ public class ScriptLib {
var configId = table.get("config_id").toint(); var configId = table.get("config_id").toint();
var group = getCurrentGroup(); var group = getCurrentGroup();
if (group.isEmpty()) { if (group.isEmpty()) {
return 1; return 1;
} }
var gadget = group.get().gadgets.get(configId); var gadget = group.get().gadgets.get(configId);
var entity = getSceneScriptManager().createGadget(group.get().id, group.get().block_id, gadget); var entity = getSceneScriptManager().createGadget(group.get().id, group.get().block_id, gadget);
getSceneScriptManager().addEntity(entity); getSceneScriptManager().addEntity(entity);
return 0; return 0;