From 1fe2854411e28b290ead574685a4ddeff4ea21c6 Mon Sep 17 00:00:00 2001 From: hartie95 Date: Tue, 6 Feb 2024 20:32:09 +0100 Subject: [PATCH] [Refactoring] Directly use Enum Type for some gi_lua properties and add visionTypeList field to SceneRegion --- .../models/constants/VisionLevelType.java | 15 ------------- .../models/constants/VisionLevelType.kt | 21 +++++++++++++++++++ .../models/scene/block/SceneGroupInfo.java | 6 +++++- .../gi_lua/models/scene/group/SceneGroup.java | 3 ++- .../models/scene/group/SceneInitConfig.java | 6 ++++-- .../models/scene/group/SceneObject.java | 3 ++- .../models/scene/group/SceneRegion.java | 6 +++++- .../gi_lua/script_lib/ScriptLibHandler.java | 7 +++++++ 8 files changed, 46 insertions(+), 21 deletions(-) delete mode 100644 GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.java create mode 100644 GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.kt diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.java deleted file mode 100644 index 162dd0f..0000000 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.anime_game_servers.gi_lua.models.constants; - -import org.anime_game_servers.core.base.annotations.lua.LuaStatic; - -@LuaStatic -public enum VisionLevelType { - VISION_LEVEL_NORMAL, - VISION_LEVEL_LITTLE_REMOTE, - VISION_LEVEL_REMOTE, - VISION_LEVEL_SUPER, - VISION_LEVEL_NEARBY, - VISION_LEVEL_SUPER_NEARBY, - VISION_LEVEL_SUPER_NUM, - -} diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.kt b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.kt new file mode 100644 index 0000000..9f3b6c9 --- /dev/null +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/constants/VisionLevelType.kt @@ -0,0 +1,21 @@ +package org.anime_game_servers.gi_lua.models.constants + +import org.anime_game_servers.core.base.annotations.lua.LuaStatic +import org.anime_game_servers.core.base.interfaces.IntValueEnum + +@LuaStatic +enum class VisionLevelType(private val value: Int) : IntValueEnum { + VISION_LEVEL_NORMAL(0), + VISION_LEVEL_LITTLE_REMOTE(1), + VISION_LEVEL_REMOTE(2), + VISION_LEVEL_SUPER(3), + VISION_LEVEL_NEARBY(4), + VISION_LEVEL_SUPER_NEARBY(5), + VISION_LEVEL_SUPER_NUM(6); + + override fun getValue() = value + companion object { + @JvmStatic + fun getDefault() = VISION_LEVEL_NORMAL + } +} diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/block/SceneGroupInfo.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/block/SceneGroupInfo.java index 541852e..da53b53 100644 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/block/SceneGroupInfo.java +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/block/SceneGroupInfo.java @@ -3,6 +3,7 @@ package org.anime_game_servers.gi_lua.models.scene.block; import lombok.Getter; import org.anime_game_servers.core.base.annotations.lua.LuaNames; import org.anime_game_servers.gi_lua.models.PositionImpl; +import org.anime_game_servers.gi_lua.models.constants.GroupLoadStrategy; import org.anime_game_servers.gi_lua.models.scene.SceneMeta; import javax.annotation.Nullable; @@ -29,6 +30,9 @@ public class SceneGroupInfo { private int activityReviseLevelGrowId; @LuaNames("rely_start_world_level_limit_activity_id") private int relyStartWorldLevelLimitActivityId; // SceneScriptConfig LuaConfigMgr + /** + * seems to be linked to SceneRegion.visionTypeList + */ @LuaNames("vision_type") private int visionType; @LuaNames("across_block") @@ -44,7 +48,7 @@ public class SceneGroupInfo { @LuaNames("is_load_by_vision_type") private boolean isLoadByVisionType = false; @LuaNames("load_strategy") - private int loadStrategy; + private GroupLoadStrategy loadStrategy; @LuaNames("forbid_monster_die") private Set forbidMonsterDie; //todo find enum values @LuaNames("related_level_tag_series_list") diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneGroup.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneGroup.java index 3e4f452..fea55f7 100644 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneGroup.java +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneGroup.java @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.ToString; import lombok.val; import org.anime_game_servers.core.base.annotations.lua.LuaNames; +import org.anime_game_servers.gi_lua.models.constants.IOType; import org.anime_game_servers.gi_lua.models.loader.SceneGroupScriptLoadParams; import org.anime_game_servers.gi_lua.models.scene.SceneMeta; import org.anime_game_servers.gi_lua.models.loader.ScriptSource; @@ -168,7 +169,7 @@ public class SceneGroup { public int findInitSuiteIndex(int exclude_index) { //TODO: Investigate end index if (initConfig == null) return 1; - if (initConfig.getIoType() == 1) return initConfig.getSuite(); //IO TYPE FLOW + if (initConfig.getIoType() == IOType.GROUP_IO_TYPE_FLOW) return initConfig.getSuite(); if (initConfig.isRandSuite()) { if (suites.size() == 1) { return initConfig.getSuite(); diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneInitConfig.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneInitConfig.java index 689e785..2c17066 100644 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneInitConfig.java +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneInitConfig.java @@ -3,6 +3,8 @@ package org.anime_game_servers.gi_lua.models.scene.group; import lombok.Getter; import lombok.ToString; import org.anime_game_servers.core.base.annotations.lua.LuaNames; +import org.anime_game_servers.gi_lua.models.constants.FlowGroupSubType; +import org.anime_game_servers.gi_lua.models.constants.IOType; @ToString @Getter @@ -11,9 +13,9 @@ public class SceneInitConfig { @LuaNames("end_suite") private int endSuite; @LuaNames("io_type") - private int ioType ; + private IOType ioType = IOType.GROUP_IO_TYPE_DEFAULT; @LuaNames("sub_flow_type") - private int subFlowType; + private FlowGroupSubType subFlowType = FlowGroupSubType.GROUP_SUB_FLOW_TYPE_DEFAULT; @LuaNames("secure_suite_index") private int secureSuiteIndex; @LuaNames("rand_suite") diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneObject.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneObject.java index 99979ae..794e64d 100644 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneObject.java +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneObject.java @@ -4,6 +4,7 @@ import lombok.Getter; import lombok.ToString; import org.anime_game_servers.core.base.annotations.lua.LuaNames; import org.anime_game_servers.gi_lua.models.PositionImpl; +import org.anime_game_servers.gi_lua.models.constants.VisionLevelType; import org.anime_game_servers.gi_lua.models.scene.SceneMeta; import org.anime_game_servers.gi_lua.models.constants.EntityType; @@ -16,7 +17,7 @@ public abstract class SceneObject { @LuaNames("area_id") protected int areaId; @LuaNames("vision_level") - protected int visionLevel = 0; + protected VisionLevelType visionLevel = VisionLevelType.VISION_LEVEL_NORMAL; @LuaNames("mark_flag") protected int markFlag; @LuaNames("drop_tag") diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneRegion.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneRegion.java index 40835db..65676a8 100644 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneRegion.java +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/models/scene/group/SceneRegion.java @@ -9,7 +9,6 @@ import org.anime_game_servers.gi_lua.models.constants.ScriptRegionShape; import java.util.List; - @SuppressWarnings("FieldMayBeFinal") @Getter public class SceneRegion extends SceneObject{ @@ -28,6 +27,11 @@ public class SceneRegion extends SceneObject{ private List teamAbilityGroup; @LuaNames("is_trigger_reload_group") private boolean isTriggerReloadGroup = false; + /** + * seems to be linked to SceneGroupInfo.visionType + */ + @LuaNames("vision_type_list") + private List visionTypeList; public boolean contains(Vector position) { switch (shape) { diff --git a/GILua/src/main/java/org/anime_game_servers/gi_lua/script_lib/ScriptLibHandler.java b/GILua/src/main/java/org/anime_game_servers/gi_lua/script_lib/ScriptLibHandler.java index 7743d56..4fa9cf8 100644 --- a/GILua/src/main/java/org/anime_game_servers/gi_lua/script_lib/ScriptLibHandler.java +++ b/GILua/src/main/java/org/anime_game_servers/gi_lua/script_lib/ScriptLibHandler.java @@ -37,6 +37,13 @@ public interface ScriptLibHandler