---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by gyz.
--- DateTime: 2020/9/22 19:51
---

---@class LRoleListManager
LRoleListManager = LRoleListManager or class("LRoleListManager");

function LRoleListManager:ctor()

end

function LRoleListManager:dtor()
    
end

---@return LLocalPlayer
function LRoleListManager:GetDefaultActor()
    -- 读档,若无则写入默认角色
    local lLocalPlayer;
    local tbActorInfo = g_SaveManager:GetActorInfoFromFile();
    if type(tbActorInfo) == 'table' and #tbActorInfo > 0 then
        local actorIdx = #tbActorInfo;
        lLocalPlayer = g_ActorManager:CreateLocalPlayer(tbActorInfo[actorIdx]['Path']);
        lLocalPlayer:SetSchoolIdx(tbActorInfo[actorIdx]['School']);
    else
        local tbCreatedActorInfo = {};
        local tbTmpCreatedActorInfo = {};
        lLocalPlayer = g_ActorManager:CreateLocalPlayer("data/source/player/actor/cy_f2.actor");
        if lLocalPlayer ~= nil then
            lLocalPlayer:SetSchoolIdx(1);

            tbTmpCreatedActorInfo["Name"] = "cy_f2";
            tbTmpCreatedActorInfo["Path"] = "data/source/player/actor/cy_f2.actor";
            tbTmpCreatedActorInfo["Json"] = g_ActorManager:GetActorJsonString(lLocalPlayer);
            tbTmpCreatedActorInfo["School"] = 1;
            tbTmpCreatedActorInfo["RoleType"] = lLocalPlayer:GetRoleType();

            table.insert(tbCreatedActorInfo, tbTmpCreatedActorInfo);
            g_SaveManager:SaveActorInfoToFile(tbCreatedActorInfo);
        end
    end

    return lLocalPlayer;
end

_G.g_RoleListManager = LRoleListManager:new();
