mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-15 08:24:39 +00:00
corpse remvoal should now remove corpses
This commit is contained in:
parent
a3f50cc8a4
commit
54e2e37b54
1 changed files with 30 additions and 24 deletions
|
|
@ -51,7 +51,8 @@ class CorpseRemovalActor extends Actor {
|
||||||
|
|
||||||
def Processing : Receive = {
|
def Processing : Receive = {
|
||||||
case CorpseRemovalActor.AddCorpse(corpse, zone, time) =>
|
case CorpseRemovalActor.AddCorpse(corpse, zone, time) =>
|
||||||
if(corpse.isBackpack && !buriedCorpses.exists(_.corpse == corpse)) {
|
import CorpseRemovalActor.SimilarCorpses
|
||||||
|
if(corpse.isBackpack && !buriedCorpses.exists(entry => SimilarCorpses(entry.corpse, corpse) )) {
|
||||||
if(corpses.isEmpty) {
|
if(corpses.isEmpty) {
|
||||||
//we were the only entry so the event must be started from scratch
|
//we were the only entry so the event must be started from scratch
|
||||||
corpses = List(CorpseRemovalActor.Entry(corpse, zone, time))
|
corpses = List(CorpseRemovalActor.Entry(corpse, zone, time))
|
||||||
|
|
@ -60,7 +61,7 @@ class CorpseRemovalActor extends Actor {
|
||||||
else {
|
else {
|
||||||
//unknown number of entries; append, sort, then re-time tasking
|
//unknown number of entries; append, sort, then re-time tasking
|
||||||
val oldHead = corpses.head
|
val oldHead = corpses.head
|
||||||
if(!corpses.exists(_.corpse == corpse)) {
|
if(!corpses.exists(entry => SimilarCorpses(entry.corpse, corpse))) {
|
||||||
corpses = (corpses :+ CorpseRemovalActor.Entry(corpse, zone, time)).sortBy(_.timeAlive)
|
corpses = (corpses :+ CorpseRemovalActor.Entry(corpse, zone, time)).sortBy(_.timeAlive)
|
||||||
if(oldHead != corpses.head) {
|
if(oldHead != corpses.head) {
|
||||||
RetimeFirstTask()
|
RetimeFirstTask()
|
||||||
|
|
@ -80,45 +81,44 @@ class CorpseRemovalActor extends Actor {
|
||||||
if(targets.size == 1) {
|
if(targets.size == 1) {
|
||||||
log.debug(s"a target corpse submitted for early cleanup: ${targets.head}")
|
log.debug(s"a target corpse submitted for early cleanup: ${targets.head}")
|
||||||
//simple selection
|
//simple selection
|
||||||
CorpseRemovalActor.recursiveFindCorpse(corpses.iterator, targets.head) match {
|
CorpseRemovalActor.recursiveFindCorpse(corpses.iterator, targets.head) match {
|
||||||
case None => ;
|
case None => ;
|
||||||
case Some(index) =>
|
case Some(index) =>
|
||||||
decomposition.cancel
|
decomposition.cancel
|
||||||
BurialTask(corpses(index))
|
BurialTask(corpses(index))
|
||||||
buriedCorpses = buriedCorpses :+ corpses(index)
|
buriedCorpses = buriedCorpses :+ corpses(index)
|
||||||
corpses = corpses.take(index) ++ corpses.drop(index+1)
|
corpses = (corpses.take(index) ++ corpses.drop(index + 1)).sortBy(_.timeAlive)
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
decomposition = context.system.scheduler.scheduleOnce(500 milliseconds, self, CorpseRemovalActor.TryDelete())
|
decomposition = context.system.scheduler.scheduleOnce(500 milliseconds, self, CorpseRemovalActor.TryDelete())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debug(s"multiple target corpses submitted for early cleanup: $targets")
|
log.debug(s"multiple target corpses submitted for early cleanup: $targets")
|
||||||
|
import CorpseRemovalActor.SimilarCorpses
|
||||||
decomposition.cancel
|
decomposition.cancel
|
||||||
//cumbersome partition
|
//cumbersome partition
|
||||||
//a - find targets from corpses
|
//a - find targets from corpses
|
||||||
val locatedTargets = for {
|
val locatedTargets = for {
|
||||||
a <- targets
|
a <- targets
|
||||||
b <- corpses
|
b <- corpses
|
||||||
if b.corpse == a &&
|
if b.corpse.HasGUID && a.HasGUID && SimilarCorpses(b.corpse, a)
|
||||||
b.corpse.Continent.equals(a.Continent) &&
|
|
||||||
b.corpse.HasGUID && a.HasGUID && b.corpse.GUID == a.GUID
|
|
||||||
} yield b
|
} yield b
|
||||||
locatedTargets.foreach { BurialTask }
|
if(locatedTargets.nonEmpty) {
|
||||||
buriedCorpses = locatedTargets ++ buriedCorpses
|
decomposition.cancel
|
||||||
//b - corpses, after the found targets are removed (cull any non-GUID entries while at it)
|
locatedTargets.foreach { BurialTask }
|
||||||
corpses = (for {
|
buriedCorpses = locatedTargets ++ buriedCorpses
|
||||||
a <- locatedTargets.map { _.corpse }
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
b <- corpses
|
decomposition = context.system.scheduler.scheduleOnce(500 milliseconds, self, CorpseRemovalActor.TryDelete())
|
||||||
if b.corpse.HasGUID && a.HasGUID &&
|
//b - corpses, after the found targets are removed (cull any non-GUID entries while at it)
|
||||||
(b.corpse != a ||
|
corpses = (for {
|
||||||
!b.corpse.Continent.equals(a.Continent) ||
|
a <- locatedTargets
|
||||||
!b.corpse.HasGUID || !a.HasGUID || b.corpse.GUID != a.GUID)
|
b <- corpses
|
||||||
} yield b).sortBy(_.timeAlive)
|
if b.corpse.HasGUID && a.corpse.HasGUID && !SimilarCorpses(b.corpse, a.corpse)
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
} yield b).sortBy(_.timeAlive)
|
||||||
decomposition = context.system.scheduler.scheduleOnce(500 milliseconds, self, CorpseRemovalActor.TryDelete())
|
}
|
||||||
}
|
|
||||||
RetimeFirstTask()
|
|
||||||
}
|
}
|
||||||
|
RetimeFirstTask()
|
||||||
|
}
|
||||||
|
|
||||||
case CorpseRemovalActor.StartDelete() =>
|
case CorpseRemovalActor.StartDelete() =>
|
||||||
burial.cancel
|
burial.cancel
|
||||||
|
|
@ -136,7 +136,9 @@ class CorpseRemovalActor extends Actor {
|
||||||
|
|
||||||
case CorpseRemovalActor.TryDelete() =>
|
case CorpseRemovalActor.TryDelete() =>
|
||||||
decomposition.cancel
|
decomposition.cancel
|
||||||
val (decomposed, rotting) = buriedCorpses.partition(entry => { !entry.zone.Corpses.contains(entry.corpse) })
|
val (decomposed, rotting) = buriedCorpses.partition(entry => {
|
||||||
|
!entry.zone.Corpses.contains(entry.corpse)
|
||||||
|
})
|
||||||
buriedCorpses = rotting
|
buriedCorpses = rotting
|
||||||
decomposed.foreach { LastRitesTask }
|
decomposed.foreach { LastRitesTask }
|
||||||
if(rotting.nonEmpty) {
|
if(rotting.nonEmpty) {
|
||||||
|
|
@ -214,6 +216,10 @@ object CorpseRemovalActor {
|
||||||
|
|
||||||
private final case class TryDelete()
|
private final case class TryDelete()
|
||||||
|
|
||||||
|
private def SimilarCorpses(obj1 : Player, obj2 : Player) : Boolean = {
|
||||||
|
obj1 == obj2 && obj1.Continent.equals(obj2.Continent) && obj1.GUID == obj2.GUID
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A recursive function that finds and removes a specific player from a list of players.
|
* A recursive function that finds and removes a specific player from a list of players.
|
||||||
* @param iter an `Iterator` of `CorpseRemovalActor.Entry` objects
|
* @param iter an `Iterator` of `CorpseRemovalActor.Entry` objects
|
||||||
|
|
@ -228,7 +234,7 @@ object CorpseRemovalActor {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val corpse = iter.next.corpse
|
val corpse = iter.next.corpse
|
||||||
if(corpse == player && corpse.Continent.equals(player.Continent) && corpse.GUID == player.GUID) {
|
if(corpse.HasGUID && player.HasGUID && SimilarCorpses(corpse, player)) {
|
||||||
Some(index)
|
Some(index)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue