//************************************************************************** //** //** ## ## ## ## ## #### #### ### ### //** ## ## ## ## ## ## ## ## ## ## #### #### //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## //** ## ## ######## ## ## ## ## ## ## ## ### ## //** ### ## ## ### ## ## ## ## ## ## //** # ## ## # #### #### ## ## //** //** $Id: SectorMover.vc 2045 2007-03-08 22:14:32Z dj_jl $ //** //** Copyright (C) 1999-2006 Jānis Legzdiņš //** //** This program is free software; you can redistribute it and/or //** modify it under the terms of the GNU General Public License //** as published by the Free Software Foundation; either version 2 //** of the License, or (at your option) any later version. //** //** This program is distributed in the hope that it will be useful, //** but WITHOUT ANY WARRANTY; without even the implied warranty of //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //** GNU General Public License for more details. //** //************************************************************************** class SectorMover : SectorThinker; //========================================================================== // // Finished // //========================================================================== void Finished() { if (Sector->FloorData == self) Sector->FloorData = none; if (Sector->CeilingData == self) Sector->CeilingData = none; if (Sector->LightingData == self) Sector->LightingData = none; RemoveAffector(); Destroy(); } //************************************************************************** // // MOVE FLOOR/CEILING // //************************************************************************** //========================================================================== // // MovePlane // // Move a plane (floor or ceiling) and check for crushing // //========================================================================== int MovePlane(sector_t* sector, float amount, float dest, int crush, int floorOrCeiling, int direction, bool StopOnCrush) { bool flag; float lastpos; switch (floorOrCeiling) { case 0: // FLOOR lastpos = sector->floor.dist; switch (direction) { case -1: // DOWN sector->floor.dist -= amount * sector->floor.normal.z; if (sector->floor.dist <= dest) { sector->floor.dist = dest; flag = XLevel.ChangeSector(sector, crush); if (flag) { sector->floor.dist = lastpos; XLevel.ChangeSector(sector, crush); } return RES_PASTDEST; } else { flag = XLevel.ChangeSector(sector, crush); // This is completely illigical and aparently in Strife they // fixed this one. /*if (flag) { sector->floor.dist = lastpos; P_ChangeSector(sector, crush); return RES_CRUSHED; }*/ } break; case 1: // UP // jff 02/04/98 keep floor from moving thru ceilings // [RH] not so easy with arbitrary planes if (!sector->bExtrafloorSource && !sector->ceiling.normal.x && !sector->ceiling.normal.y && !sector->floor.normal.x && !sector->floor.normal.y && dest > -sector->ceiling.dist) { dest = -sector->ceiling.dist; } sector->floor.dist += amount * sector->floor.normal.z; if (sector->floor.dist > dest) { sector->floor.dist = dest; flag = XLevel.ChangeSector(sector, crush); if (flag) { sector->floor.dist = lastpos; XLevel.ChangeSector(sector, crush); } return RES_PASTDEST; } else { // COULD GET CRUSHED flag = XLevel.ChangeSector(sector, crush); if (flag) { if (!crush || StopOnCrush) { sector->floor.dist = lastpos; XLevel.ChangeSector(sector, crush); } return RES_CRUSHED; } } break; } break; case 1: // CEILING lastpos = sector->ceiling.dist; switch (direction) { case -1: // DOWN // jff 02/04/98 keep ceiling from moving thru floors // [RH] not so easy with arbitrary planes if (!sector->bExtrafloorSource && !sector->ceiling.normal.x && !sector->ceiling.normal.y && sector->floor.normal.x && !sector->floor.normal.y && -dest < sector->floor.dist) { dest = -sector->floor.dist; } sector->ceiling.dist -= amount * sector->ceiling.normal.z; if (sector->ceiling.dist > dest) { sector->ceiling.dist = dest; flag = XLevel.ChangeSector(sector, crush); if (flag) { sector->ceiling.dist = lastpos; XLevel.ChangeSector(sector, crush); } return RES_PASTDEST; } else { // COULD GET CRUSHED flag = XLevel.ChangeSector(sector, crush); if (flag) { if (!crush || StopOnCrush) { sector->ceiling.dist = lastpos; XLevel.ChangeSector(sector, crush); } return RES_CRUSHED; } } break; case 1: // UP sector->ceiling.dist += amount * sector->ceiling.normal.z; if (sector->ceiling.dist < dest) { sector->ceiling.dist = dest; flag = XLevel.ChangeSector(sector, crush); if (flag) { sector->ceiling.dist = lastpos; XLevel.ChangeSector(sector, crush); } return RES_PASTDEST; } else { flag = XLevel.ChangeSector(sector, crush); } break; } break; } return RES_OK; } defaultproperties { }