miscobjs.hh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #ifndef G1_MISCOBJS_HH
  9. #define G1_MISCOBJS_HH
  10. #include "g1_object.hh"
  11. #include "lisp/li_types.hh"
  12. #include "objs/structure_death.hh"
  13. g1_object_type g1_create_deco_object(char *name);
  14. class g1_deco_definition_class;
  15. class g1_deco_type_manager_class : public i4_init_class
  16. {
  17. i4_array<g1_deco_definition_class *> deco_objs;
  18. public:
  19. g1_deco_type_manager_class() : deco_objs(0,32) {}
  20. void uninit();
  21. const char *find_name(const char *name);
  22. void add_type(g1_deco_definition_class *def)
  23. {
  24. int i;
  25. for (i=0; i<deco_objs.size() && deco_objs[i]; i++) ;
  26. if (i==deco_objs.size())
  27. deco_objs.add(def);
  28. else
  29. deco_objs[i] = def;
  30. }
  31. void remove_type(g1_deco_definition_class *def)
  32. {
  33. for (int i=0; i<deco_objs.size(); i++)
  34. if (deco_objs[i]==def)
  35. deco_objs[i]=0;
  36. }
  37. };
  38. extern g1_deco_type_manager_class g1_deco_type_manager;
  39. class g1_deco_object_class : public g1_object_class
  40. {
  41. protected:
  42. g1_structure_death_class death;
  43. public:
  44. sw16 health; // the health its got left
  45. w8 collision_type;
  46. enum { DATA_VERSION=2 };
  47. const char *model_name;
  48. static g1_deco_object_class *cast(g1_object_class *o)
  49. {
  50. if (o->get_type()->get_flag(g1_object_definition_class::TO_DECO_OBJECT))
  51. return (g1_deco_object_class *)o;
  52. else return 0;
  53. }
  54. g1_deco_object_class(g1_object_type id, g1_loader_class *fp);
  55. virtual i4_bool check_collision(const i4_3d_vector &start,
  56. i4_3d_vector &ray);
  57. void save(g1_saver_class *fp);
  58. // void occupy_location()
  59. // {
  60. // h=g1_get_map()->terrain_height(x,y);
  61. // lh=h;
  62. // g1_object_class::occupy_location();
  63. // }
  64. virtual i4_bool occupy_location()
  65. {
  66. if (occupancy_radius()<0.6)
  67. return occupy_location_corners();
  68. else
  69. return occupy_location_model(draw_params);
  70. }
  71. virtual void think();
  72. virtual void damage(g1_object_class *who_is_hurting,
  73. int how_much_hurt, i4_3d_vector damage_dir);
  74. };
  75. #endif