package ru.dbotthepony.kstarbound.world.api

import ru.dbotthepony.kommons.util.IStruct2i
import ru.dbotthepony.kommons.vector.Vector2i
import ru.dbotthepony.kstarbound.world.ChunkState

class OffsetCellAccess(private val parent: ICellAccess, var x: Int, var y: Int) : ICellAccess {
	constructor(parent: ICellAccess, offset: IStruct2i) : this(parent, offset.component1(), offset.component2())

	override fun getCell(x: Int, y: Int): AbstractCell {
		return parent.getCell(x + this.x, y + this.y)
	}

	override fun setCell(x: Int, y: Int, cell: AbstractCell, chunkState: ChunkState): Boolean {
		return parent.setCell(x + this.x, y + this.y, cell, chunkState)
	}

	override fun setCell(x: Int, y: Int, cell: AbstractCell): Boolean {
		return parent.setCell(x + this.x, y + this.y, cell)
	}
}