1 /** @file p_actor.h Common code relating to mobj management. 2 * 3 * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net> 5 * 6 * @par License 7 * GPL: http://www.gnu.org/licenses/gpl.html 8 * 9 * <small>This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by the 11 * Free Software Foundation; either version 2 of the License, or (at your 12 * option) any later version. This program is distributed in the hope that it 13 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 * Public License for more details. You should have received a copy of the GNU 16 * General Public License along with this program; if not, write to the Free 17 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 * 02110-1301 USA</small> 19 */ 20 21 #ifndef LIBCOMMON_P_ACTOR_H 22 #define LIBCOMMON_P_ACTOR_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** 29 * Removes the given mobj from the world. 30 * 31 * @param mo The mobj to be removed. 32 * @param noRespawn Disable the automatical respawn which occurs 33 * with mobjs of certain type(s) (also dependant on 34 * the current gamemode). 35 * Generally this should be @c false. 36 */ 37 void P_MobjRemove(mobj_t *mo, dd_bool noRespawn); 38 39 /** 40 * To be called after a move, to link the mobj back into the world. 41 * 42 * @param mobj Mobj instance. 43 */ 44 void P_MobjLink(struct mobj_s *mobj); 45 46 /** 47 * Unlinks a mobj from the world so that it can be moved. 48 * 49 * @param mobj Mobj instance. 50 */ 51 void P_MobjUnlink(struct mobj_s *mobj); 52 53 /** 54 * The actor has taken a step, set the corresponding short-range visual 55 * offset. 56 */ 57 void P_MobjSetSRVO(mobj_t *mo, coord_t stepx, coord_t stepy); 58 59 /** 60 * The actor has taken a step, set the corresponding short-range visual 61 * offset. 62 */ 63 void P_MobjSetSRVOZ(mobj_t *mo, coord_t stepz); 64 65 /** 66 * The thing's timer has run out, which means the thing has completed its 67 * step. Or there has been a teleport. 68 */ 69 void P_MobjClearSRVO(mobj_t *mo); 70 71 /** 72 * Turn visual angle towards real angle. An engine cvar controls whether 73 * the visangle or the real angle is used in rendering. 74 * Real-life analogy: angular momentum (you can't suddenly just take a 75 * 90 degree turn in zero time). 76 */ 77 void P_MobjAngleSRVOTicker(mobj_t *mo); 78 79 dd_bool P_MobjIsCamera(mobj_t const *mo); 80 81 /** 82 * Returns @c true iff @a mobj is currently "crunchable", i.e., it can be turned 83 * into a pile of giblets if it no longer fits in the opening between floor and 84 * ceiling planes. 85 */ 86 dd_bool Mobj_IsCrunchable(mobj_t *mobj); 87 88 /** 89 * Returns @c true iff @a mobj is a dropped item. 90 */ 91 dd_bool Mobj_IsDroppedItem(mobj_t *mobj); 92 93 /** 94 * Returns the terraintype_t of the floor plane at the mobj's origin. 95 * 96 * @param mobj Mobj instance. 97 */ 98 terraintype_t const *P_MobjFloorTerrain(mobj_t const *mobj); 99 100 /** 101 * The first three bits of the selector special byte contain a relative 102 * health level. 103 */ 104 void P_UpdateHealthBits(mobj_t *mo); 105 106 /** 107 * Given a mobjtype, lookup the statenum associated to the named state. 108 * 109 * @param mobjType Type of mobj. 110 * @param name State name identifier. 111 * 112 * @return Statenum of the associated state ELSE @c, S_NULL. 113 */ 114 statenum_t P_GetState(mobjtype_t mobjType, statename_t name); 115 116 void P_ProcessDeferredSpawns(void); 117 void P_PurgeDeferredSpawns(void); 118 119 /** 120 * Deferred mobj spawning until at least @a minTics have passed. 121 * Spawn behavior is otherwise exactly the same as an immediate spawn. 122 */ 123 void P_DeferSpawnMobj3f(int minTics, mobjtype_t type, coord_t x, coord_t y, coord_t z, angle_t angle, int spawnFlags, void (*callback) (mobj_t *mo, void *context), void *context); 124 void P_DeferSpawnMobj3fv(int minTics, mobjtype_t type, coord_t const pos[3], angle_t angle, int spawnFlags, void (*callback) (mobj_t *mo, void *context), void *context); 125 126 #ifdef __JHEXEN__ 127 128 void P_CreateTIDList(void); 129 130 void P_MobjRemoveFromTIDList(mobj_t *mo); 131 132 void P_MobjInsertIntoTIDList(mobj_t *mo, int tid); 133 134 mobj_t *P_FindMobjFromTID(int tid, int *searchPosition); 135 136 #endif // __JHEXEN__ 137 138 #ifdef __cplusplus 139 } // extern "C" 140 #endif 141 142 #endif // LIBCOMMON_P_ACTOR_H 143