mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
some changes regarding actorblocks
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -104,7 +104,7 @@ id;drop;world;name;shdr;shdg;shdb;shduv;str;dsty;mate;solid;plat;wall;grav;dlfn;
|
||||
273;273;273;BLOCK_SCAFFOLDING_EBONY;0.0312;0.0312;0.0312;0.0312;1;1400;WOOD;0;1;0;6;0;0;16;0.0;0.0;0.0;0.0;N/A;N/A;0.0;PLATFORM
|
||||
274;274;274;BLOCK_SCAFFOLDING_BIRCH;0.0312;0.0312;0.0312;0.0312;1;670;WOOD;0;1;0;6;0;0;16;0.0;0.0;0.0;0.0;N/A;N/A;0.0;PLATFORM
|
||||
275;275;275;BLOCK_SCAFFOLDING_BLOODROSE;0.0312;0.0312;0.0312;0.0312;1;900;WOOD;0;1;0;6;0;0;16;0.0;0.0;0.0;0.0;N/A;N/A;0.0;PLATFORM
|
||||
4090;N/A;N/A;ACTORBLOCK_TILING_PLACEHOLDER;0.1252;0.1252;0.1252;0.1252;48;2400;ROCK;1;0;1;N/A;0;4;16;0.0000;0.0000;0.0000;0.0000;N/A;N/A;0.0;INTERNAL
|
||||
4090;N/A;N/A;ACTORBLOCK_TILING_PLACEHOLDER;0.1252;0.1252;0.1252;0.1252;48;2400;ROCK;1;0;1;N/A;0;4;16;0.0000;0.0000;0.0000;0.0000;N/A;N/A;0.0;INTERNAL,DORENDER
|
||||
4091;N/A;N/A;ACTORBLOCK_NO_COLLISION;0.0312;0.0312;0.0312;0.0312;1;1;NULL;0;0;0;N/A;0;0;4;0.0;0.0;0.0;0.0;N/A;N/A;0.0;INTERNAL
|
||||
4092;N/A;N/A;ACTORBLOCK_FULL_COLLISION;0.0312;0.0312;0.0312;0.0312;1;1;NULL;0;0;0;N/A;0;0;16;0.0;0.0;0.0;0.0;N/A;N/A;0.0;INTERNAL
|
||||
4093;N/A;N/A;ACTORBLOCK_ALLOW_MOVE_DOWN;0.0312;0.0312;0.0312;0.0312;1;1;NULL;0;1;0;N/A;0;0;16;0.0;0.0;0.0;0.0;N/A;N/A;0.0;INTERNAL
|
||||
@@ -117,6 +117,7 @@ id;drop;world;name;shdr;shdg;shdb;shduv;str;dsty;mate;solid;plat;wall;grav;dlfn;
|
||||
|
||||
#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 ##
|
||||
#
|
||||
# Every block must have a shade value that is at least as dark as the air block's
|
||||
#
|
||||
# Lava/Water props are left for future references, do not delete them until FluidCodex is built #
|
||||
@@ -154,7 +155,6 @@ id;drop;world;name;shdr;shdg;shdb;shduv;str;dsty;mate;solid;plat;wall;grav;dlfn;
|
||||
# grav: Whether the block should fall through the empty space. N/A to not make it fall;
|
||||
# 0 to fall immediately (e.g. Sand), nonzero to indicate that number of floating blocks can be supported (e.g. Scaffolding)
|
||||
#
|
||||
# tags: tag(s) to the item which is used by the crafting system. Multiple tags are separated using commas. Each tag must be all uppercase and only [0-9A-Z] chars are supported.
|
||||
#
|
||||
## Illuminators ##
|
||||
#
|
||||
@@ -175,6 +175,25 @@ id;drop;world;name;shdr;shdg;shdb;shduv;str;dsty;mate;solid;plat;wall;grav;dlfn;
|
||||
# Magical ice: theoretical __metallic__ ice that might form under super-high pressure (> 5 TPa). Its density is a wild guess.
|
||||
#
|
||||
#
|
||||
## Actorblocks ##
|
||||
#
|
||||
# Actorblocks are virtual/placeholder blocks that accompanies actors (usually fixtures).
|
||||
# Any tile that contains "ACTORBLOCK" in its "name" will be recognised as one, so avoid having the particular string on
|
||||
# the name if your tile is not Actorblock!
|
||||
#
|
||||
#
|
||||
## Tags ##
|
||||
#
|
||||
# Tag(s) to the item which is used by the crafting system. Multiple tags are separated using commas. Each tag must be all
|
||||
# uppercase and only [0-9A-Z] chars are supported.
|
||||
#
|
||||
### Internal Tags ##
|
||||
##
|
||||
## Some tags are reserved for internal use, which are:
|
||||
## - INTERNAL: denotes that the tile is internal-use. Will not be rendered unless debug window is on.
|
||||
## - DORENDER: this internal tile must go through the standard-issue tile drawing routine.
|
||||
#
|
||||
#
|
||||
## References ##
|
||||
#
|
||||
# * Density of various woods : http://www.engineeringtoolbox.com/wood-density-d_40.html
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 181 and column 26.
|
@@ -31,6 +31,7 @@ module Terrarum {
|
||||
requires com.ibm.icu;
|
||||
requires org.lwjgl.opengl;
|
||||
requires prtree;
|
||||
requires kotlin.stdlib.jdk7;
|
||||
|
||||
|
||||
exports net.torvald.colourutil;
|
||||
|
||||
@@ -131,12 +131,4 @@ object Block {
|
||||
|
||||
const val NULL = "basegame:-1"
|
||||
|
||||
val actorblocks = listOf(
|
||||
ACTORBLOCK_TILING_PLACEHOLDER,
|
||||
ACTORBLOCK_NO_COLLISION,
|
||||
ACTORBLOCK_FULL_COLLISION,
|
||||
ACTORBLOCK_ALLOW_MOVE_DOWN,
|
||||
ACTORBLOCK_NO_PASS_RIGHT,
|
||||
ACTORBLOCK_NO_PASS_LEFT
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import java.nio.file.FileSystems
|
||||
import net.torvald.terrarum.App
|
||||
import java.nio.file.Files
|
||||
import kotlin.io.path.Path
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-07.
|
||||
@@ -10,7 +11,7 @@ internal object Batch : ConsoleCommand {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
Files.lines(FileSystems.getDefault().getPath(args[1])).forEach(
|
||||
Files.lines(Path(App.defaultDir, args[1])).forEach(
|
||||
{ CommandInterpreter.execute(it) })
|
||||
}
|
||||
else {
|
||||
@@ -19,6 +20,6 @@ internal object Batch : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Usage: batch path/to/batch.txt")
|
||||
Echo("Usage: batch path/to/batch.txt relative to the app data folder")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1281,7 +1281,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
else if (canAttackOrDig) {
|
||||
val punchBlockSize = punchSize.div(TILE_SIZED).floorInt()
|
||||
if (punchBlockSize > 0) {
|
||||
PickaxeCore.startPrimaryUse(actor, delta, null, Terrarum.mouseTileX, Terrarum.mouseTileY, 1.0 / punchBlockSize, punchBlockSize, punchBlockSize, false)
|
||||
PickaxeCore.startPrimaryUse(actor, delta, null, Terrarum.mouseTileX, Terrarum.mouseTileY, 1.0 / punchBlockSize, punchBlockSize, punchBlockSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
/** Real time, in nanoseconds */
|
||||
@Transient var spawnRequestedTime: Long = 0L
|
||||
private set
|
||||
protected set
|
||||
|
||||
lateinit var blockBox: BlockBox // something like TapestryObject will want to redefine this
|
||||
fun blockBoxIndexToPoint2i(it: BlockBoxIndex): Point2i = this.blockBox.width.let { w -> Point2i(it % w, it / w) }
|
||||
@@ -74,7 +74,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
* Tile-wise position of this fixture when it's placed on the world, top-left origin. Null if it's not on the world
|
||||
*/
|
||||
var worldBlockPos: Point2i? = null
|
||||
private set
|
||||
protected set
|
||||
|
||||
// something like TapestryObject will want to redefine this
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
for (y in posY until posY + blockBox.height) {
|
||||
for (x in posX until posX + blockBox.width) {
|
||||
val tile = world!!.getTileFromTerrain(x, y)
|
||||
if (BlockCodex[tile].isSolid || tile in Block.actorblocks) {
|
||||
if (BlockCodex[tile].isSolid || BlockCodex[tile].isActorBlock) {
|
||||
hasCollision = true
|
||||
break@checkForCollision
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Lightbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -37,14 +38,89 @@ class FixtureSwingingDoorBase : FixtureBase, Luminous {
|
||||
|
||||
protected var doorState = 0 // -1: open toward left, 0: closed, 1: open toward right
|
||||
|
||||
@Transient private var placeActorBlockLatch = false
|
||||
// @Transient private var placeActorBlockLatch = false
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.FULL_COLLISION, 1, 3), // temporary value, will be overwritten by reload()
|
||||
nameFun = { "item not loaded properly, alas!" }
|
||||
) {
|
||||
val hbw = TILE_SIZE * (tw * 2 - twClosed)
|
||||
val hbh = TILE_SIZE * th
|
||||
|
||||
nameFun = customNameFun
|
||||
|
||||
density = 1200.0
|
||||
actorValue[AVKey.BASEMASS] = 10.0
|
||||
|
||||
// loading textures
|
||||
CommonResourcePool.addToLoadingList("$moduleName-$textureIdentifier") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, texturePath), hbw, hbh)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
makeNewSprite(FixtureBase.getSpritesheet(moduleName, texturePath, hbw, hbh)).let {
|
||||
it.setRowsAndFrames(3,1)
|
||||
}
|
||||
|
||||
// define light/shadebox
|
||||
(if (isOpacityActuallyLuminosity) lightBoxList else shadeBoxList).add(
|
||||
Lightbox(Hitbox(0.0, 0.0, TILE_SIZED, th * TILE_SIZED), opacity))
|
||||
|
||||
reload()
|
||||
placeActorBlockLatch = true
|
||||
}
|
||||
|
||||
override fun spawn(posX: Int, posY: Int) = spawn(posX, posY, TILE_SIZE * (tw * 2 - twClosed), TILE_SIZE * th)
|
||||
|
||||
// TODO move this function over FixtureBase once it's done and perfected
|
||||
protected fun spawn(posX: Int, posY: Int, hbw: Int, hbh: Int): Boolean {
|
||||
// wrap x-position
|
||||
val posX = posX fmod world!!.width
|
||||
|
||||
// define physical size
|
||||
setHitboxDimension(hbw, hbh, 0, 0)
|
||||
/*this.hitbox.setFromWidthHeight(
|
||||
posX * TILE_SIZED,
|
||||
posY * TILE_SIZED,
|
||||
blockBox.width * TILE_SIZED,
|
||||
blockBox.height * TILE_SIZED
|
||||
)*/
|
||||
blockBox = BlockBox(BlockBox.FULL_COLLISION, tw * 2 - twClosed, th)
|
||||
|
||||
// check for existing blocks (and fixtures)
|
||||
var hasCollision = false
|
||||
checkForCollision@
|
||||
for (y in posY until posY + blockBox.height) {
|
||||
for (x in posX until posX + blockBox.width) {
|
||||
val tile = world!!.getTileFromTerrain(x, y)
|
||||
if (BlockCodex[tile].isSolid || BlockCodex[tile].isActorBlock) {
|
||||
hasCollision = true
|
||||
break@checkForCollision
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCollision) {
|
||||
printdbg(this, "cannot spawn fixture ${nameFun()} at F${INGAME.WORLD_UPDATE_TIMER}, has tile collision; tilewise dim: (${blockBox.width}, ${blockBox.height}) ")
|
||||
return false
|
||||
}
|
||||
|
||||
printdbg(this, "spawn fixture ${nameFun()} at F${INGAME.WORLD_UPDATE_TIMER}, tilewise dim: (${blockBox.width}, ${blockBox.height})")
|
||||
|
||||
// set the position of this actor
|
||||
worldBlockPos = Point2i(posX - (hbw - 1) / 2, posY)
|
||||
|
||||
// fill the area with the filler blocks
|
||||
placeActorBlocks()
|
||||
|
||||
|
||||
this.isVisible = true
|
||||
|
||||
|
||||
// actually add this actor into the world
|
||||
INGAME.queueActorAddition(this)
|
||||
spawnRequestedTime = System.nanoTime()
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun reload() {
|
||||
@@ -55,28 +131,16 @@ class FixtureSwingingDoorBase : FixtureBase, Luminous {
|
||||
val hbw = TILE_SIZE * (tw * 2 - twClosed)
|
||||
val hbh = TILE_SIZE * th
|
||||
|
||||
blockBox = BlockBox(BlockBox.FULL_COLLISION, tw * 2 - twClosed, th)
|
||||
// redefined things that are affected by sprite size
|
||||
// blockBox = BlockBox(BlockBox.FULL_COLLISION, tw * 2 - twClosed, th)
|
||||
|
||||
// loading textures
|
||||
CommonResourcePool.addToLoadingList("$moduleName-$textureIdentifier") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, texturePath), hbw, hbh)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
density = 1200.0
|
||||
actorValue[AVKey.BASEMASS] = 10.0
|
||||
|
||||
// setHitboxDimension(hbw, hbh, TILE_SIZE * (tw * 2 - twClosed), 0)
|
||||
setHitboxDimension(hbw, hbh, TILE_SIZE * ((tw * 2 - twClosed - 1) / 2), 0)
|
||||
// setHitboxDimension(hbw, hbh, TILE_SIZE * ((tw * 2 - twClosed - 1) / 2), 0)
|
||||
|
||||
(if (isOpacityActuallyLuminosity) lightBoxList else shadeBoxList).add(
|
||||
Lightbox(Hitbox(0.0, 0.0, TILE_SIZED, th * TILE_SIZED), opacity))
|
||||
|
||||
makeNewSprite(FixtureBase.getSpritesheet(moduleName, texturePath, hbw, hbh)).let {
|
||||
it.setRowsAndFrames(3,1)
|
||||
}
|
||||
|
||||
placeActorBlockLatch = false
|
||||
// placeActorBlockLatch = false
|
||||
}
|
||||
|
||||
open protected fun closeDoor() {
|
||||
@@ -94,14 +158,14 @@ class FixtureSwingingDoorBase : FixtureBase, Luminous {
|
||||
doorState = -1
|
||||
}
|
||||
|
||||
override fun forEachBlockbox(action: (Int, Int, Int, Int) -> Unit) {
|
||||
/*override fun forEachBlockbox(action: (Int, Int, Int, Int) -> Unit) {
|
||||
val xStart = worldBlockPos!!.x - ((tw * 2 - twClosed - 1) / 2) // worldBlockPos.x is where the mouse was, of when the tilewise width was 1.
|
||||
for (y in worldBlockPos!!.y until worldBlockPos!!.y + blockBox.height) {
|
||||
for (x in xStart until xStart + blockBox.width) {
|
||||
action(x, y, x - xStart, y - worldBlockPos!!.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
override fun placeActorBlocks() {
|
||||
forEachBlockbox { x, y, ox, oy ->
|
||||
@@ -131,10 +195,10 @@ class FixtureSwingingDoorBase : FixtureBase, Luminous {
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
if (placeActorBlockLatch) {
|
||||
/*if (placeActorBlockLatch) {
|
||||
placeActorBlockLatch = false
|
||||
placeActorBlocks()
|
||||
}
|
||||
}*/
|
||||
|
||||
super.update(delta)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ object PickaxeCore {
|
||||
*/
|
||||
fun startPrimaryUse(
|
||||
actor: ActorWithBody, delta: Float, item: GameItem?, mx: Int, my: Int,
|
||||
dropProbability: Double = 1.0, mw: Int = 1, mh: Int = 1, attackActorBlocks: Boolean = true
|
||||
dropProbability: Double = 1.0, mw: Int = 1, mh: Int = 1
|
||||
) = mouseInInteractableRangeTools(actor, item) {
|
||||
// un-round the mx
|
||||
val ww = INGAME.world.width
|
||||
@@ -67,7 +67,7 @@ object PickaxeCore {
|
||||
if (!ret1) return ret1*/
|
||||
|
||||
// return false if here's no tile
|
||||
if (Block.AIR == tile || (!attackActorBlocks && tile in Block.actorblocks)) {
|
||||
if (Block.AIR == tile || BlockCodex[tile].isActorBlock) {
|
||||
usageStatus = usageStatus or false
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user