just some tinkering and clean-up

This commit is contained in:
Fate-JH 2024-08-05 00:28:32 -04:00
parent 02f95a293e
commit 698a5609ab
2 changed files with 13 additions and 19 deletions

View file

@ -18,16 +18,11 @@ trait OwnableByPlayer {
def OwnerGuid_=(owner: Player): Option[PlanetSideGUID] = OwnerGuid_=(Some(owner.GUID)) def OwnerGuid_=(owner: Player): Option[PlanetSideGUID] = OwnerGuid_=(Some(owner.GUID))
def OwnerGuid_=(owner: Option[PlanetSideGUID]): Option[PlanetSideGUID] = { def OwnerGuid_=(owner: Option[PlanetSideGUID]): Option[PlanetSideGUID] = {
owner match { ownerGuid = owner
case Some(_) =>
ownerGuid = owner
case None =>
ownerGuid = None
}
OwnerGuid OwnerGuid
} }
def OwnerName: Option[String] = owner.map { _.name } def OwnerName: Option[String] = owner.map(_.name)
def OriginalOwnerName: Option[String] = originalOwnerName def OriginalOwnerName: Option[String] = originalOwnerName
@ -47,7 +42,7 @@ trait OwnableByPlayer {
(originalOwnerName, playerOpt) match { (originalOwnerName, playerOpt) match {
case (None, Some(player)) => case (None, Some(player)) =>
owner = Some(UniquePlayer(player)) owner = Some(UniquePlayer(player))
originalOwnerName = originalOwnerName.orElse { Some(player.Name) } originalOwnerName = originalOwnerName.orElse(Some(player.Name))
OwnerGuid = player OwnerGuid = player
case (_, Some(player)) => case (_, Some(player)) =>
owner = Some(UniquePlayer(player)) owner = Some(UniquePlayer(player))

View file

@ -75,7 +75,7 @@ trait DeployableBehavior {
} }
case Deployable.Ownership(Some(player)) case Deployable.Ownership(Some(player))
if !DeployableObject.Destroyed && DeployableObject.OwnerGuid.isEmpty => if !DeployableObject.Destroyed /*&& DeployableObject.OwnerGuid.isEmpty*/ =>
if (constructed.contains(true)) { if (constructed.contains(true)) {
gainOwnership(player) gainOwnership(player)
} else { } else {
@ -143,7 +143,7 @@ trait DeployableBehavior {
DeployableBehavior.changeOwnership( DeployableBehavior.changeOwnership(
obj, obj,
toFaction, toFaction,
DeployableInfo(obj.GUID, Deployable.Icon.apply(obj.Definition.Item), obj.Position, obj.OwnerGuid.get) DeployableInfo(obj.GUID, Deployable.Icon.apply(obj.Definition.Item), obj.Position, player.GUID)
) )
} }
@ -292,26 +292,25 @@ object DeployableBehavior {
*/ */
def changeOwnership(obj: Deployable, toFaction: PlanetSideEmpire.Value, info: DeployableInfo): Unit = { def changeOwnership(obj: Deployable, toFaction: PlanetSideEmpire.Value, info: DeployableInfo): Unit = {
val originalFaction = obj.Faction val originalFaction = obj.Faction
val zone = obj.Zone
val localEvents = zone.LocalEvents
if (originalFaction != toFaction) { if (originalFaction != toFaction) {
val guid = obj.GUID
val zone = obj.Zone
val localEvents = zone.LocalEvents
obj.Faction = toFaction obj.Faction = toFaction
//visual tells in regards to ownership by faction //visual tells in regards to ownership by faction
zone.AvatarEvents ! AvatarServiceMessage( zone.AvatarEvents ! AvatarServiceMessage(
zone.id, zone.id,
AvatarAction.SetEmpire(Service.defaultPlayerGUID, guid, toFaction) AvatarAction.SetEmpire(Service.defaultPlayerGUID, obj.GUID, toFaction)
) )
//remove knowledge by the previous owner's faction //remove knowledge by the previous owner's faction
localEvents ! LocalServiceMessage( localEvents ! LocalServiceMessage(
originalFaction.toString, originalFaction.toString,
LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Dismiss, info) LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Dismiss, info)
) )
//display to the given faction
localEvents ! LocalServiceMessage(
toFaction.toString,
LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Build, info)
)
} }
//display to the given faction
localEvents ! LocalServiceMessage(
toFaction.toString,
LocalAction.DeployableMapIcon(Service.defaultPlayerGUID, DeploymentAction.Build, info)
)
} }
} }