mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
Enable script in big world (#884)
* add docs for tower * fix: LEAK: ByteBuf.release() was not called * enableScriptInBigWorld * not print log when loaded scripts from cache * revert the change of server tick * revert the change of server tick * fix * optimize the performance: lazy load & cache * fix the refresh group * fix NPE Co-authored-by: Melledy <52122272+Melledy@users.noreply.github.com>
This commit is contained in:
@@ -355,6 +355,36 @@ public class ScriptLib {
|
||||
|
||||
//TODO
|
||||
|
||||
return 0;
|
||||
}
|
||||
public int CheckRemainGadgetCountByGroupId(LuaTable table){
|
||||
logger.debug("[LUA] Call CheckRemainGadgetCountByGroupId with {}",
|
||||
printTable(table));
|
||||
var groupId = table.get("group_id").toint();
|
||||
|
||||
var count = getSceneScriptManager().getScene().getEntities().values().stream()
|
||||
.filter(g -> g instanceof EntityGadget entityGadget && entityGadget.getGroupId() == groupId)
|
||||
.count();
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
public int GetGadgetStateByConfigId(int groupId, int configId){
|
||||
logger.debug("[LUA] Call GetGadgetStateByConfigId with {},{}",
|
||||
groupId, configId);
|
||||
var gadget = getSceneScriptManager().getScene().getEntities().values().stream()
|
||||
.filter(g -> g instanceof EntityGadget entityGadget && entityGadget.getGroupId() == groupId)
|
||||
.filter(g -> g.getConfigId() == configId)
|
||||
.findFirst();
|
||||
if(gadget.isEmpty()){
|
||||
return 0;
|
||||
}
|
||||
var stat = ((EntityGadget)gadget.get()).getState();
|
||||
return stat;
|
||||
}
|
||||
public int SetGadgetStateByConfigId(int configId, LuaTable gadgetState){
|
||||
logger.debug("[LUA] Call SetGadgetStateByConfigId with {},{}",
|
||||
configId, printTable(gadgetState));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user