pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
+124
-43
@@ -1,11 +1,13 @@
|
||||
-- Read-only template. Replace __FLOOR_INPUTS__ with Lua pairs from the
|
||||
-- installed MapEntrance table, and __CAPTURE_KEY__ with a unique string.
|
||||
-- Read a bounded batch per heartbeat; never enter a map or alter entities.
|
||||
-- Read-only RuntimeFloor capture template. Substitute __FLOOR_INPUTS__ from
|
||||
-- the matching Client MapEntrance rows and __CAPTURE_KEY__ with a unique key.
|
||||
-- Work is bounded per heartbeat; level graphs are serialized, never executed.
|
||||
do
|
||||
local key = '__CAPTURE_KEY__'
|
||||
_G.__gacSceneExports = _G.__gacSceneExports or {}
|
||||
local progress = _G.__gacSceneExports[key] or 1
|
||||
local floors = __FLOOR_INPUTS__
|
||||
_G.__gacSceneExports = _G.__gacSceneExports or {}
|
||||
local state = _G.__gacSceneExports[key] or {floorIndex = 1}
|
||||
_G.__gacSceneExports[key] = state
|
||||
|
||||
local function log(kind, text)
|
||||
CS.UnityEngine.Debug.Log('[GAC_SCENE_' .. kind .. '] ' .. tostring(text))
|
||||
end
|
||||
@@ -20,55 +22,134 @@ do
|
||||
local x, y, z, rot = world(group, item)
|
||||
log(kind, prefix .. ' pos=' .. tostring(x) .. ',' .. tostring(y) .. ',' .. tostring(z) .. ' rot=' .. tostring(rot))
|
||||
end
|
||||
local batchSize = 4
|
||||
for index = progress, math.min(progress + batchSize - 1, #floors) do
|
||||
local pair = floors[index]
|
||||
|
||||
if state.floorIndex <= #floors then
|
||||
local pair = floors[state.floorIndex]
|
||||
local ok, err = pcall(function()
|
||||
local path = CS.RPG.Client.MapDef.GetRtFloorInfoPath(pair[1], pair[2])
|
||||
local floor = CS.RPG.GameCore.GameCoreConfigLoader.LoadRtLevelFloorInfo(path)
|
||||
if floor == nil then error('missing RuntimeFloor ' .. path) end
|
||||
if state.floor == nil then
|
||||
local path = CS.RPG.Client.MapDef.GetRtFloorInfoPath(pair[1], pair[2])
|
||||
state.floor = CS.RPG.GameCore.GameCoreConfigLoader.LoadRtLevelFloorInfo(path)
|
||||
if state.floor == nil then error('missing RuntimeFloor ' .. path) end
|
||||
state.floorIndexInGroups = 0
|
||||
state.failed = false
|
||||
log('META', 'FLOOR ' .. tostring(pair[1]) .. ' ' .. tostring(pair[2])
|
||||
.. ' startGroup=' .. tostring(state.floor.StartGroupIndex)
|
||||
.. ' anchor=' .. tostring(state.floor.StartAnchorID)
|
||||
.. ' count=' .. tostring(state.floor.GroupInstanceCommonMap.Count))
|
||||
state.commonEntries = {}
|
||||
local iterator = state.floor.GroupInstanceCommonMap:GetEnumerator()
|
||||
while iterator:MoveNext() do
|
||||
local entry = iterator.Current
|
||||
state.commonEntries[#state.commonEntries + 1] = entry
|
||||
end
|
||||
state.commonIndex = 1
|
||||
state.groupIndex = 0
|
||||
end
|
||||
|
||||
local floor = state.floor
|
||||
local floorID = tostring(pair[2])
|
||||
log('META', 'FLOOR ' .. tostring(pair[1]) .. ' ' .. floorID
|
||||
.. ' startGroup=' .. tostring(floor.StartGroupIndex) .. ' anchor=' .. tostring(floor.StartAnchorID)
|
||||
.. ' count=' .. tostring(floor.GroupInstanceCommonMap.Count))
|
||||
local iterator = floor.GroupInstanceCommonMap:GetEnumerator()
|
||||
while iterator:MoveNext() do
|
||||
local entry = iterator.Current
|
||||
if not state.savedCaptured then
|
||||
for index = 0, math.min(floor.DimensionList.Length - 1, 3) do
|
||||
local dimension = floor.DimensionList[index]
|
||||
log('SAVED', 'DIMENSION ' .. floorID .. ' ' .. tostring(index) .. ' '
|
||||
.. CS.Newtonsoft.Json.JsonConvert.SerializeObject(dimension.SavedValues))
|
||||
local ids = {}
|
||||
for j = 0, dimension.GroupIndexList.Length - 1 do
|
||||
ids[#ids + 1] = floor.GroupInstanceList[dimension.GroupIndexList[j]].ID
|
||||
end
|
||||
log('DIMENSION', 'GROUPS ' .. floorID .. ' ' .. tostring(index) .. ' ' .. tostring(dimension.ID)
|
||||
.. ' [' .. table.concat(ids, ',') .. ']')
|
||||
end
|
||||
state.savedCaptured = true
|
||||
end
|
||||
local commonEnd = math.min(state.commonIndex + 15, #state.commonEntries)
|
||||
for index = state.commonIndex, commonEnd do
|
||||
local entry = state.commonEntries[index]
|
||||
log('META', 'GROUP ' .. floorID .. ' ' .. tostring(entry.Key)
|
||||
.. ' side=' .. tostring(entry.Value.LoadSide) .. ' hoyo=' .. tostring(entry.Value.IsHoyoGroup)
|
||||
.. ' side=' .. tostring(entry.Value.LoadSide)
|
||||
.. ' hoyo=' .. tostring(entry.Value.IsHoyoGroup)
|
||||
.. ' deleted=' .. tostring(entry.Value.IsDelete))
|
||||
end
|
||||
log('META', 'END ' .. floorID)
|
||||
for i = 0, floor.GroupInstanceList.Length - 1 do
|
||||
local group = floor.GroupInstanceList[i]
|
||||
local common = floor.GroupInstanceCommonMap[group.ID]
|
||||
if not group.IsDelete and common ~= nil and not common.IsDelete
|
||||
and (i == floor.StartGroupIndex or tostring(common.LoadSide):find('Server', 1, true)) then
|
||||
local data = CS.RPG.GameCore.GameCoreConfigLoader.LoadRtLevelGroupInfo(group.GroupPath)
|
||||
if data == nil then error('missing RuntimeGroup ' .. tostring(group.GroupPath)) end
|
||||
if i == floor.StartGroupIndex and data.AnchorList ~= nil then
|
||||
for j = 0, data.AnchorList.Length - 1 do
|
||||
local anchor = data.AnchorList[j]
|
||||
if not anchor.IsDelete and anchor.ID == floor.StartAnchorID then
|
||||
position('PLACEMENT', 'ANCHOR ' .. floorID .. ' ' .. tostring(anchor.ID), group, anchor)
|
||||
state.commonIndex = commonEnd + 1
|
||||
|
||||
if state.commonIndex > #state.commonEntries then
|
||||
-- Skip cheap Client-owned instances without spending a whole
|
||||
-- heartbeat on each four indices; still load at most four groups.
|
||||
local groupEnd = math.min(state.groupIndex + 31, floor.GroupInstanceList.Length - 1)
|
||||
local lastIndex = state.groupIndex - 1
|
||||
local loadedGroups = 0
|
||||
for index = state.groupIndex, groupEnd do
|
||||
if loadedGroups >= 4 then break end
|
||||
lastIndex = index
|
||||
local group = floor.GroupInstanceList[index]
|
||||
local common = floor.GroupInstanceCommonMap[group.ID]
|
||||
if not group.IsDelete and common ~= nil and not common.IsDelete
|
||||
and (index == floor.StartGroupIndex or tostring(common.LoadSide):find('Server', 1, true)) then
|
||||
loadedGroups = loadedGroups + 1
|
||||
local loaded, groupErr = pcall(function()
|
||||
local data = CS.RPG.GameCore.GameCoreConfigLoader.LoadRtLevelGroupInfo(group.GroupPath)
|
||||
if data == nil then error('missing RuntimeGroup ' .. tostring(group.GroupPath)) end
|
||||
if index == floor.StartGroupIndex and data.AnchorList ~= nil then
|
||||
for j = 0, data.AnchorList.Length - 1 do
|
||||
local anchor = data.AnchorList[j]
|
||||
if not anchor.IsDelete and anchor.ID == floor.StartAnchorID then
|
||||
position('PLACEMENT', 'ANCHOR ' .. floorID .. ' ' .. tostring(anchor.ID), group, anchor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if data.MonsterList ~= nil then
|
||||
for j = 0, data.MonsterList.Length - 1 do
|
||||
local monster = data.MonsterList[j]
|
||||
if not monster.IsDelete and not monster.IsClientOnly then
|
||||
position('PLACEMENT', 'MONSTER ' .. floorID .. ' ' .. tostring(group.ID)
|
||||
.. ' ' .. tostring(monster.ID), group, monster)
|
||||
if data.MonsterList ~= nil then
|
||||
for j = 0, data.MonsterList.Length - 1 do
|
||||
local monster = data.MonsterList[j]
|
||||
if not monster.IsDelete and not monster.IsClientOnly then
|
||||
position('PLACEMENT', 'MONSTER ' .. floorID .. ' ' .. tostring(group.ID)
|
||||
.. ' ' .. tostring(monster.ID), group, monster)
|
||||
end
|
||||
end
|
||||
end
|
||||
if data.PropList ~= nil then
|
||||
for j = 0, data.PropList.Length - 1 do
|
||||
local prop = data.PropList[j]
|
||||
if not prop.IsDelete and not prop.IsClientOnly then
|
||||
local x, y, z, rot = world(group, prop)
|
||||
log('PROPS', 'PROP ' .. floorID .. ' ' .. tostring(group.ID)
|
||||
.. ' ' .. tostring(prop.ID) .. ' ' .. tostring(prop.PropID)
|
||||
.. ' ' .. tostring(CS.System.Convert.ToUInt32(prop.State))
|
||||
.. ' pos=' .. tostring(x) .. ',' .. tostring(y) .. ',' .. tostring(z)
|
||||
.. ' rot=' .. tostring(rot))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
if not loaded then
|
||||
state.failed = true
|
||||
log('META', 'ERROR group=' .. tostring(group.ID) .. ' ' .. tostring(groupErr))
|
||||
end
|
||||
end
|
||||
end
|
||||
state.groupIndex = lastIndex + 1
|
||||
if state.groupIndex >= floor.GroupInstanceList.Length then
|
||||
log('META', 'END ' .. floorID)
|
||||
if not state.failed then
|
||||
log('PLACEMENT', 'END ' .. floorID)
|
||||
log('PROPS', 'END ' .. floorID)
|
||||
end
|
||||
state.floorIndex = state.floorIndex + 1
|
||||
state.floor = nil
|
||||
state.savedCaptured = nil
|
||||
state.commonEntries = nil
|
||||
end
|
||||
end
|
||||
log('PLACEMENT', 'END ' .. floorID)
|
||||
end)
|
||||
if not ok then log('META', 'ERROR ' .. tostring(pair[2]) .. ' ' .. tostring(err)) end
|
||||
progress = index + 1
|
||||
if not ok then
|
||||
state.failed = true
|
||||
log('META', 'ERROR floor=' .. tostring(pair[2]) .. ' ' .. tostring(err))
|
||||
state.floorIndex = state.floorIndex + 1
|
||||
state.floor = nil
|
||||
state.savedCaptured = nil
|
||||
state.commonEntries = nil
|
||||
end
|
||||
elseif not state.done then
|
||||
state.done = true
|
||||
log('META', 'CAPTURE_COMPLETE')
|
||||
end
|
||||
_G.__gacSceneExports[key] = progress
|
||||
end
|
||||
Reference in new issue
Block a user