Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PREFAB3D_H
  8. #define PREFAB3D_H
  9. #pragma once
  10. #include "Prefabs.h"
  11. class CChunkFile;
  12. class CMapWorld;
  13. class Vector;
  14. enum ChunkFileResult_t;
  15. class CPrefab3D : public CPrefab
  16. {
  17. public:
  18. CPrefab3D();
  19. ~CPrefab3D();
  20. virtual bool IsLoaded(void);
  21. void FreeData();
  22. void CenterOnZero();
  23. CMapClass *Create(void);
  24. CMapClass *CreateInBox(BoundBox *pBox);
  25. CMapClass *CreateAtPoint(const Vector &point);
  26. CMapClass *CreateAtPointAroundOrigin( Vector const &point );
  27. int GetType(void) { return pt3D; }
  28. inline CMapWorld *GetWorld(void);
  29. inline void SetWorld(CMapWorld *pWorld);
  30. protected:
  31. // prefab data:
  32. CMapWorld *m_pWorld;
  33. };
  34. //-----------------------------------------------------------------------------
  35. // Purpose: Returns a world containing the objects that make up this prefab.
  36. //-----------------------------------------------------------------------------
  37. CMapWorld *CPrefab3D::GetWorld(void)
  38. {
  39. return(m_pWorld);
  40. }
  41. //-----------------------------------------------------------------------------
  42. // Purpose:
  43. //-----------------------------------------------------------------------------
  44. void CPrefab3D::SetWorld(CMapWorld *pWorld)
  45. {
  46. FreeData();
  47. m_pWorld = pWorld;
  48. }
  49. class CPrefabRMF : public CPrefab3D
  50. {
  51. public:
  52. CPrefabRMF();
  53. ~CPrefabRMF();
  54. int Init(LPCTSTR pszFilename, BOOL bLoadNow = FALSE, DWORD = 0);
  55. int Load(DWORD dwFlags = 0);
  56. int Save(LPCTSTR pszFilename, DWORD = 0);
  57. int Init(std::fstream &file, BOOL bLoadNow = FALSE, DWORD = 0);
  58. int Save(std::fstream &file, DWORD = 0);
  59. private:
  60. int DoLoad(std::fstream&, DWORD = 0);
  61. int DoSave(std::fstream&, DWORD = 0);
  62. };
  63. class CPrefabVMF : public CPrefab3D
  64. {
  65. public:
  66. CPrefabVMF();
  67. ~CPrefabVMF();
  68. int Load(DWORD dwFlags = 0);
  69. int Save(LPCTSTR pszFilename, DWORD = 0);
  70. virtual bool IsLoaded(void);
  71. void SetFilename(const char *szFilename);
  72. protected:
  73. static ChunkFileResult_t LoadEntityCallback(CChunkFile *pFile, CPrefabVMF *pPrefab);
  74. static ChunkFileResult_t LoadWorldCallback(CChunkFile *pFile, CPrefabVMF *pPrefab);
  75. char m_szFilename[MAX_PATH]; // Full path of the prefab VMF.
  76. int m_nFileTime; // File modification time of the last loaded version of the prefab.
  77. };
  78. #endif // PREFAB3D_H