mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
particle: disable campfire sprite texture, fix mass ticking if ThreadPool was busy
This commit is contained in:
parent
db23cf8047
commit
80985053cf
@ -43,16 +43,10 @@ class CampfireSmokeParticle(connection: PlayConnection, particleRenderer: Partic
|
||||
|
||||
this.velocity assign Vec3(velocity.x, velocity.y + (random.nextFloat() / 500.0f), velocity.z)
|
||||
movement = false
|
||||
spriteDisabled = true
|
||||
setRandomSprite()
|
||||
}
|
||||
|
||||
override fun tick(deltaTime: Int) {
|
||||
super.tick(deltaTime)
|
||||
if (dead) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun realTick() {
|
||||
super.realTick()
|
||||
val horizontal = { (random.nextFloat() / 5000.0f * (if (random.nextBoolean()) 1.0f else -1.0f)) }
|
||||
|
@ -21,11 +21,12 @@ import glm_.vec3.Vec3
|
||||
|
||||
abstract class SimpleTextureParticle(connection: PlayConnection, particleRenderer: ParticleRenderer, position: Vec3, velocity: Vec3, data: ParticleData) : TextureParticle(connection, particleRenderer, position, velocity, data) {
|
||||
override var texture = particleRenderer.renderWindow.textures.allTextures[data.type.textures.first()]!!
|
||||
var spriteDisabled = false
|
||||
|
||||
|
||||
private fun checkSpriteTexture() {
|
||||
val totalTextures = data.type.textures.size
|
||||
if (totalTextures <= 1) {
|
||||
if (totalTextures <= 1 || spriteDisabled) {
|
||||
return
|
||||
}
|
||||
// calculate next texture
|
||||
@ -36,6 +37,10 @@ abstract class SimpleTextureParticle(connection: PlayConnection, particleRendere
|
||||
texture = particleRenderer.renderWindow.textures.allTextures[nextTextureResourceLocation]!!
|
||||
}
|
||||
|
||||
fun setRandomSprite() {
|
||||
texture = particleRenderer.renderWindow.textures.allTextures[data.type.textures.random(random)]!!
|
||||
}
|
||||
|
||||
override fun tick(deltaTime: Int) {
|
||||
super.tick(deltaTime)
|
||||
if (dead) {
|
||||
|
@ -138,7 +138,7 @@ class PlayConnection(
|
||||
}
|
||||
TimeWorker.addTask(velocityHandlerTask)
|
||||
|
||||
worldTickTask = TimeWorkerTask(ProtocolDefinition.TICK_TIME) {
|
||||
worldTickTask = TimeWorkerTask(ProtocolDefinition.TICK_TIME, maxDelayTime = ProtocolDefinition.TICK_TIME / 2) {
|
||||
world.realTick()
|
||||
}
|
||||
TimeWorker.addTask(worldTickTask)
|
||||
|
@ -36,9 +36,11 @@ class ThreadPool(
|
||||
state = ThreadPoolStates.STARTED
|
||||
}
|
||||
|
||||
val pendingCount: Int
|
||||
get() = pending.size
|
||||
|
||||
@Synchronized
|
||||
private fun checkThreads() {
|
||||
|
||||
fun wait() {
|
||||
try {
|
||||
availableThreads += Thread.currentThread()
|
||||
|
@ -23,6 +23,9 @@ object TimeWorker {
|
||||
if (task.getsExecuted) {
|
||||
return@execute
|
||||
}
|
||||
if (System.currentTimeMillis() - currentTime >= task.maxDelayTime) {
|
||||
return@execute
|
||||
}
|
||||
task.getsExecuted = true
|
||||
task.runnable.run()
|
||||
task.lastExecution = currentTime
|
||||
|
@ -3,6 +3,7 @@ package de.bixilon.minosoft.util.task.time
|
||||
data class TimeWorkerTask(
|
||||
val interval: Int,
|
||||
val runOnce: Boolean = false,
|
||||
val maxDelayTime: Int = Int.MAX_VALUE,
|
||||
val runnable: Runnable,
|
||||
) {
|
||||
var getsExecuted: Boolean = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user