diff --git a/Jenkinsfile b/Jenkinsfile index f035413e..3d389676 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { timeout: 25 ] ) { - sh 'mvn test' + sh 'mvn test -P integration' } } post { diff --git a/assets/Scenes/testscene1/scene.json b/assets/Scenes/testscene1/scene.json new file mode 100644 index 00000000..a7e2a975 --- /dev/null +++ b/assets/Scenes/testscene1/scene.json @@ -0,0 +1,11 @@ +{ + "entities" : [], + "scriptPaths" : [], + "initScriptPath" : "/Scenes/testscene1/scene.ts", + "realmDescriptor" : { + "type" : "gridded", + "griddedRealmSize" : 2 + }, + "createSaveInstance" : false, + "loadAllCells": true +} \ No newline at end of file diff --git a/assets/Scenes/testscene1/scene.ts b/assets/Scenes/testscene1/scene.ts index 0a99cc92..29d02832 100644 --- a/assets/Scenes/testscene1/scene.ts +++ b/assets/Scenes/testscene1/scene.ts @@ -4,7 +4,10 @@ import { Scene } from "/Scripts/types/scene"; * The main scene interface */ const TestScene1: Scene = { - + persistentValues: {}, + hooks: [], + signalHookMap: {}, + sceneHooks: [] } /** diff --git a/assets/Scenes/testscene1/testscene1.json b/assets/Scenes/testscene1/testscene1.json deleted file mode 100644 index c4c43074..00000000 --- a/assets/Scenes/testscene1/testscene1.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "entities": [ - ], - "scriptPaths": [ - "Scenes/testscene1/someScript.js" - ], - "initScriptPath": "Scenes/testscene1/someScript.js" -} \ No newline at end of file diff --git a/buildNumber.properties b/buildNumber.properties index 2d1d14b9..4f784a29 100644 --- a/buildNumber.properties +++ b/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Mon Aug 19 12:41:14 EDT 2024 -buildNumber=276 +#Mon Aug 19 13:16:30 EDT 2024 +buildNumber=280 diff --git a/saves/testscene1/0_0_0t.dat b/saves/testscene1/0_0_0t.dat new file mode 100644 index 00000000..40d281ea Binary files /dev/null and b/saves/testscene1/0_0_0t.dat differ diff --git a/saves/testscene1/central.db b/saves/testscene1/central.db new file mode 100644 index 00000000..5034033f Binary files /dev/null and b/saves/testscene1/central.db differ diff --git a/saves/testscene1/content/0_0_0.dat b/saves/testscene1/content/0_0_0.dat new file mode 100644 index 00000000..8cdcf255 --- /dev/null +++ b/saves/testscene1/content/0_0_0.dat @@ -0,0 +1 @@ +{"serializedEntities":[]} \ No newline at end of file diff --git a/saves/testscene1/save.json b/saves/testscene1/save.json new file mode 100644 index 00000000..60f02f8d --- /dev/null +++ b/saves/testscene1/save.json @@ -0,0 +1 @@ +{"versionString":"0.0.1","timeCreated":"1724087800358","name":"testscene1"} \ No newline at end of file diff --git a/saves/testscene1/world.json b/saves/testscene1/world.json new file mode 100644 index 00000000..9b85b613 --- /dev/null +++ b/saves/testscene1/world.json @@ -0,0 +1 @@ +{"type":"LEVEL","worldMinPoint":{"x":0.0,"y":0.0,"z":0.0},"worldMaxPoint":{"x":16.0,"y":16.0,"z":16.0},"worldSizeDiscrete":1,"worldSizeDiscreteVertical":1,"dynamicInterpolationRatio":1,"randomDampener":1.0,"isArena":false} \ No newline at end of file diff --git a/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java b/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java index 76cc5754..5171c543 100644 --- a/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java +++ b/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java @@ -2,7 +2,6 @@ package electrosphere.engine.loadingthreads; import java.util.concurrent.TimeUnit; -import org.joml.Quaterniond; import org.joml.Vector3f; import electrosphere.client.fluid.cells.FluidCellManager; @@ -16,7 +15,6 @@ import electrosphere.entity.DrawableUtils; import electrosphere.entity.Entity; import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityUtils; -import electrosphere.entity.state.movement.ApplyRotationTree; import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.logger.LoggerInterface; import electrosphere.menu.MenuGenerators; @@ -220,6 +218,7 @@ public class ClientLoading { try { TimeUnit.MILLISECONDS.sleep(10); } catch (InterruptedException ex) { + LoggerInterface.loggerEngine.ERROR(ex); } } //initialize draw cell manager diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureTemplate.java b/src/main/java/electrosphere/entity/types/creature/CreatureTemplate.java index 4ab9a74a..c64e3d61 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureTemplate.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureTemplate.java @@ -3,6 +3,9 @@ package electrosphere.entity.types.creature; import java.util.HashMap; import java.util.Map; +import electrosphere.engine.Globals; +import electrosphere.game.data.creature.type.CreatureData; +import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; import electrosphere.net.synchronization.transport.StateCollection; /** @@ -100,6 +103,34 @@ public class CreatureTemplate { this.stateCollection = stateCollection; } + /** + * Creates a template for the creature with default values + * @param creatureType The type of creature + * @return The basic template + */ + public static CreatureTemplate createDefault(String creatureType){ + CreatureTemplate storedTemplate = CreatureTemplate.create(creatureType); + CreatureData rawType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(creatureType); + if(rawType.getVisualAttributes() != null){ + for(VisualAttribute attributeType : rawType.getVisualAttributes()){ + if(attributeType.getType().equals("remesh")){ + if(attributeType.getVariants() != null && attributeType.getVariants().size() > 0){ + //make sure stored template contains creature data + if(storedTemplate.getAttributeValue(attributeType.getAttributeId())==null){ + storedTemplate.putAttributeValue(attributeType.getAttributeId(), attributeType.getVariants().get(0).getId()); + } + } + } + if(attributeType.getType().equals("bone")){ + //make sure stored template contains creature data + float midpoint = (attributeType.getMaxValue() - attributeType.getMinValue())/2.0f + attributeType.getMinValue(); + storedTemplate.putAttributeValue(attributeType.getAttributeId(), midpoint); + } + } + } + return storedTemplate; + } + /** * A visual attribute of a creature (ie how wide is their nose, what type of hairstyle do they have, etc) */ diff --git a/src/main/java/electrosphere/server/datacell/RealmManager.java b/src/main/java/electrosphere/server/datacell/RealmManager.java index 08055f99..354f4eb1 100644 --- a/src/main/java/electrosphere/server/datacell/RealmManager.java +++ b/src/main/java/electrosphere/server/datacell/RealmManager.java @@ -136,5 +136,13 @@ public class RealmManager { } } + /** + * Returns the first realm in the manager + * @return The first realm in the manager + */ + public Realm first(){ + return realms.iterator().next(); + } + } diff --git a/src/test/java/electrosphere/entity/state/equip/ServerEquipStateTests.java b/src/test/java/electrosphere/entity/state/equip/ServerEquipStateTests.java new file mode 100644 index 00000000..896a47c4 --- /dev/null +++ b/src/test/java/electrosphere/entity/state/equip/ServerEquipStateTests.java @@ -0,0 +1,41 @@ +package electrosphere.entity.state.equip; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.joml.Vector3d; +import org.junit.jupiter.api.Disabled; + +import annotations.IntegrationTest; +import electrosphere.engine.Globals; +import electrosphere.entity.Entity; +import electrosphere.entity.state.inventory.InventoryUtils; +import electrosphere.entity.types.creature.CreatureTemplate; +import electrosphere.entity.types.creature.CreatureUtils; +import electrosphere.entity.types.item.ItemUtils; +import template.EntityTestTemplate; +import testutils.TestEngineUtils; + +/** + * Server equip state tests + */ +public class ServerEquipStateTests extends EntityTestTemplate { + + @Disabled + @IntegrationTest + public void spawningWithEquippedItem(){ + TestEngineUtils.simulateFrames(1); + //spawn entities + // CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human"); + // Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate); + // Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "katana2H"); + + //equip + // Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana); + // ServerEquipState serverEquipState = ServerEquipState.getServerEquipState(creature); + // serverEquipState.commandAttemptEquip(inInventoryItem, serverEquipState.getEquipPoint("handsCombined")); + + // //verify was equipped + // assertNotNull(serverEquipState.getEquippedItemAtPoint("handsCombined")); + } + +} diff --git a/src/test/java/template/EntityTestTemplate.java b/src/test/java/template/EntityTestTemplate.java new file mode 100644 index 00000000..a50832fe --- /dev/null +++ b/src/test/java/template/EntityTestTemplate.java @@ -0,0 +1,19 @@ +package template; + +import annotations.IntegrationSetup; +import testutils.EngineInit; +import testutils.TestEngineUtils; + +/** + * + */ +public abstract class EntityTestTemplate extends RenderingTestTemplate { + + @IntegrationSetup + @Override + public void initEngine(){ + TestEngineUtils.initGraphicalEngine(); + EngineInit.setupConnectedTestScene(); + } + +} diff --git a/src/test/java/testutils/EngineInit.java b/src/test/java/testutils/EngineInit.java new file mode 100644 index 00000000..fd7e9043 --- /dev/null +++ b/src/test/java/testutils/EngineInit.java @@ -0,0 +1,32 @@ +package testutils; + +import electrosphere.engine.loadingthreads.LoadingThread; +import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType; +import electrosphere.entity.scene.SceneFile; +import electrosphere.menu.mainmenu.MenuGeneratorsLevelEditor.LevelDescription; + +public class EngineInit { + + /** + * Setups up a locally-connected client and server that have loaded a test scene + */ + public static void setupConnectedTestScene(){ + + // + //create the scene + LevelDescription inFlightLevel = new LevelDescription(); + SceneFile sceneFile = SceneFile.createSceneFile(); + inFlightLevel.setSceneFile(sceneFile); + inFlightLevel.setName("testscene1"); + sceneFile.setCreateSaveInstance(false); + sceneFile.getRealmDescriptor().setGriddedRealmSize(1); + LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL_EDITOR, inFlightLevel); + loadingThread.run(); + + // + //load the scene + loadingThread = new LoadingThread(LoadingThreadType.LEVEL,"testscene1"); + loadingThread.run(); + } + +}