Upper Body Angle (#292)

* constrain angles on specialized yaw and pitch fields

* integrated new Angular Codec into OCM and OCDM of avatar; corrected tests; wrote shortcut for whether a unit is moving (under its own power)

* apply clamp

* Accessed containers while moving

Removed unintentional code duplication outside of conditional.
This commit is contained in:
Fate-JH 2019-11-29 11:14:25 -05:00 committed by GitHub
parent 9e99dc75e3
commit a5a85e6cc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 209 additions and 108 deletions

View file

@ -24,7 +24,7 @@ class EntityTest extends Specification {
val obj : EntityTestClass = new EntityTestClass()
obj.Position mustEqual Vector3(0f, 0f, 0f)
obj.Orientation mustEqual Vector3(0f, 0f, 0f)
obj.Velocity mustEqual None
obj.Velocity.isEmpty mustEqual true
}
"mutate and access" in {
@ -35,7 +35,7 @@ class EntityTest extends Specification {
obj.Position mustEqual Vector3(1f, 1f, 1f)
obj.Orientation mustEqual Vector3(2f, 2f, 2f)
obj.Velocity mustEqual Some(Vector3(3f, 3f, 3f))
obj.Velocity.contains(Vector3(3f, 3f, 3f)) mustEqual true
}
"clamp Orientation" in {
@ -43,6 +43,61 @@ class EntityTest extends Specification {
obj.Orientation = Vector3(-1f, 361f, -0f)
obj.Orientation mustEqual Vector3(359f, 1f, 0f)
}
"is moving (at all)" in {
val obj : EntityTestClass = new EntityTestClass
obj.Velocity.isEmpty mustEqual true
obj.isMoving mustEqual false
obj.Velocity = Vector3.Zero
obj.isMoving mustEqual false
obj.Velocity = Vector3(1,0,0)
obj.isMoving mustEqual true
obj.Velocity = None
obj.isMoving mustEqual false
}
"is moving (Vector3 comparison)" in {
val obj : EntityTestClass = new EntityTestClass
val test1 = Vector3(1,0,0)
val test2 = Vector3(2,0,0)
obj.Velocity.isEmpty mustEqual true
obj.isMoving mustEqual false
obj.isMoving(test1) mustEqual false
obj.isMoving(test2) mustEqual false
obj.Velocity = Vector3(1,0,0)
obj.isMoving(test1) mustEqual true
obj.isMoving(test2) mustEqual false
obj.Velocity = Vector3(3,0,0)
obj.isMoving(test1) mustEqual true
obj.isMoving(test2) mustEqual true
obj.Velocity = Vector3(1,1,0)
obj.isMoving(test1) mustEqual true
obj.isMoving(test2) mustEqual false
}
"is moving (Float comparison)" in {
val obj : EntityTestClass = new EntityTestClass
obj.Velocity.isEmpty mustEqual true
obj.isMoving mustEqual false
obj.isMoving(1) mustEqual false
obj.isMoving(2) mustEqual false
obj.isMoving(4) mustEqual false
obj.Velocity = Vector3(1,0,0)
obj.isMoving(1) mustEqual true
obj.isMoving(2) mustEqual false
obj.isMoving(4) mustEqual false
obj.Velocity = Vector3(3,0,0)
obj.isMoving(1) mustEqual true
obj.isMoving(2) mustEqual true
obj.isMoving(4) mustEqual true
obj.Velocity = Vector3(1,1,1)
obj.isMoving(1) mustEqual true
obj.isMoving(2) mustEqual true
obj.isMoving(4) mustEqual false
}
}
"IdentifiableEntity" should {

View file

@ -133,26 +133,26 @@ class PlayerTest extends Specification {
obj.Stamina mustEqual 456
}
"set new values (health, armor, stamina) but only when alive" in {
val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
obj.Health = 23
obj.Armor = 34
obj.Stamina = 45
obj.Health mustEqual 0
obj.Armor mustEqual 0
obj.Stamina mustEqual 0
obj.Spawn
obj.Health mustEqual obj.MaxHealth
obj.Armor mustEqual obj.MaxArmor
obj.Stamina mustEqual obj.MaxStamina
obj.Health = 23
obj.Armor = 34
obj.Stamina = 45
obj.Health mustEqual 23
obj.Armor mustEqual 34
obj.Stamina mustEqual 45
}
// "set new values (health, armor, stamina) but only when alive" in {
// val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
// obj.Health = 23
// obj.Armor = 34
// obj.Stamina = 45
// obj.Health mustEqual 0
// obj.Armor mustEqual 0
// obj.Stamina mustEqual 0
//
// obj.Spawn
// obj.Health mustEqual obj.MaxHealth
// obj.Armor mustEqual obj.MaxArmor
// obj.Stamina mustEqual obj.MaxStamina
// obj.Health = 23
// obj.Armor = 34
// obj.Stamina = 45
// obj.Health mustEqual 23
// obj.Armor mustEqual 34
// obj.Stamina mustEqual 45
// }
"has visible slots" in {
val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)