more tests around movement components
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
2ecdaed9c9
commit
3fd77c09f1
@ -2057,6 +2057,7 @@ Rendering engine legacy code reorganization
|
||||
Code cleanup work
|
||||
Logging for loading thread failure
|
||||
Code cleanup
|
||||
More tests
|
||||
|
||||
|
||||
|
||||
|
||||
@ -53,17 +53,17 @@ public class ClientSynchronizationManager {
|
||||
/**
|
||||
* The list of messages to loop through
|
||||
*/
|
||||
List<SynchronizationMessage> messages = new CopyOnWriteArrayList<SynchronizationMessage>();
|
||||
private List<SynchronizationMessage> messages = new CopyOnWriteArrayList<SynchronizationMessage>();
|
||||
|
||||
/**
|
||||
* Map that tracks the number of times a network message bounces
|
||||
*/
|
||||
Map<SynchronizationMessage,Integer> messageBounceCount = new HashMap<SynchronizationMessage,Integer>();
|
||||
private Map<SynchronizationMessage,Integer> messageBounceCount = new HashMap<SynchronizationMessage,Integer>();
|
||||
|
||||
/**
|
||||
* The list of Ids that the server has said to destroy
|
||||
*/
|
||||
Map<Integer,Integer> deletedEntityIds = new HashMap<Integer,Integer>();
|
||||
private Map<Integer,Integer> deletedEntityIds = new HashMap<Integer,Integer>();
|
||||
|
||||
/**
|
||||
* Pushes a message into the queue to be processed
|
||||
|
||||
@ -31,8 +31,10 @@ public class ServerSynchronizationManager {
|
||||
public static final int SERVER_SYNC_INTERRUPT = 1;
|
||||
|
||||
|
||||
//The list of messages to loop through
|
||||
List<SynchronizationMessage> messages = new LinkedList<SynchronizationMessage>();
|
||||
/**
|
||||
* The list of messages to loop through
|
||||
*/
|
||||
private List<SynchronizationMessage> messages = new LinkedList<SynchronizationMessage>();
|
||||
|
||||
/**
|
||||
* Pushes a message into the queue to be processed
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
package electrosphere.entity.state.gravity;
|
||||
|
||||
import static electrosphere.test.testutils.Assertions.assertEventually;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.creature.ObjectTemplate;
|
||||
import electrosphere.test.annotations.IntegrationTest;
|
||||
import electrosphere.test.template.EntityTestTemplate;
|
||||
import electrosphere.test.testutils.TestEngineUtils;
|
||||
|
||||
/**
|
||||
* Tests client gravity tree
|
||||
*/
|
||||
public class ClientGravityTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isActive_AtRest_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientGravityTree clientGravityTree = ClientGravityTree.getClientGravityTree(clientEntity);
|
||||
assertEquals(false, clientGravityTree.isActive());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void activates_on_jump(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientJumpTree clientJumpTree = ClientJumpTree.getClientJumpTree(clientEntity);
|
||||
clientJumpTree.start();
|
||||
|
||||
ClientGravityTree clientGravityTree = ClientGravityTree.getClientGravityTree(clientEntity);
|
||||
|
||||
assertEventually(() -> clientGravityTree.isActive());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void deactivates_on_collide_world_bound(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientJumpTree clientJumpTree = ClientJumpTree.getClientJumpTree(clientEntity);
|
||||
clientJumpTree.start();
|
||||
|
||||
ClientGravityTree clientGravityTree = ClientGravityTree.getClientGravityTree(clientEntity);
|
||||
|
||||
assertEventually(() -> clientGravityTree.isActive());
|
||||
|
||||
assertEventually(() -> !clientGravityTree.isActive());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package electrosphere.entity.state.movement.jump;
|
||||
|
||||
import static electrosphere.test.testutils.Assertions.assertEventually;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.creature.ObjectTemplate;
|
||||
import electrosphere.test.annotations.IntegrationTest;
|
||||
import electrosphere.test.template.EntityTestTemplate;
|
||||
import electrosphere.test.testutils.TestEngineUtils;
|
||||
|
||||
/**
|
||||
* Tests the client jump tree
|
||||
*/
|
||||
public class ClientJumpTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isJumping_AtRest_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientJumpTree clientJumpTree = ClientJumpTree.getClientJumpTree(clientEntity);
|
||||
assertEquals(false, clientJumpTree.isJumping());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void isJumping_WhileJumping_true(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientJumpTree clientJumpTree = ClientJumpTree.getClientJumpTree(clientEntity);
|
||||
clientJumpTree.start();
|
||||
|
||||
assertEventually(() -> clientJumpTree.isJumping());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void isJumping_AfterLanding_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientJumpTree clientJumpTree = ClientJumpTree.getClientJumpTree(clientEntity);
|
||||
clientJumpTree.start();
|
||||
|
||||
assertEventually(() -> clientJumpTree.isJumping());
|
||||
|
||||
assertEventually(() -> !clientJumpTree.isJumping());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void verticalMovement_WhileJumping_true(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientJumpTree clientJumpTree = ClientJumpTree.getClientJumpTree(clientEntity);
|
||||
clientJumpTree.start();
|
||||
|
||||
assertEventually(() -> EntityUtils.getPosition(clientEntity).y > 0.3);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package electrosphere.entity.state.movement.jump;
|
||||
|
||||
import static electrosphere.test.testutils.Assertions.assertEventually;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.creature.ObjectTemplate;
|
||||
import electrosphere.test.annotations.IntegrationTest;
|
||||
import electrosphere.test.template.EntityTestTemplate;
|
||||
|
||||
/**
|
||||
* Tests the server jump tree
|
||||
*/
|
||||
public class ServerJumpTreeTests extends EntityTestTemplate {
|
||||
|
||||
/**
|
||||
* Expected height that a jump would get us to
|
||||
*/
|
||||
static final double EXPECTED_HEIGHT = 0.5;
|
||||
|
||||
@IntegrationTest
|
||||
public void isJumping_AtRest_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(serverEntity);
|
||||
assertEquals(false, serverJumpTree.isJumping());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void isJumping_WhileJumping_true(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(serverEntity);
|
||||
serverJumpTree.start();
|
||||
|
||||
assertEventually(() -> serverJumpTree.isJumping());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void isJumping_AfterLanding_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(serverEntity);
|
||||
serverJumpTree.start();
|
||||
|
||||
assertEventually(() -> serverJumpTree.isJumping());
|
||||
|
||||
assertEventually(() -> !serverJumpTree.isJumping());
|
||||
}
|
||||
|
||||
@IntegrationTest
|
||||
public void verticalMovement_WhileJumping_true(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(serverEntity);
|
||||
serverJumpTree.start();
|
||||
|
||||
assertEventually(() -> EntityUtils.getPosition(serverEntity).y > EXPECTED_HEIGHT);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user