mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
fixtures won't spawn when there's block or other fixtures
This commit is contained in:
@@ -127,4 +127,12 @@ object Block {
|
|||||||
const val WATER = 4095
|
const val WATER = 4095
|
||||||
|
|
||||||
const val NULL = -1
|
const val NULL = -1
|
||||||
|
|
||||||
|
val actorblocks = listOf(
|
||||||
|
ACTORBLOCK_NO_COLLISION,
|
||||||
|
ACTORBLOCK_FULL_COLLISION,
|
||||||
|
ACTORBLOCK_ALLOW_MOVE_DOWN,
|
||||||
|
ACTORBLOCK_NO_PASS_RIGHT,
|
||||||
|
ACTORBLOCK_NO_PASS_LEFT
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.dyn4j.geometry.Vector2
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2016-01-15.
|
* Created by minjaesong on 2016-01-15.
|
||||||
*/
|
*/
|
||||||
class Hitbox(x1: Double, y1: Double, width: Double, height: Double, var suppressWarning: Boolean = false) {
|
class Hitbox (x1: Double, y1: Double, width: Double, height: Double, var suppressWarning: Boolean = true) {
|
||||||
|
|
||||||
@Volatile var hitboxStart: Point2d
|
@Volatile var hitboxStart: Point2d
|
||||||
private set
|
private set
|
||||||
|
|||||||
@@ -568,15 +568,12 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun filterVisibleActors() {
|
private fun filterVisibleActors() {
|
||||||
visibleActorsRenderBehind = actorsRenderBehind.filter { it.inScreen() }
|
visibleActorsRenderBehind = actorsRenderBehind.filter { it.inScreen() }
|
||||||
visibleActorsRenderMiddle = actorsRenderMiddle.filter { it.inScreen() }
|
visibleActorsRenderMiddle = actorsRenderMiddle.filter { it.inScreen() }
|
||||||
visibleActorsRenderMidTop = actorsRenderMidTop.filter { it.inScreen() }
|
visibleActorsRenderMidTop = actorsRenderMidTop.filter { it.inScreen() }
|
||||||
visibleActorsRenderFront = actorsRenderFront.filter { it.inScreen() }
|
visibleActorsRenderFront = actorsRenderFront.filter { it.inScreen() }
|
||||||
visibleActorsRenderOverlay=actorsRenderOverlay.filter { it.inScreen() }
|
visibleActorsRenderOverlay=actorsRenderOverlay.filter { it.inScreen() }
|
||||||
|
|
||||||
//printdbg(this, "total visible actors: ${visibleActorsRenderMiddle.size}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun repossessActor() {
|
private fun repossessActor() {
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ object IngameRenderer : Disposable {
|
|||||||
AppLoader.disposableSingletonsPool.add(this)
|
AppLoader.disposableSingletonsPool.add(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var renderingActorsCount = 0
|
||||||
|
private set
|
||||||
|
var renderingUIsCount = 0
|
||||||
|
private set
|
||||||
|
/*var renderingParticleCount = 0
|
||||||
|
private set*/
|
||||||
|
|
||||||
operator fun invoke(
|
operator fun invoke(
|
||||||
gamePaused: Boolean,
|
gamePaused: Boolean,
|
||||||
world: GameWorldExtension,
|
world: GameWorldExtension,
|
||||||
@@ -78,6 +85,14 @@ object IngameRenderer : Disposable {
|
|||||||
player: ActorWithBody? = null,
|
player: ActorWithBody? = null,
|
||||||
uisToDraw: ArrayList<UICanvas>? = null
|
uisToDraw: ArrayList<UICanvas>? = null
|
||||||
) {
|
) {
|
||||||
|
renderingActorsCount = (actorsRenderBehind?.size ?: 0) +
|
||||||
|
(actorsRenderMiddle?.size ?: 0) +
|
||||||
|
(actorsRenderMidTop?.size ?: 0) +
|
||||||
|
(actorsRenderFront?.size ?: 0) +
|
||||||
|
(actorsRenderOverlay?.size ?: 0)
|
||||||
|
//renderingParticleCount = particlesContainer?.size ?: 0
|
||||||
|
renderingUIsCount = uisToDraw?.size ?: 0
|
||||||
|
|
||||||
|
|
||||||
if (uisToDraw != null) {
|
if (uisToDraw != null) {
|
||||||
uiListToDraw = uisToDraw
|
uiListToDraw = uisToDraw
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import net.torvald.terrarum.IngameInstance
|
|||||||
import net.torvald.terrarum.Point2i
|
import net.torvald.terrarum.Point2i
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
|
|
||||||
@@ -45,10 +46,26 @@ open class FixtureBase(blockBox0: BlockBox, val blockBoxProps: BlockBoxProps = B
|
|||||||
// posY: bottom of the blockBox
|
// posY: bottom of the blockBox
|
||||||
// using the actor's hitbox
|
// using the actor's hitbox
|
||||||
|
|
||||||
// TODO: obviously check for collision
|
|
||||||
|
|
||||||
for (x in posX until posX + blockBox.width) {
|
// check for existing blocks (and fixtures)
|
||||||
for (y in posY until posY + blockBox.height) {
|
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 || tile in Block.actorblocks) {
|
||||||
|
hasCollision = true
|
||||||
|
break@checkForCollision
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasCollision) return false
|
||||||
|
|
||||||
|
|
||||||
|
// fill the area with the filler blocks
|
||||||
|
for (y in posY until posY + blockBox.height) {
|
||||||
|
for (x in posX until posX + blockBox.width) {
|
||||||
if (blockBox.collisionType == BlockBox.ALLOW_MOVE_DOWN) {
|
if (blockBox.collisionType == BlockBox.ALLOW_MOVE_DOWN) {
|
||||||
// if the collision type is allow_move_down, only the top surface tile should be "the platform"
|
// if the collision type is allow_move_down, only the top surface tile should be "the platform"
|
||||||
// lower part must not have such property (think of the table!)
|
// lower part must not have such property (think of the table!)
|
||||||
@@ -72,7 +89,7 @@ open class FixtureBase(blockBox0: BlockBox, val blockBoxProps: BlockBoxProps = B
|
|||||||
Terrarum.ingame!!.addNewActor(this)
|
Terrarum.ingame!!.addNewActor(this)
|
||||||
|
|
||||||
|
|
||||||
return true // TODO for the tests' sake, just get fucking spawned
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
|||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
override fun startPrimaryUse(delta: Float): Boolean {
|
||||||
val torch = FixtureTikiTorch()
|
val torch = FixtureTikiTorch()
|
||||||
|
|
||||||
//println("aroisetn")
|
|
||||||
|
|
||||||
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
|
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
|
||||||
// return true when placed, false when cannot be placed
|
// return true when placed, false when cannot be placed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.Terrarum.mouseTileY
|
|||||||
import net.torvald.terrarum.controller.TerrarumController
|
import net.torvald.terrarum.controller.TerrarumController
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
|
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||||
@@ -240,6 +241,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
Terrarum.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as Ingame).particlesActive}",
|
Terrarum.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as Ingame).particlesActive}",
|
||||||
(2 + 41 * 8).toFloat(), Terrarum.HEIGHT - 10f)
|
(2 + 41 * 8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}",
|
||||||
|
2f, Terrarum.HEIGHT - 18f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user