mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 12:05:52 +00:00
Cleanup and remove business_type filter
This commit is contained in:
parent
9902ba381a
commit
2e24d77bc2
@ -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();
|
||||
}
|
||||
|
||||
|
@ -354,6 +354,9 @@ public class SceneScriptManager {
|
||||
entity.setPointType(g.point_type);
|
||||
entity.buildContent();
|
||||
|
||||
// Lua event
|
||||
this.callEvent(EventType.EVENT_GADGET_CREATE, new ScriptArgs(entity.getConfigId()));
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -391,31 +394,22 @@ 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;
|
||||
|
Loading…
Reference in New Issue
Block a user