mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
actors are now active/dormant depending on the distance to the player, only the active actors are to be updated. Actors outside of the camera (actually a distance to the player) are not rendered
Former-commit-id: 5f80c2ef3592aab5567723087c264e05458e98b3 Former-commit-id: 7714c6f5a6d7a48d4f5adfe8f6990b249bdb80b0
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.imagefont.GameFontBase
|
||||
import net.torvald.terrarum.Game
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
@@ -8,18 +9,23 @@ import net.torvald.terrarum.Terrarum
|
||||
*/
|
||||
internal class SetAV : ConsoleCommand {
|
||||
|
||||
val ccW = GameFontBase.colToCode["w"]
|
||||
val ccG = GameFontBase.colToCode["g"]
|
||||
val ccY = GameFontBase.colToCode["y"]
|
||||
val ccR = GameFontBase.colToCode["r"]
|
||||
val ccM = GameFontBase.colToCode["m"]
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("Set actor value of specific target to desired value.")
|
||||
echo.execute("Usage: setav (id) <av> <val>")
|
||||
echo.execute("blank ID for player")
|
||||
echo.execute("Contaminated (float -> string) actor value will crash the game,")
|
||||
echo.execute(" so make it sure before you issue the command.")
|
||||
echo.execute("Use '__true' and '__false' for boolean value.")
|
||||
echo.execute("${ccW}Set actor value of specific target to desired value.")
|
||||
echo.execute("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>")
|
||||
echo.execute("${ccW}blank ID for player")
|
||||
echo.execute("${ccR}Contaminated (float -> string) ActorValue will crash the game,")
|
||||
echo.execute("${ccR}so make sure it will not happen before you issue the command!")
|
||||
echo.execute("${ccW}Use ${ccG}__true ${ccW}and ${ccG}__false ${ccW}for boolean value.")
|
||||
}
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
fun parseAVInput(arg: String): Any {
|
||||
val `val`: Any
|
||||
|
||||
@@ -58,30 +64,37 @@ internal class SetAV : ConsoleCommand {
|
||||
|
||||
// check if av is number
|
||||
if (args[1].isNum()) {
|
||||
echo.error("Illegal ActorValue “${args[1]}”: ActorValue cannot be a number.")
|
||||
echo.error("Illegal ActorValue ${args[1]}: ActorValue cannot be a number.")
|
||||
System.err.println("[SetAV] Illegal ActorValue ${args[1]}: ActorValue cannot be a number.")
|
||||
return
|
||||
}
|
||||
|
||||
Terrarum.game.player.actorValue[args[1]] = `val`
|
||||
echo.execute("Set ${args[1]} to $`val`")
|
||||
echo.execute("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$`val`")
|
||||
println("[SetAV] set ActorValue '${args[1]}' for player to '$`val`'.")
|
||||
}
|
||||
else if (args.size == 4) {
|
||||
try {
|
||||
val id = args[1].toInt()
|
||||
val `val` = parseAVInput(args[3])
|
||||
val actor = Terrarum.game.getActor(id)
|
||||
|
||||
// check if av is number
|
||||
if (args[2].isNum()) {
|
||||
echo.error("Illegal ActorValue “${args[2]}”: ActorValue cannot be a number.")
|
||||
echo.error("Illegal ActorValue ${args[2]}: ActorValue cannot be a number.")
|
||||
System.err.println("[SetAV] Illegal ActorValue ${args[2]}: ActorValue cannot be a number.")
|
||||
return
|
||||
}
|
||||
|
||||
Terrarum.game.getActor(id).actorValue[args[2]] = `val`
|
||||
echo.execute("Set ${args[2]} of $id to $`val`")
|
||||
actor.actorValue[args[2]] = `val`
|
||||
echo.execute("${ccW}Set $ccM${args[2]} ${ccW}for $ccY$id ${ccW}to $ccG$`val`")
|
||||
println("[SetAV] set ActorValue '${args[2]}' for $actor to '$`val`'.")
|
||||
}
|
||||
catch (e: IllegalArgumentException) {
|
||||
if (args.size == 4)
|
||||
echo.error(args[1] + ": no actor with this ID.")
|
||||
if (args.size == 4) {
|
||||
echo.error("${args[1]}: no actor with this ID.")
|
||||
System.err.println("[SetAV] ${args[1]}: no actor with this ID.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user