fixtures won't spawn when there's block or other fixtures

This commit is contained in:
minjaesong
2019-05-31 22:57:20 +09:00
parent 874834b2d1
commit ec8b57abd1
8 changed files with 51 additions and 12 deletions

View File

@@ -568,15 +568,12 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
)
}
private fun filterVisibleActors() {
visibleActorsRenderBehind = actorsRenderBehind.filter { it.inScreen() }
visibleActorsRenderMiddle = actorsRenderMiddle.filter { it.inScreen() }
visibleActorsRenderMidTop = actorsRenderMidTop.filter { it.inScreen() }
visibleActorsRenderFront = actorsRenderFront.filter { it.inScreen() }
visibleActorsRenderOverlay=actorsRenderOverlay.filter { it.inScreen() }
//printdbg(this, "total visible actors: ${visibleActorsRenderMiddle.size}")
}
private fun repossessActor() {

View File

@@ -66,6 +66,13 @@ object IngameRenderer : Disposable {
AppLoader.disposableSingletonsPool.add(this)
}
var renderingActorsCount = 0
private set
var renderingUIsCount = 0
private set
/*var renderingParticleCount = 0
private set*/
operator fun invoke(
gamePaused: Boolean,
world: GameWorldExtension,
@@ -78,6 +85,14 @@ object IngameRenderer : Disposable {
player: ActorWithBody? = 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) {
uiListToDraw = uisToDraw

View File

@@ -4,6 +4,7 @@ import net.torvald.terrarum.IngameInstance
import net.torvald.terrarum.Point2i
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.gameworld.GameWorld
@@ -45,10 +46,26 @@ open class FixtureBase(blockBox0: BlockBox, val blockBoxProps: BlockBoxProps = B
// posY: bottom of the blockBox
// using the actor's hitbox
// TODO: obviously check for collision
for (x in posX until posX + blockBox.width) {
for (y in posY until posY + blockBox.height) {
// 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 || 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 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!)
@@ -72,7 +89,7 @@ open class FixtureBase(blockBox0: BlockBox, val blockBoxProps: BlockBoxProps = B
Terrarum.ingame!!.addNewActor(this)
return true // TODO for the tests' sake, just get fucking spawned
return true
}

View File

@@ -32,8 +32,6 @@ class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
override fun startPrimaryUse(delta: Float): Boolean {
val torch = FixtureTikiTorch()
//println("aroisetn")
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
// return true when placed, false when cannot be placed
}