local this = class("timelineSceneHandle")

function this:ctor(_timelinePrefabHandle)
  self._timelinePrefabHandle = _timelinePrefabHandle
  self._scenePrefabMap = {}
  self._sceneName = nil
end

function this:dispose()
  for i, v in pairs(self._scenePrefabMap) do
    C_GameObject.DestroyImmediate(v)
    self._scenePrefabMap[i] = nil
  end
  self._scenePrefabMap = nil
  self._sceneName = nil
end

function this:loadScenePrefab(sceneName)
  if self._sceneName == sceneName then
    return
  end
  local prefab
  if self._scenePrefabMap[self._sceneName] then
    self._scenePrefabMap[self._sceneName]:ActiveTrans(false)
  end
  self._sceneName = sceneName
  if self._scenePrefabMap[sceneName] then
    prefab = self._scenePrefabMap[sceneName]
  else
    prefab = L_ResPool:syncGameObject(sceneName)
    prefab.transform.parent = self._timelinePrefabHandle:getRoot().transform
    L_Vector3.setPos(prefab.transform, L_Vector3.getTemp())
    L_Vector3.setRot(prefab.transform, L_Vector3.getTemp())
    self._scenePrefabMap[sceneName] = prefab
  end
  prefab:ActiveTrans(true)
end

return this
