Advertisement
dcomicboy

specialfx.h

Apr 1st, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. class CSpecialFX
  2. {
  3. public :
  4.  
  5. CSpecialFX()
  6. {
  7. m_bWantRemove = LTFALSE;
  8. m_pClientDE = LTNULL;
  9. m_hObject = LTNULL;
  10. m_hServerObject = LTNULL;
  11. m_fUpdateDelta = 0.001f;
  12. m_fNextUpdateTime = 0.0f;
  13. m_vLastServPos.Init();
  14. m_vVel.Init();
  15. m_nMenuLayer = 0;
  16. }
  17.  
  18. virtual ~CSpecialFX()
  19. {
  20. CSpecialFX::Term();
  21. }
  22.  
  23. virtual void Term()
  24. {
  25. if (m_pClientDE && m_hObject)
  26. {
  27. m_pClientDE->RemoveObject(m_hObject);
  28. m_hObject = LTNULL;
  29. }
  30. }
  31.  
  32. virtual LTBOOL CreateObject(ILTClient* pClientDE)
  33. {
  34. if (!pClientDE) return LTFALSE;
  35. m_pClientDE = pClientDE;
  36.  
  37. if (m_hServerObject)
  38. {
  39. m_pClientDE->GetObjectPos(m_hServerObject, &m_vLastServPos);
  40. }
  41.  
  42. return LTTRUE;
  43. }
  44.  
  45. virtual LTBOOL Init(HLOCALOBJ hServObj, ILTMessage_Read *pMsg)
  46. {
  47. if (!pMsg) return LTFALSE;
  48.  
  49. m_hServerObject = hServObj;
  50.  
  51. return LTTRUE;
  52. }
  53.  
  54. virtual LTBOOL Init(SFXCREATESTRUCT* psfxCreateStruct)
  55. {
  56. if (!psfxCreateStruct) return LTFALSE;
  57.  
  58. m_hServerObject = psfxCreateStruct->hServerObj;
  59.  
  60. return LTTRUE;
  61. }
  62.  
  63. // Return of LTFALSE indicates special fx is done and can be removed.
  64.  
  65. virtual LTBOOL Update()
  66. {
  67. // Calculate our server-object's velocity...
  68.  
  69. if (m_hServerObject && m_pClientDE)
  70. {
  71. LTVector vPos;
  72. m_pClientDE->GetObjectPos(m_hServerObject, &vPos);
  73.  
  74. m_vVel = vPos - m_vLastServPos;
  75. m_vVel /= m_pClientDE->GetFrameTime();
  76.  
  77. m_vLastServPos = vPos;
  78. }
  79.  
  80. return LTTRUE;
  81. }
  82.  
  83. virtual void Render(HOBJECT hCamera) {}
  84.  
  85. // Call this to tell special fx to finish up so we can remove it...
  86.  
  87. virtual void WantRemove(LTBOOL bRemove=LTTRUE)
  88. {
  89. m_bWantRemove = bRemove;
  90. if (m_bWantRemove) m_hServerObject = LTNULL;
  91. }
  92. LTBOOL IsWaitingForRemove() const { return m_bWantRemove; }
  93.  
  94. HLOCALOBJ GetObject() const { return m_hObject; }
  95. HLOCALOBJ GetServerObj() const { return m_hServerObject; }
  96.  
  97. LTFLOAT GetUpdateDelta() const { return m_fUpdateDelta; }
  98.  
  99. virtual void OnObjectRotate( LTRotation *pRot ) {}
  100. virtual void HandleTouch(CollisionInfo *pInfo) {}
  101. virtual void OnModelKey(HLOCALOBJ hObj, ArgList *pArgs) {}
  102. virtual LTBOOL OnServerMessage(ILTMessage_Read *pMsg) { return (!!pMsg); }
  103.  
  104. LTFLOAT m_fNextUpdateTime; // When do we update next
  105.  
  106. // Function for returning a special effect ID from a derived class
  107. virtual uint32 GetSFXID() { return SFX_TOTAL_NUMBER + 1; }
  108.  
  109. virtual uint8 GetMenuLayer() { return m_nMenuLayer; }
  110.  
  111. protected :
  112.  
  113. ILTClient* m_pClientDE;
  114. HOBJECT m_hObject; // Special FX object
  115. HOBJECT m_hServerObject; // Local handle to Server-side object
  116. LTVector m_vLastServPos; // Last position of the server object
  117. LTVector m_vVel; // Our server object's velocity
  118. LTBOOL m_bWantRemove;
  119. LTFLOAT m_fUpdateDelta; // Time between updates
  120. uint8 m_nMenuLayer;
  121. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement