mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
actors now use 'updateImpl'; static sound for smelter and furnace
This commit is contained in:
@@ -125,7 +125,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
override fun updateImpl(delta: Float) {
|
||||
hitbox.setPosition(
|
||||
Terrarum.mouseTileX * 16.0,
|
||||
Terrarum.mouseTileY * 16.0
|
||||
@@ -187,7 +187,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
override fun drawGlow(frameDelta: Float, batch: SpriteBatch) { }
|
||||
|
||||
override fun update(delta: Float) { }
|
||||
override fun updateImpl(delta: Float) { }
|
||||
|
||||
override fun onActorValueChange(key: String, value: Any?) { }
|
||||
|
||||
@@ -688,9 +688,7 @@ class MovableWorldCamera(val parent: BuildingMaker) : ActorHumanoid(0, physProp
|
||||
parent.world.height * TILE_SIZE - (App.scr.height - hitbox.height) / 2.0
|
||||
)
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
// confine the camera so it won't wrap
|
||||
this.hitbox.hitboxStart.setCoerceIn(coerceInStart, coerceInEnd)
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
override fun drawBody(frameDelta: Float, batch: SpriteBatch) { }
|
||||
override fun drawGlow(frameDelta: Float, batch: SpriteBatch) { }
|
||||
|
||||
override fun update(delta: Float) {
|
||||
override fun updateImpl(delta: Float) {
|
||||
ai.update(this, delta)
|
||||
}
|
||||
|
||||
|
||||
@@ -201,13 +201,13 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
override fun updateImpl(delta: Float) {
|
||||
// update lightbox
|
||||
lightBoxList[0].light = actorValueColour
|
||||
shadeBoxList[0].light = actorValueShade
|
||||
|
||||
|
||||
super.update(delta)
|
||||
super.updateImpl(delta)
|
||||
|
||||
if (vehicleRiding is IngamePlayer)
|
||||
throw Error("Attempted to 'ride' player object. ($vehicleRiding)")
|
||||
|
||||
@@ -67,8 +67,8 @@ open class SaplingBase(val species: Int) : Cultivable(72000) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
// these have to run every frame to make the sprite static
|
||||
(sprite as SheetSpriteAnimation).currentRow = species
|
||||
|
||||
@@ -140,15 +140,13 @@ open class DroppedItem : ActorWithBody {
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
override fun updateImpl(delta: Float) {
|
||||
renderOrder = RenderOrder.OVERLAY // for some reason the "overlaying" won't work without this
|
||||
|
||||
if (this.itemID.isBlock() || this.itemID.isItem()) {
|
||||
this.lightBoxList[0].light = getLum(this.itemID)
|
||||
}
|
||||
|
||||
super.update(delta)
|
||||
|
||||
timeSinceSpawned += delta
|
||||
|
||||
// merge into the already existing droppeditem with isStationary==true if one is detected
|
||||
|
||||
@@ -116,8 +116,8 @@ open class Electric : FixtureBase {
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
oldSinkStatus.indices.forEach { index ->
|
||||
val wx = (index % blockBox.width) + intTilewiseHitbox.startX.toInt()
|
||||
val wy = (index / blockBox.width) + intTilewiseHitbox.startY.toInt()
|
||||
@@ -478,7 +478,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
wireConsumption.clear()
|
||||
}
|
||||
|
||||
despawnHook(this)
|
||||
|
||||
super.despawn()
|
||||
}
|
||||
else {
|
||||
printdbg(this, "failed to despawn at T${INGAME.WORLD_UPDATE_TIMER}: ${nameFun()}")
|
||||
@@ -494,8 +495,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
/**
|
||||
* This function MUST BE super-called for make despawn call to work at all.
|
||||
*/
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,7 +512,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
despawned = true
|
||||
}
|
||||
// actual actor removal is performed by the TerrarumIngame.killOrKnockdownActors
|
||||
super.update(delta)
|
||||
super.updateImpl(delta)
|
||||
}
|
||||
|
||||
override fun flagDespawn() {
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.audio.MusicContainer
|
||||
import net.torvald.terrarum.audio.decibelsToFullscale
|
||||
import net.torvald.terrarum.audio.dsp.Gain
|
||||
import net.torvald.terrarum.audio.dsp.NullFilter
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
@@ -47,8 +52,20 @@ class FixtureFurnaceAndAnvil : FixtureBase, CraftingStation {
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 100.0
|
||||
|
||||
despawnHook = {
|
||||
stopAudio(static) {
|
||||
it.filters[filterIndex] = NullFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transient val static = MusicContainer("bonfire", ModMgr.getFile("basegame", "audio/effects/static/bonfire.ogg"), Gdx.audio.newMusic(
|
||||
ModMgr.getGdxFile("basegame", "audio/effects/static/bonfire.ogg")
|
||||
).also {
|
||||
it.isLooping = true
|
||||
})
|
||||
|
||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 0.0, TerrarumAppConfiguration.TILE_SIZED * 2, TerrarumAppConfiguration.TILE_SIZED * 2), Cvec(0.5f, 0.18f, 0f, 0f)))
|
||||
|
||||
@Transient private val actorBlocks = arrayOf(
|
||||
@@ -68,9 +85,8 @@ class FixtureFurnaceAndAnvil : FixtureBase, CraftingStation {
|
||||
private var nextDelay = 0.25f
|
||||
private var spawnTimer = 0f
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
// emit smokes TODO: only when hot
|
||||
if (spawnTimer >= nextDelay) {
|
||||
@@ -88,5 +104,28 @@ class FixtureFurnaceAndAnvil : FixtureBase, CraftingStation {
|
||||
}
|
||||
|
||||
spawnTimer += delta
|
||||
|
||||
|
||||
// manage audio
|
||||
getTrackByAudio(static).let {
|
||||
if (it != null && !it.isPlaying) {
|
||||
startAudio(static) {
|
||||
it.filters[filterIndex] = Gain(0f)
|
||||
}
|
||||
}
|
||||
}
|
||||
getTrackByAudio(static)?.let {
|
||||
if (it.filters[filterIndex] !is Gain) // just in case...
|
||||
it.filters[filterIndex] = Gain(0f)
|
||||
|
||||
(it.filters[filterIndex] as Gain).gain = 0.4f // TODO randomsied undulation
|
||||
}
|
||||
}
|
||||
|
||||
@Transient private val filterIndex = 0
|
||||
|
||||
override fun dispose() {
|
||||
super.dispose()
|
||||
static.dispose()
|
||||
}
|
||||
}
|
||||
@@ -103,8 +103,8 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
override val canBeDespawned: Boolean
|
||||
get() = discInventory.isEmpty()
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
// supress the normal background music playback
|
||||
if (musicIsPlaying && !flagDespawn) {
|
||||
|
||||
@@ -70,8 +70,8 @@ class FixtureMusicalTurntable : Electric, PlaysMusic {
|
||||
override val canBeDespawned: Boolean
|
||||
get() = disc == null
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
// right click
|
||||
if (mouseUp) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
@@ -9,6 +10,9 @@ import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.audio.MusicContainer
|
||||
import net.torvald.terrarum.audio.dsp.Gain
|
||||
import net.torvald.terrarum.audio.dsp.NullFilter
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
@@ -77,6 +81,12 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
this.mainUI = UISmelterBasic(this)
|
||||
}
|
||||
|
||||
@Transient val static = MusicContainer("bonfire", ModMgr.getFile("basegame", "audio/effects/static/bonfire.ogg"), Gdx.audio.newMusic(
|
||||
ModMgr.getGdxFile("basegame", "audio/effects/static/bonfire.ogg")
|
||||
).also {
|
||||
it.isLooping = true
|
||||
})
|
||||
|
||||
@Transient val light = Cvec(0.5f, 0.18f, 0f, 0f)
|
||||
|
||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 2*TILE_SIZED, TILE_SIZED * 2, TILE_SIZED * 2), Cvec(0.5f, 0.18f, 0f, 0f)))
|
||||
@@ -190,8 +200,8 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
val oreItemProp = ItemCodex[oreItem?.itm]
|
||||
val fuelItemProp = ItemCodex[fireboxItem?.itm]
|
||||
@@ -277,6 +287,35 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||
spawnTimer += delta
|
||||
else
|
||||
spawnTimer = 0f
|
||||
|
||||
|
||||
|
||||
// manage audio
|
||||
getTrackByAudio(static).let {
|
||||
if (it == null || (temperature > 0f && !it.isPlaying)) {
|
||||
startAudio(static) {
|
||||
it.filters[filterIndex] = Gain(0f)
|
||||
}
|
||||
}
|
||||
else if (it != null && it.isPlaying && temperature <= 0f) {
|
||||
stopAudio(static) {
|
||||
it.filters[filterIndex] = NullFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
getTrackByAudio(static)?.let {
|
||||
if (it.filters[filterIndex] !is Gain) // just in case...
|
||||
it.filters[filterIndex] = Gain(0f)
|
||||
|
||||
(it.filters[filterIndex] as Gain).gain = (it.maxVolume * temperature).toFloat() // TODO randomsied undulation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transient private val filterIndex = 0
|
||||
|
||||
override fun dispose() {
|
||||
super.dispose()
|
||||
static.dispose()
|
||||
}
|
||||
}
|
||||
@@ -366,9 +366,8 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
private var lastDoorHandler = 0 // 0: automatic, 1: manual
|
||||
private var doorCloseQueueHandler = 0
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
// debug colouring
|
||||
// this.sprite?.colourFilter =
|
||||
|
||||
@@ -51,10 +51,10 @@ internal class FixtureTikiTorch : FixtureBase {
|
||||
private var nextDelay = 0.25f
|
||||
private var spawnTimer = 0f
|
||||
|
||||
override fun update(delta: Float) {
|
||||
lightBoxList[0].light = BlockCodex[Block.TORCH].getLumCol(rndHash1, rndHash2)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
super.update(delta)
|
||||
lightBoxList[0].light = BlockCodex[Block.TORCH].getLumCol(rndHash1, rndHash2)
|
||||
|
||||
if (spawnTimer >= nextDelay) {
|
||||
(Terrarum.ingame as TerrarumIngame).addParticle(ParticleVanishingSprite(
|
||||
|
||||
@@ -38,8 +38,8 @@ class FixtureTypewriter : FixtureBase {
|
||||
actorValue[AVKey.BASEMASS] = 3.6
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
(sprite as SheetSpriteAnimation).currentRow = 1 + (carriagePosition.toFloat() / TYPEWRITER_COLUMNS * 10).roundToInt()
|
||||
}
|
||||
|
||||
@@ -84,9 +84,9 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
ai.update(this, delta)
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
override fun moveLeft(amount: Float) { // hit the buttons on the controller box
|
||||
|
||||
@@ -29,9 +29,7 @@ class PhysTestLuarLander : ActorWithBody(RenderOrder.MIDTOP, PhysProperties.PHYS
|
||||
super.run()
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
|
||||
controllerV!!.y = avSpeedCap
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ open class ProjectileSimple : ActorWithBody, Projectile {
|
||||
collisionType = COLLISION_KINEMATIC
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
override fun updateImpl(delta: Float) {
|
||||
// hit something and despawn
|
||||
lifetimeCounter += delta
|
||||
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
|
||||
@@ -86,8 +86,6 @@ open class ProjectileSimple : ActorWithBody, Projectile {
|
||||
}
|
||||
|
||||
posPre.set(centrePosPoint)
|
||||
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user