Misc fixes
This commit is contained in:
parent
eb6fef150e
commit
dc585273b7
@ -476,7 +476,7 @@ class DungeonWorld(val parent: ServerWorld, val random: RandomGenerator, val mar
|
|||||||
val placedObjects = placedObjects.entries
|
val placedObjects = placedObjects.entries
|
||||||
.map { (pos, data) ->
|
.map { (pos, data) ->
|
||||||
try {
|
try {
|
||||||
WorldObject.create(data.prototype, pos, data.parameters).also { it?.randomize(random) } to data.direction
|
WorldObject.create(data.prototype, pos, data.parameters).also { it?.randomize(random, parent.template.threatLevel) } to data.direction
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
LOGGER.error("Exception while creating dungeon object ${data.prototype} at $pos", err)
|
LOGGER.error("Exception while creating dungeon object ${data.prototype} at $pos", err)
|
||||||
null to data.direction
|
null to data.direction
|
||||||
|
@ -300,10 +300,12 @@ class WorldTemplate(val geometry: WorldGeometry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val cellCache = Caffeine.newBuilder()
|
private val cellCache = Caffeine.newBuilder()
|
||||||
.maximumSize(150_000L)
|
.maximumSize(1_500_000L) // plentiful of space, and allows for high hit ratio (around 79%) in most situations
|
||||||
.expireAfterAccess(Duration.ofMinutes(1))
|
// downside is memory consumption, but why should it matter when we save 80% of cpu time?
|
||||||
|
.expireAfterAccess(Duration.ofSeconds(20))
|
||||||
.executor(Starbound.EXECUTOR)
|
.executor(Starbound.EXECUTOR)
|
||||||
.scheduler(Starbound)
|
.scheduler(Starbound)
|
||||||
|
// .recordStats()
|
||||||
.build<Vector2i, CellInfo> { (x, y) -> cellInfo0(x, y) }
|
.build<Vector2i, CellInfo> { (x, y) -> cellInfo0(x, y) }
|
||||||
|
|
||||||
fun cellInfo(x: Int, y: Int): CellInfo {
|
fun cellInfo(x: Int, y: Int): CellInfo {
|
||||||
|
@ -110,8 +110,8 @@ class ContainerObject(config: Registry.Entry<ObjectDefinition>) : WorldObject(co
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun randomizeContents(random: RandomGenerator) {
|
private fun randomizeContents(random: RandomGenerator, threatLevel: Double) {
|
||||||
var level = world.template.threatLevel
|
var level = threatLevel
|
||||||
level = lookupProperty("level") { JsonPrimitive(level) }.asDouble
|
level = lookupProperty("level") { JsonPrimitive(level) }.asDouble
|
||||||
level += lookupProperty("levelAdjustment") { JsonPrimitive(0.0) }.asDouble
|
level += lookupProperty("levelAdjustment") { JsonPrimitive(0.0) }.asDouble
|
||||||
|
|
||||||
@ -144,9 +144,9 @@ class ContainerObject(config: Registry.Entry<ObjectDefinition>) : WorldObject(co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun randomize(random: RandomGenerator) {
|
override fun randomize(random: RandomGenerator, threatLevel: Double) {
|
||||||
super.randomize(random)
|
super.randomize(random, threatLevel)
|
||||||
randomizeContents(random)
|
randomizeContents(random, threatLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onJoinWorld(world: World<*, *>) {
|
override fun onJoinWorld(world: World<*, *>) {
|
||||||
@ -162,9 +162,9 @@ class ContainerObject(config: Registry.Entry<ObjectDefinition>) : WorldObject(co
|
|||||||
val seed = lookupProperty("treasureSeed")
|
val seed = lookupProperty("treasureSeed")
|
||||||
|
|
||||||
if (seed.isJsonNull) {
|
if (seed.isJsonNull) {
|
||||||
randomizeContents(world.random)
|
randomizeContents(world.random, world.template.threatLevel)
|
||||||
} else {
|
} else {
|
||||||
randomizeContents(random(seed.asLong))
|
randomizeContents(random(seed.asLong), world.template.threatLevel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ open class WorldObject(val config: Registry.Entry<ObjectDefinition>) : TileEntit
|
|||||||
/**
|
/**
|
||||||
* called by DungeonWorld to deterministically randomize parameters
|
* called by DungeonWorld to deterministically randomize parameters
|
||||||
*/
|
*/
|
||||||
open fun randomize(random: RandomGenerator) {
|
open fun randomize(random: RandomGenerator, threatLevel: Double) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user