22 #ifndef NUVIE_CORE_OBJ_MANAGER_H 23 #define NUVIE_CORE_OBJ_MANAGER_H 25 #include "ultima/shared/std/containers.h" 26 #include "ultima/nuvie/misc/iavl_tree.h" 27 #include "ultima/nuvie/core/tile_manager.h" 28 #include "ultima/nuvie/misc/u6_llist.h" 29 #include "ultima/nuvie/core/obj.h" 44 #define OBJ_NOT_PASSABLE 1 45 #define OBJ_PASSABLE 2 47 #define OBJ_WEIGHT_INCLUDE_CONTAINER_ITEMS true 48 #define OBJ_WEIGHT_EXCLUDE_CONTAINER_ITEMS false 50 #define OBJ_WEIGHT_DO_SCALE true 51 #define OBJ_WEIGHT_DONT_SCALE false 53 #define OBJ_WEIGHT_EXCLUDE_QTY false 55 #define OBJ_ADD_TOP true 57 #define OBJ_SHOW_PREFIX true 59 #define OBJ_TEMP_INIT 255 // this is used to stop temporary objects from being cleaned upon startup. 61 #define OBJ_SEARCH_TOP true 62 #define OBJ_INCLUDE_IGNORED true 63 #define OBJ_EXCLUDE_IGNORED false 70 Obj *new_obj(uint16 obj_n, uint8 frame_n, uint16 x, uint16 y, uint16 z);
71 void delete_obj(
Obj *obj);
73 void clean_obj_tree_node(
void *node);
84 uint16 obj_to_tile[1024];
85 uint8 obj_weight[1024];
86 uint8 obj_stackable[1024];
87 U6LList *actor_inventories[256];
96 uint16 last_obj_blk_x, last_obj_blk_y;
99 uint16 obj_save_count;
101 bool custom_actor_tiles;
108 bool use_custom_actor_tiles() {
109 return custom_actor_tiles;
111 bool is_showing_eggs() {
114 void set_show_eggs(
bool value) {
119 bool load_super_chunk(
NuvieIO *chunk_buf, uint8 level, uint8 chunk_offset);
122 void clean_actor_inventories();
124 bool save_super_chunk(
NuvieIO *save_buf, uint8 level, uint8 chunk_offset);
125 bool save_eggs(
NuvieIO *save_buf);
126 bool save_inventories(
NuvieIO *save_buf);
127 bool save_obj(
NuvieIO *save_buf,
Obj *obj, uint16 parent_objblk_n);
129 void set_usecode(
UseCode *uc) {
140 bool is_boundary(uint16 x, uint16 y, uint8 level, uint8 boundary_type = TILEFLAG_BOUNDARY,
Obj *excluded_obj =
nullptr);
142 bool is_damaging(uint16 x, uint16 y, uint8 level);
143 uint8 is_passable(uint16 x, uint16 y, uint8 level);
144 bool is_forced_passable(uint16 x, uint16 y, uint8 level);
145 bool is_stackable(
const Obj *obj)
const;
146 bool is_breakable(
const Obj *obj);
147 bool can_store_obj(
const Obj *target,
Obj *src)
const;
148 bool can_get_obj(
Obj *obj)
const;
149 bool has_reduced_weight(uint16 obj_n)
const;
150 bool has_reduced_weight(
const Obj *obj)
const {
151 return has_reduced_weight(obj->obj_n);
153 bool has_toptile(
const Obj *obj)
const;
154 bool obj_is_damaging(
const Obj *obj,
Actor *actor =
nullptr);
155 bool is_door(uint16 x, uint16 y, uint8 level);
157 U6LList *get_obj_list(uint16 x, uint16 y, uint8 level)
const;
159 Tile *get_obj_tile(uint16 obj_n, uint8 frame_n);
160 const Tile *get_obj_tile(uint16 x, uint16 y, uint8 level,
bool top_obj =
true);
161 const Tile *get_obj_dmg_tile(uint16 x, uint16 y, uint8 level);
162 Obj *get_obj(uint16 x, uint16 y, uint8 level,
bool top_obj = OBJ_SEARCH_TOP,
bool include_ignored_objects = OBJ_EXCLUDE_IGNORED,
Obj *excluded_obj =
nullptr);
163 Obj *get_obj_of_type_from_location_inc_multi_tile(uint16 obj_n, uint16 x, uint16 y, uint8 z);
164 Obj *get_obj_of_type_from_location_inc_multi_tile(uint16 obj_n, sint16 quality, sint32 qty, uint16 x, uint16 y, uint8 z);
165 Obj *get_obj_of_type_from_location(uint16 obj_n, uint16 x, uint16 y, uint8 z);
166 Obj *get_obj_of_type_from_location(uint16 obj_n, sint16 quality, sint32 qty, uint16 x, uint16 y, uint8 z);
167 Obj *get_objBasedAt(uint16 x, uint16 y, uint8 level,
bool top_obj,
bool include_ignored_objects =
true,
Obj *excluded_obj =
nullptr);
168 Obj *get_tile_obj(uint16 obj_n);
170 uint16 get_obj_tile_num(uint16 obj_num)
const;
171 inline bool is_corpse(
const Obj *obj)
const;
172 uint16 get_obj_tile_num(
const Obj *obj)
const;
173 void set_obj_tile_num(uint16 obj_num, uint16 tile_num);
175 U6LList *get_actor_inventory(uint16 actor_num);
176 bool actor_has_inventory(uint16 actor_num);
178 Obj *find_next_obj(uint8 level,
Obj *prev_obj,
bool match_frame_n = OBJ_NOMATCH_FRAME_N,
bool match_quality = OBJ_MATCH_QUALITY);
179 Obj *find_obj(uint8 level, uint16 obj_n, uint8 quality,
bool match_quality = OBJ_MATCH_QUALITY, uint16 frame_n = 0,
bool match_frame_n = OBJ_NOMATCH_FRAME_N,
Obj **prev_obj =
nullptr);
181 bool move(
Obj *obj, uint16 x, uint16 y, uint8 level);
182 bool add_obj(
Obj *obj,
bool addOnTop =
false);
183 bool remove_obj_from_map(
Obj *obj);
184 bool remove_obj_type_from_location(uint16 obj_n, uint16 x, uint16 y, uint8 z);
187 Obj *copy_obj(
const Obj *obj);
188 const char *look_obj(
Obj *obj,
bool show_prefix =
false);
189 Obj *get_obj_from_stack(
Obj *obj, uint32 count);
191 bool list_add_obj(
U6LList *
list,
Obj *obj,
bool stack_objects =
true, uint32 pos = 0);
193 const char *get_obj_name(
Obj *obj);
194 const char *get_obj_name(uint16 obj_n);
195 const char *get_obj_name(uint16 obj_n, uint8 frame_n);
197 float get_obj_weight(
const Obj *obj,
bool include_container_items = OBJ_WEIGHT_INCLUDE_CONTAINER_ITEMS,
bool scale =
true,
bool include_qty =
true)
const;
198 uint8 get_obj_weight_unscaled(uint16 obj_n)
const {
199 return obj_weight[obj_n];
201 float get_obj_weight(uint16 obj_n)
const;
203 void animate_forwards(
Obj *obj, uint32 loop_count = 1);
204 void animate_backwards(
Obj *obj, uint32 loop_count = 1);
206 void update(uint16 x, uint16 y, uint8 z,
bool teleport =
false);
208 bool unlink_from_engine(
Obj *obj,
bool run_usecode =
true);
211 bool moveto_inventory(
Obj *obj, uint16 actor_num);
212 bool moveto_inventory(
Obj *obj,
Actor *actor);
213 bool moveto_container(
Obj *obj,
Obj *container_obj,
bool stack =
true);
217 void remove_obj(
Obj *obj);
219 bool load_basetile();
220 bool load_weight_table();
223 bool addObjToContainer(
U6LList *list,
Obj *obj);
225 iAVLTree *get_obj_tree(uint16 x, uint16 y, uint8 level)
const;
228 iAVLKey get_obj_tree_key(uint16 x, uint16 y, uint8 level)
const;
231 bool temp_obj_list_add(
Obj *obj);
232 bool temp_obj_list_remove(
Obj *obj);
233 void temp_obj_list_clean_level(uint8 z);
234 void temp_obj_list_clean_area(uint16 x, uint16 y);
236 void remove_temp_obj(
Obj *tmp_obj);
238 inline Obj *find_obj_in_tree(uint16 obj_n, uint8 quality,
bool match_quality, uint8 frame_n,
bool match_frame_n,
Obj **prev_obj,
iAVLTree *obj_tree);
239 inline void start_obj_usecode(
iAVLTree *obj_tree);
240 inline void print_egg_tree(
iAVLTree *obj_tree);
243 void print_object_list();
244 void print_egg_list();
245 void print_obj(
const Obj *obj,
bool in_container, uint8 indent = 0);
Definition: iavl_tree.h:50
Definition: egg_manager.h:45
Definition: configuration.h:61
Definition: usecode.h:151
Definition: tile_manager.h:145
Definition: detection.h:27
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: iavl_tree.h:31
Definition: u6_llist.h:46
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: containers.h:200
Definition: obj_manager.h:75
Definition: tile_manager.h:113
Definition: obj_manager.h:65
Definition: nuvie_io.h:32