[Fix/refactoring] Added helpers to get SceneReplacement and SharedQuest scripts and fixed a the path for Shared quest scripts

This commit is contained in:
hartie95 2023-11-06 03:33:45 +01:00
parent a7048c7023
commit 2c1646396c
10 changed files with 26 additions and 14 deletions

View File

@ -39,10 +39,11 @@ public interface GIScriptLoader extends BaseScriptLoader {
default Path getScriptPath(ScriptSource type, int typeId, String scriptName){
val basePath = switch (type) {
case SCENE -> "Scene/" + typeId + "/" + scriptName;
case SCENE_REPLACEMENT -> "Scene/" + scriptName;
case ACTIVITY-> "Activity/" + typeId + "/" + scriptName;
case COMMON -> "Common/" + scriptName;
case GADGET -> "Gadget/" + scriptName;
case SHARED_QUESTS -> "Common/" + scriptName;
case SHARED_QUESTS -> "Quest/Share/" + scriptName;
};
return getScriptPath(basePath);
}
@ -90,6 +91,14 @@ public interface GIScriptLoader extends BaseScriptLoader {
luaEngine.addGlobalStaticClass("ScriptLib", ScriptLib.class);
}
default boolean loadSceneReplacementScript(ScriptParser parser){
return loadData(ScriptSource.SCENE_REPLACEMENT, 0, "groups_replacement.lua", ScriptType.DATA_STORAGE, parser);
}
default boolean loadSharedQuestScript(ScriptParser parser, int questId){
return loadData(ScriptSource.SHARED_QUESTS, questId, "Q"+questId+"ShareConfig.lua", ScriptType.DATA_STORAGE, parser);
}
default boolean loadSceneMetaScript(int sceneId, ScriptParser parser){
return loadData(ScriptSource.SCENE, sceneId, "scene"+sceneId+".lua", ScriptType.DATA_STORAGE, parser);
}
@ -98,9 +107,9 @@ public interface GIScriptLoader extends BaseScriptLoader {
}
default boolean loadSceneGroupScript(ScriptSource scriptSource, int targetId, int groupId, ScriptParser parser){
if(scriptSource == ScriptSource.SCENE)
return loadData(scriptSource, targetId, "scene"+targetId+"_group"+groupId+".lua", ScriptType.DATA_STORAGE, parser);
return loadData(scriptSource, targetId, "scene"+targetId+"_group"+groupId+".lua", ScriptType.EXECUTABLE, parser);
else
return loadData(scriptSource, targetId, "activity"+targetId+"_group"+groupId+".lua", ScriptType.DATA_STORAGE, parser);
return loadData(scriptSource, targetId, "activity"+targetId+"_group"+groupId+".lua", ScriptType.EXECUTABLE, parser);
}
default boolean loadSceneDummyPoints(int sceneId, ScriptParser parser){
return loadData(ScriptSource.SCENE, sceneId, "scene"+sceneId+"_dummy_points.lua", ScriptType.DATA_STORAGE, parser);

View File

@ -5,8 +5,9 @@ enum class ScriptSource(
val needsId: Boolean
) {
SCENE("Scene", true),
SCENE_REPLACEMENT("Scene", false),
ACTIVITY("Activity", true),
COMMON("Common", false),
GADGET("Gadget", false),
SHARED_QUESTS("Quests/Shared", false),;
SHARED_QUESTS("Quest/Share", false),;
}

View File

@ -1,8 +1,9 @@
package org.anime_game_servers.gi_lua.models;
package org.anime_game_servers.gi_lua.models.scene;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.anime_game_servers.gi_lua.models.PositionImpl;
@Getter @EqualsAndHashCode @ToString
public class DummyPoint {

View File

@ -1,7 +1,8 @@
package org.anime_game_servers.gi_lua.models;
package org.anime_game_servers.gi_lua.models.scene;
import lombok.Getter;
import lombok.ToString;
import org.anime_game_servers.gi_lua.models.PositionImpl;
@ToString
@Getter

View File

@ -1,4 +1,4 @@
package org.anime_game_servers.gi_lua.models;
package org.anime_game_servers.gi_lua.models.scene;
import io.github.oshai.kotlinlogging.KLogger;
import io.github.oshai.kotlinlogging.KotlinLogging;
@ -34,7 +34,8 @@ public class SceneMeta {
//private RTree<SceneBlock, Geometry> sceneBlockIndex;
public static SceneMeta of(int sceneId, GIScriptLoader scriptLoader) {
return new SceneMeta(sceneId).load(scriptLoader);
return new SceneMeta(sceneId)
.load(scriptLoader);
}
private SceneMeta(int sceneId) {

View File

@ -5,7 +5,7 @@ import io.github.oshai.kotlinlogging.KLogger;
import io.github.oshai.kotlinlogging.KotlinLogging;
import lombok.*;
import org.anime_game_servers.gi_lua.models.PositionImpl;
import org.anime_game_servers.gi_lua.models.SceneMeta;
import org.anime_game_servers.gi_lua.models.scene.SceneMeta;
import org.anime_game_servers.gi_lua.models.loader.GIScriptLoader;
import java.util.Map;

View File

@ -2,7 +2,7 @@ package org.anime_game_servers.gi_lua.models.scene.block;
import lombok.Getter;
import org.anime_game_servers.gi_lua.models.PositionImpl;
import org.anime_game_servers.gi_lua.models.SceneMeta;
import org.anime_game_servers.gi_lua.models.scene.SceneMeta;
import javax.annotation.Nullable;
import java.util.List;

View File

@ -5,7 +5,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging;
import lombok.Getter;
import lombok.ToString;
import lombok.val;
import org.anime_game_servers.gi_lua.models.SceneMeta;
import org.anime_game_servers.gi_lua.models.scene.SceneMeta;
import org.anime_game_servers.gi_lua.models.loader.ScriptSource;
import org.anime_game_servers.gi_lua.models.scene.block.SceneGroupInfo;
import org.anime_game_servers.gi_lua.models.loader.GIScriptLoader;

View File

@ -3,7 +3,7 @@ package org.anime_game_servers.gi_lua.models.scene.group;
import lombok.Getter;
import lombok.ToString;
import org.anime_game_servers.gi_lua.models.PositionImpl;
import org.anime_game_servers.gi_lua.models.SceneMeta;
import org.anime_game_servers.gi_lua.models.scene.SceneMeta;
import org.anime_game_servers.gi_lua.models.constants.EntityType;
@ToString

View File

@ -2,8 +2,7 @@ package org.anime_game_servers.gi_lua.models.scene.group;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.anime_game_servers.gi_lua.models.SceneMeta;
import org.anime_game_servers.gi_lua.models.scene.group.SceneGroup;
import org.anime_game_servers.gi_lua.models.scene.SceneMeta;
@Data
@NoArgsConstructor