summaryrefslogtreecommitdiff
path: root/game/vehicles
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-04 14:27:23 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-04 14:27:23 +0000
commit54ddcd3da0916b6a46f5fcf3f33ff0fbffe375ce (patch)
treea1a46ac32486375a7b2636e467779916d28c8c4c /game/vehicles
parentAdd Asset helpers to construct OpenGL ready meshes from Asset Factory meshes ... (diff)
downloadilt-54ddcd3da0916b6a46f5fcf3f33ff0fbffe375ce.tar.bz2
ilt-54ddcd3da0916b6a46f5fcf3f33ff0fbffe375ce.tar.xz
ilt-54ddcd3da0916b6a46f5fcf3f33ff0fbffe375ce.zip
Support and load factory asset directly into a RailVehicleClass instance
Diffstat (limited to 'game/vehicles')
-rw-r--r--game/vehicles/railVehicleClass.cpp9
-rw-r--r--game/vehicles/railVehicleClass.h8
2 files changed, 16 insertions, 1 deletions
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index dff1416..7052396 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -39,6 +39,15 @@ RailVehicleClass::RailVehicleClass(std::unique_ptr<ObjParser> o, std::shared_ptr
bogies[1] = m.at("Bogie2");
}
+RailVehicleClass::RailVehicleClass() { }
+
+bool
+RailVehicleClass::persist(Persistence::PersistenceStore & store)
+{
+ return STORE_TYPE && STORE_MEMBER(maxSpeed) && STORE_NAME_HELPER("bogie", bogies, Asset::MeshArrayConstruct)
+ && STORE_HELPER(bodyMesh, Asset::MeshConstruct) && Asset::persist(store);
+}
+
void
RailVehicleClass::render(
const SceneShader & shader, const Location & location, const std::array<Location, 2> & bl) const
diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h
index bd74ab9..c50dacc 100644
--- a/game/vehicles/railVehicleClass.h
+++ b/game/vehicles/railVehicleClass.h
@@ -1,5 +1,6 @@
#pragma once
+#include "assetFactory/asset.h"
#include "gfx/models/mesh.h"
#include <array>
#include <memory>
@@ -11,9 +12,10 @@ class Texture;
class ObjParser;
class Location;
-class RailVehicleClass {
+class RailVehicleClass : public Asset {
public:
explicit RailVehicleClass(const std::string & name);
+ RailVehicleClass();
void render(const SceneShader &, const Location &, const std::array<Location, 2> &) const;
void shadows(const ShadowMapper &, const Location &) const;
@@ -25,6 +27,10 @@ public:
float length;
float maxSpeed;
+protected:
+ friend Persistence::SelectionPtrBase<std::shared_ptr<RailVehicleClass>>;
+ bool persist(Persistence::PersistenceStore & store) override;
+
private:
RailVehicleClass(std::unique_ptr<ObjParser> obj, std::shared_ptr<Texture>);
static float bogieOffset(ObjParser & o);