Добавлен подинтерфейс ITileAccess
This commit is contained in:
parent
4bd1cae5e1
commit
fe7529d208
@ -144,17 +144,17 @@ private fun loop() {
|
||||
var y = 0
|
||||
|
||||
for (tile in Starbound.tilesAccess.values) {
|
||||
chunk[x, y + 1] = (tile)
|
||||
chunk[x++, y] = (tile)
|
||||
chunk[x, y + 1] = (tile)
|
||||
chunk[x++, y] = (tile)
|
||||
chunk[x, y + 1] = (tile)
|
||||
chunk[x++, y] = (tile)
|
||||
chunk[x, y + 1] = (tile)
|
||||
chunk[x++, y] = (tile)
|
||||
chunk[x, y + 1] = (tile)
|
||||
chunk[x++, y] = (tile)
|
||||
chunk[x, y + 1] = (tile)
|
||||
chunk[x, y + 1] = tile
|
||||
chunk[x++, y] = tile
|
||||
chunk[x, y + 1] = tile
|
||||
chunk[x++, y] = tile
|
||||
chunk[x, y + 1] = tile
|
||||
chunk[x++, y] = tile
|
||||
chunk[x, y + 1] = tile
|
||||
chunk[x++, y] = tile
|
||||
chunk[x, y + 1] = tile
|
||||
chunk[x++, y] = tile
|
||||
chunk[x, y + 1] = tile
|
||||
|
||||
if (x >= 32) {
|
||||
x = 0
|
||||
|
@ -10,6 +10,7 @@ import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.math.Vector2i
|
||||
import ru.dbotthepony.kstarbound.util.Color
|
||||
import ru.dbotthepony.kstarbound.world.IChunk
|
||||
import ru.dbotthepony.kstarbound.world.ITileAccess
|
||||
import java.io.File
|
||||
|
||||
data class TileDefinition(
|
||||
@ -180,7 +181,7 @@ sealed class RenderRule(params: Map<String, Any>) {
|
||||
val matchHue = params["matchHue"] as? Boolean ?: false
|
||||
val inverse = params["inverse"] as? Boolean ?: false
|
||||
|
||||
abstract fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean
|
||||
abstract fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean
|
||||
|
||||
companion object {
|
||||
fun factory(name: String, params: Map<String, Any>): RenderRule {
|
||||
@ -220,7 +221,7 @@ sealed class RenderRule(params: Map<String, Any>) {
|
||||
}
|
||||
|
||||
class RenderRuleEqualsSelf(params: Map<String, Any>) : RenderRule(params) {
|
||||
override fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
override fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
val otherTile = getter[thisPos + offsetPos] ?: return inverse
|
||||
|
||||
if (inverse)
|
||||
@ -231,13 +232,13 @@ class RenderRuleEqualsSelf(params: Map<String, Any>) : RenderRule(params) {
|
||||
}
|
||||
|
||||
class RenderRuleShadows(params: Map<String, Any>) : RenderRule(params) {
|
||||
override fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
override fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
return false // TODO
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRuleConnects(params: Map<String, Any>) : RenderRule(params) {
|
||||
override fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
override fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
if (inverse)
|
||||
return getter[thisPos + offsetPos] == null
|
||||
|
||||
@ -246,13 +247,13 @@ class RenderRuleConnects(params: Map<String, Any>) : RenderRule(params) {
|
||||
}
|
||||
|
||||
class AlwaysPassingRenderRule(params: Map<String, Any>) : RenderRule(params) {
|
||||
override fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
override fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
return inverse
|
||||
}
|
||||
}
|
||||
|
||||
class AlwaysFailingRenderRule(params: Map<String, Any>) : RenderRule(params) {
|
||||
override fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
override fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
return !inverse
|
||||
}
|
||||
}
|
||||
@ -273,7 +274,7 @@ data class TileRenderRule(
|
||||
val join: RenderRuleCombination,
|
||||
val pieces: List<RenderRule>
|
||||
) {
|
||||
fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i, offsetPos: Vector2i): Boolean {
|
||||
if (join == RenderRuleCombination.ANY) {
|
||||
for (piece in pieces) {
|
||||
if (piece.test(getter, thisRef, thisPos, offsetPos)) {
|
||||
@ -337,7 +338,7 @@ data class TileRenderMatchPositioned(
|
||||
/**
|
||||
* Состояние [condition] на [thisPos] с [offset]
|
||||
*/
|
||||
fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i): Boolean {
|
||||
fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i): Boolean {
|
||||
return condition.test(getter, thisRef, thisPos, offset)
|
||||
}
|
||||
|
||||
@ -372,7 +373,7 @@ data class TileRenderMatchPiece(
|
||||
*
|
||||
* [subMatches] стоит итерировать только если это вернуло true
|
||||
*/
|
||||
fun test(getter: IChunk, thisRef: TileDefinition, thisPos: Vector2i): Boolean {
|
||||
fun test(getter: ITileAccess, thisRef: TileDefinition, thisPos: Vector2i): Boolean {
|
||||
for (matcher in matchAllPoints) {
|
||||
if (!matcher.test(getter, thisRef, thisPos)) {
|
||||
return false
|
||||
|
@ -8,9 +8,7 @@ data class ChunkTile(val def: TileDefinition) {
|
||||
var forceVariant = -1
|
||||
}
|
||||
|
||||
interface IChunk {
|
||||
val pos: ChunkPos
|
||||
|
||||
interface ITileAccess {
|
||||
/**
|
||||
* Возвращает тайл по ОТНОСИТЕЛЬНЫМ координатам внутри чанка
|
||||
*/
|
||||
@ -20,7 +18,10 @@ interface IChunk {
|
||||
* Возвращает тайл по ОТНОСИТЕЛЬНЫМ координатам внутри чанка
|
||||
*/
|
||||
operator fun get(pos: Vector2i) = get(pos.x, pos.y)
|
||||
}
|
||||
|
||||
interface IChunk : ITileAccess {
|
||||
val pos: ChunkPos
|
||||
|
||||
/**
|
||||
* Возвращает фоновый тайл по ОТНОСИТЕЛЬНЫМ координатам внутри чанка
|
||||
|
Loading…
Reference in New Issue
Block a user