mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-09-21 06:13:49 -04:00
Merge pull request #634 from madsboddum/infinite_combat_duel
Removed a feature in CombatStatusService that intentionally locked co…
This commit is contained in:
+1
-32
@@ -2,7 +2,6 @@ package com.projectswg.holocore.services.gameplay.combat
|
||||
|
||||
import com.projectswg.holocore.intents.gameplay.combat.EnterCombatIntent
|
||||
import com.projectswg.holocore.intents.gameplay.combat.ExitCombatIntent
|
||||
import com.projectswg.holocore.intents.gameplay.combat.duel.DuelPlayerIntent
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject
|
||||
import com.projectswg.holocore.services.support.objects.ObjectStorageService.ObjectLookup
|
||||
import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool
|
||||
@@ -14,12 +13,10 @@ import java.util.stream.Collectors
|
||||
class CombatStatusService : Service() {
|
||||
|
||||
private val inCombat: MutableSet<CreatureObject>
|
||||
private val duels: MutableSet<DuelInstance>
|
||||
private val executor: ScheduledThreadPool
|
||||
|
||||
init {
|
||||
this.inCombat = ConcurrentHashMap.newKeySet()
|
||||
this.duels = ConcurrentHashMap.newKeySet()
|
||||
this.executor = ScheduledThreadPool(1, 3, "combat-status-service")
|
||||
}
|
||||
|
||||
@@ -37,7 +34,7 @@ class CombatStatusService : Service() {
|
||||
|
||||
private fun periodicCombatStatusChecks() {
|
||||
for (creature in inCombat) {
|
||||
if (creature.timeSinceLastCombat >= 10E3 && !isDueling(creature))
|
||||
if (creature.timeSinceLastCombat >= 10E3)
|
||||
ExitCombatIntent.broadcast(creature)
|
||||
}
|
||||
}
|
||||
@@ -74,33 +71,5 @@ class CombatStatusService : Service() {
|
||||
source.isInCombat = false
|
||||
inCombat.remove(source)
|
||||
}
|
||||
|
||||
@IntentHandler
|
||||
private fun handleDuelPlayerIntent(dpi: DuelPlayerIntent) {
|
||||
when (dpi.eventType) {
|
||||
DuelPlayerIntent.DuelEventType.ACCEPT -> {
|
||||
val duel = if (dpi.sender.objectId < dpi.reciever.objectId) DuelInstance(dpi.sender, dpi.reciever) else DuelInstance(dpi.reciever, dpi.sender)
|
||||
duels.add(duel)
|
||||
}
|
||||
DuelPlayerIntent.DuelEventType.END -> {
|
||||
duels.remove(if (dpi.sender.objectId < dpi.reciever.objectId) DuelInstance(dpi.sender, dpi.reciever) else DuelInstance(dpi.reciever, dpi.sender))
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDueling(player: CreatureObject): Boolean {
|
||||
for (duel in duels) {
|
||||
if ((duel.playerA == player || duel.playerB == player) && duel.isDueling)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
data class DuelInstance(val playerA: CreatureObject, val playerB: CreatureObject) {
|
||||
|
||||
val isDueling: Boolean
|
||||
get() = playerA.isDuelingPlayer(playerB)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user