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: Option[PlanetSideGUID]): Option[PlanetSideGUID] = {
owner match {
case Some(_) =>
ownerGuid = owner
case None =>
ownerGuid = None
}
ownerGuid = owner
OwnerGuid
}
def OwnerName: Option[String] = owner.map { _.name }
def OwnerName: Option[String] = owner.map(_.name)
def OriginalOwnerName: Option[String] = originalOwnerName
@ -47,7 +42,7 @@ trait OwnableByPlayer {
(originalOwnerName, playerOpt) match {
case (None, Some(player)) =>
owner = Some(UniquePlayer(player))
originalOwnerName = originalOwnerName.orElse { Some(player.Name) }
originalOwnerName = originalOwnerName.orElse(Some(player.Name))
OwnerGuid = player
case (_, Some(player)) =>
owner = Some(UniquePlayer(player))

View file

@ -75,7 +75,7 @@ trait DeployableBehavior {
}
case Deployable.Ownership(Some(player))
if !DeployableObject.Destroyed && DeployableObject.OwnerGuid.isEmpty =>
if !DeployableObject.Destroyed /*&& DeployableObject.OwnerGuid.isEmpty*/ =>
if (constructed.contains(true)) {
gainOwnership(player)
} else {
@ -143,7 +143,7 @@ trait DeployableBehavior {
DeployableBehavior.changeOwnership(
obj,
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 = {
val originalFaction = obj.Faction
val zone = obj.Zone
val localEvents = zone.LocalEvents
if (originalFaction != toFaction) {
val guid = obj.GUID
val zone = obj.Zone
val localEvents = zone.LocalEvents
obj.Faction = toFaction
//visual tells in regards to ownership by faction
zone.AvatarEvents ! AvatarServiceMessage(
zone.id,
AvatarAction.SetEmpire(Service.defaultPlayerGUID, guid, toFaction)
AvatarAction.SetEmpire(Service.defaultPlayerGUID, obj.GUID, toFaction)
)
//remove knowledge by the previous owner's faction
localEvents ! LocalServiceMessage(
originalFaction.toString,
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)
)
}
}