mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 05:24: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,13 +1,21 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.Game
|
||||
import com.sun.javaws.exceptions.InvalidArgumentException
|
||||
import net.torvald.imagefont.GameFontBase
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
*/
|
||||
class GetAV : ConsoleCommand {
|
||||
|
||||
val ccW = GameFontBase.colToCode["w"]
|
||||
val ccG = GameFontBase.colToCode["g"]
|
||||
val ccY = GameFontBase.colToCode["y"]
|
||||
val ccM = GameFontBase.colToCode["m"]
|
||||
val ccK = GameFontBase.colToCode["k"]
|
||||
val ccO = GameFontBase.colToCode["o"]
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
|
||||
@@ -17,8 +25,12 @@ class GetAV : ConsoleCommand {
|
||||
val av = Terrarum.game.player.actorValue
|
||||
val keyset = av.keySet
|
||||
|
||||
echo.execute("== ActorValue list for player ==")
|
||||
keyset.forEach { elem -> echo.execute("$elem = ${av[elem as String]}") }
|
||||
echo.execute("$ccW== ActorValue list for ${ccY}player $ccW==")
|
||||
println("[GetAV] == ActorValue list for 'player' ==")
|
||||
keyset.forEach { elem ->
|
||||
echo.execute("$ccM$elem $ccW= $ccG${av[elem as String]}")
|
||||
println("[GetAV] $elem = ${av[elem]}")
|
||||
}
|
||||
}
|
||||
else if (args.size != 3 && args.size != 2) {
|
||||
printUsage()
|
||||
@@ -26,50 +38,69 @@ class GetAV : ConsoleCommand {
|
||||
else if (args.size == 2) {
|
||||
// check if args[1] is number or not
|
||||
if (!args[1].isNum()) { // args[1] is ActorValue name
|
||||
echo.execute("player.${args[1]} = "
|
||||
+ Terrarum.game.player.actorValue[args[1]]
|
||||
+ " ("
|
||||
+ Terrarum.game.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||
+ ")"
|
||||
echo.execute("${ccW}player.$ccM${args[1]} $ccW= " +
|
||||
ccG +
|
||||
Terrarum.game.player.actorValue[args[1]] +
|
||||
" $ccO" +
|
||||
Terrarum.game.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||
)
|
||||
println("[GetAV] player.${args[1]} = " +
|
||||
Terrarum.game.player.actorValue[args[1]] +
|
||||
" " +
|
||||
Terrarum.game.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||
)
|
||||
}
|
||||
else { // args[1] is actor ID
|
||||
val av = Terrarum.game.getActor(args[1].toInt()).actorValue
|
||||
else {
|
||||
// args[1] is actor ID
|
||||
val actor = Terrarum.game.getActor(args[1].toInt())
|
||||
val av = actor.actorValue
|
||||
val keyset = av.keySet
|
||||
|
||||
echo.execute("== ActorValue list for ${args[1].toInt()} ==")
|
||||
if (keyset.size == 0)
|
||||
echo.execute("(nothing)")
|
||||
else
|
||||
keyset.forEach { elem -> echo.execute("$elem = ${av[elem as String]}") }
|
||||
echo.execute("$ccW== ActorValue list for $ccY$actor $ccW==")
|
||||
println("[GetAV] == ActorValue list for '$actor' ==")
|
||||
if (keyset.size == 0) {
|
||||
echo.execute("$ccK(nothing)")
|
||||
println("[GetAV] (nothing)")
|
||||
}
|
||||
else {
|
||||
keyset.forEach { elem ->
|
||||
echo.execute("$ccM$elem $ccW= $ccG${av[elem as String]}")
|
||||
println("[GetAV] $elem = ${av[elem]}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.size == 3) {
|
||||
val id = args[1].toInt()
|
||||
val av = args[2]
|
||||
echo.execute("$id.$av = " +
|
||||
echo.execute("$ccW$id.$ccM$av $ccW= $ccG" +
|
||||
Terrarum.game.getActor(id).actorValue[av] +
|
||||
" (" +
|
||||
Terrarum.game.getActor(id).actorValue[av]!!.javaClass.simpleName +
|
||||
")"
|
||||
" $ccO" +
|
||||
Terrarum.game.getActor(id).actorValue[av]!!.javaClass.simpleName
|
||||
)
|
||||
println("id.av = " +
|
||||
Terrarum.game.getActor(id).actorValue[av] +
|
||||
" " +
|
||||
Terrarum.game.getActor(id).actorValue[av]!!.javaClass.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
if (args.size == 2) {
|
||||
echo.error(args[1] + ": actor value does not exist.")
|
||||
System.err.println("[GetAV] ${args[1]}: actor value does not exist.")
|
||||
}
|
||||
else if (args.size == 3) {
|
||||
echo.error(args[2] + ": actor value does not exist.")
|
||||
System.err.println("[GetAV] ${args[2]}: actor value does not exist.")
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
catch (e1: IllegalArgumentException) {
|
||||
if (args.size == 3) {
|
||||
echo.error(args[1] + ": no actor with this ID.")
|
||||
}
|
||||
echo.error("${args[1]}: no actor with this ID.")
|
||||
System.err.println("[GetAV] ${args[1]}: no actor with this ID.")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -86,8 +117,8 @@ class GetAV : ConsoleCommand {
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("Get desired actor value of specific target.")
|
||||
echo.execute("Usage: getav (id) <av>")
|
||||
echo.execute("blank ID for player")
|
||||
echo.execute("${ccW}Get desired ActorValue of specific target.")
|
||||
echo.execute("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>")
|
||||
echo.execute("${ccW}blank ID for player")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user