package ru.dbotthepony.kstarbound.world.api

import ru.dbotthepony.kstarbound.Registry
import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
import ru.dbotthepony.kstarbound.network.LegacyNetworkTileState

data class ImmutableTileState(
	override val material: Registry.Entry<TileDefinition> = BuiltinMetaMaterials.NULL,
	override val modifier: Registry.Entry<TileModifierDefinition> = BuiltinMetaMaterials.EMPTY_MOD,
	override val color: TileColor = TileColor.DEFAULT,
	override val hueShift: Float = 0f,
	override val modifierHueShift: Float = 0f,
) : AbstractTileState() {
	override fun immutable(): ImmutableTileState {
		return this
	}

	private val legacyNet by lazy { super.toLegacyNet() }

	override fun toLegacyNet(): LegacyNetworkTileState {
		return legacyNet
	}

	override fun mutable(): MutableTileState {
		return MutableTileState(material, modifier, color, hueShift, modifierHueShift)
	}
}
