source: golgotha/src/golg/objs/def_object.hh

Last change on this file was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.1 KB
Line 
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
9#ifndef G1_DEF_OBJECT_HH
10#define G1_DEF_OBJECT_HH
11
12#include "g1_object.hh"
13#include "lisp/li_types.hh"
14#include "li_objref.hh"
15
16class li_class;
17
18
19struct g1_mini_object_def
20{
21  i4_3d_vector offset;
22  i4_3d_vector position;
23  i4_3d_vector rotation;         // contains rotation information
24  g1_model_id_type defmodeltype; //model used by this mini object. can be overridden with draw()
25 
26  void init() { memset(this,0,sizeof(*this)); }
27  void assign_to(g1_mini_object *m);
28};
29
30enum { G1_F_THINK,
31       G1_F_DAMAGE,
32       G1_F_NOTIFY_DAMAGE,
33       G1_F_ENTER_RANGE,
34       G1_F_DRAW,
35       G1_F_MESSAGE,
36       G1_F_DEPLOY_TO,
37       G1_F_CHANGE_TEAMS,
38       G1_F_OCCUPY_LOCATION,
39       G1_F_UNOCCUPY_LOCATION,
40       G1_F_TOTAL
41};
42
43
44class g1_dynamic_object_type_class : public g1_object_definition_class
45{
46public:
47
48  g1_quad_object_class         *model;
49  i4_array<g1_mini_object_def>  minis;
50  w32                           obj_flags;
51
52  li_function_type funs[G1_F_TOTAL];
53 
54
55  g1_dynamic_object_type_class(li_symbol *sym);
56  g1_object_class *create_object(g1_object_type type, g1_loader_class *fp);
57  void gc_mark(int set);
58};
59
60class g1_dynamic_object_class : public g1_object_class
61{
62  enum { VERSION=0xdef1};
63public:
64
65  static g1_dynamic_object_class *cast(g1_object_class *o)
66  {
67    if (o && o->get_type()->get_flag(g1_object_definition_class::TO_DYNAMIC_OBJECT))
68      return (g1_dynamic_object_class *)o;
69    else return 0;
70  }
71
72
73  g1_dynamic_object_type_class *get_type() const
74  {
75    return (g1_dynamic_object_type_class *)g1_object_type_array[id];
76  }
77 
78  li_class *type_vars()
79  {
80    return get_type()->vars;
81  }
82
83  // called when the object is on a map cell that is drawn
84  void draw(g1_draw_context_class *context);
85  void think();
86  li_object *message(li_symbol *name, li_object *params, li_environment *env);
87
88  void change_player_num(int new_player);  // don't change player_num directly
89  i4_bool occupy_location();
90  void unoccupy_location();
91
92
93  void damage(g1_object_class *obj, int hp, i4_3d_vector damage_dir);
94  void notify_damage(g1_object_class *obj, int hp, w32 notes);
95  i4_bool deploy_to(float x, float y);
96
97  g1_dynamic_object_class(g1_object_type type, g1_loader_class *fp);
98  void save(g1_saver_class *fp);
99
100  li_object *value(li_symbol *sym);
101  void set(li_symbol *sym, li_object *value);
102
103  static g1_dynamic_object_class *get(li_object *o, li_environment *env)
104  {
105    return g1_dynamic_object_class::cast(li_g1_ref::get(o,env)->value());
106  }
107};
108
109
110class g1_draw_context_class;
111extern g1_draw_context_class *g1_draw_context;
112
113
114#endif
115
Note: See TracBrowser for help on using the repository browser.