mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
signal emitter is now a fixture
This commit is contained in:
@@ -111,7 +111,7 @@
|
||||
"65536";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16";"0.0"
|
||||
"65537";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32";"0.0"
|
||||
"-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0"
|
||||
"5000";"5000";"BLOCK_SIGNAL_POWER_SOURCE";"0.1252";"0.1252";"0.1252";"0.1252";"24";"1400";"NULL";"0";"0";"0";"N/A";"0";"4";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||
#"5000";"5000";"BLOCK_SIGNAL_POWER_SOURCE";"0.1252";"0.1252";"0.1252";"0.1252";"24";"1400";"NULL";"0";"0";"0";"N/A";"0";"4";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||
|
||||
|
||||
## Notes ##
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 114 and column 2.
|
@@ -5,3 +5,4 @@
|
||||
"5";"net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester"
|
||||
"6";"net.torvald.terrarum.modulebasegame.gameitems.ItemStorageChest"
|
||||
"7";"net.torvald.terrarum.modulebasegame.gameitems.WireGraphDebugger"
|
||||
"8";"net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalEmitter"
|
||||
|
||||
|
@@ -10,6 +10,8 @@ import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import org.khelekore.prtree.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -447,8 +449,28 @@ object WorldSimulator {
|
||||
}
|
||||
|
||||
|
||||
private fun simulateWires(delta: Float) {
|
||||
private val wiresimOverscan = 60
|
||||
|
||||
/*private fun wiresimGetSourceBlocks(): List<Q> {
|
||||
val ret = ArrayList<Q>()
|
||||
|
||||
val for_y_start = (WorldCamera.y.toFloat() / TILE_SIZE).floorInt()
|
||||
val for_y_end = for_y_start + BlocksDrawer.tilesInVertical - 1
|
||||
|
||||
val for_x_start = (WorldCamera.x.toFloat() / TILE_SIZE).floorInt()
|
||||
val for_x_end = for_x_start + BlocksDrawer.tilesInHorizontal - 1
|
||||
|
||||
for (y in for_y_start - wiresimOverscan..for_y_end + wiresimOverscan) {
|
||||
for (x in for_x_start - wiresimOverscan..for_x_end + wiresimOverscan) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}*/
|
||||
|
||||
private fun simulateWires(delta: Float) {
|
||||
//val sourceBlocks = wiresimGetSourceBlocks()
|
||||
}
|
||||
|
||||
private enum class WireConStatus { THRU, END, BRANCH }
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-06-17.
|
||||
@@ -29,6 +30,9 @@ open class FixtureBase(
|
||||
var blockBox: BlockBox = blockBox0
|
||||
protected set // something like TapestryObject will want to redefine this
|
||||
|
||||
open val wireEmitterType = ""
|
||||
open val wireEmission = Vector2()
|
||||
open val wireConsumption = Vector2()
|
||||
|
||||
/**
|
||||
* Block-wise position of this fixture when it's placed on the world. Null if it's not on the world
|
||||
@@ -103,13 +107,6 @@ open class FixtureBase(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update code that runs once for every frame
|
||||
*/
|
||||
open fun updateSelf() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this instance of the fixture from the world
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
class FixtureLogicSignalEmitter(nameFun: () -> String) : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, 1), nameFun = nameFun) {
|
||||
|
||||
override val wireEmitterType = "digital_bit"
|
||||
override val wireEmission = Vector2(1.0, 0.0)
|
||||
|
||||
init {
|
||||
density = 1400.0
|
||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, -1)
|
||||
|
||||
makeNewSprite(TextureRegionPack(CommonResourcePool.getAsTextureRegion("basegame-sprites-fixtures-signal_source.tga").texture, TILE_SIZE, TILE_SIZE))
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
actorValue[AVKey.BASEMASS] = MASS
|
||||
}
|
||||
|
||||
override fun dispose() { }
|
||||
|
||||
companion object {
|
||||
const val MASS = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ object PlayerBuilderSigrid {
|
||||
inventory.add("item@basegame:5", 385930603) // test tiki torch
|
||||
inventory.add("item@basegame:6", 95) // storage chest
|
||||
inventory.add("item@basegame:7", 1) // wire debugger
|
||||
inventory.add("item@basegame:8", 9995) // power source
|
||||
|
||||
WireCodex.getAll().forEach {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureLogicSignalEmitter
|
||||
|
||||
class ItemLogicSignalEmitter(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "ITEM_TIKI_TORCH"
|
||||
override var baseMass = FixtureLogicSignalEmitter.MASS
|
||||
override var stackable = true
|
||||
override var inventoryCategory = Category.FIXTURE
|
||||
override val isUnique = false
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsTextureRegion("basegame-sprites-fixtures-signal_source.tga")
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame-sprites-fixtures-signal_source.tga") {
|
||||
val t = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "sprites/fixtures/signal_source.tga")))
|
||||
t.flip(false, true)
|
||||
/*return*/t
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
equipPosition = EquipPosition.HAND_GRIP
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val item = FixtureLogicSignalEmitter { Lang[originalName] }
|
||||
|
||||
return item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
// return true when placed, false when cannot be placed
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.gdx.graphics.UnsafeCvecArray
|
||||
import net.torvald.terrarum.blockproperties.Block.AIR
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.ui.abs
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2020-03-04
|
||||
*/
|
||||
|
||||
internal class LightCalculatorContext(
|
||||
private val world: GameWorld,
|
||||
private val lightmap: UnsafeCvecArray,
|
||||
private val lanternMap: HashMap<BlockAddress, Cvec>
|
||||
) {
|
||||
// No longer in use because of the much efficient light updating method
|
||||
}
|
||||
@@ -211,46 +211,9 @@ object LightmapRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
// YE OLDE LIGHT UPDATER
|
||||
// O((5*9)n where n is a size of the map.
|
||||
// Because of inevitable overlaps on the area, it only works with MAX blend
|
||||
/*fun or1() {
|
||||
// Round 1
|
||||
for (y in for_y_start - overscan_open..for_y_end) {
|
||||
for (x in for_x_start - overscan_open..for_x_end) {
|
||||
calculateAndAssign(lightmap, x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
fun or2() {
|
||||
// Round 2
|
||||
for (y in for_y_end + overscan_open downTo for_y_start) {
|
||||
for (x in for_x_start - overscan_open..for_x_end) {
|
||||
calculateAndAssign(lightmap, x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
fun or3() {
|
||||
// Round 3
|
||||
for (y in for_y_end + overscan_open downTo for_y_start) {
|
||||
for (x in for_x_end + overscan_open downTo for_x_start) {
|
||||
calculateAndAssign(lightmap, x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
fun or4() {
|
||||
// Round 4
|
||||
for (y in for_y_start - overscan_open..for_y_end) {
|
||||
for (x in for_x_end + overscan_open downTo for_x_start) {
|
||||
calculateAndAssign(lightmap, x, y)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// 'NEWLIGHT2' LIGHT SWIPER
|
||||
// O((8*2)n) where n is a size of the map.
|
||||
fun r1() {
|
||||
// TODO test non-parallel
|
||||
swipeDiag = false
|
||||
for (line in 1 until LIGHTMAP_HEIGHT - 1) {
|
||||
swipeLight(
|
||||
@@ -261,7 +224,6 @@ object LightmapRenderer {
|
||||
}
|
||||
}
|
||||
fun r2() {
|
||||
// TODO test non-parallel
|
||||
swipeDiag = false
|
||||
for (line in 1 until LIGHTMAP_WIDTH - 1) {
|
||||
swipeLight(
|
||||
@@ -272,7 +234,6 @@ object LightmapRenderer {
|
||||
}
|
||||
}
|
||||
fun r3() {
|
||||
// TODO test non-parallel
|
||||
swipeDiag = true
|
||||
/* construct indices such that:
|
||||
56789ABC
|
||||
@@ -310,7 +271,6 @@ object LightmapRenderer {
|
||||
}
|
||||
}
|
||||
fun r4() {
|
||||
// TODO test non-parallel
|
||||
swipeDiag = true
|
||||
/*
|
||||
1 w-2
|
||||
@@ -612,59 +572,6 @@ object LightmapRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/** Another YE OLDE light simulator
|
||||
* Calculates the light simulation, using main lightmap as one of the input.
|
||||
*/
|
||||
/*private fun calculateAndAssign(lightmap: UnsafeCvecArray, worldX: Int, worldY: Int) {
|
||||
|
||||
//if (inNoopMask(worldX, worldY)) return
|
||||
|
||||
// O(9n) == O(n) where n is a size of the map
|
||||
|
||||
//getLightsAndShades(worldX, worldY)
|
||||
|
||||
val x = worldX.convX()
|
||||
val y = worldY.convY()
|
||||
|
||||
// calculate ambient
|
||||
/* + * + 0 4 1
|
||||
* * @ * 6 @ 7
|
||||
* + * + 2 5 3
|
||||
* sample ambient for eight points and apply attenuation for those
|
||||
* maxblend eight values and use it
|
||||
*/
|
||||
|
||||
|
||||
// TODO getLightsAndShades is replaced with precalculate; change following codes accordingly!
|
||||
_ambientAccumulator.r = _mapLightLevelThis.getR(x, y)
|
||||
_ambientAccumulator.g = _mapLightLevelThis.getG(x, y)
|
||||
_ambientAccumulator.b = _mapLightLevelThis.getB(x, y)
|
||||
_ambientAccumulator.a = _mapLightLevelThis.getA(x, y)
|
||||
|
||||
_thisTileOpacity.r = _mapThisTileOpacity.getR(x, y)
|
||||
_thisTileOpacity.g = _mapThisTileOpacity.getG(x, y)
|
||||
_thisTileOpacity.b = _mapThisTileOpacity.getB(x, y)
|
||||
_thisTileOpacity.a = _mapThisTileOpacity.getA(x, y)
|
||||
|
||||
_thisTileOpacity2.r = _mapThisTileOpacity2.getR(x, y)
|
||||
_thisTileOpacity2.g = _mapThisTileOpacity2.getG(x, y)
|
||||
_thisTileOpacity2.b = _mapThisTileOpacity2.getB(x, y)
|
||||
_thisTileOpacity2.a = _mapThisTileOpacity2.getA(x, y)
|
||||
|
||||
// will "overwrite" what's there in the lightmap if it's the first pass
|
||||
// takes about 2 ms on 6700K
|
||||
/* + */_ambientAccumulator.maxAndAssign(darkenColoured(x - 1, y - 1, _thisTileOpacity2))
|
||||
/* + */_ambientAccumulator.maxAndAssign(darkenColoured(x + 1, y - 1, _thisTileOpacity2))
|
||||
/* + */_ambientAccumulator.maxAndAssign(darkenColoured(x - 1, y + 1, _thisTileOpacity2))
|
||||
/* + */_ambientAccumulator.maxAndAssign(darkenColoured(x + 1, y + 1, _thisTileOpacity2))
|
||||
/* * */_ambientAccumulator.maxAndAssign(darkenColoured(x, y - 1, _thisTileOpacity))
|
||||
/* * */_ambientAccumulator.maxAndAssign(darkenColoured(x, y + 1, _thisTileOpacity))
|
||||
/* * */_ambientAccumulator.maxAndAssign(darkenColoured(x - 1, y, _thisTileOpacity))
|
||||
/* * */_ambientAccumulator.maxAndAssign(darkenColoured(x + 1, y, _thisTileOpacity))
|
||||
|
||||
lightmap.setVec(x, y, _ambientAccumulator)
|
||||
}*/
|
||||
|
||||
private fun isSolid(x: Int, y: Int): Float? { // ...so that they wouldn't appear too dark
|
||||
if (!inBounds(x, y)) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user