mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
moved responsibility for determing the type of un/mounting entity to specific subclass rather than generic parent class (#1184)
This commit is contained in:
parent
b7dc2b6623
commit
9319f7e7bd
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2021 PSForever
|
||||
package net.psforever.objects.serverobject.mount
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.types.BailType
|
||||
|
||||
trait MountableSpace[A <: MountableEntity] {
|
||||
|
|
@ -93,10 +92,6 @@ trait MountableSpace[A <: MountableEntity] {
|
|||
case Some(p) if testToUnmount(p) =>
|
||||
_occupant = None
|
||||
p.BailProtection = bailable && (bailType == BailType.Bailed || bailType == BailType.Kicked)
|
||||
p match {
|
||||
case player: Player =>
|
||||
player.VehicleSeated = None
|
||||
}
|
||||
None
|
||||
case _ =>
|
||||
occupant
|
||||
|
|
|
|||
|
|
@ -2,9 +2,19 @@
|
|||
package net.psforever.objects.serverobject.mount
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.types.BailType
|
||||
|
||||
class Seat(private val sdef: SeatDefinition) extends MountableSpace[Player] {
|
||||
override protected def testToMount(target: Player): Boolean = target.VehicleSeated.isEmpty && super.testToMount(target)
|
||||
|
||||
override def unmount(target: Option[Player], bailType: BailType.Value): Option[Player] = {
|
||||
val outcome = super.unmount(target, bailType)
|
||||
target.collect {
|
||||
case p if outcome.isEmpty && !isOccupiedBy(p) =>
|
||||
p.VehicleSeated = None
|
||||
}
|
||||
outcome
|
||||
}
|
||||
|
||||
def definition: SeatDefinition = sdef
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,17 @@ package net.psforever.objects.vehicles
|
|||
|
||||
import net.psforever.objects.Vehicle
|
||||
import net.psforever.objects.serverobject.mount.{MountableSpace, MountableSpaceDefinition}
|
||||
import net.psforever.types.BailType
|
||||
|
||||
class Cargo(private val cdef: MountableSpaceDefinition[Vehicle]) extends MountableSpace[Vehicle] {
|
||||
override def unmount(target: Option[Vehicle], bailType: BailType.Value): Option[Vehicle] = {
|
||||
val outcome = super.unmount(target, bailType)
|
||||
target.collect {
|
||||
case v if outcome.isEmpty && !isOccupiedBy(v) =>
|
||||
v.MountedIn = None
|
||||
}
|
||||
outcome
|
||||
}
|
||||
|
||||
def definition: MountableSpaceDefinition[Vehicle] = cdef
|
||||
}
|
||||
|
|
|
|||
|
|
@ -683,7 +683,6 @@ object CarrierBehavior {
|
|||
hold: Cargo,
|
||||
bailType: BailType.Value
|
||||
): Unit = {
|
||||
cargo.MountedIn = None
|
||||
hold.unmount(cargo, bailType)
|
||||
val event = VehicleCargoMountActivity(VehicleSource(carrier), VehicleSource(cargo), carrier.Zone.Number)
|
||||
cargo.LogActivity(event)
|
||||
|
|
|
|||
Loading…
Reference in a new issue