getActorByID now searches for inactive actors

Former-commit-id: 1828e2819bc5575d590e51b616415c91645cad56
Former-commit-id: 5b470d524401135358f9926587651ae932d4d5e9
This commit is contained in:
Song Minjae
2016-12-30 23:28:44 +09:00
parent da06e0fa93
commit d1f01a203d
2 changed files with 28 additions and 24 deletions

View File

@@ -213,9 +213,9 @@ constructor() : BasicGameState() {
///////////////////////////
repossessActor()
// determine whether the inactive actor should be re-active
// determine whether the inactive actor should be activated
wakeDormantActors()
// determine whether the actor should be active or dormant
// determine whether the actor should keep being activated or be dormant
KillOrKnockdownActors()
updateActors(gc, delta)
// TODO thread pool(?)
@@ -624,11 +624,18 @@ constructor() : BasicGameState() {
val DEBUG_ARRAY = false
fun getActorByID(ID: Int): Actor {
if (actorContainer.size == 0) throw IllegalArgumentException("Actor with ID $ID does not exist.")
val index = actorContainer.binarySearch(ID)
if (index < 0)
if (actorContainer.size == 0 && actorContainerInactive.size == 0)
throw IllegalArgumentException("Actor with ID $ID does not exist.")
var index = actorContainer.binarySearch(ID)
if (index < 0) {
index = actorContainerInactive.binarySearch(ID)
if (index < 0)
throw IllegalArgumentException("Actor with ID $ID does not exist.")
else
return actorContainerInactive[index]
}
else
return actorContainer[index]
}