Commit 3cffdd97 authored by Melledy's avatar Melledy
Browse files

Cleanup and remove business_type filter

parent 4b5f5b3d
......@@ -531,14 +531,14 @@ public class Scene {
public List<SceneGroup> playerMeetGroups(Player player, SceneBlock block){
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()
.filter(group -> !scriptManager.getLoadedGroupSetPerBlock().get(block.id).contains(group) && group.getBusinessType() == 0)
List<SceneGroup> groups = sceneGroups.stream()
.filter(group -> !scriptManager.getLoadedGroupSetPerBlock().get(block.id).contains(group))
.peek(group -> scriptManager.getLoadedGroupSetPerBlock().get(block.id).add(group))
.toList());
.toList();
if(groups.size() == 0){
if (groups.size() == 0) {
return List.of();
}
......
......@@ -353,6 +353,9 @@ public class SceneScriptManager {
entity.setState(g.state);
entity.setPointType(g.point_type);
entity.buildContent();
// Lua event
this.callEvent(EventType.EVENT_GADGET_CREATE, new ScriptArgs(entity.getConfigId()));
return entity;
}
......@@ -390,32 +393,23 @@ public class SceneScriptManager {
this.getScriptMonsterSpawnService()
.onMonsterCreatedListener.forEach(action -> action.onNotify(entity));
// Lua event
callEvent(EventType.EVENT_ANY_MONSTER_LIVE, new ScriptArgs(entity.getConfigId()));
return entity;
}
public void addEntity(GameEntity gameEntity){
getScene().addEntity(gameEntity);
callCreateEvent(gameEntity);
}
public void meetEntities(List<? extends GameEntity> gameEntity){
getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_MEET);
gameEntity.forEach(this::callCreateEvent);
}
public void addEntities(List<? extends GameEntity> 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() {
......
......@@ -376,11 +376,14 @@ public class ScriptLib {
var configId = table.get("config_id").toint();
var group = getCurrentGroup();
if(group.isEmpty()){
if (group.isEmpty()) {
return 1;
}
var gadget = group.get().gadgets.get(configId);
var entity = getSceneScriptManager().createGadget(group.get().id, group.get().block_id, gadget);
getSceneScriptManager().addEntity(entity);
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment