fix most tests
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
7a36c56c57
commit
92bdb54108
@ -2050,6 +2050,9 @@ More verbose loading display
|
||||
|
||||
(05/29/2025)
|
||||
Scaffolding towns and character jobs data
|
||||
Properly async-ify inventory/item related tests
|
||||
Fix viewport interaction with lod emitter service
|
||||
Fix most tests
|
||||
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,10 @@ public class ViewportLoading {
|
||||
//init realm manager with viewport realm
|
||||
Globals.serverState.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(16,16,16));
|
||||
|
||||
//
|
||||
//Disable LOD service
|
||||
Globals.serverState.lodEmitterService.setDisable(true);
|
||||
|
||||
//
|
||||
//connect client to server
|
||||
LoggerInterface.loggerEngine.INFO("run server: " + EngineState.EngineFlags.RUN_SERVER + " run client: " + EngineState.EngineFlags.RUN_CLIENT);
|
||||
|
||||
@ -35,6 +35,11 @@ public class LODEmitterService extends SignalServiceImpl {
|
||||
*/
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* Disables lod checking (always returns that everything is full LOD)
|
||||
*/
|
||||
private boolean disable;
|
||||
|
||||
/**
|
||||
* Creates the LOD emitter service
|
||||
*/
|
||||
@ -95,6 +100,9 @@ public class LODEmitterService extends SignalServiceImpl {
|
||||
* @return true if it is full lod, false otherwise
|
||||
*/
|
||||
public boolean isFullLod(Vector3d position){
|
||||
if(this.disable){
|
||||
return true;
|
||||
}
|
||||
for(Entity emitter : this.getEmitters()){
|
||||
Vector3d emitterLoc = EntityUtils.getPosition(emitter);
|
||||
double dist = position.distance(emitterLoc);
|
||||
@ -110,5 +118,23 @@ public class LODEmitterService extends SignalServiceImpl {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the disabled status of the lod emitter service
|
||||
* @return true if it is disabled, false otherwise
|
||||
*/
|
||||
public boolean getDisable() {
|
||||
return disable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the disabled status of the lod emitter service
|
||||
* @param disable true to disable it, false otherwise
|
||||
*/
|
||||
public void setDisable(boolean disable) {
|
||||
this.disable = disable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.entity.state.equip;
|
||||
|
||||
import static electrosphere.test.testutils.Assertions.assertEventually;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@ -42,7 +43,10 @@ public class ServerEquipStateTests extends EntityTestTemplate {
|
||||
serverEquipState.commandAttemptEquip(inInventoryItem, serverEquipState.getEquipPoint("handsCombined"));
|
||||
|
||||
//propagate to client
|
||||
TestEngineUtils.simulateFrames(2);
|
||||
assertEventually(() -> {
|
||||
List<Entity> children = AttachUtils.getChildrenList(creature);
|
||||
return children.size() == 1;
|
||||
});
|
||||
|
||||
//
|
||||
//verify was equipped
|
||||
@ -75,7 +79,10 @@ public class ServerEquipStateTests extends EntityTestTemplate {
|
||||
serverEquipState.commandAttemptEquip(inInventoryItem, serverEquipState.getEquipPoint("handsCombined"));
|
||||
|
||||
//render a frame so network propagates to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
assertEventually(() -> {
|
||||
List<Entity> children = AttachUtils.getChildrenList(creature);
|
||||
return children.size() == 1;
|
||||
});
|
||||
|
||||
//attempt to equip second katana
|
||||
Entity inInventoryItem2 = ServerInventoryState.attemptStoreItemAnyInventory(creature, katana2);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.entity.state.inventory;
|
||||
|
||||
import static electrosphere.test.testutils.Assertions.assertEventually;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
@ -35,13 +36,17 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localCreatureSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
return localCreatureSet.size() == 1;
|
||||
});
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
return localItemSet.size() == 1;
|
||||
});
|
||||
|
||||
//verify the client got the extra entities
|
||||
Set<Entity> clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
Set<Entity> clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(1, clientSideItems.size());
|
||||
|
||||
//grab player entity
|
||||
Entity clientCreature = clientSideCreatures.iterator().next();
|
||||
@ -51,23 +56,26 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
//attempt to store
|
||||
ClientInventoryState.clientAttemptStoreItem(clientCreature, clientKatana);
|
||||
|
||||
//propagate to client
|
||||
TestEngineUtils.simulateFrames(2);
|
||||
//wait for the store to propagate
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localCreatureSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
return localCreatureSet.size() == 1;
|
||||
});
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
return localItemSet.size() == 1;
|
||||
});
|
||||
|
||||
//verify we still have everything
|
||||
clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(1, clientSideItems.size());
|
||||
|
||||
//grab the item in particular
|
||||
Entity child = clientSideItems.iterator().next();
|
||||
|
||||
//
|
||||
//verify was created properly
|
||||
assertTrue(ItemUtils.isItem(child));
|
||||
assertTrue(ItemUtils.isWeapon(child));
|
||||
assertNotNull(ItemUtils.getContainingParent(child));
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
Entity localChild = localItemSet.iterator().next();
|
||||
return ItemUtils.isItem(localChild) && ItemUtils.isWeapon(localChild) && ItemUtils.getContainingParent(localChild) != null;
|
||||
});
|
||||
|
||||
//
|
||||
//verify the item is stored in the inventory properly
|
||||
@ -88,15 +96,17 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
//verify the client got the extra entities
|
||||
Set<Entity> clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
Set<Entity> clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(1, clientSideItems.size());
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localCreatureSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
return localCreatureSet.size() == 1;
|
||||
});
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
return localItemSet.size() == 1;
|
||||
});
|
||||
|
||||
//grab player entity
|
||||
Set<Entity> clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
Entity clientCreature = clientSideCreatures.iterator().next();
|
||||
Entity clientKatana = TestEngineUtils.getClientEquivalent(katana);
|
||||
Globals.clientState.playerEntity = clientCreature;
|
||||
@ -104,16 +114,25 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
//attempt to store
|
||||
ClientInventoryState.clientAttemptStoreItem(clientCreature, clientKatana);
|
||||
|
||||
//allow time for client->server->client communication
|
||||
TestEngineUtils.simulateFrames(2);
|
||||
//wait for item to store
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
Entity localChild = localItemSet.iterator().next();
|
||||
return ItemUtils.isItem(localChild) && ItemUtils.isWeapon(localChild) && ItemUtils.getContainingParent(localChild) != null;
|
||||
});
|
||||
|
||||
//attempt to eject
|
||||
Set<Entity> clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
clientKatana = clientSideItems.iterator().next();
|
||||
ClientInventoryState.clientAttemptEjectItem(clientCreature, clientKatana);
|
||||
|
||||
//allow time for client->server->client communication
|
||||
TestEngineUtils.simulateFrames(2);
|
||||
//wait for item to eject
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
Entity localChild = localItemSet.iterator().next();
|
||||
return ItemUtils.isItem(localChild) && ItemUtils.isWeapon(localChild) && ItemUtils.getContainingParent(localChild) == null;
|
||||
});
|
||||
|
||||
//verify we still have everything
|
||||
clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
@ -148,15 +167,13 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
TestEngineUtils.spawnPlayerEntity();
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
//verify the client got the extra entities
|
||||
Set<Entity> clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
Set<Entity> clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(0, clientSideItems.size());
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localCreatureSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
return localCreatureSet.size() == 1;
|
||||
});
|
||||
|
||||
//grab player entity
|
||||
Set<Entity> clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
Entity clientCreature = clientSideCreatures.iterator().next();
|
||||
Globals.clientState.playerEntity = clientCreature;
|
||||
|
||||
@ -165,6 +182,7 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
|
||||
//verify we still have everything
|
||||
clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
Set<Entity> clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(1, clientSideItems.size());
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.entity.types.item;
|
||||
|
||||
import static electrosphere.test.testutils.Assertions.assertEventually;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
@ -35,13 +36,14 @@ public class ItemUtilsTests extends EntityTestTemplate {
|
||||
TestEngineUtils.spawnPlayerEntity();
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localCreatureSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
return localCreatureSet.size() == 1;
|
||||
});
|
||||
|
||||
//verify the client got the extra entities
|
||||
Set<Entity> clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
Set<Entity> clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(0, clientSideItems.size());
|
||||
|
||||
//get server equivalent of client entity
|
||||
Entity serverEquivalent = TestEngineUtils.getServerEquivalent(clientSideCreatures.iterator().next());
|
||||
@ -59,9 +61,12 @@ public class ItemUtilsTests extends EntityTestTemplate {
|
||||
|
||||
//verify we still have everything
|
||||
clientSideCreatures = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||
assertEquals(1, clientSideCreatures.size());
|
||||
clientSideItems = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
assertEquals(1, clientSideItems.size());
|
||||
assertEventually(() -> {
|
||||
Set<Entity> localItemSet = Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||
Entity child = localItemSet.iterator().next();
|
||||
return ItemUtils.getContainingParent(child) != null;
|
||||
});
|
||||
|
||||
//grab the item in particular
|
||||
Entity child = clientSideItems.iterator().next();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user