mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 13:04:05 +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,47 +1,113 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.imagefont.GameFontBase
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
import java.util.HashSet
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.Factionable
|
||||
import net.torvald.terrarum.gameactors.Player
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-17.
|
||||
*/
|
||||
class GetFactioning : 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 ccB = GameFontBase.colToCode["b"]
|
||||
|
||||
private val PRINT_INDENTATION = " --> "
|
||||
private val PRINT_INDENTATION = "$ccK --> $ccW"
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
|
||||
if (args.size == 1) {
|
||||
// get all factioning data of player
|
||||
val factionSet = Terrarum.game.player.faction
|
||||
fun printOutFactioning(id: Int) {
|
||||
val a = Terrarum.game.getActor(id)
|
||||
if (a is Factionable) {
|
||||
echo.execute("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
|
||||
println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==")
|
||||
|
||||
if (factionSet.isEmpty()) {
|
||||
echo.execute("The actor has empty faction set.")
|
||||
// get all factioning data of player
|
||||
val factionSet = a.faction
|
||||
|
||||
if (factionSet.isEmpty()) {
|
||||
echo.execute("The actor has empty faction set.")
|
||||
println("[GetFactioning] The actor has empty faction set.")
|
||||
return
|
||||
}
|
||||
|
||||
val count = factionSet.size
|
||||
echo.execute("$ccG${count.toString()} $ccW${Lang.pluralise(" faction", count)} assigned.")
|
||||
println("[GetFactioning] ${count.toString()} ${Lang.pluralise(" faction", count)} assigned.")
|
||||
|
||||
for (faction in factionSet) {
|
||||
echo.execute("${ccW}faction $ccM${faction.factionName}")
|
||||
println("[GetFactioning] faction '${faction.factionName}'")
|
||||
echo.execute("$ccY Amicable")
|
||||
println("[GetFactioning] Amicable")
|
||||
faction.factionAmicable.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
|
||||
echo.execute("$ccY Explicit neutral")
|
||||
println("[GetFactioning] Explicit neutral")
|
||||
faction.factionNeutral.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
|
||||
echo.execute("$ccY Hostile")
|
||||
println("[GetFactioning] Hostile")
|
||||
faction.factionHostile.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
|
||||
echo.execute("$ccY Fearful")
|
||||
println("[GetFactioning] Fearful")
|
||||
faction.factionFearful.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo.error("The actor is not factionable.")
|
||||
System.err.println("[GetFactioning] The actor is not factionable.")
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size == 1) {
|
||||
printOutFactioning(Player.PLAYER_REF_ID)
|
||||
}
|
||||
else {
|
||||
if (!args[1].isNum()) {
|
||||
echo.error("Invalid actor ID input.")
|
||||
System.err.println("[GetFactioning] Invalid actor ID input.")
|
||||
return
|
||||
}
|
||||
|
||||
val count = factionSet.size
|
||||
echo.execute(count.toString() + Lang.pluralise(" faction", count) + " assigned.")
|
||||
|
||||
for (faction in factionSet) {
|
||||
echo.execute("faction “${faction.factionName}”")
|
||||
echo.execute(" Amicable")
|
||||
faction.factionAmicable.forEach { s -> echo.execute(PRINT_INDENTATION + s) }
|
||||
|
||||
echo.execute(" Explicit neutral")
|
||||
faction.factionNeutral.forEach { s -> echo.execute(PRINT_INDENTATION + s) }
|
||||
|
||||
echo.execute(" Hostile")
|
||||
faction.factionHostile.forEach { s -> echo.execute(PRINT_INDENTATION + s) }
|
||||
|
||||
echo.execute(" Fearful")
|
||||
faction.factionFearful.forEach { s -> echo.execute(PRINT_INDENTATION + s) }
|
||||
try {
|
||||
val actorID = args[1].toInt()
|
||||
printOutFactioning(actorID)
|
||||
}
|
||||
catch (e: IllegalArgumentException) {
|
||||
echo.error("${args[1]}: no actor with this ID.")
|
||||
System.err.println("[GetFactioning] ${args[1]}: no actor with this ID.")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun String.isNum(): Boolean {
|
||||
try {
|
||||
this.toInt()
|
||||
return true
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user