@@ -20,5 +20,179 @@ with this program; if not, write to the Free Software Foundation, Inc.,
20
20
#ifndef CONTENT_CAO_HEADER
21
21
#define CONTENT_CAO_HEADER
22
22
23
+ #include < map>
24
+ #include " irrlichttypes_extrabloated.h"
25
+ #include " content_object.h"
26
+ #include " clientobject.h"
27
+ #include " object_properties.h"
28
+ #include " itemgroup.h"
29
+
30
+ /*
31
+ SmoothTranslator
32
+ */
33
+
34
+ struct SmoothTranslator
35
+ {
36
+ v3f vect_old;
37
+ v3f vect_show;
38
+ v3f vect_aim;
39
+ f32 anim_counter;
40
+ f32 anim_time;
41
+ f32 anim_time_counter;
42
+ bool aim_is_end;
43
+
44
+ SmoothTranslator ();
45
+
46
+ void init (v3f vect);
47
+
48
+ void sharpen ();
49
+
50
+ void update (v3f vect_new, bool is_end_position=false , float update_interval=-1 );
51
+
52
+ void translate (f32 dtime);
53
+
54
+ bool is_moving ();
55
+ };
56
+
57
+ class GenericCAO : public ClientActiveObject
58
+ {
59
+ private:
60
+ // Only set at initialization
61
+ std::string m_name;
62
+ bool m_is_player;
63
+ bool m_is_local_player;
64
+ int m_id;
65
+ // Property-ish things
66
+ ObjectProperties m_prop;
67
+ //
68
+ scene::ISceneManager *m_smgr;
69
+ IrrlichtDevice *m_irr;
70
+ core::aabbox3d<f32> m_selection_box;
71
+ scene::IMeshSceneNode *m_meshnode;
72
+ scene::IAnimatedMeshSceneNode *m_animated_meshnode;
73
+ scene::IBillboardSceneNode *m_spritenode;
74
+ scene::ITextSceneNode* m_textnode;
75
+ v3f m_position;
76
+ v3f m_velocity;
77
+ v3f m_acceleration;
78
+ float m_yaw;
79
+ s16 m_hp;
80
+ SmoothTranslator pos_translator;
81
+ // Spritesheet/animation stuff
82
+ v2f m_tx_size;
83
+ v2s16 m_tx_basepos;
84
+ bool m_initial_tx_basepos_set;
85
+ bool m_tx_select_horiz_by_yawpitch;
86
+ v2s32 m_animation_range;
87
+ int m_animation_speed;
88
+ int m_animation_blend;
89
+ std::map<std::string, core::vector2d<v3f> > m_bone_position; // stores position and rotation for each bone name
90
+ std::string m_attachment_bone;
91
+ v3f m_attachment_position;
92
+ v3f m_attachment_rotation;
93
+ bool m_attached_to_local;
94
+ int m_anim_frame;
95
+ int m_anim_num_frames;
96
+ float m_anim_framelength;
97
+ float m_anim_timer;
98
+ ItemGroupList m_armor_groups;
99
+ float m_reset_textures_timer;
100
+ bool m_visuals_expired;
101
+ float m_step_distance_counter;
102
+ u8 m_last_light;
103
+ bool m_is_visible;
104
+
105
+ public:
106
+ GenericCAO (IGameDef *gamedef, ClientEnvironment *env);
107
+
108
+ ~GenericCAO ();
109
+
110
+ static ClientActiveObject* create (IGameDef *gamedef, ClientEnvironment *env)
111
+ {
112
+ return new GenericCAO (gamedef, env);
113
+ }
114
+
115
+ inline u8 getType () const
116
+ {
117
+ return ACTIVEOBJECT_TYPE_GENERIC;
118
+ }
119
+
120
+ void initialize (const std::string &data);
121
+
122
+ ClientActiveObject *getParent ();
123
+
124
+ bool getCollisionBox (aabb3f *toset);
125
+
126
+ bool collideWithObjects ();
127
+
128
+ core::aabbox3d<f32>* getSelectionBox ();
129
+
130
+ v3f getPosition ();
131
+
132
+ scene::IMeshSceneNode *getMeshSceneNode ();
133
+
134
+ scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode ();
135
+
136
+ scene::IBillboardSceneNode *getSpriteSceneNode ();
137
+
138
+ inline bool isPlayer () const
139
+ {
140
+ return m_is_player;
141
+ }
142
+
143
+ inline bool isLocalPlayer () const
144
+ {
145
+ return m_is_local_player;
146
+ }
147
+
148
+ inline bool isVisible () const
149
+ {
150
+ return m_is_visible;
151
+ }
152
+
153
+ inline void setVisible (bool toset)
154
+ {
155
+ m_is_visible = toset;
156
+ }
157
+
158
+ void setAttachments ();
159
+
160
+ void removeFromScene (bool permanent);
161
+
162
+ void addToScene (scene::ISceneManager *smgr, ITextureSource *tsrc,
163
+ IrrlichtDevice *irr);
164
+
165
+ inline void expireVisuals ()
166
+ {
167
+ m_visuals_expired = true ;
168
+ }
169
+
170
+ void updateLight (u8 light_at_pos);
171
+
172
+ v3s16 getLightPosition ();
173
+
174
+ void updateNodePos ();
175
+
176
+ void step (float dtime, ClientEnvironment *env);
177
+
178
+ void updateTexturePos ();
179
+
180
+ void updateTextures (const std::string &mod);
181
+
182
+ void updateAnimation ();
183
+
184
+ void updateBonePosition ();
185
+
186
+ void updateAttachments ();
187
+
188
+ void processMessage (const std::string &data);
189
+
190
+ bool directReportPunch (v3f dir, const ItemStack *punchitem=NULL ,
191
+ float time_from_last_punch=1000000 );
192
+
193
+ std::string debugInfoText ();
194
+ };
195
+
196
+
23
197
#endif
24
198
0 commit comments