Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions assets/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
"output": "Models/ShipComputer/digital_displays.dds",
"method": "Texture"
},
{
"input": "tree/shapespark-low-poly-plants-kit.gltf",
"output": "Models/Tree/shapespark-low-poly-plants-kit.gltf",
"method": "Copy"
},
{
"input": "Shaders/BlockPBR.nzsl",
"output": "Shaders/BlockPBR.nzslb",
Expand Down Expand Up @@ -665,6 +660,46 @@
"input": "UI/ToolsMenu/ToolsMenu_Tool5.png",
"output": "UI/ToolsMenu/ToolsMenu_Tool5.dds",
"method": "Texture"
},
{
"input": "sounds/computer/sci-fi_beep_computer_ui_05.wav",
"output": "Sounds/Computer/Activation.opus",
"method": "Audio"
},
{
"input": "sounds/computer/sci-fi_computer_running_code_02.wav",
"output": "Sounds/Computer/NoEnergy.opus",
"method": "Audio"
},
{
"input": "sounds/footsteps/joentnt-walk-on-dirt-1-291981.mp3",
"output": "Sounds/Footsteps/Dirt_1.opus",
"method": "Audio"
},
{
"input": "sounds/footsteps/joentnt-walk-on-dirt-2-291982.mp3",
"output": "Sounds/Footsteps/Dirt_2.opus",
"method": "Audio"
},
{
"input": "sounds/footsteps/joentnt-walk-on-dirt-3-291983.mp3",
"output": "Sounds/Footsteps/Dirt_3.opus",
"method": "Audio"
},
{
"input": "sounds/footsteps/joentnt-walk-on-grass-1-291984.mp3",
"output": "Sounds/Footsteps/Grass_1.opus",
"method": "Audio"
},
{
"input": "sounds/footsteps/joentnt-walk-on-grass-2-291985.mp3",
"output": "Sounds/Footsteps/Grass_2.opus",
"method": "Audio"
},
{
"input": "sounds/footsteps/joentnt-walk-on-grass-3-291986.mp3",
"output": "Sounds/Footsteps/Grass_3.opus",
"method": "Audio"
}
]
}
18 changes: 12 additions & 6 deletions assets/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"basePath": "blocks/dirt",
"isSmooth": true,
"density": 2.0,
"permeability": 0.1
"permeability": 0.1,
"surfaceType": "dirt"
},
"hull": {
"basePath": "blocks/smooth_stone"
Expand All @@ -56,13 +57,15 @@
"basePath": "blocks/stone_bricks"
},
"copper_block": {
"basePath": "blocks/copper_block"
"basePath": "blocks/copper_block",
"surfaceType": "metal"
},
"grass": {
"basePath": "blocks/grass",
"isSmooth": true,
"density": 2.0,
"permeability": 0.1
"permeability": 0.1,
"surfaceType": "grass"
},
"glass": {
"basePath": "blocks/glass",
Expand Down Expand Up @@ -96,13 +99,16 @@
"basePath": "blocks/white_bricks"
},
"gold": {
"basePath": "blocks/gold"
"basePath": "blocks/gold",
"surfaceType": "metal"
},
"metal": {
"basePath": "blocks/metal"
"basePath": "blocks/metal",
"surfaceType": "metal"
},
"metal_plates": {
"basePath": "blocks/metal_plates"
"basePath": "blocks/metal_plates",
"surfaceType": "metal"
},
"brickswall": {
"basePath": "blocks/brickswall"
Expand Down
7 changes: 6 additions & 1 deletion include/ClientLib/ClientAssetLibraryAppComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Nz
class Material;
class MaterialInstance;
class Model;
class SoundBuffer;
class TextureAsset;
}

Expand All @@ -36,19 +37,22 @@ namespace tsom
inline std::shared_ptr<Nz::Material> GetMaterial(std::string_view name) const;
inline std::shared_ptr<Nz::MaterialInstance> GetMaterialInstance(std::string_view name) const;
inline std::shared_ptr<Nz::Model> GetModel(std::string_view name) const;
inline std::shared_ptr<Nz::SoundBuffer> GetSoundBuffer(std::string_view name) const;
inline std::shared_ptr<Nz::TextureAsset> GetTexture(std::string_view name) const;

inline std::shared_ptr<Nz::Font> QueryFont(std::string_view name) const;
inline std::shared_ptr<Nz::Material> QueryMaterial(std::string_view name) const;
inline std::shared_ptr<Nz::MaterialInstance> QueryMaterialInstance(std::string_view name) const;
inline std::shared_ptr<Nz::Model> QueryModel(std::string_view name) const;
inline std::shared_ptr<Nz::SoundBuffer> QuerySoundBuffer(std::string_view name) const;
inline std::shared_ptr<Nz::TextureAsset> QueryTexture(std::string_view name) const;

