Persist Tower Data && Set The Tower Schedule

This commit is contained in:
Akka
2022-05-08 17:11:02 +08:00
parent 39e8f810d2
commit 4b6842f006
20 changed files with 500 additions and 66 deletions

View File

@@ -90,6 +90,10 @@ public class SceneScriptManager {
return config;
}
public SceneGroup getCurrentGroup() {
return currentGroup;
}
public List<SceneBlock> getBlocks() {
return blocks;
}
@@ -237,16 +241,16 @@ public class SceneScriptManager {
for (SceneSuite suite : group.suites) {
suite.sceneMonsters = new ArrayList<>(suite.monsters.size());
for (int id : suite.monsters) {
try {
SceneMonster monster = (SceneMonster) map.get(id);
if (monster != null) {
suite.sceneMonsters.add(monster);
suite.monsters.forEach(id -> {
Object objEntry = map.get(id.intValue());
if (objEntry instanceof Map.Entry<?,?> monsterEntry) {
Object monster = monsterEntry.getValue();
if(monster instanceof SceneMonster sceneMonster){
suite.sceneMonsters.add(sceneMonster);
}
} catch (Exception e) {
continue;
}
}
});
suite.sceneGadgets = new ArrayList<>(suite.gadgets.size());
for (int id : suite.gadgets) {
try {
@@ -320,13 +324,15 @@ public class SceneScriptManager {
}
public void spawnMonstersInGroup(SceneGroup group, int suiteIndex) {
this.currentGroup = group;
this.monsterSceneLimit = 0;
var suite = group.getSuiteByIndex(suiteIndex);
if(suite == null){
return;
}
suite.sceneMonsters.forEach(mob -> spawnMonstersInGroup(group, mob));
if(suite.sceneMonsters.size() > 0){
this.currentGroup = group;
this.monsterSceneLimit = 0;
suite.sceneMonsters.forEach(mob -> spawnMonstersInGroup(group, mob));
}
}
public void spawnMonstersInGroup(SceneGroup group) {
@@ -401,6 +407,7 @@ public class SceneScriptManager {
spawnMonstersInGroup(this.currentGroup, this.currentGroup.monsters.get(this.monsterOrders.poll()));
}else if(this.monsterAlive.get() == 0){
// spawn the last turn of monsters
//callEvent(EventType.EVENT_MONSTER_TIDE_DIE, new ScriptArgs());
while(!this.monsterOrders.isEmpty()){
spawnMonstersInGroup(this.currentGroup, this.currentGroup.monsters.get(this.monsterOrders.poll()));
}

View File

@@ -118,7 +118,7 @@ public class ScriptLib {
challengeIndex,groupId,ordersConfigId,tideCount,sceneLimit,param6);
SceneGroup group = getSceneScriptManager().getGroupById(groupId);
if (group == null || group.monsters == null) {
return 1;
}
@@ -136,8 +136,7 @@ public class ScriptLib {
if (group == null || group.monsters == null) {
return 1;
}
// TODO just spawn all from group for now
this.getSceneScriptManager().spawnMonstersInGroup(group, suite);
return 0;
@@ -159,7 +158,13 @@ public class ScriptLib {
if (group == null || group.monsters == null) {
return 1;
}
if(getSceneScriptManager().getScene().getChallenge() != null &&
getSceneScriptManager().getScene().getChallenge().inProgress())
{
return 0;
}
DungeonChallenge challenge = new DungeonChallenge(getSceneScriptManager().getScene(), group);
challenge.setChallengeId(challengeId);
challenge.setChallengeIndex(challengeIndex);
@@ -249,7 +254,7 @@ public class ScriptLib {
var1);
return (int) getSceneScriptManager().getScene().getEntities().values().stream()
.filter(e -> e instanceof EntityMonster)
.filter(e -> e instanceof EntityMonster && e.getGroupId() == getSceneScriptManager().getCurrentGroup().id)
.count();
}
public int SetMonsterBattleByGroup(int var1, int var2, int var3){
@@ -266,13 +271,11 @@ public class ScriptLib {
return 0;
}
// 8-1
public int GetGroupVariableValueByGroup(int var1, String var2, int var3){
logger.debug("[LUA] Call GetGroupVariableValueByGroup with {},{},{}",
var1,var2,var3);
public int GetGroupVariableValueByGroup(String name, int groupId){
logger.debug("[LUA] Call GetGroupVariableValueByGroup with {},{}",
name,groupId);
//TODO
return getSceneScriptManager().getVariables().getOrDefault(var2, 0);
return getSceneScriptManager().getVariables().getOrDefault(name, 0);
}
public int SetIsAllowUseSkill(int canUse, int var2){
@@ -299,4 +302,11 @@ public class ScriptLib {
return 0;
}
public int SetGroupVariableValueByGroup(String key, int value, int groupId){
logger.debug("[LUA] Call SetGroupVariableValueByGroup with {},{},{}",
key,value,groupId);
return 0;
}
}