more correct tile connection match
This commit is contained in:
parent
9bbff0403a
commit
86742b537e
@ -91,7 +91,9 @@ fun main() {
|
||||
chunk.foreground[x, y]?.modifier = getModifier
|
||||
}
|
||||
|
||||
reader.skipBytes(1) // Foreground mod hue shift
|
||||
val modifierHueShift = reader.readUnsignedByte()
|
||||
|
||||
chunk.foreground[x, y]?.setModifierHueShift(modifierHueShift)
|
||||
|
||||
val materialID2 = reader.readShort()
|
||||
val getMat2 = Starbound.tilesAccessID[materialID2.toInt()]
|
||||
@ -101,8 +103,11 @@ fun main() {
|
||||
hitTile = true
|
||||
}
|
||||
|
||||
reader.skipBytes(1) // Background hue shift
|
||||
reader.skipBytes(1) // Background color variant
|
||||
// reader.skipBytes(1) // Background hue shift
|
||||
// reader.skipBytes(1) // Background color variant
|
||||
|
||||
val colorShift2 = reader.readUnsignedByte()
|
||||
val colorVariant2 = reader.readUnsignedByte()
|
||||
|
||||
val modifier2 = reader.readUnsignedShort()
|
||||
val getModifier2 = Starbound.tileModifiersByIDAccess[modifier2]
|
||||
@ -111,7 +116,14 @@ fun main() {
|
||||
chunk.background[x, y]?.modifier = getModifier2
|
||||
}
|
||||
|
||||
reader.skipBytes(18)
|
||||
chunk.background[x, y]?.color = colorVariant2
|
||||
chunk.background[x, y]?.setHueShift(colorShift2)
|
||||
|
||||
val modifierHueShift2 = reader.readUnsignedByte()
|
||||
|
||||
chunk.background[x, y]?.setModifierHueShift(modifierHueShift2)
|
||||
|
||||
reader.skipBytes(17)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,14 +171,14 @@ private enum class TileRenderTesselateResult {
|
||||
private fun vertexTextureBuilder() = HeapVertexBuilder(GLAttributeList.VERTEX_HSV_TEXTURE, VertexType.QUADS)
|
||||
|
||||
private class TileEqualityTester(val definition: TileDefinition) : EqualityRuleTester {
|
||||
override fun test(tile: TileState?): Boolean {
|
||||
return tile?.def == definition
|
||||
override fun test(thisTile: TileState?, otherTile: TileState?): Boolean {
|
||||
return otherTile?.def == definition && thisTile?.hueShift == otherTile.hueShift
|
||||
}
|
||||
}
|
||||
|
||||
private class ModifierEqualityTester(val definition: MaterialModifier) : EqualityRuleTester {
|
||||
override fun test(tile: TileState?): Boolean {
|
||||
return tile?.modifier == definition
|
||||
override fun test(thisTile: TileState?, otherTile: TileState?): Boolean {
|
||||
return otherTile?.modifier == definition
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ class TileRenderer(val state: GLStateTracker, val def: IRenderableTile) {
|
||||
val (u0, v0) = texture.pixelToUV(mins)
|
||||
val (u1, v1) = texture.pixelToUV(maxs)
|
||||
|
||||
builder.quadZ(a, b, c, d, Z_LEVEL, QuadTransformers.uv(u0, v1, u1, v0).after { it, _ -> it.push(if (!isModifier || self.modifier?.grass == true) self.hueShift else 0f) })
|
||||
builder.quadZ(a, b, c, d, Z_LEVEL, QuadTransformers.uv(u0, v1, u1, v0).after { it, _ -> it.push(if (isModifier) self.modifierHueShift else self.hueShift) })
|
||||
}
|
||||
|
||||
private fun tesselatePiece(
|
||||
|
@ -38,7 +38,7 @@ data class RenderPiece(
|
||||
}
|
||||
|
||||
fun interface EqualityRuleTester {
|
||||
fun test(tile: TileState?): Boolean
|
||||
fun test(thisTile: TileState?, otherTile: TileState?): Boolean
|
||||
}
|
||||
|
||||
data class RenderRuleList(
|
||||
@ -56,7 +56,7 @@ data class RenderRuleList(
|
||||
) {
|
||||
private fun doTest(getter: ITileGetter, equalityTester: EqualityRuleTester, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
return when (type) {
|
||||
"EqualsSelf" -> equalityTester.test(getter[thisPos + offsetPos])
|
||||
"EqualsSelf" -> equalityTester.test(getter[thisPos], getter[thisPos + offsetPos])
|
||||
"Connects" -> getter[thisPos + offsetPos] != null
|
||||
|
||||
else -> {
|
||||
|
@ -51,6 +51,19 @@ class TileState(val chunk: Chunk<*, *>.TileLayer, val def: TileDefinition) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Выставляет hue shift как байтовое значение в диапазоне 0 .. 255
|
||||
*/
|
||||
fun setModifierHueShift(value: Int) {
|
||||
if (value < 0) {
|
||||
modifierHueShift = 0f
|
||||
} else if (value > 255) {
|
||||
modifierHueShift = 360f
|
||||
} else {
|
||||
modifierHueShift = (value / 255f) * 360f
|
||||
}
|
||||
}
|
||||
|
||||
var hueShift = 0f
|
||||
set(value) {
|
||||
var newValue = value % 360f
|
||||
@ -65,6 +78,20 @@ class TileState(val chunk: Chunk<*, *>.TileLayer, val def: TileDefinition) {
|
||||
}
|
||||
}
|
||||
|
||||
var modifierHueShift = 0f
|
||||
set(value) {
|
||||
var newValue = value % 360f
|
||||
|
||||
if (newValue < 0f) {
|
||||
newValue += 360f
|
||||
}
|
||||
|
||||
if (newValue != field) {
|
||||
field = newValue
|
||||
chunk.incChangeset()
|
||||
}
|
||||
}
|
||||
|
||||
var modifier: MaterialModifier? = null
|
||||
set(value) {
|
||||
if (value != field) {
|
||||
@ -74,7 +101,12 @@ class TileState(val chunk: Chunk<*, *>.TileLayer, val def: TileDefinition) {
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is TileState && other.color == color && other.modifier === modifier && other.def === def
|
||||
return other is TileState &&
|
||||
other.color == color &&
|
||||
other.modifier === modifier &&
|
||||
other.modifierHueShift == modifierHueShift &&
|
||||
other.hueShift == hueShift &&
|
||||
other.def === def
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
|
Loading…
Reference in New Issue
Block a user