2017-11-06 10:24:36 -05:00
|
|
|
// Copyright (c) 2017 PSForever
|
|
|
|
|
package objects
|
|
|
|
|
|
2020-05-30 12:28:10 -04:00
|
|
|
import akka.actor.{ActorSystem, Props}
|
2018-07-14 21:25:44 -04:00
|
|
|
import base.ActorTest
|
2020-08-01 12:25:03 +02:00
|
|
|
import net.psforever.objects.avatar.Avatar
|
|
|
|
|
import net.psforever.objects.{Default, GlobalDefinitions, Player}
|
2017-11-06 10:24:36 -05:00
|
|
|
import net.psforever.objects.serverobject.CommonMessages
|
|
|
|
|
import net.psforever.objects.serverobject.locks.{IFFLock, IFFLockControl}
|
2018-03-24 00:28:02 -04:00
|
|
|
import net.psforever.objects.serverobject.structures.{Building, StructureType}
|
2018-01-26 15:32:08 -05:00
|
|
|
import net.psforever.objects.zones.Zone
|
2020-01-06 08:45:55 -05:00
|
|
|
import net.psforever.types._
|
2017-11-06 10:24:36 -05:00
|
|
|
import org.specs2.mutable.Specification
|
|
|
|
|
|
|
|
|
|
class IFFLockTest extends Specification {
|
|
|
|
|
"IFFLock" should {
|
|
|
|
|
"construct" in {
|
|
|
|
|
IFFLock(GlobalDefinitions.lock_external)
|
|
|
|
|
ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO internal hacking logic will be re-written later
|
2019-04-04 19:32:28 +01:00
|
|
|
|
|
|
|
|
"keep track of its orientation as a North-corrected vector" in {
|
2020-07-14 05:54:05 +02:00
|
|
|
val ulp = math.ulp(1)
|
2019-04-04 19:32:28 +01:00
|
|
|
val lock = IFFLock(GlobalDefinitions.lock_external)
|
|
|
|
|
|
|
|
|
|
lock.Orientation = Vector3(0, 0, 0) //face North
|
|
|
|
|
lock.Outwards.x < ulp mustEqual true
|
|
|
|
|
lock.Outwards.y mustEqual 1
|
|
|
|
|
|
|
|
|
|
lock.Orientation = Vector3(0, 0, 90) //face East
|
|
|
|
|
lock.Outwards.x mustEqual 1
|
|
|
|
|
lock.Outwards.y < ulp mustEqual true
|
|
|
|
|
|
|
|
|
|
lock.Orientation = Vector3(0, 0, 180) //face South
|
|
|
|
|
lock.Outwards.x < ulp mustEqual true
|
|
|
|
|
lock.Outwards.y mustEqual -1
|
|
|
|
|
|
|
|
|
|
lock.Orientation = Vector3(0, 0, 270) //face West
|
|
|
|
|
lock.Outwards.x mustEqual -1
|
|
|
|
|
lock.Outwards.y < ulp mustEqual true
|
|
|
|
|
}
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-14 21:25:44 -04:00
|
|
|
class IFFLockControl1Test extends ActorTest {
|
2017-11-06 10:24:36 -05:00
|
|
|
"IFFLockControl" should {
|
|
|
|
|
"construct" in {
|
|
|
|
|
val lock = IFFLock(GlobalDefinitions.lock_external)
|
|
|
|
|
lock.Actor = system.actorOf(Props(classOf[IFFLockControl], lock), "lock-control")
|
2020-05-30 12:28:10 -04:00
|
|
|
assert(lock.Actor != Default.Actor)
|
2017-11-06 10:24:36 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-14 21:25:44 -04:00
|
|
|
class IFFLockControl2Test extends ActorTest {
|
2017-11-06 10:24:36 -05:00
|
|
|
"IFFLockControl" should {
|
|
|
|
|
"can hack" in {
|
2018-01-26 15:32:08 -05:00
|
|
|
val (player, lock) = IFFLockControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
2017-11-06 10:24:36 -05:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
|
|
|
|
assert(lock.HackedBy.isEmpty)
|
|
|
|
|
|
Destroy and repair (#346)
* bog-standard order_terminal amenities now take damage up to the point of destruction and can be repaired from destruction to functional to the point of being fully repaired; this is mostly proof fo concept
* restored proper destruction to FacilityTurrets; extended proper rrepairs to FacilityTurrets; co-opted terminal hacking into TerminalControl; started to expand on hacking protocol, but chose restraint
* changes made thus that a clear Definition hierarchy is established; all of this is in line with making future changes to repair/destroy variables, and making generic the repair code
* all meaningful facility amenities take damage and can be repaired; spawn tubes can be destroyed and the base will properly lose spawns (and show it on the map); some hack logic has been redistributed into the appropriate control objects, following in the wake of repair/damage logic
* deployables are repairable; the TRAP has been converted into a ComplexDeployable; changed the nature of the Repairable traits
* player bank repair and medapp heal has been moved out from WSA into PlayerControl
* overhaul of Progress callback system and the inclusion of player revival as a Progress activity
* begun relocating functionality for hacking outside of WSA; set up behavoir mixin for cargo operations, in order to move vehicle hack function, but did not yet integrate
* integration of the actor behavior mixin for vehicle cargo operations to support the integration of vehicle hacking finalization
* establishing inheritance/override potential of Damageable activity; Generator and SpawnTube map behavior behavior (currently inactive)
* ImplantTerminalMech objects now have a 'with-coordinates' constructor and a deprecated 'no-coordinates' constructor; implants mechs and interfaces are now damageable and repairable, and their damage state can also block mounting
* generators are destroyed and repaired properly, and even explode, killing a radius-worth of players
* destroy and repair pass on deployables, except for explosive types
* Damageable pass; client synchronization pass
* helpful comments
* some tests for damageable and repairable; refined output and repaired existing tests
* enabled friendly fire check and recovery
* handled friendly fire against allied mines; moved jammer code to common damageable behavior
* tweaks to damageability, infantry heal and repair, and sensor and explosive animations
* animations; framework for future vitals events; closing database connections
* adding some deployable tests; fixing a bunch of other tests; History is back
* testing for basic Damageable functions; removing a log message
* finicky animation stuff
* event messages to the Generator to represent health changes
* damage against BFR's is now only used against mythical creatures
* test fix
2020-04-14 15:17:32 -04:00
|
|
|
lock.Actor ! CommonMessages.Hack(player, lock)
|
2020-07-14 05:54:05 +02:00
|
|
|
Thread.sleep(500L) //blocking
|
2017-11-06 10:24:36 -05:00
|
|
|
assert(lock.HackedBy.nonEmpty) //TODO rewrite later
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-14 21:25:44 -04:00
|
|
|
class IFFLockControl3Test extends ActorTest {
|
2017-11-06 10:24:36 -05:00
|
|
|
"IFFLockControl" should {
|
2019-12-10 14:17:55 +00:00
|
|
|
"can clear hack" in {
|
2018-01-26 15:32:08 -05:00
|
|
|
val (player, lock) = IFFLockControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
2017-11-06 10:24:36 -05:00
|
|
|
player.GUID = PlanetSideGUID(1)
|
|
|
|
|
assert(lock.HackedBy.isEmpty)
|
|
|
|
|
|
Destroy and repair (#346)
* bog-standard order_terminal amenities now take damage up to the point of destruction and can be repaired from destruction to functional to the point of being fully repaired; this is mostly proof fo concept
* restored proper destruction to FacilityTurrets; extended proper rrepairs to FacilityTurrets; co-opted terminal hacking into TerminalControl; started to expand on hacking protocol, but chose restraint
* changes made thus that a clear Definition hierarchy is established; all of this is in line with making future changes to repair/destroy variables, and making generic the repair code
* all meaningful facility amenities take damage and can be repaired; spawn tubes can be destroyed and the base will properly lose spawns (and show it on the map); some hack logic has been redistributed into the appropriate control objects, following in the wake of repair/damage logic
* deployables are repairable; the TRAP has been converted into a ComplexDeployable; changed the nature of the Repairable traits
* player bank repair and medapp heal has been moved out from WSA into PlayerControl
* overhaul of Progress callback system and the inclusion of player revival as a Progress activity
* begun relocating functionality for hacking outside of WSA; set up behavoir mixin for cargo operations, in order to move vehicle hack function, but did not yet integrate
* integration of the actor behavior mixin for vehicle cargo operations to support the integration of vehicle hacking finalization
* establishing inheritance/override potential of Damageable activity; Generator and SpawnTube map behavior behavior (currently inactive)
* ImplantTerminalMech objects now have a 'with-coordinates' constructor and a deprecated 'no-coordinates' constructor; implants mechs and interfaces are now damageable and repairable, and their damage state can also block mounting
* generators are destroyed and repaired properly, and even explode, killing a radius-worth of players
* destroy and repair pass on deployables, except for explosive types
* Damageable pass; client synchronization pass
* helpful comments
* some tests for damageable and repairable; refined output and repaired existing tests
* enabled friendly fire check and recovery
* handled friendly fire against allied mines; moved jammer code to common damageable behavior
* tweaks to damageability, infantry heal and repair, and sensor and explosive animations
* animations; framework for future vitals events; closing database connections
* adding some deployable tests; fixing a bunch of other tests; History is back
* testing for basic Damageable functions; removing a log message
* finicky animation stuff
* event messages to the Generator to represent health changes
* damage against BFR's is now only used against mythical creatures
* test fix
2020-04-14 15:17:32 -04:00
|
|
|
lock.Actor ! CommonMessages.Hack(player, lock)
|
2020-07-14 05:54:05 +02:00
|
|
|
Thread.sleep(500L) //blocking
|
2017-11-06 10:24:36 -05:00
|
|
|
assert(lock.HackedBy.nonEmpty) //TODO rewrite later
|
|
|
|
|
lock.Actor ! CommonMessages.ClearHack()
|
2020-07-14 05:54:05 +02:00
|
|
|
Thread.sleep(500L) //blocking
|
2017-11-06 10:24:36 -05:00
|
|
|
assert(lock.HackedBy.isEmpty) //TODO rewrite
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-26 15:32:08 -05:00
|
|
|
|
|
|
|
|
object IFFLockControlTest {
|
2020-07-14 05:54:05 +02:00
|
|
|
def SetUpAgents(faction: PlanetSideEmpire.Value)(implicit system: ActorSystem): (Player, IFFLock) = {
|
2018-01-26 15:32:08 -05:00
|
|
|
val lock = IFFLock(GlobalDefinitions.lock_external)
|
|
|
|
|
lock.Actor = system.actorOf(Props(classOf[IFFLockControl], lock), "lock-control")
|
2020-07-14 05:54:05 +02:00
|
|
|
lock.Owner = new Building(
|
|
|
|
|
"Building",
|
|
|
|
|
building_guid = 0,
|
|
|
|
|
map_id = 0,
|
|
|
|
|
Zone.Nowhere,
|
|
|
|
|
StructureType.Building,
|
|
|
|
|
GlobalDefinitions.building
|
|
|
|
|
)
|
2018-01-26 15:32:08 -05:00
|
|
|
lock.Owner.Faction = faction
|
2020-08-01 12:25:03 +02:00
|
|
|
(Player(Avatar(0, "test", faction, CharacterGender.Male, 0, CharacterVoice.Mute)), lock)
|
2018-01-26 15:32:08 -05:00
|
|
|
}
|
|
|
|
|
}
|