Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0854720
Server: Fix entity properties reset when switching env
SirLynix Feb 23, 2025
1953c7b
Server: Add atmosphere system
SirLynix Feb 23, 2025
efc711a
Server: Allow properties and RPCs to be replicated even if entity dies
SirLynix Feb 23, 2025
b7e672b
Make client aware of player and ship_exterior entities
SirLynix Feb 23, 2025
1793eb5
Make player breathe and die when it runs empty of oxygen
SirLynix Feb 23, 2025
ab810d0
Game: Display health and oxygen
SirLynix Feb 24, 2025
2c47ff5
Network: Fix properties synchronization
SirLynix Feb 26, 2025
7972168
Add script component
SirLynix Feb 26, 2025
6414c86
Make player breathe in O2 from atmosphere and breathe out CO2
SirLynix Feb 26, 2025
6c5a567
Add atmosphere_sensor entity and /spawnsensor command
SirLynix Feb 26, 2025
c6fb197
Server/Environment: Make GetAtmosphereAtPosition handle AtmosphereCar…
SirLynix Mar 1, 2025
39ee4e0
Server: Handle environment switching automatically for more components
SirLynix Mar 1, 2025
466d5ed
Server: Allow scripted entities to switch environment
SirLynix Mar 1, 2025
6fcc20f
Server/Ship: Fix buoyancy and gravity not working in ships
SirLynix Mar 1, 2025
5540e83
Server/Ship: Handle area atmosphere merging/splitting
SirLynix Mar 1, 2025
4e4df3f
Server/Ship: Handle all environment switchable entities to exit
SirLynix Mar 1, 2025
8502096
Scripting: Give access to more assets scripting methods
SirLynix Mar 9, 2025
1efcfac
xmake check-files -f
SirLynix Mar 9, 2025
4cbb1e1
Server: Fix crash when player enter/exit ship
SirLynix Mar 9, 2025
27425a0
Server/Environment: Destroy entities in child classes
SirLynix Mar 9, 2025
e61b78b
Minor fixes
SirLynix Mar 9, 2025
0c1d4f7
Server/ShipEnvironment: Take surrounding atmosphere into ship on spawn
SirLynix Mar 9, 2025
6b2e601
Server/ShipEnvironment: Release atmosphere on despawn
SirLynix Mar 9, 2025
1a56e14
Add trees
SirLynix Apr 7, 2025
1b5bdbc
Save entities to database (for ship and planets)
SirLynix Apr 7, 2025
94b2a86
Reorder includes
SirLynix Apr 7, 2025
5149fb7
Add /spawntree command
SirLynix Apr 7, 2025
770d631
Fix trees
SirLynix Apr 7, 2025
9dfa53f
Fix compilation
SirLynix Apr 8, 2025
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
6 changes: 3 additions & 3 deletions database/server/202503252314_create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE "planet_chunks" (
"chunk_data" BLOB NOT NULL,
"last_update" TEXT NOT NULL,
PRIMARY KEY("position_x","planet_id","position_y","position_z"),
FOREIGN KEY("planet_id") REFERENCES "planets"("id")
FOREIGN KEY("planet_id") REFERENCES "planets"("id") ON DELETE CASCADE
) WITHOUT ROWID,STRICT;

