mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
actorwithbody splitted in favour of new particle type
Former-commit-id: 121bd069d0a9eeef60f5ecb085a11a93c4b4a84d Former-commit-id: 539b4b6916e808c01298190cf347e928f61fe62e
This commit is contained in:
@@ -41,6 +41,7 @@ object CommandDict {
|
||||
Pair("inventory", Inventory),
|
||||
Pair("avtracker", AVTracker),
|
||||
Pair("actorslist", ActorsList),
|
||||
Pair("setscale", SetScale),
|
||||
|
||||
// Test codes
|
||||
Pair("bulletintest", SetBulletin),
|
||||
|
||||
35
src/net/torvald/terrarum/console/SetScale.kt
Normal file
35
src/net/torvald/terrarum/console/SetScale.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithSprite
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-01-20.
|
||||
*/
|
||||
object SetScale : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2 || args.size == 3) {
|
||||
try {
|
||||
val targetID = if (args.size == 3) args[1].toInt() else Terrarum.ingame.player.referenceID
|
||||
val scale = args[if (args.size == 3) 2 else 1].toDouble()
|
||||
|
||||
val target = Terrarum.ingame.getActorByID(targetID)
|
||||
|
||||
if (target !is ActorWithSprite) {
|
||||
EchoError("Target is not ActorWithSprite")
|
||||
}
|
||||
else {
|
||||
target.scale = scale
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
EchoError("Wrong number input")
|
||||
}
|
||||
}
|
||||
else printUsage()
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Usage: setscale scale | setscale actorID scale")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ActorWithSprite
|
||||
import net.torvald.terrarum.gameactors.PhysTestBall
|
||||
import net.torvald.terrarum.mapdrawer.TilesDrawer
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
@@ -20,6 +20,6 @@ object SpawnTapestry : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
println("Usage: spawntapestry <tapestry_file>")
|
||||
Echo("Usage: spawntapestry <tapestry_file>")
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.console
|
||||
import net.torvald.terrarum.StateInGame
|
||||
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ActorWithSprite
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-24.
|
||||
@@ -31,8 +31,8 @@ internal object Teleport : ConsoleCommand {
|
||||
EchoError("missing 'to' on teleport command")
|
||||
return
|
||||
}
|
||||
val fromActor: ActorWithBody
|
||||
val targetActor: ActorWithBody
|
||||
val fromActor: ActorWithSprite
|
||||
val targetActor: ActorWithSprite
|
||||
try {
|
||||
val fromActorID = args[1].toInt()
|
||||
val targetActorID = if (args[3].toLowerCase() == "player")
|
||||
@@ -43,13 +43,13 @@ internal object Teleport : ConsoleCommand {
|
||||
// if from == target, ignore the action
|
||||
if (fromActorID == targetActorID) return
|
||||
|
||||
if (Terrarum.ingame.getActorByID(fromActorID) !is ActorWithBody ||
|
||||
Terrarum.ingame.getActorByID(targetActorID) !is ActorWithBody) {
|
||||
if (Terrarum.ingame.getActorByID(fromActorID) !is ActorWithSprite ||
|
||||
Terrarum.ingame.getActorByID(targetActorID) !is ActorWithSprite) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
fromActor = Terrarum.ingame.getActorByID(fromActorID) as ActorWithBody
|
||||
targetActor = Terrarum.ingame.getActorByID(targetActorID) as ActorWithBody
|
||||
fromActor = Terrarum.ingame.getActorByID(fromActorID) as ActorWithSprite
|
||||
targetActor = Terrarum.ingame.getActorByID(targetActorID) as ActorWithSprite
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
@@ -72,7 +72,7 @@ internal object Teleport : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
val actor: ActorWithBody
|
||||
val actor: ActorWithSprite
|
||||
val x: Int
|
||||
val y: Int
|
||||
try {
|
||||
@@ -80,11 +80,11 @@ internal object Teleport : ConsoleCommand {
|
||||
y = args[4].toInt() * FeaturesDrawer.TILE_SIZE + FeaturesDrawer.TILE_SIZE / 2
|
||||
val actorID = args[1].toInt()
|
||||
|
||||
if (Terrarum.ingame.getActorByID(actorID) !is ActorWithBody) {
|
||||
if (Terrarum.ingame.getActorByID(actorID) !is ActorWithSprite) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
actor = Terrarum.ingame.getActorByID(actorID) as ActorWithBody
|
||||
actor = Terrarum.ingame.getActorByID(actorID) as ActorWithSprite
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
|
||||
Reference in New Issue
Block a user