| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef ROBOT_H |
| 20 | #define ROBOT_H |
| 21 | |
| 22 | #include "pstypes.h" |
| 23 | #include "manage.h" |
| 24 | #include "object.h" |
| 25 | #include "objinfo.h" |
| 26 | |
| 27 | #define MAX_ROBOTS 100 |
| 28 | |
| 29 | extern int Num_robots; |
| 30 | extern object_info Robots[MAX_ROBOTS]; |
| 31 | extern const char * const Movement_class_names[]; |
| 32 | extern const char * const Anim_state_names[]; |
| 33 | |
| 34 | // Sets all robots to unused |
| 35 | void InitRobots(); |
| 36 | |
| 37 | // Allocs a robot for use, returns -1 if error, else index on success |
| 38 | int AllocRobot(); |
| 39 | |
| 40 | // Frees robot index n |
| 41 | void FreeRobot(int n); |
| 42 | |
| 43 | // Gets next robot from n that has actually been alloced |
| 44 | int GetNextRobot(int n); |
| 45 | |
| 46 | // Gets previous robot from n that has actually been alloced |
| 47 | int GetPrevRobot(int n); |
| 48 | |
| 49 | // Searches thru all robots for a specific name, returns -1 if not found |
| 50 | // or index of robot with name |
| 51 | int FindRobotName(char *name); |
| 52 | |
| 53 | // Given a filename, loads either the model or vclip found in that file. If type |
| 54 | // is not NULL, sets it to 1 if file is model, otherwise sets it to zero |
| 55 | int LoadRobotImage(char *filename); |
| 56 | |
| 57 | // Given a robot handle, returns that robots image for framenum |
| 58 | int GetRobotImage(int handle); |
| 59 | |
| 60 | // Given an object, renders the representation of this robot |
| 61 | // Currently only handles bitmap types, not poly models |
| 62 | void DrawRobotObject(object *obj); |
| 63 | |
| 64 | // Given a robot name, assigns that robot to a specific index into |
| 65 | // the Robots array. Returns -1 if the named robot is not found, 0 if the robot |
| 66 | // is already in its place, or 1 if successfully moved |
| 67 | int MatchRobotToIndex(char *name, int dest_index); |
| 68 | |
| 69 | // Moves a robot from a given index into a new one (above MAX_STATIC_POWERUPS) |
| 70 | // returns new index |
| 71 | int MoveRobotFromIndex(int index); |
| 72 | |
| 73 | // This is a very confusing function. It takes all the robots that we have loaded |
| 74 | // and remaps then into their proper places (if they are static). |
| 75 | void RemapRobots(); |
| 76 | |
| 77 | // goes thru every entity that could possible have a robot index (ie objects, robots, etc) |
| 78 | // and changes the old index to the new index |
| 79 | void RemapAllRobotObjects(int old_index, int new_index); |
| 80 | |
| 81 | #endif |