actorwithbody splitted in favour of new particle type

Former-commit-id: 121bd069d0a9eeef60f5ecb085a11a93c4b4a84d
Former-commit-id: 539b4b6916e808c01298190cf347e928f61fe62e
This commit is contained in:
Song Minjae
2017-01-21 16:52:16 +09:00
parent 5db3aadaf4
commit 4acc797fee
49 changed files with 752 additions and 428 deletions

View File

@@ -41,6 +41,7 @@ object CommandDict {
Pair("inventory", Inventory),
Pair("avtracker", AVTracker),
Pair("actorslist", ActorsList),
Pair("setscale", SetScale),
// Test codes
Pair("bulletintest", SetBulletin),

View 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")
}
}

View File

@@ -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

View File

@@ -20,6 +20,6 @@ object SpawnTapestry : ConsoleCommand {
}
override fun printUsage() {
println("Usage: spawntapestry <tapestry_file>")
Echo("Usage: spawntapestry <tapestry_file>")
}
}

View 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) {