mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
always sorting arraylist; more wire stuffs
This commit is contained in:
@@ -80,10 +80,12 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
|
||||
// check for collision with actors (BLOCK only)
|
||||
if (this.inventoryCategory == Category.BLOCK) {
|
||||
var ret1 = true
|
||||
ingame.actorContainerActive.forEach {
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
ret1 = false // return is not allowed here
|
||||
}
|
||||
if (!ret1) return ret1
|
||||
}
|
||||
|
||||
// return false if the tile is already there
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.dataclass.CircularArray
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||
@@ -34,6 +33,7 @@ import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.util.CircularArray
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
|
||||
@@ -795,7 +795,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
printStackTrace()
|
||||
|
||||
actorContainerActive.add(actor)
|
||||
insertionSortLastElem(actorContainerActive) // we can do this as we are only adding single actor
|
||||
|
||||
if (actor is ActorWithBody) {
|
||||
when (actor.renderOrder) {
|
||||
@@ -829,7 +828,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
else {
|
||||
actorContainerInactive.remove(actor)
|
||||
actorContainerActive.add(actor)
|
||||
insertionSortLastElem(actorContainerActive) // we can do this as we are only adding single actor
|
||||
|
||||
if (actor is ActorWithBody) {
|
||||
when (actor.renderOrder) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.utils.ScreenUtils
|
||||
import net.torvald.dataclass.CircularArray
|
||||
import net.torvald.util.CircularArray
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
@@ -94,7 +94,7 @@ object IngameRenderer {
|
||||
LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay)
|
||||
|
||||
prepLightmapRGBA()
|
||||
BlocksDrawer.renderData()
|
||||
BlocksDrawer.renderData(selectedWireBitToDraw)
|
||||
drawToRGB(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||
drawToA(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||
drawOverlayActors(actorsRenderOverlay)
|
||||
@@ -216,7 +216,7 @@ object IngameRenderer {
|
||||
batch.color = Color.WHITE
|
||||
|
||||
|
||||
drawWires = false
|
||||
selectedWireBitToDraw = 0
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,19 @@ object IngameRenderer {
|
||||
|
||||
internal var fboRGBexportRequested = false
|
||||
|
||||
var drawWires = false
|
||||
/**
|
||||
* Which wires should be drawn. Normally this value is set by the wiring item (e.g. wire pieces, wirecutters)
|
||||
* This number is directly related with the World's wire bits:
|
||||
*
|
||||
* ```
|
||||
* world.getWires(x, y) -> 0000101 (for example)
|
||||
* value of 3 selects this ^ ^
|
||||
* value of 1 selects this |
|
||||
*
|
||||
* The wire piece gets rendered when selected bit is set.
|
||||
* ```
|
||||
*/
|
||||
var selectedWireBitToDraw = 0
|
||||
|
||||
private fun drawToRGB(
|
||||
actorsRenderBehind: List<ActorWithBody>?,
|
||||
@@ -279,7 +291,7 @@ object IngameRenderer {
|
||||
}
|
||||
|
||||
setCameraPosition(0f, 0f)
|
||||
BlocksDrawer.drawFront(batch.projectionMatrix, drawWires) // blue coloured filter of water, etc.
|
||||
BlocksDrawer.drawFront(batch.projectionMatrix, selectedWireBitToDraw) // blue coloured filter of water, etc.
|
||||
|
||||
batch.inUse {
|
||||
FeaturesDrawer.drawEnvOverlay(batch)
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package net.torvald.terrarum.modulebasegame.console
|
||||
|
||||
import net.torvald.colourutil.Col4096
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.utils.RasterWriter
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
|
||||
import java.io.*
|
||||
import java.util.HashMap
|
||||
import net.torvald.terrarum.utils.RasterWriter
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-17.
|
||||
@@ -20,57 +18,20 @@ internal object ExportMap : ConsoleCommand {
|
||||
//private var mapData: ByteArray? = null
|
||||
// private var mapDataPointer = 0
|
||||
|
||||
private val colorTable = HashMap<Int, Col4096>()
|
||||
|
||||
init {
|
||||
colorTable.put(Block.AIR, Col4096(0xCEF))
|
||||
colorTable.put(Block.STONE, Col4096(0x888))
|
||||
colorTable.put(Block.DIRT, Col4096(0x753))
|
||||
colorTable.put(Block.GRASS, Col4096(0x472))
|
||||
|
||||
colorTable.put(Block.ORE_COPPER, Col4096(0x6A8))
|
||||
colorTable.put(Block.ORE_IRON, Col4096(0xC75))
|
||||
colorTable.put(Block.ORE_GOLD, Col4096(0xA87))
|
||||
colorTable.put(Block.ORE_ILMENITE, Col4096(0x8AB))
|
||||
colorTable.put(Block.ORE_AURICHALCUM, Col4096(0xD92))
|
||||
colorTable.put(Block.ORE_SILVER, Col4096(0xDDD))
|
||||
|
||||
colorTable.put(Block.RAW_DIAMOND, Col4096(0x2BF))
|
||||
colorTable.put(Block.RAW_RUBY, Col4096(0xB10))
|
||||
colorTable.put(Block.RAW_EMERALD, Col4096(0x0B1))
|
||||
colorTable.put(Block.RAW_SAPPHIRE, Col4096(0x01B))
|
||||
colorTable.put(Block.RAW_TOPAZ, Col4096(0xC70))
|
||||
colorTable.put(Block.RAW_AMETHYST, Col4096(0x70C))
|
||||
|
||||
colorTable.put(Block.WATER, Col4096(0x038))
|
||||
|
||||
colorTable.put(Block.SAND, Col4096(0xDDB))
|
||||
colorTable.put(Block.SAND_WHITE, Col4096(0xFFD))
|
||||
colorTable.put(Block.SAND_RED, Col4096(0xA32))
|
||||
colorTable.put(Block.SAND_DESERT, Col4096(0xEDB))
|
||||
colorTable.put(Block.SAND_BLACK, Col4096(0x444))
|
||||
colorTable.put(Block.SAND_GREEN, Col4096(0x9A6))
|
||||
|
||||
colorTable.put(Block.GRAVEL, Col4096(0x664))
|
||||
colorTable.put(Block.GRAVEL_GREY, Col4096(0x999))
|
||||
|
||||
colorTable.put(Block.ICE_NATURAL, Col4096(0x9AB))
|
||||
colorTable.put(Block.ICE_MAGICAL, Col4096(0x7AC))
|
||||
colorTable.put(Block.ICE_FRAGILE, Col4096(0x6AF))
|
||||
colorTable.put(Block.SNOW, Col4096(0xCDE))
|
||||
}
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!!.world)
|
||||
|
||||
if (args.size == 2) {
|
||||
|
||||
// TODO rewrite to use Pixmap and PixmapIO
|
||||
|
||||
var mapData = ByteArray(world.width * world.height * 3)
|
||||
var mapDataPointer = 0
|
||||
|
||||
for (tile in world.terrainIterator()) {
|
||||
val colArray = (colorTable as Map<Int, Col4096>)
|
||||
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
|
||||
val colArray = CreateTileAtlas.terrainTileColourMap.getRaw(tile % 16, tile / 16).toByteArray()
|
||||
|
||||
for (i in 0..2) {
|
||||
mapData[mapDataPointer + i] = colArray[i]
|
||||
@@ -107,6 +68,16 @@ internal object ExportMap : ConsoleCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* R-G-B-A order for RGBA input value
|
||||
*/
|
||||
private fun Int.toByteArray() = byteArrayOf(
|
||||
this.shl(24).and(0xff).toByte(),
|
||||
this.shl(16).and(0xff).toByte(),
|
||||
this.shl(8).and(0xff).toByte(),
|
||||
this.and(0xff).toByte()
|
||||
)
|
||||
|
||||
override fun printUsage() {
|
||||
|
||||
Echo("Usage: export <name>")
|
||||
|
||||
@@ -588,7 +588,7 @@ open class ActorHumanoid(
|
||||
}
|
||||
|
||||
override fun onActorValueChange(key: String, value: Any?) {
|
||||
// quickslot implementation
|
||||
// make quickslot work
|
||||
if (key == AVKey.__PLAYER_QUICKSLOTSEL && value != null) {
|
||||
// ONLY FOR HAND_GRIPs!!
|
||||
val quickBarItem = ItemCodex[inventory.getQuickslot(actorValue.getAsInt(key)!!)?.item]
|
||||
@@ -596,6 +596,9 @@ open class ActorHumanoid(
|
||||
if (quickBarItem != null && quickBarItem.equipPosition == GameItem.EquipPosition.HAND_GRIP) {
|
||||
equipItem(quickBarItem)
|
||||
}
|
||||
else {
|
||||
unequipSlot(GameItem.EquipPosition.HAND_GRIP)
|
||||
}
|
||||
|
||||
// force update inventory UI
|
||||
try {
|
||||
|
||||
@@ -35,10 +35,12 @@ object PickaxeCore {
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
var ret1 = true
|
||||
Terrarum.ingame!!.actorContainerActive.forEach {
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
ret1 = false // return is not allowed here
|
||||
}
|
||||
if (!ret1) return ret1
|
||||
|
||||
// return false if here's no tile
|
||||
if (Block.AIR == (Terrarum.ingame!!.world).getTileFromTerrain(mouseTileX, mouseTileY))
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.items
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.blockproperties.Wire
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
@@ -35,6 +36,7 @@ class WirePieceSignalWire(override val originalID: ItemID) : GameItem() {
|
||||
}
|
||||
|
||||
override fun effectWhenEquipped(delta: Float) {
|
||||
IngameRenderer.drawWires = true
|
||||
IngameRenderer.selectedWireBitToDraw = Wire.BIT_SIGNAL_RED
|
||||
//println("wires!")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.worldgenerator
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.dataclass.IntArrayStack
|
||||
import net.torvald.util.IntArrayStack
|
||||
import net.torvald.colourutil.Col4096
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.modulebasegame.RNGConsumer
|
||||
|
||||
Reference in New Issue
Block a user