summaryrefslogtreecommitdiff
path: root/hammer/prefab3d.h
blob: 850f62b70b271ecef2bf0a9c5d7d02d893a7c139 (plain) (blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef PREFAB3D_H
#define PREFAB3D_H
#pragma once


#include "Prefabs.h"


class CChunkFile;
class CMapWorld;
class Vector;


enum ChunkFileResult_t;


class CPrefab3D : public CPrefab
{
	public:

		CPrefab3D();
		~CPrefab3D();

		virtual bool IsLoaded(void);
		void FreeData();

		void CenterOnZero();

		CMapClass *Create(void);
		CMapClass *CreateInBox(BoundBox *pBox);
		CMapClass *CreateAtPoint(const Vector &point);
		CMapClass *CreateAtPointAroundOrigin( Vector const &point );

		int GetType(void) { return pt3D; }
		inline CMapWorld *GetWorld(void);
		inline void SetWorld(CMapWorld *pWorld);

	protected:

		// prefab data:
		CMapWorld *m_pWorld;
}; 


//-----------------------------------------------------------------------------
// Purpose: Returns a world containing the objects that make up this prefab.
//-----------------------------------------------------------------------------
CMapWorld *CPrefab3D::GetWorld(void)
{
	return(m_pWorld);
}


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPrefab3D::SetWorld(CMapWorld *pWorld)
{
	FreeData();
	m_pWorld = pWorld;
}


class CPrefabRMF : public CPrefab3D
{
	public:

		CPrefabRMF();
		~CPrefabRMF();

		int Init(LPCTSTR pszFilename, BOOL bLoadNow = FALSE, DWORD = 0);
		int Load(DWORD dwFlags = 0);
		int Save(LPCTSTR pszFilename, DWORD = 0);

		int Init(std::fstream &file, BOOL bLoadNow = FALSE, DWORD = 0);
		int Save(std::fstream &file, DWORD = 0);

	private:

		int DoLoad(std::fstream&, DWORD = 0);
		int DoSave(std::fstream&, DWORD = 0);
}; 


class CPrefabVMF : public CPrefab3D
{
	public:

		CPrefabVMF();
		~CPrefabVMF();

		int Load(DWORD dwFlags = 0);
		int Save(LPCTSTR pszFilename, DWORD = 0);

		virtual bool IsLoaded(void);

		void SetFilename(const char *szFilename);

	protected:

		static ChunkFileResult_t LoadEntityCallback(CChunkFile *pFile, CPrefabVMF *pPrefab);
		static ChunkFileResult_t LoadWorldCallback(CChunkFile *pFile, CPrefabVMF *pPrefab);

		char m_szFilename[MAX_PATH];	// Full path of the prefab VMF.
		int m_nFileTime;				// File modification time of the last loaded version of the prefab.
}; 

#endif // PREFAB3D_H