Item.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /******************************************************************************
  2. Use 'Item' as a base class for creating your own item class, in order to add more custom parameters.
  3. /******************************************************************************/
  4. namespace Game{
  5. /******************************************************************************/
  6. STRUCT(Item , Obj) // Game Item 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. // manage
  14. virtual void create(Object &obj); // create from object
  15. virtual void setUnsavedParams(); // set parameters which are not included in the save file
  16. // get / set
  17. virtual Vec pos ( ); // get position
  18. virtual void pos (C Vec &pos ); // set position
  19. virtual Matrix matrix ( ); // get matrix , returned matrix is normalized
  20. virtual Matrix matrixScaled( ); // get matrix , returned matrix is scaled by 'scale'
  21. virtual void matrix (C Matrix &matrix); // set matrix , 'matrix' must be normalized
  22. void setDrawingVelocities(C Vec &vel, C Vec &ang_vel); // manually set drawing velocities for motion blur effect, this method should be called for items in the inventory which have their actor deactivated, but still want to be drawn, this shouldn't be called before 'update' because 'update' sets the default velocities from the actor
  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. virtual void willBeMovedFromWorldToStorage(); // called before object was moved from world to custom object container
  26. virtual void willBeMovedFromStorageToWorld(); // called before object was moved from custom object container to world
  27. // update
  28. virtual Bool update(); // update, return false when object wants to be deleted, and true if wants to exist
  29. // draw
  30. 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)
  31. virtual void drawShadow (); // in this method you should add the meshes to the shadow draw list (Mesh::drawShadow)
  32. // enable / disable
  33. 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
  34. 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
  35. // io
  36. virtual Bool save(File &f); // save, false on fail
  37. virtual Bool load(File &f); // load, false on fail
  38. ~Item();
  39. Item();
  40. public: // following members/methods are public, however don't modify/call them manually unless you know what you're doing
  41. Chr* grabber( ) {return _grabber ;} // get character grabbing the item
  42. void grabber(Chr *chr) { _grabber=chr;} // set character grabbing the item
  43. protected:
  44. Chr *_grabber;
  45. Vec _vel, _ang_vel;
  46. };
  47. /******************************************************************************/
  48. } // namespace
  49. /******************************************************************************/