inline void RegisterFont(std::string name, std::shared_ptr<Nz::Font> font);
inline void RegisterMaterial(std::string name, std::shared_ptr<Nz::Material> material);
inline void RegisterMaterialInstance(std::string name, std::shared_ptr<Nz::MaterialInstance> materialInstance);
inline void RegisterModel(std::string name, std::shared_ptr<Nz::Model> font);
inline void RegisterTexture(std::string name, std::shared_ptr<Nz::TextureAsset> font);
inline void RegisterSoundBuffer(std::string name, std::shared_ptr<Nz::SoundBuffer> soundBuffer);
inline void RegisterTexture(std::string name, std::shared_ptr<Nz::TextureAsset> texture);

ClientAssetLibraryAppComponent& operator=(const ClientAssetLibraryAppComponent&) = delete;
ClientAssetLibraryAppComponent& operator=(ClientAssetLibraryAppComponent&&) = delete;
Expand All @@ -61,6 +65,7 @@ namespace tsom
Nz::ObjectLibrary<Nz::Material> m_materialLibrary;
Nz::ObjectLibrary<Nz::MaterialInstance> m_materialInstanceLibrary;
Nz::ObjectLibrary<Nz::Model> m_modelLibrary;
Nz::ObjectLibrary<Nz::SoundBuffer> m_soundBufferLibrary;
Nz::ObjectLibrary<Nz::TextureAsset> m_textureLibrary;
};
}
Expand Down
15 changes: 15 additions & 0 deletions include/ClientLib/ClientAssetLibraryAppComponent.inl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ namespace tsom
return m_modelLibrary.Get(name);
}

inline std::shared_ptr<Nz::SoundBuffer> ClientAssetLibraryAppComponent::GetSoundBuffer(std::string_view name) const
{
return m_soundBufferLibrary.Get(name);
}

inline std::shared_ptr<Nz::TextureAsset> ClientAssetLibraryAppComponent::GetTexture(std::string_view name) const
{
return m_textureLibrary.Get(name);
Expand All @@ -49,6 +54,11 @@ namespace tsom
return m_modelLibrary.Query(name);
}

inline std::shared_ptr<Nz::SoundBuffer> tsom::ClientAssetLibraryAppComponent::QuerySoundBuffer(std::string_view name) const
{
return m_soundBufferLibrary.Query(name);
}

inline std::shared_ptr<Nz::TextureAsset> ClientAssetLibraryAppComponent::QueryTexture(std::string_view name) const
{
return m_textureLibrary.Query(name);
Expand All @@ -74,6 +84,11 @@ namespace tsom
m_modelLibrary.Register(std::move(name), std::move(model));
}

inline void ClientAssetLibraryAppComponent::RegisterSoundBuffer(std::string name, std::shared_ptr<Nz::SoundBuffer> soundBuffer)
{
m_soundBufferLibrary.Register(std::move(name), std::move(soundBuffer));
}

