Implied Swap Item (#530)

* by deleting a swap item for the entirety of a zone, avert the end of the world
* drop the item you are holding when you die
This commit is contained in:
Fate-JH 2020-08-23 22:36:20 -04:00 committed by GitHub
parent 3bdc681c9d
commit d46110874e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 12 deletions

View file

@ -1892,6 +1892,12 @@ class SessionActor extends Actor with MDCContextAware {
case AvatarResponse.Killed(mount) => case AvatarResponse.Killed(mount) =>
val respawnTimer = 300.seconds val respawnTimer = 300.seconds
//drop free hand item
player.FreeHand.Equipment match {
case Some(item) =>
DropEquipmentFromInventory(player)(item)
case None => ;
}
ToggleMaxSpecialState(enable = false) ToggleMaxSpecialState(enable = false)
keepAliveFunc = NormalKeepAlive keepAliveFunc = NormalKeepAlive
zoningStatus = Zoning.Status.None zoningStatus = Zoning.Status.None

View file

@ -112,7 +112,7 @@ class LockerContainerControl(locker: LockerContainer, toChannel: String) extends
) )
} }
def SwapItemCallback(item: Equipment): Unit = { def SwapItemCallback(item: Equipment, fromSlot: Int): Unit = {
val zone = locker.Zone val zone = locker.Zone
zone.AvatarEvents ! AvatarServiceMessage( zone.AvatarEvents ! AvatarServiceMessage(
toChannel, toChannel,

View file

@ -62,7 +62,7 @@ class CorpseControl(player: Player) extends Actor with ContainableBehavior {
) )
} }
def SwapItemCallback(item: Equipment): Unit = { def SwapItemCallback(item: Equipment, fromSlot: Int): Unit = {
val obj = ContainerObject val obj = ContainerObject
val zone = obj.Zone val zone = obj.Zone
zone.AvatarEvents ! AvatarServiceMessage( zone.AvatarEvents ! AvatarServiceMessage(

View file

@ -861,12 +861,13 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
} }
} }
def SwapItemCallback(item: Equipment): Unit = { def SwapItemCallback(item: Equipment, fromSlot: Int): Unit = {
val obj = ContainerObject val obj = ContainerObject
val zone = obj.Zone val zone = obj.Zone
val toChannel = if (obj.VisibleSlots.contains(fromSlot)) zone.id else player.Name
zone.AvatarEvents ! AvatarServiceMessage( zone.AvatarEvents ! AvatarServiceMessage(
player.Name, toChannel,
AvatarAction.SendResponse(Service.defaultPlayerGUID, ObjectDetachMessage(obj.GUID, item.GUID, Vector3.Zero, 0f)) AvatarAction.ObjectDelete(Service.defaultPlayerGUID, item.GUID)
) )
} }
} }

View file

@ -213,7 +213,7 @@ trait ContainableBehavior {
ContainableBehavior.TryPutItemInSlot(destination, item, dest) match { ContainableBehavior.TryPutItemInSlot(destination, item, dest) match {
case (true, swapItem) => case (true, swapItem) =>
swapItem match { swapItem match {
case Some(thing) => SwapItemCallback(thing) case Some(thing) => SwapItemCallback(thing, dest)
case None => ; case None => ;
} }
PutItemInSlotCallback(item, dest) PutItemInSlotCallback(item, dest)
@ -249,7 +249,7 @@ trait ContainableBehavior {
ContainableBehavior.TryPutItemInSlotOrAway(destination, item, dest) match { ContainableBehavior.TryPutItemInSlotOrAway(destination, item, dest) match {
case (Some(slot), swapItem) => case (Some(slot), swapItem) =>
swapItem match { swapItem match {
case Some(thing) => SwapItemCallback(thing) case Some(thing) => SwapItemCallback(thing, slot)
case None => ; case None => ;
} }
PutItemInSlotCallback(item, slot) PutItemInSlotCallback(item, slot)
@ -330,8 +330,9 @@ trait ContainableBehavior {
* Reaction to the existence of a swap item being produced from a container into the environment. * Reaction to the existence of a swap item being produced from a container into the environment.
* To be implemented. * To be implemented.
* @param item the item that was removed * @param item the item that was removed
* @param fromSlot the slot from where the item was removed (where it previous was)
*/ */
def SwapItemCallback(item: Equipment): Unit def SwapItemCallback(item: Equipment, fromSlot: Int): Unit
} }
object ContainableBehavior { object ContainableBehavior {
@ -626,7 +627,7 @@ object Containable {
/** /**
* A response for the `RemoveItemFromSlot` message. * A response for the `RemoveItemFromSlot` message.
* It serves the dual purpose of reporting a missing item (by not reporting any slot information) * It serves the dual purpose of reporting a missing item (by not reporting any slot information)
* and reporting no item ata given position (by not reporting any item information). * and reporting no item at a given position (by not reporting any item information).
* @param obj the container * @param obj the container
* @param item the equipment that was removed * @param item the equipment that was removed
* @param slot the index position from which any item was removed * @param slot the index position from which any item was removed

View file

@ -450,12 +450,13 @@ class VehicleControl(vehicle: Vehicle)
} }
} }
def SwapItemCallback(item: Equipment): Unit = { def SwapItemCallback(item: Equipment, fromSlot: Int): Unit = {
val obj = ContainerObject val obj = ContainerObject
val zone = obj.Zone val zone = obj.Zone
val toChannel = if (obj.VisibleSlots.contains(fromSlot)) zone.id else self.toString
zone.VehicleEvents ! VehicleServiceMessage( zone.VehicleEvents ! VehicleServiceMessage(
self.toString, toChannel,
VehicleAction.SendResponse(Service.defaultPlayerGUID, ObjectDetachMessage(obj.GUID, item.GUID, Vector3.Zero, 0f)) VehicleAction.ObjectDelete(Service.defaultPlayerGUID, item.GUID)
) )
} }