mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
external classloader from modmgr
This commit is contained in:
@@ -172,8 +172,17 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
val SIZE_NORMAL = Point2i(CHUNK_W*100, CHUNK_H*60)
|
||||
val SIZE_LARGE = Point2i(CHUNK_W*150, CHUNK_H*60)
|
||||
val SIZE_HUGE = Point2i(CHUNK_W*250, CHUNK_H*60)
|
||||
val NEW_WORLD_SIZE = arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
|
||||
val WORLDPORTAL_NEW_WORLD_SIZE = arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
|
||||
val SIZE_TEST = Point2i(CHUNK_W*11, CHUNK_H*7)
|
||||
val NEW_WORLD_SIZE =
|
||||
if (App.IS_DEVELOPMENT_BUILD)
|
||||
arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE, SIZE_TEST)
|
||||
else
|
||||
arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
|
||||
val WORLDPORTAL_NEW_WORLD_SIZE =
|
||||
if (App.IS_DEVELOPMENT_BUILD)
|
||||
arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE, SIZE_TEST)
|
||||
else
|
||||
arrayOf(SIZE_SMALL, SIZE_NORMAL, SIZE_LARGE, SIZE_HUGE)
|
||||
|
||||
val worldgenThreadExecutor = ThreadExecutor()
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class ActorConveyors : ActorWithBody {
|
||||
override fun updateImpl(delta: Float) {
|
||||
super.updateImpl(delta)
|
||||
|
||||
turn += delta / 1
|
||||
turn += delta * 8
|
||||
while (turn >= 1.0) turn -= 1.0
|
||||
|
||||
// turn = 0.0
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameitems.getModuleName
|
||||
import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
|
||||
@@ -22,8 +23,8 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
// @Transient private val hash = RandomWordsName(4)
|
||||
|
||||
|
||||
@Transient protected open val makeFixture: () -> FixtureBase = {
|
||||
Class.forName(fixtureClassName).getDeclaredConstructor().newInstance() as FixtureBase
|
||||
@Transient protected open val makeFixture: (String) -> FixtureBase = { moduleName: String ->
|
||||
ModMgr.getJavaClass<FixtureBase>(moduleName, fixtureClassName)
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -62,7 +63,7 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) {
|
||||
// println("ghost: ${ghostItem}; ghostInit = $ghostInit; instance: $hash")
|
||||
if (!ghostInit.compareAndExchangeAcquire(false, true)) {
|
||||
ghostItem.set(makeFixture())
|
||||
ghostItem.set(makeFixture(originalID.getModuleName()))
|
||||
// printdbg(this, "ghost item initialised: $ghostItem")
|
||||
|
||||
}
|
||||
@@ -98,7 +99,7 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) { _, _, mx, my ->
|
||||
val item = ghostItem.getAndSet(makeFixture()) // renew the "ghost" otherwise you'll be spawning exactly the same fixture again; old ghost will be returned
|
||||
val item = ghostItem.getAndSet(makeFixture(originalID.getModuleName())) // renew the "ghost" otherwise you'll be spawning exactly the same fixture again; old ghost will be returned
|
||||
|
||||
if (item.spawn(mx, my, if (actor is IngamePlayer) actor.uuid else null)) 1 else -1
|
||||
// return true when placed, false when cannot be placed
|
||||
|
||||
@@ -26,7 +26,7 @@ class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torval
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_TAPESTRY"
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
@Transient override val makeFixture: (String) -> FixtureBase = { moduleName: String ->
|
||||
FixtureTapestry(
|
||||
// TODO use extra["fileRef"] (string) and extra["framingMaterial"] (string)
|
||||
Gdx.files.internal("assets/monkey_island").readBytes(),
|
||||
|
||||
@@ -35,7 +35,7 @@ class ItemTextSignCopper(originalID: ItemID) : FixtureItemBase(originalID, "net.
|
||||
stackable = false
|
||||
}
|
||||
|
||||
@Transient override val makeFixture: () -> FixtureBase = {
|
||||
@Transient override val makeFixture: (String) -> FixtureBase = { moduleName: String ->
|
||||
FixtureTextSignCopper(
|
||||
extra.getAsString("signContent") ?: "",
|
||||
extra.getAsInt("signPanelCount") ?: 2
|
||||
|
||||
@@ -53,7 +53,7 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
private val normalTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/normal.png")))
|
||||
private val smallTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/small.png")))
|
||||
|
||||
private val tex = arrayOf(smallTex, normalTex, largeTex, hugeTex)
|
||||
private val tex = arrayOf(smallTex, normalTex, largeTex, hugeTex, smallTex)
|
||||
|
||||
override var width = 480
|
||||
override var height = 480
|
||||
@@ -72,12 +72,23 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
private val sizeSelector = UIItemInlineRadioButtons(this,
|
||||
drawX + radioX, drawY + sizeSelY, radioCellWidth,
|
||||
listOf(
|
||||
{ Lang["CONTEXT_DESCRIPTION_TINY"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_SMALL"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_BIG"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_HUGE"] }
|
||||
)
|
||||
if (App.IS_DEVELOPMENT_BUILD) {
|
||||
listOf(
|
||||
{ Lang["CONTEXT_DESCRIPTION_TINY"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_SMALL"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_BIG"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_HUGE"] },
|
||||
{ "Testification" }
|
||||
)
|
||||
}
|
||||
else {
|
||||
listOf(
|
||||
{ Lang["CONTEXT_DESCRIPTION_TINY"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_SMALL"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_BIG"] },
|
||||
{ Lang["CONTEXT_DESCRIPTION_HUGE"] }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
private val rng = HQRNG()
|
||||
@@ -290,8 +301,12 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
)
|
||||
|
||||
// name/seed input labels
|
||||
App.fontGame.draw(batch, Lang["MENU_NAME"], drawX - 4, drawY + sizeSelY + inputLineY1)
|
||||
App.fontGame.draw(batch, Lang["CONTEXT_GENERATOR_SEED"], drawX - 4, drawY + sizeSelY + inputLineY2)
|
||||
App.fontGame.draw(batch,
|
||||
if (sizeSelector.selection == 4) "Test Program" else Lang["MENU_NAME"],
|
||||
drawX - 4, drawY + sizeSelY + inputLineY1)
|
||||
App.fontGame.draw(batch,
|
||||
if (sizeSelector.selection == 4) "Parameters" else Lang["CONTEXT_GENERATOR_SEED"],
|
||||
drawX - 4, drawY + sizeSelY + inputLineY2)
|
||||
|
||||
val (wx, wy) = TerrarumIngame.NEW_WORLD_SIZE[sizeSelector.selection]
|
||||
val etaSec = Worldgen.getEstimationSec(wx, wy)
|
||||
|
||||
Reference in New Issue
Block a user