mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-07-16 08:55:18 +00:00
renaming methods; progress bar calculations change
This commit is contained in:
parent
7caa64d5df
commit
48a1e130da
2 changed files with 35 additions and 38 deletions
|
|
@ -1477,7 +1477,7 @@ class AvatarActor(
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case SetImplantInitialized(implantType) =>
|
case SetImplantInitialized(implantType) =>
|
||||||
setImplantInitialized(implantType)
|
actuallyInitializeImplant(implantType)
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case ActivateImplant(implantType) =>
|
case ActivateImplant(implantType) =>
|
||||||
|
|
@ -1493,7 +1493,7 @@ class AvatarActor(
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case InitializeImplants =>
|
case InitializeImplants =>
|
||||||
initializeImplants()
|
startInitializeImplants()
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case DeinitializeImplants =>
|
case DeinitializeImplants =>
|
||||||
|
|
@ -1501,7 +1501,7 @@ class AvatarActor(
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case ResetImplant(implantType) =>
|
case ResetImplant(implantType) =>
|
||||||
reinitializeImplant(implantType)
|
startReinitializeImplant(implantType)
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case SoftResetImplants =>
|
case SoftResetImplants =>
|
||||||
|
|
@ -3287,7 +3287,7 @@ class AvatarActor(
|
||||||
)
|
)
|
||||||
findImplantByType(definition.implantType).foreach {
|
findImplantByType(definition.implantType).foreach {
|
||||||
case (implant, slot) =>
|
case (implant, slot) =>
|
||||||
updateAvatarForImplant(implant, slot, initializeImplant(AvatarActor.initializationTime(implant)))
|
updateAvatarForImplant(implant, slot, startInitializeImplant(AvatarActor.initializationTime(implant)))
|
||||||
}
|
}
|
||||||
sessionActor ! SessionActor.CharSaved
|
sessionActor ! SessionActor.CharSaved
|
||||||
case _ =>
|
case _ =>
|
||||||
|
|
@ -3391,7 +3391,7 @@ class AvatarActor(
|
||||||
avatarCopy(avatar.copy(implants = avatar.implants.updated(slot, None)))
|
avatarCopy(avatar.copy(implants = avatar.implants.updated(slot, None)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private def initializeImplants(): Unit = {
|
private def startInitializeImplants(): Unit = {
|
||||||
avatar.implants.zipWithIndex.foreach {
|
avatar.implants.zipWithIndex.foreach {
|
||||||
case (Some(implant), slot) =>
|
case (Some(implant), slot) =>
|
||||||
// TODO if this implant is Installed but does not have shortcut, add to a free slot or write over slot 61/62/63
|
// TODO if this implant is Installed but does not have shortcut, add to a free slot or write over slot 61/62/63
|
||||||
|
|
@ -3403,57 +3403,54 @@ class AvatarActor(
|
||||||
Some(implant.definition.implantType.shortcut)
|
Some(implant.definition.implantType.shortcut)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
initializeImplant(AvatarActor.initializationTime(implant))(implant, slot)
|
startInitializeImplant(AvatarActor.initializationTime(implant))(implant, slot)
|
||||||
case (None, _) => ()
|
case (None, _) => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def reinitializeImplant(implantType: ImplantType): Unit = {
|
private def startReinitializeImplant(implantType: ImplantType): Unit = {
|
||||||
findImplantByType(implantType).collect {
|
findImplantByType(implantType).collect {
|
||||||
case (implant, slot) if implant.active =>
|
case (implant, slot) if implant.active =>
|
||||||
updateAvatarForImplant(deactivateImplant(implant, slot), slot, reinitializeImplant)
|
updateAvatarForImplant(deactivateImplant(implant, slot), slot, startReinitializeImplant)
|
||||||
case (implant, slot) =>
|
case (implant, slot) =>
|
||||||
updateAvatarForImplant(implant, slot, reinitializeImplant)
|
updateAvatarForImplant(implant, slot, startReinitializeImplant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def reinitializeImplant(implant: Implant, slot: Int): Implant = {
|
private def startReinitializeImplant(implant: Implant, slot: Int): Implant = {
|
||||||
//deinitialize
|
//deinitialize
|
||||||
session.get.zone.AvatarEvents ! AvatarServiceMessage(
|
session.get.zone.AvatarEvents ! AvatarServiceMessage(
|
||||||
session.get.zone.id,
|
session.get.zone.id,
|
||||||
AvatarAction.AvatarImplant(session.get.player.GUID, ImplantAction.Initialization, slot, 0)
|
AvatarAction.AvatarImplant(session.get.player.GUID, ImplantAction.Initialization, slot, 0)
|
||||||
)
|
)
|
||||||
initializeImplant(AvatarActor.initializationTime(implant))(implant, slot)
|
startInitializeImplant(AvatarActor.initializationTime(implant))(implant, slot)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def initializeImplant(delay: FiniteDuration)(implant: Implant, slot: Int): Implant = {
|
private def startInitializeImplant(delay: FiniteDuration)(implant: Implant, slot: Int): Implant = {
|
||||||
val curr = System.currentTimeMillis()
|
if (implantTimers.lift(slot).exists(_.isCancelled)) {
|
||||||
val implantTimer = implant.timer
|
val curr = System.currentTimeMillis()
|
||||||
val (actualDelay, futureDelay, actionProgress): (FiniteDuration, Long, Long) = if (
|
val implantTimer = implant.timer
|
||||||
implantTimer > 0 &&
|
val (actualDelay, futureDelay, actionProgress): (FiniteDuration, Long, Long) = if (implantTimer > curr) {
|
||||||
implantTimers.lift(slot).exists(_.isCancelled)
|
val countedDelay = math.max(0L, (implantTimer - curr) / 1000L)
|
||||||
) {
|
val fullNormalDelay = implant.definition.InitializationDuration.toFloat
|
||||||
val countedDelay = math.max(0L, (implantTimer - curr) / 1000L)
|
val progress = (100f * ((fullNormalDelay - countedDelay.toFloat) / fullNormalDelay)).toLong
|
||||||
val fullNormalDelay = implant.definition.InitializationDuration
|
(countedDelay.seconds, implantTimer, progress)
|
||||||
val progress = if (countedDelay > fullNormalDelay) {
|
|
||||||
0L
|
|
||||||
} else {
|
} else {
|
||||||
(100f * ((fullNormalDelay - countedDelay).toFloat / fullNormalDelay.toFloat)).toLong
|
(delay, curr + delay.toMillis, 0L)
|
||||||
}
|
}
|
||||||
(countedDelay.seconds, implantTimer, progress)
|
//start initialization process
|
||||||
|
setImplantInitializedTimer(implant, slot, actualDelay)
|
||||||
|
// Start client-side initialization timer, visible on the character screen
|
||||||
|
// Progress accumulates according to the client's knowledge of the implant initialization time
|
||||||
|
// What is normally a 60s timer that is set to 120s on the server will still visually update as if 60s
|
||||||
|
session.get.zone.AvatarEvents ! AvatarServiceMessage(
|
||||||
|
avatar.name,
|
||||||
|
AvatarAction.SendResponse(Service.defaultPlayerGUID, ActionProgressMessage(slot + 6, actionProgress))
|
||||||
|
)
|
||||||
|
implant.copy(initialized = false, active = false, timer = futureDelay)
|
||||||
} else {
|
} else {
|
||||||
(delay, curr + delay.toMillis, 0L)
|
implant
|
||||||
}
|
}
|
||||||
//start initialization process
|
|
||||||
setImplantInitializedTimer(implant, slot, actualDelay)
|
|
||||||
// Start clien t side initialization timer, visible on the character screen
|
|
||||||
// Progress accumulates according to the client's knowledge of the implant initialization time
|
|
||||||
// What is normally a 60s timer that is set to 120s on the server will still visually update as if 60s
|
|
||||||
session.get.zone.AvatarEvents ! AvatarServiceMessage(
|
|
||||||
avatar.name,
|
|
||||||
AvatarAction.SendResponse(Service.defaultPlayerGUID, ActionProgressMessage(slot + 6, actionProgress))
|
|
||||||
)
|
|
||||||
implant.copy(initialized = false, active = false, timer = futureDelay)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private def deinitializeImplants(): Unit = {
|
private def deinitializeImplants(): Unit = {
|
||||||
|
|
@ -3484,7 +3481,7 @@ class AvatarActor(
|
||||||
implant.copy(initialized = false, active = false, timer = 0L)
|
implant.copy(initialized = false, active = false, timer = 0L)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def setImplantInitialized(implantType: ImplantType): Unit = {
|
private def actuallyInitializeImplant(implantType: ImplantType): Unit = {
|
||||||
findImplantByType(implantType)
|
findImplantByType(implantType)
|
||||||
.collect {
|
.collect {
|
||||||
case (implant, slot) =>
|
case (implant, slot) =>
|
||||||
|
|
@ -3660,7 +3657,7 @@ class AvatarActor(
|
||||||
Some(deactivateImplant(implant, slot))
|
Some(deactivateImplant(implant, slot))
|
||||||
case (Some(implant), slot) if !implant.initialized && implantTimers(slot).isCancelled =>
|
case (Some(implant), slot) if !implant.initialized && implantTimers(slot).isCancelled =>
|
||||||
//restart stopped/unstarted initialization process
|
//restart stopped/unstarted initialization process
|
||||||
Some(reinitializeImplant(implant, slot))
|
Some(startReinitializeImplant(implant, slot))
|
||||||
case (implantOpt, _) =>
|
case (implantOpt, _) =>
|
||||||
//fine as is
|
//fine as is
|
||||||
implantOpt
|
implantOpt
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import net.psforever.objects.serverobject.tube.SpawnTube
|
||||||
import net.psforever.objects.serverobject.turret.auto.AutomatedTurret
|
import net.psforever.objects.serverobject.turret.auto.AutomatedTurret
|
||||||
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry, VehicleSource}
|
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry, VehicleSource}
|
||||||
import net.psforever.objects.vital.{InGameHistory, IncarnationActivity, ReconstructionActivity, SpawningActivity}
|
import net.psforever.objects.vital.{InGameHistory, IncarnationActivity, ReconstructionActivity, SpawningActivity}
|
||||||
import net.psforever.packet.game.{AvatarImplantMessage, CampaignStatistic, ChangeFireStateMessage_Start, ImplantAction, MailMessage, ObjectDetectedMessage, SessionStatistic}
|
import net.psforever.packet.game.{CampaignStatistic, ChangeFireStateMessage_Start, MailMessage, ObjectDetectedMessage, SessionStatistic}
|
||||||
import net.psforever.services.chat.DefaultChannel
|
import net.psforever.services.chat.DefaultChannel
|
||||||
|
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue