Rename MaterialModifier to TileModifier
This commit is contained in:
parent
0c60dd6a02
commit
77f19b77ff
@ -34,7 +34,7 @@ import ru.dbotthepony.kstarbound.defs.animation.ParticleConfig
|
||||
import ru.dbotthepony.kstarbound.defs.projectile.ProjectileDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.quest.QuestTemplate
|
||||
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.world.BushVariant
|
||||
import ru.dbotthepony.kstarbound.defs.world.GrassVariant
|
||||
@ -59,7 +59,7 @@ object Registries {
|
||||
}
|
||||
|
||||
val tiles = Registry<TileDefinition>("tiles").also(registriesInternal::add).also { adapters.add(it.adapter()) }
|
||||
val tileModifiers = Registry<MaterialModifier>("tile modifiers").also(registriesInternal::add).also { adapters.add(it.adapter()) }
|
||||
val tileModifiers = Registry<TileModifierDefinition>("tile modifiers").also(registriesInternal::add).also { adapters.add(it.adapter()) }
|
||||
val liquid = Registry<LiquidDefinition>("liquid").also(registriesInternal::add).also { adapters.add(it.adapter()) }
|
||||
val species = Registry<Species>("species").also(registriesInternal::add).also { adapters.add(it.adapter()) }
|
||||
val statusEffects = Registry<StatusEffectDefinition>("status effect").also(registriesInternal::add).also { adapters.add(it.adapter()) }
|
||||
@ -144,7 +144,7 @@ object Registries {
|
||||
tasks.addAll(loadTerrainSelectors(fileTree["terrain"] ?: listOf()))
|
||||
|
||||
tasks.addAll(loadRegistry(tiles, fileTree["material"] ?: listOf(), key(TileDefinition::materialName, TileDefinition::materialId)))
|
||||
tasks.addAll(loadRegistry(tileModifiers, fileTree["matmod"] ?: listOf(), key(MaterialModifier::modName, MaterialModifier::modId)))
|
||||
tasks.addAll(loadRegistry(tileModifiers, fileTree["matmod"] ?: listOf(), key(TileModifierDefinition::modName, TileModifierDefinition::modId)))
|
||||
tasks.addAll(loadRegistry(liquid, fileTree["liquid"] ?: listOf(), key(LiquidDefinition::name, LiquidDefinition::liquidId)))
|
||||
|
||||
tasks.addAll(loadRegistry(worldObjects, fileTree["object"] ?: listOf(), key(ObjectDefinition::objectName)))
|
||||
|
@ -14,14 +14,12 @@ import ru.dbotthepony.kstarbound.client.gl.*
|
||||
import ru.dbotthepony.kstarbound.client.gl.shader.UberShader
|
||||
import ru.dbotthepony.kstarbound.client.gl.vertex.*
|
||||
import ru.dbotthepony.kstarbound.defs.tile.*
|
||||
import ru.dbotthepony.kstarbound.util.random.staticRandom32
|
||||
import ru.dbotthepony.kstarbound.util.random.staticRandomFloat
|
||||
import ru.dbotthepony.kstarbound.world.api.ITileAccess
|
||||
import ru.dbotthepony.kstarbound.world.api.AbstractTileState
|
||||
import ru.dbotthepony.kstarbound.world.api.TileColor
|
||||
import java.time.Duration
|
||||
import java.util.concurrent.Callable
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
@ -103,7 +101,7 @@ private class TileEqualityTester(val definition: TileDefinition) : EqualityRuleT
|
||||
}
|
||||
}
|
||||
|
||||
private class ModifierEqualityTester(val definition: MaterialModifier) : EqualityRuleTester {
|
||||
private class ModifierEqualityTester(val definition: TileModifierDefinition) : EqualityRuleTester {
|
||||
override fun test(thisTile: AbstractTileState?, otherTile: AbstractTileState?): Boolean {
|
||||
return otherTile?.modifier?.value == definition
|
||||
}
|
||||
@ -121,7 +119,7 @@ class TileRenderer(val renderers: TileRenderers, val def: IRenderableTile) {
|
||||
|
||||
val equalityTester: EqualityRuleTester = when (def) {
|
||||
is TileDefinition -> TileEqualityTester(def)
|
||||
is MaterialModifier -> ModifierEqualityTester(def)
|
||||
is TileModifierDefinition -> ModifierEqualityTester(def)
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||
|
||||
@JsonFactory
|
||||
data class MaterialModifier(
|
||||
data class TileModifierDefinition(
|
||||
val modId: Int,
|
||||
val modName: String,
|
||||
val itemDrop: String? = null,
|
@ -9,7 +9,6 @@ import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.collect.WeightedList
|
||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||
import ru.dbotthepony.kstarbound.defs.JsonConfigFunction
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||
import ru.dbotthepony.kstarbound.json.NativeLegacy
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||
|
@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableSet
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonPrimitive
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import com.google.gson.TypeAdapter
|
||||
@ -21,7 +20,7 @@ import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.collect.WeightedList
|
||||
import ru.dbotthepony.kstarbound.defs.PerlinNoiseParameters
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.json.NativeLegacy
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||
@ -31,8 +30,8 @@ import java.util.stream.Stream
|
||||
|
||||
@JsonFactory
|
||||
data class BiomePlaceables(
|
||||
val grassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref<MaterialModifier>?),
|
||||
val ceilingGrassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref<MaterialModifier>?),
|
||||
val grassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref<TileModifierDefinition>?),
|
||||
val ceilingGrassMod: NativeLegacy.TileMod = NativeLegacy.TileMod(null as Registry.Ref<TileModifierDefinition>?),
|
||||
val grassModDensity: Double = 0.0,
|
||||
val ceilingGrassModDensity: Double = 0.0,
|
||||
val itemDistributions: ImmutableList<DistributionItem> = ImmutableList.of(),
|
||||
|
@ -10,12 +10,11 @@ import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.collect.WeightedList
|
||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||
import ru.dbotthepony.kstarbound.defs.PerlinNoiseParameters
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.json.NativeLegacy
|
||||
import ru.dbotthepony.kstarbound.json.builder.IStringSerializable
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFlat
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonSingleton
|
||||
import ru.dbotthepony.kstarbound.util.random.AbstractPerlinNoise
|
||||
import ru.dbotthepony.kstarbound.util.random.nextRange
|
||||
import ru.dbotthepony.kstarbound.util.random.random
|
||||
@ -23,9 +22,9 @@ import java.util.stream.IntStream
|
||||
|
||||
@JsonFactory
|
||||
data class BiomePlaceablesDefinition(
|
||||
val grassMod: ImmutableList<Registry.Ref<MaterialModifier>> = ImmutableList.of(),
|
||||
val grassMod: ImmutableList<Registry.Ref<TileModifierDefinition>> = ImmutableList.of(),
|
||||
val grassModDensity: Double = 0.0,
|
||||
val ceilingGrassMod: ImmutableList<Registry.Ref<MaterialModifier>> = ImmutableList.of(),
|
||||
val ceilingGrassMod: ImmutableList<Registry.Ref<TileModifierDefinition>> = ImmutableList.of(),
|
||||
val ceilingGrassModDensity: Double = 0.0,
|
||||
val items: ImmutableList<DistributionItem> = ImmutableList.of(),
|
||||
) {
|
||||
|
@ -12,8 +12,7 @@ import ru.dbotthepony.kommons.util.KOptional
|
||||
import ru.dbotthepony.kstarbound.Registries
|
||||
import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.ParameterizedType
|
||||
@ -74,26 +73,26 @@ abstract class NativeLegacy<NATIVE, LEGACY> {
|
||||
}
|
||||
}
|
||||
|
||||
class TileMod() : NativeLegacy<Registry.Ref<MaterialModifier>, Int?>() {
|
||||
constructor(tile: Registry.Entry<MaterialModifier>?) : this() {
|
||||
class TileMod() : NativeLegacy<Registry.Ref<TileModifierDefinition>, Int?>() {
|
||||
constructor(tile: Registry.Entry<TileModifierDefinition>?) : this() {
|
||||
if (tile == null)
|
||||
legacyValue = KOptional(65535)
|
||||
else
|
||||
nativeValue = KOptional(tile.ref)
|
||||
}
|
||||
|
||||
constructor(tile: Registry.Ref<MaterialModifier>?) : this() {
|
||||
constructor(tile: Registry.Ref<TileModifierDefinition>?) : this() {
|
||||
if (tile == null)
|
||||
legacyValue = KOptional(65535)
|
||||
else
|
||||
nativeValue = KOptional(tile)
|
||||
}
|
||||
|
||||
override fun computeLegacy(value: Registry.Ref<MaterialModifier>): Int {
|
||||
override fun computeLegacy(value: Registry.Ref<TileModifierDefinition>): Int {
|
||||
return value.value?.modId ?: 65535
|
||||
}
|
||||
|
||||
override fun computeNative(value: Int?): Registry.Ref<MaterialModifier> {
|
||||
override fun computeNative(value: Int?): Registry.Ref<TileModifierDefinition> {
|
||||
value ?: return Registries.tileModifiers.emptyRef
|
||||
return Registries.tileModifiers.ref(value)
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ class EmptyNoise(parameters: PerlinNoiseParameters) : AbstractPerlinNoise(parame
|
||||
}
|
||||
|
||||
override fun get(x: Double): Double {
|
||||
return 0.0
|
||||
throw IllegalStateException("Tried to sample uninitialized noise")
|
||||
}
|
||||
|
||||
override fun get(x: Double, y: Double): Double {
|
||||
return 0.0
|
||||
throw IllegalStateException("Tried to sample uninitialized noise")
|
||||
}
|
||||
|
||||
override fun get(x: Double, y: Double, z: Double): Double {
|
||||
return 0.0
|
||||
throw IllegalStateException("Tried to sample uninitialized noise")
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,15 @@ import com.github.benmanes.caffeine.cache.Interner
|
||||
import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||
import ru.dbotthepony.kstarbound.network.LegacyNetworkTileState
|
||||
import ru.dbotthepony.kstarbound.util.HashTableInterner
|
||||
import java.io.DataInputStream
|
||||
import java.io.DataOutputStream
|
||||
|
||||
sealed class AbstractTileState {
|
||||
abstract val material: Registry.Entry<TileDefinition>
|
||||
abstract val modifier: Registry.Entry<MaterialModifier>?
|
||||
abstract val modifier: Registry.Entry<TileModifierDefinition>?
|
||||
abstract val color: TileColor
|
||||
abstract val hueShift: Float
|
||||
abstract val modifierHueShift: Float
|
||||
|
@ -2,13 +2,13 @@ package ru.dbotthepony.kstarbound.world.api
|
||||
|
||||
import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||
import ru.dbotthepony.kstarbound.network.LegacyNetworkTileState
|
||||
|
||||
data class ImmutableTileState(
|
||||
override var material: Registry.Entry<TileDefinition> = BuiltinMetaMaterials.NULL,
|
||||
override var modifier: Registry.Entry<MaterialModifier>? = null,
|
||||
override var modifier: Registry.Entry<TileModifierDefinition>? = null,
|
||||
override var color: TileColor = TileColor.DEFAULT,
|
||||
override var hueShift: Float = 0f,
|
||||
override var modifierHueShift: Float = 0f,
|
||||
|
@ -3,13 +3,13 @@ package ru.dbotthepony.kstarbound.world.api
|
||||
import ru.dbotthepony.kstarbound.Registries
|
||||
import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials
|
||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileModifierDefinition
|
||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||
import java.io.DataInputStream
|
||||
|
||||
data class MutableTileState(
|
||||
override var material: Registry.Entry<TileDefinition> = BuiltinMetaMaterials.NULL,
|
||||
override var modifier: Registry.Entry<MaterialModifier>? = null,
|
||||
override var modifier: Registry.Entry<TileModifierDefinition>? = null,
|
||||
override var color: TileColor = TileColor.DEFAULT,
|
||||
override var hueShift: Float = 0f,
|
||||
override var modifierHueShift: Float = 0f,
|
||||
|
Loading…
Reference in New Issue
Block a user