inline void ClientAssetLibraryAppComponent::RegisterTexture(std::string name, std::shared_ptr<Nz::TextureAsset> texture)
{
m_textureLibrary.Register(std::move(name), std::move(texture));
Expand Down
10 changes: 2 additions & 8 deletions include/ClientLib/ClientSessionHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace tsom
class ClientBlockLibrary;
class ConfigFile;
class GravityController;
struct PlayerAnimationAssets;
struct PlayerAssets;

class TSOM_CLIENTLIB_API ClientSessionHandler : public SessionHandler
{
Expand Down Expand Up @@ -136,14 +136,8 @@ namespace tsom
entt::handle entity;
};

struct PlayerModel
{
std::shared_ptr<Nz::Model> model;
};

entt::handle m_playerControlledEntity;
std::optional<PlayerModel> m_playerModel;
std::shared_ptr<PlayerAnimationAssets> m_playerAnimAssets;
std::shared_ptr<PlayerAssets> m_playerAssets;
std::vector<std::optional<EntityData>> m_entities; //< FIXME: Nz::SparseVector
std::vector<std::optional<EnvironmentData>> m_environments; //< FIXME: Nz::SparseVector
std::vector<std::optional<PlayerInfo>> m_players; //< FIXME: Nz::SparseVector
Expand Down
23 changes: 23 additions & 0 deletions include/ClientLib/Components/AudioListenerComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2026 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "This Space Of Mine" project
// For conditions of distribution and use, see copyright notice in LICENSE

#pragma once

#ifndef TSOM_CLIENTLIB_COMPONENTS_AUDIOLISTENERCOMPONENT_HPP
#define TSOM_CLIENTLIB_COMPONENTS_AUDIOLISTENERCOMPONENT_HPP

#include <ClientLib/Export.hpp>
#include <Nazara/Math/Vector3.hpp>

namespace tsom
{
struct AudioListenerComponent
{
Nz::Vector3f lastPosition; //< To compute velocity
};
}

#include <ClientLib/Components/AudioListenerComponent.inl>

#endif // TSOM_CLIENTLIB_COMPONENTS_AUDIOLISTENERCOMPONENT_HPP
7 changes: 7 additions & 0 deletions include/ClientLib/Components/AudioListenerComponent.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (C) 2026 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "This Space Of Mine" project
// For conditions of distribution and use, see copyright notice in LICENSE

namespace tsom
{
}
47 changes: 47 additions & 0 deletions include/ClientLib/Components/SoundEmitterComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (C) 2026 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "This Space Of Mine" project
// For conditions of distribution and use, see copyright notice in LICENSE

#pragma once

#ifndef TSOM_CLIENTLIB_COMPONENTS_SOUNDEMITTERCOMPONENT_HPP
#define TSOM_CLIENTLIB_COMPONENTS_SOUNDEMITTERCOMPONENT_HPP

#include <ClientLib/Export.hpp>
#include <Nazara/Audio/Sound.hpp>
#include <NazaraUtils/FixedVector.hpp>
#include <memory>

namespace Nz
{
class Node;
class SoundDataSource;
}

namespace tsom
{
class TSOM_CLIENTLIB_API SoundEmitterComponent
{
friend class AudioSystem;

public:
inline SoundEmitterComponent();

const std::shared_ptr<Nz::Sound>& AddSound(std::shared_ptr<Nz::SoundDataSource> soundSource);

void StopAllSounds();

private:
inline void SetAudioSystem(AudioSystem* audioSystem);
inline void SetLastPosition(const Nz::Vector3f& position);
void Update(Nz::Node& node, float deltaTime);

Nz::HybridVector<std::shared_ptr<Nz::Sound>, 2> m_sounds;
Nz::Vector3f m_lastPosition;
AudioSystem* m_audioSystem;
};
}

#include <ClientLib/Components/SoundEmitterComponent.inl>

#endif // TSOM_CLIENTLIB_COMPONENTS_SOUNDEMITTERCOMPONENT_HPP
21 changes: 21 additions & 0 deletions include/ClientLib/Components/SoundEmitterComponent.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2026 Jérôme "SirLynix" Leclercq (lynix680@gmail.com)
// This file is part of the "This Space Of Mine" project
// For conditions of distribution and use, see copyright notice in LICENSE

namespace tsom
{
inline SoundEmitterComponent::SoundEmitterComponent() :
m_audioSystem(nullptr)
{
}

inline void SoundEmitterComponent::SetAudioSystem(AudioSystem* audioSystem)
{
m_audioSystem = audioSystem;
}

inline void SoundEmitterComponent::SetLastPosition(const Nz::Vector3f& position)
{
m_lastPosition = position;
}
}
23 changes: 19 additions & 4 deletions include/ClientLib/PlayerAnimationController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,41 @@
#define TSOM_CLIENTLIB_PLAYERANIMATIONCONTROLLER_HPP

#include <ClientLib/AnimationController.hpp>
#include <CommonLib/SurfaceType.hpp>
#include <CommonLib/Utility/AverageValues.hpp>
#include <Nazara/Core/Animation.hpp>
#include <Nazara/Core/AnimationBlender.hpp>
#include <Nazara/Core/Skeleton.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <NazaraUtils/EnumArray.hpp>
#include <entt/entt.hpp>
#include <memory>
#include <vector>

namespace Nz
{
class Animation;
class Model;
class SoundBuffer;
}

namespace tsom
{
struct PlayerAnimationAssets
struct PlayerAssets
{
std::shared_ptr<Nz::Animation> idleAnimation;
std::shared_ptr<Nz::Animation> runningAnimation;
std::shared_ptr<Nz::Animation> walkingAnimation;
std::shared_ptr<Nz::Model> model;
Nz::EnumArray<SurfaceType, std::vector<std::shared_ptr<Nz::SoundBuffer>>> footstepSounds;
Nz::Skeleton referenceSkeleton;
};

class ClientBlockLibrary;

class TSOM_CLIENTLIB_API PlayerAnimationController : public AnimationController
{
public:
PlayerAnimationController(entt::handle entity, std::shared_ptr<PlayerAnimationAssets> animationAssets);
PlayerAnimationController(ClientBlockLibrary& blockLibrary, entt::handle entity, std::shared_ptr<PlayerAssets> playerAssets);
PlayerAnimationController(const PlayerAnimationController&) = delete;
PlayerAnimationController(PlayerAnimationController&&) = delete;
~PlayerAnimationController() = default;
Expand All @@ -42,11 +55,13 @@ namespace tsom
PlayerAnimationController& operator=(PlayerAnimationController&&) = delete;

private:
std::shared_ptr<PlayerAnimationAssets> m_animationAssets;
std::shared_ptr<PlayerAssets> m_playerAssets;
entt::handle m_entity;
Nz::AnimationBlender m_idleRunBlender;
Nz::Time m_footstepAccumulator;
Nz::Vector3f m_playerPosition;
AverageValues<float> m_playerVelocities;
ClientBlockLibrary& m_blockLibrary;
};
}

Expand Down
2 changes: 2 additions & 0 deletions include/ClientLib/Scripting/ClientAssetScriptingLibrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace tsom
void RegisterMaterialSettings(sol::state& state);
void RegisterRenderables(sol::state& state);
void RegisterRenderStates(sol::state& state);
void RegisterSound(sol::state& state);
void RegisterSoundBuffer(sol::state& state);
void RegisterTexture(sol::state& state);
};
}
Expand Down
Loading
Loading