fix: getGradientCloud not sampling correct coord

This commit is contained in:
minjaesong
2023-10-03 02:47:10 +09:00
parent 1ebca0de66
commit cd2043b044
25 changed files with 140 additions and 164 deletions

View File

@@ -18,11 +18,8 @@ import net.torvald.terrarum.modulecomputers.gameactors.FixtureHomeComputer
class ItemHomeComputer(originalID: ItemID) : GameItem(originalID) {
override var dynamicID: ItemID = originalID
override val originalName = "Computer"
override var baseMass = 20.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -32,6 +29,7 @@ class ItemHomeComputer(originalID: ItemID) : GameItem(originalID) {
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_DESKTOP_COMPUTER"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) { _, _, mtx, mty ->

Binary file not shown.

View File

@@ -1,29 +1,29 @@
{
"basegame:160": {
"basegame:160": { /* stone platform */
"workbench": "",
"ingredients": [
[2, 1, "$ROCK"]
]
},
"basegame:161": {
"basegame:161": { /* wooden platform */
"workbench": "",
"ingredients": [
[2, 1, "basegame:48"]
]
},
"basegame:162": {
"basegame:162": { /* ebony platform */
"workbench": "",
"ingredients": [
[2, 1, "basegame:49"]
]
},
"basegame:163": {
"basegame:163": { /* birch platform */
"workbench": "",
"ingredients": [
[2, 1, "basegame:50"]
]
},
"basegame:164": {
"basegame:164": { /* rosewood platform */
"workbench": "",
"ingredients": [
[2, 1, "basegame:51"]

View File

@@ -1,5 +1,5 @@
{
"item@basegame:5": {
"item@basegame:5": { /* tiki torch */
"workbench": "",
"ingredients": [
[1, 3, "$WOOD", 1, "basegame:176"],
@@ -7,32 +7,32 @@
]
},
"item@basegame:16": {
"item@basegame:16": { /* workbench */
"workbench": "",
"ingredients": [
[1, 6, "$WOOD"]
[1, 8, "$WOOD"]
]
},
"item@basegame:256": {
"item@basegame:256": { /* oak door */
"workbench": "basiccrafting",
"ingredients": [
[1, 4, "basegame:48"]
]
},
"item@basegame:257": {
"item@basegame:257": { /* ebony door */
"workbench": "basiccrafting",
"ingredients": [
[1, 4, "basegame:49"]
]
},
"item@basegame:258": {
"item@basegame:258": { /* birch door */
"workbench": "basiccrafting",
"ingredients": [
[1, 4, "basegame:50"]
]
},
"item@basegame:259": {
"item@basegame:259": { /* rosewood door */
"workbench": "basiccrafting",
"ingredients": [
[1, 4, "basegame:51"]

View File

@@ -137,7 +137,7 @@ class GenerateSkyboxTextureAtlas {
File("./assets/clut/skybox.tga").writeBytes(bytes)
}
private val gradSizes = (0 until Skybox.gradSize)
private val gradSizes = listOf(50)
private fun getByte(gammaPair: Int, albedo0: Int, turb0: Int, elev0: Int, yp: Int, channel: Int): Byte {
val imgOffX = albedo0 * Skybox.elevCnt + elev0 + Skybox.elevCnt * Skybox.albedoCnt * gammaPair
@@ -179,12 +179,12 @@ class GenerateSkyboxTextureAtlas {
println("....... Turbidity=$turbidity")
for (elev0 in 0 until Skybox.elevCnt) {
val avrB = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 0).toUint() }.toDouble() / Skybox.gradSize).div(255.0).srgbLinearise().toFloat()
val avrG = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 1).toUint() }.toDouble() / Skybox.gradSize).div(255.0).srgbLinearise().toFloat()
val avrR = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 2).toUint() }.toDouble() / Skybox.gradSize).div(255.0).srgbLinearise().toFloat()
val avrA = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 3).toUint() }.toDouble() / Skybox.gradSize).div(255.0).srgbLinearise().toFloat()
val avrB = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 0).toUint() }.toDouble() / gradSizes.size).div(255.0).toFloat()
val avrG = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 1).toUint() }.toDouble() / gradSizes.size).div(255.0).toFloat()
val avrR = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 2).toUint() }.toDouble() / gradSizes.size).div(255.0).toFloat()
val avrA = (gradSizes.sumOf { getByte(gammaPair, albedo0, turb0, elev0, it, 3).toUint() }.toDouble() / gradSizes.size).div(255.0).toFloat()
val colour = Cvec(avrR, avrG, avrB, avrA).saturate(1.6666667f)
val colour = Cvec(avrR, avrG, avrB, avrA).mul(1.02f).vibrancy(1.1f)
val colourBytes = arrayOf(
colour.b.times(255f).roundToInt().coerceIn(0..255).toByte(),
@@ -223,9 +223,12 @@ class GenerateSkyboxTextureAtlas {
this * 12.92
}
private fun Cvec.saturate(intensity: Float): Cvec {
private fun Cvec.vibrancy(intensity: Float): Cvec {
val luv = HUSLColorConverter.rgbToHsluv(floatArrayOf(this.r, this.g, this.b))
luv[1] *= intensity
val sat = luv[1] // 0..100
luv[1] = (sat / 100f).pow(1f / intensity) * 100f
val rgb = HUSLColorConverter.hsluvToRgb(luv)
this.r = rgb[0]
this.g = rgb[1]

View File

@@ -42,7 +42,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
*
* e.g. Key Items (in a Pokémon sense); only the single instance of the item can exist in the pocket
*/
abstract val isUnique: Boolean
@Transient var isUnique: Boolean = false
/**
* OriginalName is always read from Language files.
@@ -52,10 +52,10 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
* - `BLOCK_AIR` Prints out `Lang.get("BLOCK_AIR")`
* - `BLOCK_AIR>>=BLOCK_WALL_NAME_TEMPLATE` Prints out `Formatter().format(Lang.get("BLOCK_WALL_NAME_TEMPLATE"), Lang.get("BLOCK_AIR")).toString()`
*/
abstract val originalName: String
@Transient var originalName: String = ""
var newName: String = "I AM VITUN PLACEHOLDER"
var newName: String = ""
private set
/**
@@ -84,7 +84,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
var itemProperties = ItemValue()
/** Single-use then destroyed (e.g. Tiles), same as "consumable" */
abstract var stackable: Boolean
@Transient var stackable: Boolean = true
/**
@@ -110,7 +110,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
* }
* ```
*/
var equipPosition: Int = EquipPosition.NULL
@Transient var equipPosition: Int = EquipPosition.NULL
internal val material: Material
get() = MaterialCodex.getOrDefault(materialId)
@@ -180,7 +180,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
/**
* Set to zero (GameItem.DURABILITY_NA) if durability not applicable
*/
open var maxDurability: Int = 0
@Transient open var maxDurability: Int = 0
/**
* Float. NOT A MISTAKE
@@ -189,7 +189,15 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
@Transient var using = false // Always false when loaded from savegame
var tags = HashSet<String>()
/**
* Tags defined by the basegame
*/
@Transient var tags = HashSet<String>()
/**
* Tags added/removed by dynamic items
*/
var modifiers = HashSet<String>()
/**
* Mainly intended to be used by third-party modules

View File

@@ -91,10 +91,8 @@ class EntryPoint : ModuleEntryPoint() {
private fun makeNewItemObj(tile: BlockProp, isWall: Boolean) = object : GameItem(
if (isWall) "wall@"+tile.id else tile.id
) {
override val isUnique: Boolean = false
override var baseMass: Double = tile.density / 1000.0
override var baseToolSize: Double? = null
override var stackable = true
override var inventoryCategory = if (isWall) Category.WALL else Category.BLOCK
override var isDynamic = false
override val materialId = tile.material
@@ -111,13 +109,13 @@ class EntryPoint : ModuleEntryPoint() {
init {
equipPosition = EquipPosition.HAND_GRIP
tags.addAll(tile.tags)
originalName =
if (isWall && tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE>>=BLOCK_WALL_NAME_TEMPLATE"
else if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE"
else if (tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE"
else tile.nameKey
}
override val originalName: String =
if (isWall && tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE>>=BLOCK_WALL_NAME_TEMPLATE"
else if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE"
else if (tags.contains("UNLIT")) "${tile.nameKey}>>=BLOCK_UNLIT_TEMPLATE"
else tile.nameKey
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
return BlockBase.blockStartPrimaryUse(actor, this, dynamicID, delta)

View File

@@ -186,14 +186,16 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
private var jumpJustPressedLatched = false
@Transient private val nullItem = object : GameItem("item@basegame:0") {
override val isUnique: Boolean = false
override var baseMass: Double = 0.0
override var baseToolSize: Double? = null
override var inventoryCategory = "should_not_be_seen"
override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "(no name)"
override var stackable = false
override val isDynamic = false
override val materialId = ""
init {
stackable = false
originalName = actorValue.getAsString(AVKey.NAME) ?: "(no name)"
}
}
override fun update(delta: Float) {

View File

@@ -36,7 +36,6 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
// we're having GameItem data so that this class could be somewhat universal
override var itemData: GameItem = object : GameItem("actor:"+referenceID) {//GameItem(referenceID ?: forceAssignRefID!!) {
override val isUnique = true
override var baseMass: Double
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
set(value) { actorValue[AVKey.BASEMASS] = value }
@@ -47,8 +46,6 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
actorValue[AVKey.SCALE] = value
}
override var inventoryCategory = "npc"
override val originalName: String = actorValue.getAsString(AVKey.NAME) ?: "NPC"
override var stackable = true
override val isDynamic = false
override val materialId = ""
@@ -65,6 +62,12 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
return -1
}
}
init {
isUnique = true
stackable = false
originalName = actorValue.getAsString(AVKey.NAME) ?: "NPC"
}
}
override fun getItemWeight(): Double {

View File

@@ -39,11 +39,8 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
@Transient private var ghostInit = AtomicBoolean(false)
override var dynamicID: ItemID = originalID
override val originalName = "FIXTUREBASE"
override var baseMass = 1.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""

View File

@@ -11,11 +11,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureLogicSignalEmitter
class ItemLogicSignalEmitter(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureLogicSignalEmitter") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_LOGIC_SIGNAL_EMITTER"
override var baseMass = FixtureLogicSignalEmitter.MASS
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -25,6 +22,7 @@ class ItemLogicSignalEmitter(originalID: ItemID) : FixtureItemBase(originalID, "
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_LOGIC_SIGNAL_EMITTER"
}
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) {

View File

@@ -13,11 +13,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
class ItemStorageChest(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureStorageChest") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_STORAGE_CHEST"
override var baseMass = FixtureTikiTorch.MASS
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -26,6 +23,7 @@ class ItemStorageChest(originalID: ItemID) : FixtureItemBase(originalID, "net.to
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_STORAGE_CHEST"
}
}

View File

@@ -13,11 +13,8 @@ class ItemSwingingDoorOak(originalID: ItemID) :
FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSwingingDoorOak") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_DOOR_OAK"
override var baseMass = 20.0 // 360[L] * 0.1 * 0.56[SpecificGravity], rounded to the nearest integer
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -26,6 +23,7 @@ class ItemSwingingDoorOak(originalID: ItemID) :
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_DOOR_OAK"
}
@Transient override val makeFixture: () -> FixtureBase = {
@@ -38,11 +36,8 @@ class ItemSwingingDoorEbony(originalID: ItemID) :
FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSwingingDoorEbony") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_DOOR_EBONY"
override var baseMass = 30.0 // 360[L] * 0.1 * 0.82[SpecificGravity], rounded to the nearest integer
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -51,6 +46,7 @@ class ItemSwingingDoorEbony(originalID: ItemID) :
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_DOOR_EBONY"
}
@Transient override val makeFixture: () -> FixtureBase = {
@@ -63,11 +59,8 @@ class ItemSwingingDoorBirch(originalID: ItemID) :
FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSwingingDoorBirch") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_DOOR_BIRCH"
override var baseMass = 17.0 // 360[L] * 0.1 * 0.48[SpecificGravity], rounded to the nearest integer
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -76,6 +69,7 @@ class ItemSwingingDoorBirch(originalID: ItemID) :
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_DOOR_BIRCH"
}
@Transient override val makeFixture: () -> FixtureBase = {
@@ -88,11 +82,8 @@ class ItemSwingingDoorRosewood(originalID: ItemID) :
FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureSwingingDoorRosewood") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_DOOR_ROSEWOOD"
override var baseMass = 24.0 // 360[L] * 0.1 * 0.68[SpecificGravity], rounded to the nearest integer
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -101,6 +92,7 @@ class ItemSwingingDoorRosewood(originalID: ItemID) :
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_DOOR_ROSEWOOD"
}
@Transient override val makeFixture: () -> FixtureBase = {

View File

@@ -15,11 +15,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTapestry
class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureTapestry") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_TAPESTRY"
override var baseMass = 6.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -28,6 +25,7 @@ class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torval
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_TAPESTRY"
}
@Transient override val makeFixture: () -> FixtureBase = {

View File

@@ -11,11 +11,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
class ItemTikiTorch(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_TIKI_TORCH"
override var baseMass = FixtureTikiTorch.MASS
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -25,6 +22,7 @@ class ItemTikiTorch(originalID: ItemID) : FixtureItemBase(originalID, "net.torva
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_TIKI_TORCH"
}
}

View File

@@ -11,11 +11,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
class ItemTypewriter(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureTypewriter") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_TYPEWRITER"
override var baseMass = FixtureTikiTorch.MASS
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -25,6 +22,7 @@ class ItemTypewriter(originalID: ItemID) : FixtureItemBase(originalID, "net.torv
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_TYPEWRITER"
}
}

View File

@@ -10,11 +10,8 @@ import net.torvald.terrarum.gameitems.ItemID
class ItemWallCalendar(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureWallCalendar") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_CALENDAR"
override var baseMass = 1.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -24,6 +21,7 @@ class ItemWallCalendar(originalID: ItemID) : FixtureItemBase(originalID, "net.to
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_CALENDAR"
}
}

View File

@@ -9,11 +9,8 @@ import net.torvald.terrarum.gameitems.ItemID
class ItemWorkbench(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureWorkbench") {
override val originalName = "ITEM_WORKBENCH"
override var baseMass = 20.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -23,6 +20,7 @@ class ItemWorkbench(originalID: ItemID) : FixtureItemBase(originalID, "net.torva
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_WORKBENCH"
}

View File

@@ -11,11 +11,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
class ItemWorldPortal(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureWorldPortal") {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_WORLD_PORTAL"
override var baseMass = 6000.0
override var stackable = true
override var inventoryCategory = Category.MISC
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
@@ -25,6 +22,7 @@ class ItemWorldPortal(originalID: ItemID) : FixtureItemBase(originalID, "net.tor
init {
equipPosition = EquipPosition.HAND_GRIP
originalName = "ITEM_WORLD_PORTAL"
}
}

View File

@@ -112,11 +112,8 @@ object PickaxeCore {
class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
internal constructor() : this("-uninitialised-")
override val originalName = "ITEM_PICK_COPPER"
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
override var stackable = true
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override val materialId = "CUPR"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
@@ -124,10 +121,11 @@ class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,0)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
super.durability = maxDurability.toFloat()
super.tags.add("PICK")
equipPosition = GameItem.EquipPosition.HAND_GRIP
maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
durability = maxDurability.toFloat()
tags.add("PICK")
originalName = "ITEM_PICK_COPPER"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
@@ -141,11 +139,8 @@ class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
internal constructor() : this("-uninitialised-")
override val originalName = "ITEM_PICK_IRON"
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
override var stackable = true
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override val materialId = "IRON"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
@@ -153,10 +148,11 @@ class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(1,0)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
super.durability = maxDurability.toFloat()
super.tags.add("PICK")
equipPosition = GameItem.EquipPosition.HAND_GRIP
maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
durability = maxDurability.toFloat()
tags.add("PICK")
originalName = "ITEM_PICK_IRON"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
@@ -170,11 +166,8 @@ class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
internal constructor() : this("-uninitialised-")
override val originalName = "ITEM_PICK_STEEL"
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
override var stackable = true
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override val materialId = "STAL"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
@@ -182,10 +175,11 @@ class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(2,0)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
super.durability = maxDurability.toFloat()
super.tags.add("PICK")
equipPosition = GameItem.EquipPosition.HAND_GRIP
maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
durability = maxDurability.toFloat()
tags.add("PICK")
originalName = "ITEM_PICK_STEEL"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =

View File

@@ -118,11 +118,8 @@ object SledgehammerCore {
class SledgehammerCopper(originalID: ItemID) : GameItem(originalID) {
internal constructor() : this("-uninitialised-")
override val originalName = "ITEM_SLEDGEHAMMER_COPPER"
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
override var stackable = true
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override val materialId = "CUPR"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
@@ -130,10 +127,11 @@ class SledgehammerCopper(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(6,0)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
super.durability = maxDurability.toFloat()
super.tags.add("HAMR")
equipPosition = GameItem.EquipPosition.HAND_GRIP
maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
durability = maxDurability.toFloat()
tags.add("SLEDGEHAMMER")
originalName = "ITEM_SLEDGEHAMMER_COPPER"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
@@ -144,11 +142,8 @@ class SledgehammerCopper(originalID: ItemID) : GameItem(originalID) {
class SledgehammerIron(originalID: ItemID) : GameItem(originalID) {
internal constructor() : this("-uninitialised-")
override val originalName = "ITEM_SLEDGEHAMMER_IRON"
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
override var stackable = true
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override val materialId = "IRON"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
@@ -156,10 +151,11 @@ class SledgehammerIron(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(7,0)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
super.durability = maxDurability.toFloat()
super.tags.add("HAMR")
equipPosition = GameItem.EquipPosition.HAND_GRIP
maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
durability = maxDurability.toFloat()
tags.add("SLEDGEHAMMER")
originalName = "ITEM_SLEDGEHAMMER_IRON"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =
@@ -170,11 +166,8 @@ class SledgehammerIron(originalID: ItemID) : GameItem(originalID) {
class SledgehammerSteel(originalID: ItemID) : GameItem(originalID) {
internal constructor() : this("-uninitialised-")
override val originalName = "ITEM_SLEDGEHAMMER_STEEL"
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
override var stackable = true
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override val materialId = "STAL"
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
@@ -182,10 +175,11 @@ class SledgehammerSteel(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(8,0)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
super.durability = maxDurability.toFloat()
super.tags.add("HAMR")
equipPosition = GameItem.EquipPosition.HAND_GRIP
maxDurability = (TOOL_DURABILITY_BASE * material.enduranceMod).roundToInt()
durability = maxDurability.toFloat()
tags.add("SLEDGEHAMMER")
originalName = "ITEM_SLEDGEHAMMER_STEEL"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =

View File

@@ -85,19 +85,19 @@ object WireCutterBase {
class WireCutterAll(originalID: ItemID) : GameItem(originalID) {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_WIRE_CUTTER"
override var baseMass = 0.1
override var baseToolSize: Double? = baseMass
override var stackable = false
override var inventoryCategory = Category.TOOL
override val isUnique = true
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(1, 3)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
stackable = false
isUnique = true
equipPosition = GameItem.EquipPosition.HAND_GRIP
originalName = "ITEM_WIRE_CUTTER"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) =

View File

@@ -12,11 +12,8 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
override val originalName = "WIRE_DEBUGGER"
override var baseToolSize: Double? = PickaxeCore.BASE_MASS_AND_SIZE
override var stackable = false
override var inventoryCategory = Category.TOOL
override val isUnique = true
override val isDynamic = false
override val materialId = "CUPR"
override var baseMass = 2.0
@@ -24,8 +21,11 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(2,3)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
super.name = "Wire Debugger"
equipPosition = GameItem.EquipPosition.HAND_GRIP
name = "Wire Debugger"
stackable = false
isUnique = true
originalName = "WIRE_DEBUGGER"
}
private val sb = StringBuilder()

View File

@@ -15,19 +15,17 @@ import net.torvald.terrarum.itemproperties.Material
class WirePieceSignalWire(originalID: ItemID, private val atlasID: String, private val sheetX: Int, private val sheetY: Int) : GameItem(originalID) {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_WIRE"
override var baseMass = 0.001
override var baseToolSize: Double? = null
override var stackable = true
override var inventoryCategory = Category.WIRE
override val isUnique = false
override val isDynamic = false
override val materialId = ""
override val itemImage: TextureRegion
get() = CommonResourcePool.getAsItemSheet(atlasID).get(sheetX, sheetY)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
equipPosition = GameItem.EquipPosition.HAND_GRIP
originalName = "ITEM_WIRE"
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {

View File

@@ -592,9 +592,9 @@ internal object WeatherMixer : RNGConsumer {
clouds.forEach {
val altOfSolarRay = cloudYtoSolarAlt(it.posY*-1.0, solarElev)
val cloudCol1 = getGradientCloud(skyboxavr, solarElev, mornNoonBlend.toDouble(), turbidity, albedo)
val cloudCol1 = getGradientCloud(skyboxavr, solarElev, 1.0, turbidity, albedo)
val cloudCol2 = getGradientColour2(currentWeather.daylightClut, altOfSolarRay, timeNow, 4)
val cloudDrawColour = lerp(0.75, cloudCol1, cloudCol2) // no srgblerp for performance
val cloudDrawColour = lerp(0.7, cloudCol1, cloudCol2) // no srgblerp for performance
val shadiness = (1.0 / cosh(altOfSolarRay * 0.5)).toFloat().coerceAtLeast(if (altOfSolarRay < 0) 0.6666f else 0f)
@@ -653,7 +653,7 @@ internal object WeatherMixer : RNGConsumer {
turbidity0 =
(world.weatherbox.oldWeather.json.getDouble("atmoTurbidity") + turbidityCoeff * 2.5).coerceIn(1.0, 10.0)
turbidity1 = (currentWeather.json.getDouble("atmoTurbidity") + turbidityCoeff * 2.5).coerceIn(1.0, 10.0)
turbidity = FastMath.interpolateLinear(oldNewBlend.toDouble(), turbidity0, turbidity1)
turbidity = forceTurbidity ?: FastMath.interpolateLinear(oldNewBlend.toDouble(), turbidity0, turbidity1)
val oldTurbidity = forceTurbidity ?: turbidity0
val thisTurbidity = forceTurbidity ?: turbidity1
@@ -839,31 +839,36 @@ internal object WeatherMixer : RNGConsumer {
val turbY = turbidity.coerceIn(Skybox.turbiditiesD.first(), Skybox.turbiditiesD.last()).minus(1.0)
.times(Skybox.turbDivisor)
val turbY1 = turbY.floorToInt()
val turbY2 = (turbY1).coerceAtMost(Skybox.turbCnt - 1)
val turbY2 = (turbY1 + 1).coerceAtMost(Skybox.turbCnt - 1)
val tx = turbY - turbY1
// coarse-grained
val albX =
albedo.coerceIn(Skybox.albedos.first(), Skybox.albedos.last()).times(5.0) * Skybox.elevCnt // 0*151..5*151
val albX1 = albX.floorToInt()
val albX2 = (albX1 + 1).coerceAtMost(5 * Skybox.elevCnt)
val bx = albX - albX1
albedo.coerceIn(Skybox.albedos.first(), Skybox.albedos.last()).times(5.0) // 0..5
val albX1 = albX.floorToInt() * elevCnt
val albX2 = (albX + 1).floorToInt().coerceAtMost(5) * elevCnt
val bx = ((albX * elevCnt) - albX1) / elevCnt
val a1t1b1A = colorMap.getCvec(albX1 * elevCnt + angleX1, turbY1)
val a2t1b1A = colorMap.getCvec(albX1 * elevCnt + angleX2, turbY1)
val a1t2b1A = colorMap.getCvec(albX1 * elevCnt + angleX1, turbY2)
val a2t2b1A = colorMap.getCvec(albX1 * elevCnt + angleX2, turbY2)
val a1t1b2A = colorMap.getCvec(albX2 * elevCnt + angleX1, turbY1)
val a2t1b2A = colorMap.getCvec(albX2 * elevCnt + angleX2, turbY1)
val a1t2b2A = colorMap.getCvec(albX2 * elevCnt + angleX1, turbY2)
val a2t2b2A = colorMap.getCvec(albX2 * elevCnt + angleX2, turbY2)
val a1t1b1B = colorMap.getCvec(albX1 * elevCnt + angleX1 + Skybox.albedoCnt * elevCnt, turbY1)
val a2t1b1B = colorMap.getCvec(albX1 * elevCnt + angleX2 + Skybox.albedoCnt * elevCnt, turbY1)
val a1t2b1B = colorMap.getCvec(albX1 * elevCnt + angleX1 + Skybox.albedoCnt * elevCnt, turbY2)
val a2t2b1B = colorMap.getCvec(albX1 * elevCnt + angleX2 + Skybox.albedoCnt * elevCnt, turbY2)
val a1t1b2B = colorMap.getCvec(albX2 * elevCnt + angleX1 + Skybox.albedoCnt * elevCnt, turbY1)
val a2t1b2B = colorMap.getCvec(albX2 * elevCnt + angleX2 + Skybox.albedoCnt * elevCnt, turbY1)
val a1t2b2B = colorMap.getCvec(albX2 * elevCnt + angleX1 + Skybox.albedoCnt * elevCnt, turbY2)
val a2t2b2B = colorMap.getCvec(albX2 * elevCnt + angleX2 + Skybox.albedoCnt * elevCnt, turbY2)
// println("AngleX: ($angleX1,$angleX2); TurbY: ($turbY1,$turbY2); AlbX: ($albX1,$albX2); MornNoon=(0,${Skybox.albedoCnt * elevCnt}); Albedo: $albedo")
// println("ax=$ax; tx=$tx; bx=$bx")
// println("XY: ${albX1 + angleX1 + Skybox.albedoCnt * elevCnt}, $turbY1")
val a1t1b1A = colorMap.getCvec(albX1 + angleX1, turbY1)
val a2t1b1A = colorMap.getCvec(albX1 + angleX2, turbY1)
val a1t2b1A = colorMap.getCvec(albX1 + angleX1, turbY2)
val a2t2b1A = colorMap.getCvec(albX1 + angleX2, turbY2)
val a1t1b2A = colorMap.getCvec(albX2 + angleX1, turbY1)
val a2t1b2A = colorMap.getCvec(albX2 + angleX2, turbY1)
val a1t2b2A = colorMap.getCvec(albX2 + angleX1, turbY2)
val a2t2b2A = colorMap.getCvec(albX2 + angleX2, turbY2)
val a1t1b1B = colorMap.getCvec(albX1 + angleX1 + Skybox.albedoCnt * elevCnt, turbY1)
val a2t1b1B = colorMap.getCvec(albX1 + angleX2 + Skybox.albedoCnt * elevCnt, turbY1)
val a1t2b1B = colorMap.getCvec(albX1 + angleX1 + Skybox.albedoCnt * elevCnt, turbY2)
val a2t2b1B = colorMap.getCvec(albX1 + angleX2 + Skybox.albedoCnt * elevCnt, turbY2)
val a1t1b2B = colorMap.getCvec(albX2 + angleX1 + Skybox.albedoCnt * elevCnt, turbY1)
val a2t1b2B = colorMap.getCvec(albX2 + angleX2 + Skybox.albedoCnt * elevCnt, turbY1)
val a1t2b2B = colorMap.getCvec(albX2 + angleX1 + Skybox.albedoCnt * elevCnt, turbY2)
val a2t2b2B = colorMap.getCvec(albX2 + angleX2 + Skybox.albedoCnt * elevCnt, turbY2)
// no srgblerp here to match the skybox shader's behaviour
@@ -884,7 +889,7 @@ internal object WeatherMixer : RNGConsumer {
val A = lerp(bx, b1A, b2A)
val B = lerp(bx, b1B, b2B)
return lerp(mornNoonBlend, A, B)
return B//lerp(mornNoonBlend, A, B)
}
private fun lerp(x: Double, c1: Cvec, c2: Cvec): Cvec {