diff --git a/assets/Audio/interact/Grab Cloth High A.wav b/assets/Audio/interact/Grab Cloth High A.wav new file mode 100644 index 00000000..5bf2cf59 Binary files /dev/null and b/assets/Audio/interact/Grab Cloth High A.wav differ diff --git a/assets/Audio/interact/High Five A.wav b/assets/Audio/interact/High Five A.wav new file mode 100644 index 00000000..6496a408 Binary files /dev/null and b/assets/Audio/interact/High Five A.wav differ diff --git a/assets/Audio/interact/Medium Stones Impact C.wav b/assets/Audio/interact/Medium Stones Impact C.wav new file mode 100644 index 00000000..79a410b3 Binary files /dev/null and b/assets/Audio/interact/Medium Stones Impact C.wav differ diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index c7531913..f413d174 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1532,6 +1532,9 @@ ServerWorldData conversion methods are static now Fix character data serialization only serializing dataType Potential fix for realm undefined for server terrain physics entity Fix macro character entities not being assigned ServerCharacterData +Audio on placing blocks +Audio on placing/removing voxels +Debounce item usage activations diff --git a/src/main/java/electrosphere/client/interact/ItemActions.java b/src/main/java/electrosphere/client/interact/ItemActions.java index f4cdb43f..76ab425f 100644 --- a/src/main/java/electrosphere/client/interact/ItemActions.java +++ b/src/main/java/electrosphere/client/interact/ItemActions.java @@ -2,10 +2,12 @@ package electrosphere.client.interact; import org.joml.Vector3d; +import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.client.script.ClientScriptUtils; import electrosphere.collision.CollisionEngine; import electrosphere.engine.Globals; +import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.entity.Entity; import electrosphere.entity.state.attack.ClientAttackTree; import electrosphere.entity.state.attack.ShooterTree; @@ -164,6 +166,11 @@ public class ItemActions { if(data.getClientSideSecondary() != null){ ClientScriptUtils.fireSignal(data.getClientSideSecondary()); } + if(data.getSecondaryUsage() != null){ + if(data.getSecondaryUsage().getBlockId() != null){ + Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, VirtualAudioSourceType.CREATURE, false); + } + } } } } diff --git a/src/main/java/electrosphere/client/script/ScriptClientVoxelUtils.java b/src/main/java/electrosphere/client/script/ScriptClientVoxelUtils.java index fc9b73eb..c9458aa6 100644 --- a/src/main/java/electrosphere/client/script/ScriptClientVoxelUtils.java +++ b/src/main/java/electrosphere/client/script/ScriptClientVoxelUtils.java @@ -4,10 +4,13 @@ import org.graalvm.polyglot.HostAccess.Export; import org.joml.Vector3d; import org.joml.Vector3i; +import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; +import electrosphere.audio.movement.MovementAudioService.InteractionType; import electrosphere.client.entity.camera.CameraEntityUtils; import electrosphere.client.terrain.editing.TerrainEditing; import electrosphere.collision.CollisionEngine; import electrosphere.engine.Globals; +import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.entity.Entity; import electrosphere.server.physics.terrain.manager.ServerTerrainChunk; @@ -50,6 +53,7 @@ public class ScriptClientVoxelUtils { } if(Globals.clientSelectedVoxelType != null){ TerrainEditing.editTerrain(cursorPos, 1.1f, Globals.clientSelectedVoxelType.getId(), EDIT_INCREMENT); + Globals.movementAudioService.getAudioPath(Globals.clientSelectedVoxelType.getId(), InteractionType.STEP_SHOE_REG); } } } @@ -108,6 +112,7 @@ public class ScriptClientVoxelUtils { cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE)); } TerrainEditing.removeTerrainGated(cursorPos, 1.1f, REMOVE_INCREMENT); + Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_DIG, VirtualAudioSourceType.CREATURE, false); } } diff --git a/src/main/java/electrosphere/controls/categories/ControlCategoryMainGame.java b/src/main/java/electrosphere/controls/categories/ControlCategoryMainGame.java index e4e4f730..55c91985 100644 --- a/src/main/java/electrosphere/controls/categories/ControlCategoryMainGame.java +++ b/src/main/java/electrosphere/controls/categories/ControlCategoryMainGame.java @@ -585,7 +585,7 @@ public class ControlCategoryMainGame { ItemActions.attemptSecondaryItemAction(); }}); controlMap.get(ITEM_SECONDARY).setOnRepeat(new ControlMethod() {public void execute(MouseState mouseState) { - ItemActions.attemptSecondaryItemAction(); + ItemActions.repeatSecondaryItemAction(); }}); controlMap.get(ITEM_SECONDARY).setRepeatTimeout(0.5f * Main.targetFrameRate); controlMap.get(ITEM_SECONDARY).setOnRelease(new ControlMethod() {public void execute(MouseState mouseState) { diff --git a/src/main/java/electrosphere/engine/Globals.java b/src/main/java/electrosphere/engine/Globals.java index 474710eb..e5d07669 100644 --- a/src/main/java/electrosphere/engine/Globals.java +++ b/src/main/java/electrosphere/engine/Globals.java @@ -597,6 +597,9 @@ public class Globals { AssetDataStrings.UI_SFX_ITEM_RELEASE, AssetDataStrings.UI_SFX_INVENTORY_OPEN, AssetDataStrings.UI_SFX_INVENTORY_CLOSE, + AssetDataStrings.INTERACT_SFX_BLOCK_PICKUP, + AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, + AssetDataStrings.INTERACT_SFX_DIG, }; LoggerInterface.loggerStartup.INFO("Loading default audio resources"); for(String path : audioToInit){ diff --git a/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java b/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java index c071e769..08313ffc 100644 --- a/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java +++ b/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java @@ -82,4 +82,11 @@ public class AssetDataStrings { public static final String COMPUTE_LIGHT_CLUSTER = "Shaders/core/light/cluster.comp"; public static final String COMPUTE_LIGHT_CULL = "Shaders/core/light/cull.comp"; + /** + * Interaction-specific audio + */ + public static final String INTERACT_SFX_DIG = "Audio/interact/Medium Stones Impact C.wav"; + public static final String INTERACT_SFX_BLOCK_PICKUP = "Audio/interact/Grab Cloth High A.wav"; + public static final String INTERACT_SFX_BLOCK_PLACE = "Audio/interact/High Five A.wav"; + } diff --git a/src/main/java/electrosphere/game/data/item/ItemUsage.java b/src/main/java/electrosphere/game/data/item/ItemUsage.java index 4c0b34c4..8287578a 100644 --- a/src/main/java/electrosphere/game/data/item/ItemUsage.java +++ b/src/main/java/electrosphere/game/data/item/ItemUsage.java @@ -15,6 +15,11 @@ public class ItemUsage { */ Integer blockId; + /** + * Controls whether this usage only fires on mouse down + */ + Boolean onlyOnMouseDown; + /** * Gets the spawn entity id of the item usage * @return The spawn entity id @@ -47,6 +52,22 @@ public class ItemUsage { this.blockId = blockId; } + /** + * Gets whether this usage only fires on mouse down + * @return if true, the usage only fires on mouse down + */ + public Boolean getOnlyOnMouseDown() { + return onlyOnMouseDown; + } + + /** + * Sets whether this usage only fires on mouse down + * @param onlyOnMouseDown true to only fire on mouse down + */ + public void setOnlyOnMouseDown(Boolean onlyOnMouseDown) { + this.onlyOnMouseDown = onlyOnMouseDown; + } + diff --git a/src/main/java/electrosphere/server/player/PlayerActions.java b/src/main/java/electrosphere/server/player/PlayerActions.java index b01c1327..52d7e3e4 100644 --- a/src/main/java/electrosphere/server/player/PlayerActions.java +++ b/src/main/java/electrosphere/server/player/PlayerActions.java @@ -39,6 +39,7 @@ public class PlayerActions { Entity playerEntity = EntityLookupUtils.getEntityById(connectionHandler.getPlayerEntityId()); if(message.getitemActionCode() == ItemActions.ITEM_ACTION_CODE_SECONDARY){ + int itemActionCodeState = message.getitemActionCodeState(); ServerToolbarState serverToolbarState = ServerToolbarState.getServerToolbarState(playerEntity); if(serverToolbarState != null && serverToolbarState.getRealWorldItem() != null){ Item item = Globals.gameConfigCurrent.getItemMap().getItem(serverToolbarState.getRealWorldItem()); @@ -60,7 +61,12 @@ public class PlayerActions { if(shouldBlock){ PlayerActions.block(playerEntity, message); } else if(item.getSecondaryUsage() != null){ - PlayerActions.secondaryUsage(playerEntity, item, message); + if( + item.getSecondaryUsage().getOnlyOnMouseDown() == null || + (itemActionCodeState == ItemActions.ITEM_ACTION_CODE_STATE_ON && item.getSecondaryUsage().getOnlyOnMouseDown()) + ){ + PlayerActions.secondaryUsage(playerEntity, item, message); + } } } }