CREATE TABLE "planet_links" (
Expand All @@ -34,6 +34,6 @@ CREATE TABLE "planet_links" (
"position_y" REAL NOT NULL,
"position_z" REAL NOT NULL,
PRIMARY KEY("source_planet_id","destination_planet_id"),
FOREIGN KEY("destination_planet_id") REFERENCES "planets"("id"),
FOREIGN KEY("source_planet_id") REFERENCES "planets"("id")
FOREIGN KEY("destination_planet_id") REFERENCES "planets"("id") ON DELETE CASCADE,
FOREIGN KEY("source_planet_id") REFERENCES "planets"("id") ON DELETE CASCADE
) WITHOUT ROWID,STRICT;
19 changes: 19 additions & 0 deletions database/server/202504052243_planet_entities.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE "planet_entities" (
"id" INTEGER NOT NULL,
"unique_id" TEXT NOT NULL,
"planet_id" INTEGER NOT NULL,
"class_name" TEXT NOT NULL,
"class_version" INTEGER NOT NULL,
"position_x" REAL NOT NULL,
"position_y" REAL NOT NULL,
"position_z" REAL NOT NULL,
"rotation_x" REAL NOT NULL,
"rotation_y" REAL NOT NULL,
"rotation_z" REAL NOT NULL,
"rotation_w" REAL NOT NULL,
"properties" TEXT NOT NULL DEFAULT '{}' CHECK(json_valid("properties")),
"last_update" TEXT NOT NULL,
PRIMARY KEY("id"),
UNIQUE("unique_id"),
FOREIGN KEY("planet_id") REFERENCES "planets"("id") ON DELETE CASCADE
) STRICT
2 changes: 1 addition & 1 deletion include/ClientLib/ClientSessionHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace tsom
void HandlePacket(Packets::EntitiesStateUpdate&& stateUpdate);
void HandlePacket(Packets::EntityEnvironmentUpdate&& environmentUpdate);
void HandlePacket(Packets::EntityProcedureCall&& procedureCall);
void HandlePacket(Packets::EntityPropertyUpdate&& propertyUpdate);
void HandlePacket(Packets::EntityPropertiesUpdate&& propertyUpdate);
void HandlePacket(Packets::EnvironmentCreate&& envCreate);
void HandlePacket(Packets::EnvironmentDestroy&& envDestroy);
void HandlePacket(Packets::EnvironmentsUpdateOwner&& envOwnerUpdate);
Expand Down
38 changes: 38 additions & 0 deletions include/ClientLib/Entities/ClientEntityClassLibrary.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (C) 2025 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_ENTITIES_CLIENTENTITYCLASSLIBRARY_HPP
#define TSOM_CLIENTLIB_ENTITIES_CLIENTENTITYCLASSLIBRARY_HPP

#include <ClientLib/Export.hpp>
#include <CommonLib/Entities/SharedEntityClassLibrary.hpp>
#include <entt/fwd.hpp>

namespace Nz
{
class ApplicationBase;
}

namespace tsom
{
class BlockLibrary;
class ChunkContainer;
class ChunkEntities;

class TSOM_CLIENTLIB_API ClientEntityClassLibrary final : public SharedEntityClassLibrary
{
public:
using SharedEntityClassLibrary::SharedEntityClassLibrary;

private:
void OnPlayerActivate(entt::handle entity) override;
void OnPlayerRpc_Death(entt::handle entity) override;
};
}

#include <ClientLib/Entities/ClientEntityClassLibrary.inl>

#endif // TSOM_CLIENTLIB_ENTITIES_CLIENTENTITYCLASSLIBRARY_HPP
7 changes: 7 additions & 0 deletions include/ClientLib/Entities/ClientEntityClassLibrary.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (C) 2025 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
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#ifndef TSOM_CLIENTLIB_RENDERING_ATMOSPHEREPIPELINEPASS_HPP
#define TSOM_CLIENTLIB_RENDERING_ATMOSPHEREPIPELINEPASS_HPP
#ifndef TSOM_CLIENTLIB_RENDERING_ATMOSPHERESCATTERINGPIPELINEPASS_HPP
#define TSOM_CLIENTLIB_RENDERING_ATMOSPHERESCATTERINGPIPELINEPASS_HPP

#include <ClientLib/Export.hpp>
#include <Nazara/Core/ParameterList.hpp>
Expand Down Expand Up @@ -66,4 +66,4 @@ namespace tsom

#include <ClientLib/Rendering/AtmosphereScatteringPipelinePass.inl>

#endif // TSOM_CLIENTLIB_RENDERING_ATMOSPHEREPIPELINEPASS_HPP
#endif // TSOM_CLIENTLIB_RENDERING_ATMOSPHERESCATTERINGPIPELINEPASS_HPP
48 changes: 48 additions & 0 deletions include/ClientLib/Scripting/ClientAssetScriptingLibrary.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (C) 2025 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_SCRIPTING_CLIENTASSETSCRIPTINGLIBRARY_HPP
#define TSOM_CLIENTLIB_SCRIPTING_CLIENTASSETSCRIPTINGLIBRARY_HPP

#include <ClientLib/Export.hpp>
#include <CommonLib/Scripting/AssetScriptingLibrary.hpp>

namespace Nz
{
class ApplicationBase;
}

namespace tsom
{
class ClientSessionHandler;

class TSOM_CLIENTLIB_API ClientAssetScriptingLibrary final : public AssetScriptingLibrary
{
public:
using AssetScriptingLibrary::AssetScriptingLibrary;
ClientAssetScriptingLibrary(const ClientAssetScriptingLibrary&) = delete;
ClientAssetScriptingLibrary(ClientAssetScriptingLibrary&&) = delete;
~ClientAssetScriptingLibrary() = default;

void Register(sol::state& state) override;

ClientAssetScriptingLibrary& operator=(const ClientAssetScriptingLibrary&) = delete;
ClientAssetScriptingLibrary& operator=(ClientAssetScriptingLibrary&&) = delete;

private:
void RegisterAssetLibrary(sol::state& state);
void RegisterMaterial(sol::state& state);
void RegisterMaterialInstance(sol::state& state);
void RegisterMaterialSettings(sol::state& state);
void RegisterRenderables(sol::state& state);
void RegisterRenderStates(sol::state& state);
void RegisterTexture(sol::state& state);
};
}

#include <ClientLib/Scripting/ClientAssetScriptingLibrary.inl>

#endif // TSOM_CLIENTLIB_SCRIPTING_CLIENTASSETSCRIPTINGLIBRARY_HPP
7 changes: 7 additions & 0 deletions include/ClientLib/Scripting/ClientAssetScriptingLibrary.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (C) 2025 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
{
}
5 changes: 0 additions & 5 deletions include/ClientLib/Scripting/ClientScriptingLibrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ namespace tsom
ClientScriptingLibrary& operator=(ClientScriptingLibrary&&) = delete;

private:
void RegisterAssetLibrary(sol::state& state);
void RegisterClientSession(sol::state& state);
void RegisterMaterialInstance(sol::state& state);
void RegisterRenderables(sol::state& state);
void RegisterRenderStates(sol::state& state);
void RegisterScripts(sol::state& state);
void RegisterTexture(sol::state& state);

Nz::ApplicationBase& m_app;
ClientSessionHandler& m_sessionHandler;
Expand Down
1 change: 1 addition & 0 deletions include/CommonLib/Chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ namespace tsom
inline BlockIndex GetBlockContent(unsigned int blockIndex) const;
inline BlockIndex GetBlockContent(const Nz::Vector3ui& indices) const;
inline std::size_t GetBlockCount() const;
inline Nz::UInt16 GetBlockCount(std::size_t blockIndex) const;
inline float GetBlockSize() const;
inline ChunkContainer& GetContainer();
inline const ChunkContainer& GetContainer() const;
Expand Down
8 changes: 8 additions & 0 deletions include/CommonLib/Chunk.inl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ namespace tsom
return m_size.x * m_size.y * m_size.z;
}

