summaryrefslogtreecommitdiff
path: root/assetFactory/asset.h
blob: b5de0560a0b5ab4578b6e3f187de41276a06024d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "factoryMesh.h"
#include "persistence.h"
#include <manyPtr.h>
#include <stdTypeDefs.h>

class TextureAtlas;
class Renderable;

class Asset : public Persistence::Persistable, public StdTypeDefs<Asset> {
public:
	using ManyPtr = ManySharedPtr<Asset, const Renderable>;
	using TexturePtr = std::shared_ptr<TextureAtlas>;

	std::string id;
	std::string name;

protected:
	TexturePtr getTexture() const;

	struct MeshConstruct : public Persistence::SelectionPtrBase<FactoryMesh::Ptr> {
		using Persistence::SelectionPtrBase<FactoryMesh::Ptr>::setValue;

		MeshConstruct(Mesh::Ptr & m);

		void endObject(Persistence::Stack & stk) override;

		FactoryMesh::Ptr fmesh;
		Mesh::Ptr & out;
	};

	struct MeshArrayConstruct : public Persistence::SelectionPtrBase<FactoryMesh::Ptr> {
		using Persistence::SelectionPtrBase<FactoryMesh::Ptr>::setValue;

		MeshArrayConstruct(std::span<Mesh::Ptr> m);

		void endObject(Persistence::Stack & stk) override;

		FactoryMesh::Ptr fmesh;
		std::span<Mesh::Ptr> out;
	};

	friend Persistence::SelectionPtrBase<std::shared_ptr<Asset>>;
	bool persist(Persistence::PersistenceStore & store) override;
};