--- 
gModCharacters = {}
gPlayerCharacters = {}


--- The Character info from the main characters
function setDefaultCharacterInfo(registryKey, CharacterId)
    setCharacterInfo(registryKey, "", CharacterId, gPlayerCharacters[CharacterId])
end


function setCharacterInfo(registryKey, modId, CharacterId, CharacterInfo)
    --- If modId is empty do not add mod spawn prefix
    local modSpawnPrefix = modId ~= "" and modId..":" or ""

    SetString(registryKey, modSpawnPrefix..CharacterInfo.path or "")
    SetString(registryKey..".preview", CharacterInfo.preview or "")
    SetString(registryKey..".name", CharacterInfo.name or CharacterId)
    SetString(registryKey..".description", CharacterInfo.description or CharacterId)
    SetFloat(registryKey..".anim_speed", CharacterInfo.anim_speed or 0.0)
    SetFloat(registryKey..".height", CharacterInfo.height or 1.95)
    SetString(registryKey..".tool_offset", CharacterInfo.tool_offset and VecStr(CharacterInfo.tool_offset) or "0,0,0");
end


function setCharactersInfo(modId)
    local registryModIdKey = "characters."..modId
    for CharacterId, CharacterInfo in pairs(gModCharacters) do
        --- Set the model path in character id tag. "characters.characterId":"path/to/prefab/model.xml"
        local registryKey = registryModIdKey.."."..CharacterId
        setCharacterInfo(registryKey, modId, CharacterId, CharacterInfo)
    end
end
