//************************************************************************** //** //** ## ## ## ## ## #### #### ### ### //** ## ## ## ## ## ## ## ## ## ## #### #### //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## //** ## ## ######## ## ## ## ## ## ## ## ### ## //** ### ## ## ### ## ## ## ## ## ## //** # ## ## # #### #### ## ## //** //** $Id$ //** //** 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. //** //************************************************************************** //** //** CEILING WAGGLE //** //************************************************************************** class CeilingWaggle : SectorMover; enum { WGLSTATE_EXPAND, WGLSTATE_STABLE, WGLSTATE_REDUCE }; float OriginalDist; float Accumulator; float AccSpeed; float TargetScale; float Scale; float ScaleSpeed; float Timer; int State; //========================================================================== // // Init // //========================================================================== void Init(sector_t* InSector, int InTag, int InHeight, int InSpeed, int InOffset, int InTimer) { Sector = InSector; Sector->CeilingData = self; OriginalDist = Sector->ceiling.dist; Accumulator = itof(InOffset); AccSpeed = itof(InSpeed) / 2.0; Scale = 0.0; TargetScale = itof(InHeight) / 64.0; ScaleSpeed = TargetScale / (1.0 + 3.0 * itof(InHeight) / 255.0); Timer = Timer ? itof(InTimer) : -1.0; State = WGLSTATE_EXPAND; } //========================================================================== // // Tick // //========================================================================== void Tick(float DeltaTime) { switch (State) { case WGLSTATE_EXPAND: Scale += ScaleSpeed * DeltaTime; if (Scale >= TargetScale) { Scale = TargetScale; State = WGLSTATE_STABLE; } break; case WGLSTATE_REDUCE: Scale -= ScaleSpeed * DeltaTime; if (Scale <= 0.0) { // Remove Sector->floor.dist = OriginalDist; XLevel.ChangeSector(Sector, true); Finished(); return; } break; case WGLSTATE_STABLE: if (Timer >= 0.0) { Timer -= DeltaTime; if (Timer <= 0.0) { State = WGLSTATE_REDUCE; } } break; } Accumulator += AccSpeed * DeltaTime; Sector->ceiling.dist = OriginalDist + Level.Game.FloatBobOffsets[ ftoi(Accumulator) & 63] * Scale / Sector->ceiling.normal.z; XLevel.ChangeSector(Sector, true); } defaultproperties { }