---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by 0.
--- DateTime: 2019/3/21 17:40
---
XHomeRoomData = XClass()

function XHomeRoomData:Ctor(id)
    self.Id = id or 0
    self.PlayerId = XPlayer.Id
    self.Name = nil
    self.IsUnlock = false

    self.FurnitureDic = {}
    self.Character = {}
end

-- 判断数据是自己还是其他人的
function XHomeRoomData:IsSelfData()
    return self.PlayerId == XPlayer.Id
end

function XHomeRoomData:SetPlayerId(id)
    self.PlayerId = id
end

function XHomeRoomData:GetPlayerId()
    return self.PlayerId
end

function XHomeRoomData:GetRoomId()
    return self.Id
end

function XHomeRoomData:SetRoomName(name)
    self.Name = name
end

function XHomeRoomData:GetRoomName()
    return self.Name
end

function XHomeRoomData:SetRoomUnlock(isUnlock)
    self.IsUnlock = isUnlock
end

function XHomeRoomData:WhetherRoomUnlock()
    return self.IsUnlock
end

function XHomeRoomData:AddFurniture(instId, cfgId, x, y, rotateAngle)
    local furniture = {}
    furniture.Id = instId or 0
    furniture.ConfigId = cfgId
    furniture.GridX = x
    furniture.GridY = y
    furniture.RotateAngle = rotateAngle

    self.FurnitureDic[instId] = furniture
end

function XHomeRoomData:GetFurnitureDic()
    return self.FurnitureDic
end

--添加角色
function XHomeRoomData:AddCharacter(character)
    table.insert(self.Character, character)
end

--移除角色
function XHomeRoomData:RemoveCharacter(id)
    if self.Character == nil then
        return
    end

    local index = -1
    for i, v in ipairs(self.Character) do
        if v.CharacterId == id then
            index = i
            break
        end
    end

    if index > 0 then
        table.remove(self.Character, index)
    end
end

function XHomeRoomData:GetCharacterById(CharacterId)
    for i, v in ipairs(self.Character) do
        if v.CharacterId == CharacterId then
            return v
        end
    end

    return nil
end

function XHomeRoomData:GetCharacter()
    return self.Character
end