mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
console command dictionary is now automatically filled using reflection
This commit is contained in:
@@ -7,6 +7,10 @@ description=The base game
|
|||||||
# Author of the module
|
# Author of the module
|
||||||
author=Terrarum
|
author=Terrarum
|
||||||
|
|
||||||
|
# Root package name for the module
|
||||||
|
# The game will look for certain classes base on this package string, so don't mess up!
|
||||||
|
package=net.torvald.terrarum.modulebasegame
|
||||||
|
|
||||||
# Name of the entry script
|
# Name of the entry script
|
||||||
# Entry script must inherit net.torvald.terrarum.ModuleEntryPoint
|
# Entry script must inherit net.torvald.terrarum.ModuleEntryPoint
|
||||||
entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint
|
entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
propername=Dwarven Techs
|
propername=Dwarven Techs
|
||||||
description=Dwarven technicians are emerged from their hiding
|
description=Dwarven technicians are emerged from their hiding
|
||||||
author=Terrarum
|
author=Terrarum
|
||||||
|
package=net.torvald.terrarum.modulecomputers
|
||||||
entrypoint=net.torvald.terrarum.modulecomputers.EntryPoint
|
entrypoint=net.torvald.terrarum.modulecomputers.EntryPoint
|
||||||
releasedate=2017-07-14
|
releasedate=2017-07-14
|
||||||
version=0.2.0
|
version=0.2.0
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.github.strikerx3.jxinput.XInputDevice;
|
|||||||
import net.torvald.gdx.graphics.PixmapIO2;
|
import net.torvald.gdx.graphics.PixmapIO2;
|
||||||
import net.torvald.getcpuname.GetCpuName;
|
import net.torvald.getcpuname.GetCpuName;
|
||||||
import net.torvald.terrarum.concurrent.ThreadExecutor;
|
import net.torvald.terrarum.concurrent.ThreadExecutor;
|
||||||
|
import net.torvald.terrarum.console.ConsoleCommand;
|
||||||
import net.torvald.terrarum.controller.GdxControllerAdapter;
|
import net.torvald.terrarum.controller.GdxControllerAdapter;
|
||||||
import net.torvald.terrarum.controller.TerrarumController;
|
import net.torvald.terrarum.controller.TerrarumController;
|
||||||
import net.torvald.terrarum.controller.XinputControllerAdapter;
|
import net.torvald.terrarum.controller.XinputControllerAdapter;
|
||||||
@@ -28,6 +29,7 @@ import net.torvald.terrarum.imagefont.TinyAlphNum;
|
|||||||
import net.torvald.terrarum.langpack.Lang;
|
import net.torvald.terrarum.langpack.Lang;
|
||||||
import net.torvald.terrarum.modulebasegame.IngameRenderer;
|
import net.torvald.terrarum.modulebasegame.IngameRenderer;
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame;
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame;
|
||||||
|
import net.torvald.terrarum.modulebasegame.console.ToggleNoClip;
|
||||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory;
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory;
|
||||||
import net.torvald.terrarum.utils.JsonFetcher;
|
import net.torvald.terrarum.utils.JsonFetcher;
|
||||||
import net.torvald.terrarum.utils.JsonWriter;
|
import net.torvald.terrarum.utils.JsonWriter;
|
||||||
@@ -1138,20 +1140,29 @@ public class AppLoader implements ApplicationListener {
|
|||||||
public static void printdbg(Object obj, Object message) {
|
public static void printdbg(Object obj, Object message) {
|
||||||
if (IS_DEVELOPMENT_BUILD) {
|
if (IS_DEVELOPMENT_BUILD) {
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
System.out.println("[" + out + "] " + message.toString());
|
if (message == null)
|
||||||
|
System.out.println("[" + out + "] null");
|
||||||
|
else
|
||||||
|
System.out.println("[" + out + "] " + message.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printdbgerr(Object obj, Object message) {
|
public static void printdbgerr(Object obj, Object message) {
|
||||||
if (IS_DEVELOPMENT_BUILD) {
|
if (IS_DEVELOPMENT_BUILD) {
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
System.err.println("[" + out + "] " + message.toString());
|
if (message == null)
|
||||||
|
System.err.println("[" + out + "] null");
|
||||||
|
else
|
||||||
|
System.err.println("[" + out + "] " + message.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printmsg(Object obj, Object message) {
|
public static void printmsg(Object obj, Object message) {
|
||||||
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
String out = (obj instanceof String) ? (String) obj : obj.getClass().getSimpleName();
|
||||||
System.out.println("[" + out + "] " + message.toString());
|
if (message == null)
|
||||||
|
System.out.println("[" + out + "] null");
|
||||||
|
else
|
||||||
|
System.out.println("[" + out + "] " + message.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ object ModMgr {
|
|||||||
val properName: String,
|
val properName: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
val author: String,
|
val author: String,
|
||||||
|
val packageName: String,
|
||||||
val entryPoint: String,
|
val entryPoint: String,
|
||||||
val releaseDate: String,
|
val releaseDate: String,
|
||||||
val version: String,
|
val version: String,
|
||||||
@@ -96,13 +97,14 @@ object ModMgr {
|
|||||||
val properName = modMetadata.getProperty("propername")
|
val properName = modMetadata.getProperty("propername")
|
||||||
val description = modMetadata.getProperty("description")
|
val description = modMetadata.getProperty("description")
|
||||||
val author = modMetadata.getProperty("author")
|
val author = modMetadata.getProperty("author")
|
||||||
|
val packageName = modMetadata.getProperty("package")
|
||||||
val entryPoint = modMetadata.getProperty("entrypoint")
|
val entryPoint = modMetadata.getProperty("entrypoint")
|
||||||
val releaseDate = modMetadata.getProperty("releasedate")
|
val releaseDate = modMetadata.getProperty("releasedate")
|
||||||
val version = modMetadata.getProperty("version")
|
val version = modMetadata.getProperty("version")
|
||||||
val libs = modMetadata.getProperty("libraries").split(Regex(""";[ ]*""")).toTypedArray()
|
val libs = modMetadata.getProperty("libraries").split(Regex(""";[ ]*""")).toTypedArray()
|
||||||
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).toTypedArray()
|
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).toTypedArray()
|
||||||
val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory
|
val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory
|
||||||
moduleInfo[moduleName] = ModuleMetadata(index, isDir, properName, description, author, entryPoint, releaseDate, version, libs, dependency)
|
moduleInfo[moduleName] = ModuleMetadata(index, isDir, properName, description, author, packageName, entryPoint, releaseDate, version, libs, dependency)
|
||||||
|
|
||||||
printdbg(this, moduleInfo[moduleName])
|
printdbg(this, moduleInfo[moduleName])
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.torvald.terrarum.AppLoader.printdbgerr
|
|||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
|
import net.torvald.terrarum.console.CommandDict
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
@@ -155,6 +156,10 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
uiContainer.add(uiMenu)
|
uiContainer.add(uiMenu)
|
||||||
|
|
||||||
|
CommandDict // invoke
|
||||||
|
// TODO add console here
|
||||||
|
|
||||||
|
|
||||||
//loadDone = true
|
//loadDone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.apache.commons.codec.digest.DigestUtils
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2016-02-19.
|
* Created by minjaesong on 2016-02-19.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("auth")
|
||||||
internal object Authenticator : ConsoleCommand {
|
internal object Authenticator : ConsoleCommand {
|
||||||
|
|
||||||
private var a = false
|
private var a = false
|
||||||
|
|||||||
@@ -1,79 +1,73 @@
|
|||||||
package net.torvald.terrarum.console
|
package net.torvald.terrarum.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbgerr
|
||||||
|
import net.torvald.terrarum.ModMgr
|
||||||
|
import net.torvald.terrarum.ModMgr.loadOrder
|
||||||
import net.torvald.terrarum.modulebasegame.console.*
|
import net.torvald.terrarum.modulebasegame.console.*
|
||||||
|
import java.io.BufferedReader
|
||||||
|
import java.io.InputStreamReader
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.streams.toList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-15.
|
* Created by minjaesong on 2016-01-15.
|
||||||
*/
|
*/
|
||||||
object CommandDict {
|
object CommandDict {
|
||||||
|
|
||||||
// todo replace with reflection?
|
internal val dict = hashMapOf<String, ConsoleCommand>()
|
||||||
internal val dict: HashMap<String, ConsoleCommand> = hashMapOf(
|
|
||||||
"echo" to Echo,
|
|
||||||
"error" to EchoError,
|
|
||||||
"setav" to SetAV,
|
|
||||||
"qqq" to QuitApp,
|
|
||||||
"codex" to CodexEdictis,
|
|
||||||
"export" to ExportMap,
|
|
||||||
"gc" to ForceGC,
|
|
||||||
"getav" to GetAV,
|
|
||||||
"getlocale" to GetLocale,
|
|
||||||
"togglenoclip" to ToggleNoClip,
|
|
||||||
"nc" to ToggleNoClip,
|
|
||||||
"setlocale" to SetLocale,
|
|
||||||
"teleport" to Teleport,
|
|
||||||
"tp" to Teleport,
|
|
||||||
"cat" to CatStdout,
|
|
||||||
"setgl" to SetGlobalLightOverride,
|
|
||||||
"getfaction" to GetFactioning,
|
|
||||||
"auth" to Authenticator,
|
|
||||||
"batch" to Batch,
|
|
||||||
"settime" to SetTime,
|
|
||||||
"gettime" to GetTime,
|
|
||||||
"settimedelta" to SetTimeDelta,
|
|
||||||
"help" to Help,
|
|
||||||
"version" to Version,
|
|
||||||
"seed" to Seed,
|
|
||||||
"println" to EchoConsole,
|
|
||||||
"inventory" to Inventory,
|
|
||||||
"avtracker" to AVTracker,
|
|
||||||
"actorslist" to ActorsList,
|
|
||||||
"setscale" to SetScale,
|
|
||||||
"kill" to KillActor,
|
|
||||||
"screenshot" to TakeScreenshot,
|
|
||||||
"resize" to ResizeScreen,
|
|
||||||
"possess" to Possess,
|
|
||||||
|
|
||||||
// Test codes
|
init {
|
||||||
"money" to MoneyDisp,
|
printdbg(this, ModMgr.loadOrder.reversed())
|
||||||
"bulletintest" to SetBulletin,
|
printdbg(this, ModMgr.loadOrder.reversed().map { ModMgr.moduleInfo[it]?.packageName })
|
||||||
"tips" to PrintRandomTips,
|
|
||||||
"langtest" to LangTest,
|
|
||||||
"spawnball" to SpawnPhysTestBall,
|
|
||||||
"spawntorch" to SpawnTikiTorch,
|
|
||||||
"musictest" to MusicTest,
|
|
||||||
"spawntapestry" to SpawnTapestry,
|
|
||||||
"imtest" to JavaIMTest,
|
|
||||||
"cheatmotherfuckernootnoot" to CheatWarnTest,
|
|
||||||
"spawnlunarlander" to SpawnPhysTestLunarLander,
|
|
||||||
"savetest" to SavegameWriterTest,
|
|
||||||
|
|
||||||
"exportav" to ExportAV,
|
(listOf("net.torvald.terrarum") + ModMgr.loadOrder.reversed().map { ModMgr.moduleInfo[it]?.packageName }.filter { it != null }).forEach{ packageRoot ->
|
||||||
/* !! */"exportmeta" to ExportMeta,
|
printdbg(this, packageRoot)
|
||||||
/* !! */"exportworld" to ExportWorld,
|
val packageConsole = "$packageRoot.console"
|
||||||
/* !! */"exportactor" to ExportActor,
|
val stream = ClassLoader.getSystemClassLoader().getResourceAsStream(packageConsole.replace('.','/'))
|
||||||
/* !! */"importworld" to ImportWorld,
|
val reader = BufferedReader(InputStreamReader(stream))
|
||||||
/* !! */"importactor" to ImportActor,
|
|
||||||
/* !! */"exportfborgb" to ExportRendererFboRGB,
|
reader.lines()
|
||||||
/* !! */"printworld" to PrintWorld
|
.filter{ it.endsWith(".class") && !it.contains('$') }
|
||||||
)
|
.map { Class.forName("$packageConsole.${it.substring(0, it.lastIndexOf('.'))}") }
|
||||||
|
.forEach {
|
||||||
|
|
||||||
|
printdbg(this, "> Trying to instantiate ${it.canonicalName}")
|
||||||
|
|
||||||
|
try {
|
||||||
|
val instance = it.kotlin.objectInstance ?: it.kotlin.java.newInstance()
|
||||||
|
|
||||||
|
val aliases = instance.javaClass.getAnnotation(ConsoleAlias::class.java)?.aliasesCSV?.split(',')?.map { it.trim() }
|
||||||
|
val noexport = instance.javaClass.getAnnotation(ConsoleNoExport::class.java)
|
||||||
|
|
||||||
|
if (noexport == null) {
|
||||||
|
|
||||||
|
dict[instance.javaClass.simpleName.lowercase()] = instance as ConsoleCommand
|
||||||
|
aliases?.forEach {
|
||||||
|
dict[it] = instance as ConsoleCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
printdbg(this, "Class instantiated: ${instance.javaClass.simpleName}")
|
||||||
|
if (aliases != null)
|
||||||
|
printdbg(this, " Annotations: $aliases")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e: ClassCastException) {
|
||||||
|
printdbgerr(this, "${it.canonicalName} is not a ConsoleCommand")
|
||||||
|
}
|
||||||
|
catch (e: InstantiationException) {
|
||||||
|
printdbgerr(this, "Could not instantiate ${it.canonicalName}")
|
||||||
|
e.printStackTrace(System.err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
operator fun get(commandName: String): ConsoleCommand {
|
operator fun get(commandName: String): ConsoleCommand {
|
||||||
return dict[commandName]!!
|
return dict[commandName.lowercase()]!!
|
||||||
}
|
|
||||||
|
|
||||||
fun add(name: String, obj: ConsoleCommand) {
|
|
||||||
dict[name] = obj
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,15 @@ internal object CommandInterpreter {
|
|||||||
private val commandsNoAuth = arrayOf(
|
private val commandsNoAuth = arrayOf(
|
||||||
"auth",
|
"auth",
|
||||||
"qqq",
|
"qqq",
|
||||||
"zoom",
|
|
||||||
"setlocale",
|
"setlocale",
|
||||||
"getlocale",
|
"getlocale",
|
||||||
"help",
|
"help",
|
||||||
"version",
|
"version",
|
||||||
"tips",
|
"tips",
|
||||||
"screenshot",
|
"screenshot",
|
||||||
"resize"
|
"resize",
|
||||||
|
"echo",
|
||||||
|
"error"
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun execute(command: String) {
|
internal fun execute(command: String) {
|
||||||
@@ -38,7 +39,7 @@ internal object CommandInterpreter {
|
|||||||
var commandObj: ConsoleCommand? = null
|
var commandObj: ConsoleCommand? = null
|
||||||
try {
|
try {
|
||||||
if (single_command.name.toLowerCase().startsWith("qqq")) {
|
if (single_command.name.toLowerCase().startsWith("qqq")) {
|
||||||
commandObj = CommandDict["qqq"]
|
commandObj = CommandDict["QuitApp"]
|
||||||
}
|
}
|
||||||
else if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
|
else if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
|
||||||
commandObj = CommandDict[single_command.name.toLowerCase()]
|
commandObj = CommandDict[single_command.name.toLowerCase()]
|
||||||
|
|||||||
@@ -15,4 +15,7 @@ interface ConsoleCommand {
|
|||||||
|
|
||||||
fun printUsage()
|
fun printUsage()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
annotation class ConsoleAlias(val aliasesCSV: String)
|
||||||
|
annotation class ConsoleNoExport()
|
||||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.console
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-09-07.
|
* Created by minjaesong on 2016-09-07.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("println")
|
||||||
internal object EchoConsole : ConsoleCommand {
|
internal object EchoConsole : ConsoleCommand {
|
||||||
/**
|
/**
|
||||||
* Args 0: command given
|
* Args 0: command given
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.torvald.terrarum.ui.ConsoleWindow
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-04-25.
|
* Created by minjaesong on 2016-04-25.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("error")
|
||||||
internal object EchoError : ConsoleCommand {
|
internal object EchoError : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val argsWoHeader = Array(args.size - 1) { args[it + 1] }
|
val argsWoHeader = Array(args.size - 1) { args[it + 1] }
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Gdx
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-15.
|
* Created by minjaesong on 2016-01-15.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("qqq")
|
||||||
internal object QuitApp : ConsoleCommand {
|
internal object QuitApp : ConsoleCommand {
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.console
|
|||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.TerrarumScreenSize
|
import net.torvald.terrarum.TerrarumScreenSize
|
||||||
|
|
||||||
|
@ConsoleAlias("resize")
|
||||||
object ResizeScreen: ConsoleCommand {
|
object ResizeScreen: ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 3) {
|
if (args.size == 3) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.torvald.terrarum.weather.WeatherMixer
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-17.
|
* Created by minjaesong on 2016-02-17.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("setgl")
|
||||||
internal object SetGlobalLightOverride : ConsoleCommand {
|
internal object SetGlobalLightOverride : ConsoleCommand {
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.console
|
|||||||
|
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
|
|
||||||
|
@ConsoleNoExport
|
||||||
object TakeScreenshot: ConsoleCommand {
|
object TakeScreenshot: ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
AppLoader.requestScreenshot()
|
AppLoader.requestScreenshot()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -9,6 +10,7 @@ import java.nio.file.Files
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-10.
|
* Created by minjaesong on 2016-02-10.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("cat")
|
||||||
internal object CatStdout : ConsoleCommand {
|
internal object CatStdout : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
|
|
||||||
import net.torvald.terrarum.ccO
|
import net.torvald.terrarum.ccO
|
||||||
import net.torvald.terrarum.console.CommandDict
|
import net.torvald.terrarum.console.CommandDict
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
@@ -11,6 +12,7 @@ import java.util.Formatter
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-16.
|
* Created by minjaesong on 2016-01-16.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("codex")
|
||||||
internal object CodexEdictis : ConsoleCommand {
|
internal object CodexEdictis : ConsoleCommand {
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-18.
|
* Created by minjaesong on 2016-01-18.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("gc")
|
||||||
internal object ForceGC : ConsoleCommand {
|
internal object ForceGC : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
System.gc()
|
System.gc()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.console.EchoError
|
import net.torvald.terrarum.console.EchoError
|
||||||
@@ -12,12 +12,7 @@ import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-17.
|
* Created by minjaesong on 2016-02-17.
|
||||||
*/
|
*/
|
||||||
internal object GetFactioning : ConsoleCommand {
|
internal object GetFaction : ConsoleCommand {
|
||||||
val ccW = GameFontBase.toColorCode(0xFFFF)
|
|
||||||
val ccY = GameFontBase.toColorCode(0xFE8F)
|
|
||||||
val ccM = GameFontBase.toColorCode(0xEAFF)
|
|
||||||
val ccG = GameFontBase.toColorCode(0x8F8F)
|
|
||||||
val ccK = GameFontBase.toColorCode(0x888F)
|
|
||||||
|
|
||||||
private val PRINT_INDENTATION = "$ccK --> $ccW"
|
private val PRINT_INDENTATION = "$ccK --> $ccW"
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
|||||||
*/
|
*/
|
||||||
internal object Inventory : ConsoleCommand {
|
internal object Inventory : ConsoleCommand {
|
||||||
|
|
||||||
private var target: Pocketed? = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying
|
private var target: Pocketed? = null
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
//import net.torvald.terrarum.swingapp.IMStringReader
|
//import net.torvald.terrarum.swingapp.IMStringReader
|
||||||
@@ -10,6 +11,7 @@ import net.torvald.terrarum.console.Echo
|
|||||||
* Created by minjaesong on 2017-02-05.
|
* Created by minjaesong on 2017-02-05.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ConsoleAlias("imtest")
|
||||||
internal object JavaIMTest : ConsoleCommand {
|
internal object JavaIMTest : ConsoleCommand {
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.console.EchoError
|
import net.torvald.terrarum.console.EchoError
|
||||||
@@ -9,6 +10,7 @@ import net.torvald.terrarum.langpack.Lang
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-01-31.
|
* Created by minjaesong on 2017-01-31.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("kill")
|
||||||
internal object KillActor : ConsoleCommand {
|
internal object KillActor : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
|
|
||||||
import net.torvald.EMDASH
|
import net.torvald.EMDASH
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
|
|
||||||
|
@ConsoleAlias("money")
|
||||||
object MoneyDisp : ConsoleCommand {
|
object MoneyDisp : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-07-04.
|
* Created by minjaesong on 2016-07-04.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("tips")
|
||||||
internal object PrintRandomTips : ConsoleCommand {
|
internal object PrintRandomTips : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
Echo("Nope.")
|
Echo("Nope.")
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
|
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
|
import net.torvald.terrarum.console.ConsoleNoExport
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
||||||
@@ -9,6 +10,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-12-17.
|
* Created by minjaesong on 2016-12-17.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleNoExport
|
||||||
internal object SpawnTikiTorch : ConsoleCommand {
|
internal object SpawnTikiTorch : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val torch = FixtureTikiTorch { "Tiki Torch" }
|
val torch = FixtureTikiTorch { "Tiki Torch" }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration
|
import net.torvald.terrarum.TerrarumAppConfiguration
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.console.EchoError
|
import net.torvald.terrarum.console.EchoError
|
||||||
@@ -12,6 +13,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-24.
|
* Created by minjaesong on 2016-01-24.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("tp,goto")
|
||||||
internal object Teleport : ConsoleCommand {
|
internal object Teleport : ConsoleCommand {
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.console.ConsoleAlias
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
@@ -8,6 +9,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-19.
|
* Created by minjaesong on 2016-01-19.
|
||||||
*/
|
*/
|
||||||
|
@ConsoleAlias("nc,noclip")
|
||||||
internal object ToggleNoClip : ConsoleCommand {
|
internal object ToggleNoClip : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying
|
val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying
|
||||||
|
|||||||
@@ -34,24 +34,24 @@ The fields are auto-generated by GDX's JSON serialiser.
|
|||||||
{
|
{
|
||||||
worldName: "New World",
|
worldName: "New World",
|
||||||
worldIndex: 1,
|
worldIndex: 1,
|
||||||
width: 8192,
|
width: 9000,
|
||||||
height: 2048,
|
height: 2250,
|
||||||
spawnX: 4096,
|
spawnX: 4500,
|
||||||
spawnY: 248,
|
spawnY: 248,
|
||||||
creationTime: 1629857065,
|
creationTime: 1629857065,
|
||||||
lastPlayTime: 1629857065,
|
lastPlayTime: 1629857065,
|
||||||
totalPlayTime: 0,
|
totalPlayTime: 0,
|
||||||
layerTerrain: {
|
layerTerrain: {
|
||||||
h: "a441b15fe9a3cf56661190a0b93b9dec7d04127288cc87250967cf3b52894d11",
|
h: <SHA-256 hash of 'b'>,
|
||||||
b: <Ascii85-encoded gzipped terrain layerdata>,
|
b: <Ascii85-encoded gzipped terrain layerdata>,
|
||||||
x: 8192,
|
x: 9000,
|
||||||
y: 2048
|
y: 2250
|
||||||
},
|
},
|
||||||
layerWall: {
|
layerWall: {
|
||||||
h: <SHA-256 hash of 'b'>,
|
h: <SHA-256 hash of 'b'>,
|
||||||
b: <Ascii85-encoded gzipped wall layerdata>,
|
b: <Ascii85-encoded gzipped wall layerdata>,
|
||||||
x: 8192,
|
x: 9000,
|
||||||
y: 2048
|
y: 2250
|
||||||
},
|
},
|
||||||
wallDamages:{},
|
wallDamages:{},
|
||||||
terrainDamages: {},
|
terrainDamages: {},
|
||||||
@@ -69,7 +69,10 @@ The fields are auto-generated by GDX's JSON serialiser.
|
|||||||
averageTemperature: 288,
|
averageTemperature: 288,
|
||||||
generatorSeed: 0,
|
generatorSeed: 0,
|
||||||
worldTime: 27874,
|
worldTime: 27874,
|
||||||
tileNumberToNameMap: {}
|
tileNumberToNameMap: {},
|
||||||
|
extraFields: {},
|
||||||
|
genver: 4
|
||||||
|
comp: 1
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -78,8 +81,14 @@ The fields are auto-generated by GDX's JSON serialiser.
|
|||||||
The fields are auto-generated by GDX's JSON serialiser.
|
The fields are auto-generated by GDX's JSON serialiser.
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
[
|
||||||
<actor id>: { actor serialised in JSON },
|
{ /* actor serialised in JSON *
|
||||||
|
class: "net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer", /* depends on the actor */
|
||||||
|
referenceID: 1342111743,
|
||||||
|
actorValue: { /* actorValue serialised in JSON */ },
|
||||||
|
hitbox: ...,
|
||||||
|
...
|
||||||
|
},
|
||||||
...
|
...
|
||||||
}
|
]
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user