Door.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /******************************************************************************
  2. Use 'Door' class for creating door objects.
  3. /******************************************************************************/
  4. namespace Game{
  5. /******************************************************************************/
  6. STRUCT(Door , Obj) // Game Door Object
  7. //{
  8. Flt scale ; // scale
  9. ObjectPtr base ; // base object
  10. MeshPtr mesh ; // mesh
  11. Int mesh_variation; // mesh variation index
  12. Actor actor ; // actor
  13. Joint joint ; // joint
  14. PathObstacle obstacle ; // path mesh obstacle
  15. // manage
  16. virtual void create(Object &obj); // create from object
  17. virtual void setUnsavedParams(); // set parameters which are not included in the save file
  18. // get / set
  19. virtual Vec pos ( ); // get position
  20. virtual Matrix matrix( ); // get matrix
  21. virtual void pos (C Vec &pos ) {} // set position, Door objects have this method disabled
  22. virtual void matrix(C Matrix &matrix) {} // set matrix , Door objects have this method disabled
  23. // callbacks
  24. virtual void memoryAddressChanged(); // called when object memory address has been changed, you should override it and adjust Actor::obj pointer for all actors
  25. // update
  26. virtual Bool update(); // update, return false when object wants to be deleted, and true if wants to exist
  27. // draw
  28. virtual UInt drawPrepare(); // prepare for drawing, this will be called in RM_PREPARE mode, in this method you should add the meshes to the draw list (Mesh::draw), and return a combination of bits of which additional render modes will be required for custom drawing of the object (for example "return IndexToFlag(RM_BLEND)" requests blend mode rendering)
  29. virtual void drawShadow (); // in this method you should add the meshes to the shadow draw list (Mesh::drawShadow)
  30. // enable / disable
  31. virtual void disable(); // disable object when becomes too far away, here all dynamic actors should enable kinematic flag - actor.kinematic(true ), this is called when an object changes its state to AREA_INACTIVE
  32. virtual void enable(); // enable object when closes in , here all dynamic actors should disable kinematic flag - actor.kinematic(false), this is called when an object changes its state to AREA_ACTIVE
  33. // manipulate
  34. virtual void open (); // open door
  35. virtual void close (); // close door
  36. virtual void toggle(); // toggle door
  37. // io
  38. virtual Bool save(File &f); // save, false on fail
  39. virtual Bool load(File &f); // load, false on fail
  40. ~Door();
  41. Door();
  42. protected:
  43. enum STATE
  44. {
  45. STATE_CLOSED ,
  46. STATE_OPENED ,
  47. STATE_UNKNOWN,
  48. };
  49. Bool _open;
  50. Byte _state;
  51. Flt _angle;
  52. Flt _actor_to_hinge_dist ; // actor to hinge distance
  53. Matrix _hinge_matrix; // hinge matrix
  54. void setObstacle(); // set path 'obstacle' basing on the door state
  55. };
  56. /******************************************************************************/
  57. } // namespace
  58. /******************************************************************************/