inline Nz::UInt16 Chunk::GetBlockCount(std::size_t blockIndex) const
{
if (blockIndex >= m_blockTypeCount.size())
return 0;

return m_blockTypeCount[blockIndex];
}

inline float Chunk::GetBlockSize() const
{
return m_blockSize;
Expand Down
3 changes: 3 additions & 0 deletions include/CommonLib/Components/ClassInstanceComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace tsom
using PropertyUpdateSignal = Nz::Signal<Nz::UInt32, const EntityProperty&>;

ClassInstanceComponent(std::shared_ptr<const EntityClass> entityClass);
ClassInstanceComponent(std::shared_ptr<const EntityClass> entityClass, std::vector<EntityProperty>&& properties);
ClassInstanceComponent(const ClassInstanceComponent&) = delete;
ClassInstanceComponent(ClassInstanceComponent&&) noexcept = default;
~ClassInstanceComponent() = default;
Expand All @@ -34,6 +35,8 @@ namespace tsom
inline const EntityProperty& GetProperty(Nz::UInt32 propertyIndex) const;
template<EntityPropertyType Property> auto GetProperty(Nz::UInt32 propertyIndex) const;
template<EntityPropertyType Property> auto GetProperty(std::string_view propertyName) const;
inline const std::vector<EntityProperty>& GetProperties() const&;
inline std::vector<EntityProperty>&& GetProperties() &&;

Nz::UInt32 GetPropertyIndex(std::string_view propertyName) const;

Expand Down
10 changes: 10 additions & 0 deletions include/CommonLib/Components/ClassInstanceComponent.inl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ namespace tsom
return GetProperty<Property>(GetPropertyIndex(propertyName));
}

inline const std::vector<EntityProperty>& ClassInstanceComponent::GetProperties() const&
{
return m_properties;
}

inline std::vector<EntityProperty>&& ClassInstanceComponent::GetProperties()&&
{
return std::move(m_properties);
}

inline void ClassInstanceComponent::UpdateProperty(Nz::UInt32 propertyIndex, EntityProperty&& value)
{
assert(propertyIndex < m_properties.size());
Expand Down
24 changes: 24 additions & 0 deletions include/CommonLib/Components/TickComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2025 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_COMMONLIB_COMPONENTS_TICKCOMPONENT_HPP
#define TSOM_COMMONLIB_COMPONENTS_TICKCOMPONENT_HPP

#include <Nazara/Core/Time.hpp>
#include <entt/fwd.hpp>
#include <functional>

namespace tsom
{
struct TickComponent
{
std::function<void(entt::handle)> onTick;
Nz::Time timeBeforeTick = Nz::Time::Zero(); // 0 = tick each time
Nz::Time tickRate = Nz::Time::Zero();
};
}

#endif // TSOM_COMMONLIB_COMPONENTS_TICKCOMPONENT_HPP
53 changes: 53 additions & 0 deletions include/CommonLib/Entities/SharedEntityClassLibrary.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (C) 2025 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_COMMONLIB_ENTITIES_SHAREDENTITYCLASSLIBRARY_HPP
#define TSOM_COMMONLIB_ENTITIES_SHAREDENTITYCLASSLIBRARY_HPP

#include <CommonLib/Export.hpp>
#include <CommonLib/Entities/EntityClassLibrary.hpp>
#include <entt/fwd.hpp>

namespace Nz
{
class ApplicationBase;
class Collider3D;
}

namespace tsom
{
class EntityClass;

class TSOM_COMMONLIB_API SharedEntityClassLibrary : public EntityClassLibrary
{
public:
SharedEntityClassLibrary(Nz::ApplicationBase& app);
SharedEntityClassLibrary(const SharedEntityClassLibrary&) = delete;
SharedEntityClassLibrary(SharedEntityClassLibrary&&) = delete;
~SharedEntityClassLibrary() = default;

void Register(EntityRegistry& registry) override;

SharedEntityClassLibrary& operator=(const SharedEntityClassLibrary&) = delete;
SharedEntityClassLibrary& operator=(SharedEntityClassLibrary&&) = delete;

protected:
virtual void OnPlayerActivate(entt::handle entity);
virtual void OnPlayerInit(entt::handle entity);
virtual void OnPlayerRpc_Death(entt::handle entity);
virtual void OnShipExteriorActivate(entt::handle entity);
virtual void OnShipExteriorInit(entt::handle entity);

std::shared_ptr<Nz::Collider3D> m_playerCollider;
std::shared_ptr<const EntityClass> m_playerClass;
std::shared_ptr<const EntityClass> m_shipExteriorClass;
Nz::ApplicationBase& m_app;
};
}

#include <CommonLib/Entities/SharedEntityClassLibrary.inl>

#endif // TSOM_COMMONLIB_ENTITIES_SHAREDENTITYCLASSLIBRARY_HPP
7 changes: 7 additions & 0 deletions include/CommonLib/Entities/SharedEntityClassLibrary.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (C) 2025 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
{
}
5 changes: 5 additions & 0 deletions include/CommonLib/EntityClass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include <CommonLib/Export.hpp>
#include <CommonLib/EntityProperties.hpp>
#include <entt/fwd.hpp>
#include <nlohmann/json_fwd.hpp>
#include <tsl/hopscotch_map.h>
#include <functional>
#include <span>
#include <string>
#include <vector>

Expand Down Expand Up @@ -45,6 +47,9 @@ namespace tsom
void InitAndActivateEntity(entt::handle entity) const;
void InitEntity(entt::handle entity) const;

std::vector<EntityProperty> PropertiesFromJson(const nlohmann::json& propertiesJson) const;
nlohmann::json PropertiesToJson(std::span<const EntityProperty> properties) const;

EntityClass& operator=(const EntityClass&) = delete;
EntityClass& operator=(EntityClass&&) noexcept = default;

Expand Down
2 changes: 1 addition & 1 deletion include/CommonLib/EntityRegistry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace tsom

void Refresh(std::span<entt::registry*> registries, Nz::FunctionRef<void()> refreshCallback);

void RegisterClass(EntityClass entityClass);
std::shared_ptr<const EntityClass> RegisterClass(EntityClass entityClass);

template<typename T, typename... Args> void RegisterClassLibrary(Args&&... args);
void RegisterClassLibrary(std::unique_ptr<EntityClassLibrary>&& library);
Expand Down
6 changes: 6 additions & 0 deletions include/CommonLib/GameConstants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

namespace tsom::Constants
{
// Atmosphere constants
constexpr Nz::UInt64 OxygenAtmospherePct = 21;
constexpr Nz::Int64 PlayerOxygenConsumption = 100;
constexpr Nz::UInt64 SecondsToEmptyOxygenBlock = 5;

// Chat constants
constexpr std::size_t ChatMaxLines = 100;
constexpr std::size_t ChatMaxMessageLength = 1024;
Expand All @@ -35,6 +40,7 @@ namespace tsom::Constants
constexpr float PlayerWalkSpeed = 5.f;
constexpr Nz::DegreeAnglef GravityMaxRotationSpeed = 180.f;
constexpr Nz::DegreeAnglef PlayerRotationSpeed = 90.f;
constexpr Nz::Time PlayerRespawnTime = Nz::Time::Seconds(5);

// Ship constants
constexpr float ShipGravityAcceleration = 9.81f;
Expand Down
Loading
Loading