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.

119 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VPHYSICS_SAVERESTORE_H
  8. #define VPHYSICS_SAVERESTORE_H
  9. #if defined( _WIN32 )
  10. #pragma once
  11. #endif
  12. #include "datamap.h"
  13. #include "utlmap.h"
  14. #include "isaverestore.h"
  15. #include "utlvector.h"
  16. //-------------------------------------
  17. class ISave;
  18. class IRestore;
  19. class CPhysicsObject;
  20. class CPhysicsFluidController;
  21. class CPhysicsSpring;
  22. class CPhysicsConstraint;
  23. class CPhysicsConstraintGroup;
  24. class CShadowController;
  25. class CPlayerController;
  26. class CPhysicsMotionController;
  27. class CVehicleController;
  28. struct physsaveparams_t;
  29. struct physrestoreparams_t;
  30. class ISaveRestoreOps;
  31. //-----------------------------------------------------------------------------
  32. // Purpose: Fixes up pointers beteween vphysics objects
  33. //-----------------------------------------------------------------------------
  34. class CVPhysPtrSaveRestoreOps : public CDefSaveRestoreOps
  35. {
  36. public:
  37. CVPhysPtrSaveRestoreOps();
  38. void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave );
  39. void PreRestore();
  40. void PostRestore();
  41. void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore );
  42. };
  43. extern CVPhysPtrSaveRestoreOps g_VPhysPtrSaveRestoreOps;
  44. #define DEFINE_VPHYSPTR(name) \
  45. { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, &g_VPhysPtrSaveRestoreOps, NULL }
  46. #define DEFINE_VPHYSPTR_ARRAY(name,count) \
  47. { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, count, FTYPEDESC_SAVE, NULL, &g_VPhysPtrSaveRestoreOps, NULL }
  48. //-----------------------------------------------------------------------------
  49. class CVPhysPtrUtlVectorSaveRestoreOps : public CVPhysPtrSaveRestoreOps
  50. {
  51. public:
  52. void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave );
  53. void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore );
  54. private:
  55. typedef CUtlVector<int> VPhysPtrVector;
  56. };
  57. extern CVPhysPtrUtlVectorSaveRestoreOps g_VPhysPtrUtlVectorSaveRestoreOps;
  58. #define DEFINE_VPHYSPTR_UTLVECTOR(name) \
  59. { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, &g_VPhysPtrUtlVectorSaveRestoreOps, NULL }
  60. //-----------------------------------------------------------------------------
  61. typedef bool (*PhysSaveFunc_t)( const physsaveparams_t &params, void *pCastedObject ); // second parameter for convenience
  62. typedef bool (*PhysRestoreFunc_t)( const physrestoreparams_t &params, void **ppCastedObject );
  63. bool SavePhysicsObject( const physsaveparams_t &params, CPhysicsObject *pObject );
  64. bool RestorePhysicsObject( const physrestoreparams_t &params, CPhysicsObject **ppObject );
  65. bool SavePhysicsFluidController( const physsaveparams_t &params, CPhysicsFluidController *pFluidObject );
  66. bool RestorePhysicsFluidController( const physrestoreparams_t &params, CPhysicsFluidController **ppFluidObject );
  67. bool SavePhysicsSpring( const physsaveparams_t &params, CPhysicsSpring *pSpring );
  68. bool RestorePhysicsSpring( const physrestoreparams_t &params, CPhysicsSpring **ppSpring );
  69. bool SavePhysicsConstraint( const physsaveparams_t &params, CPhysicsConstraint *pConstraint );
  70. bool RestorePhysicsConstraint( const physrestoreparams_t &params, CPhysicsConstraint **ppConstraint );
  71. bool SavePhysicsConstraintGroup( const physsaveparams_t &params, CPhysicsConstraintGroup *pConstraintGroup );
  72. bool RestorePhysicsConstraintGroup( const physrestoreparams_t &params, CPhysicsConstraintGroup **ppConstraintGroup );
  73. void PostRestorePhysicsConstraintGroup();
  74. bool SavePhysicsShadowController( const physsaveparams_t &params, IPhysicsShadowController *pShadowController );
  75. bool RestorePhysicsShadowController( const physrestoreparams_t &params, IPhysicsShadowController **ppShadowController );
  76. bool RestorePhysicsShadowControllerInternal( const physrestoreparams_t &params, IPhysicsShadowController **ppShadowController, CPhysicsObject *pObject );
  77. bool SavePhysicsPlayerController( const physsaveparams_t &params, CPlayerController *pPlayerController );
  78. bool RestorePhysicsPlayerController( const physrestoreparams_t &params, CPlayerController **ppPlayerController );
  79. bool SavePhysicsMotionController( const physsaveparams_t &params, IPhysicsMotionController *pMotionController );
  80. bool RestorePhysicsMotionController( const physrestoreparams_t &params, IPhysicsMotionController **ppMotionController );
  81. bool SavePhysicsVehicleController( const physsaveparams_t &params, CVehicleController *pVehicleController );
  82. bool RestorePhysicsVehicleController( const physrestoreparams_t &params, CVehicleController **ppVehicleController );
  83. //-----------------------------------------------------------------------------
  84. ISaveRestoreOps* MaterialIndexDataOps();
  85. #endif // VPHYSICS_SAVERESTORE_H