2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** p_switch.cpp
|
|
|
|
** Switch and button maintenance and animation
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_lnspec.h"
|
2008-03-18 18:18:18 +00:00
|
|
|
#include "p_3dmidtex.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "m_random.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "tarray.h"
|
|
|
|
#include "cmdlib.h"
|
2011-07-06 14:20:54 +00:00
|
|
|
#include "farchive.h"
|
2016-02-15 01:14:34 +00:00
|
|
|
#include "p_maputl.h"
|
|
|
|
#include "p_spec.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#include "gi.h"
|
|
|
|
|
|
|
|
static FRandom pr_switchanim ("AnimSwitch");
|
|
|
|
|
|
|
|
class DActiveButton : public DThinker
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (DActiveButton, DThinker)
|
|
|
|
public:
|
|
|
|
DActiveButton ();
|
2010-12-12 15:43:35 +00:00
|
|
|
DActiveButton (side_t *, int, FSwitchDef *, fixed_t x, fixed_t y, bool flippable);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void Serialize (FArchive &arc);
|
|
|
|
void Tick ();
|
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
side_t *m_Side;
|
|
|
|
SBYTE m_Part;
|
|
|
|
bool bFlippable;
|
|
|
|
bool bReturning;
|
|
|
|
FSwitchDef *m_SwitchDef;
|
|
|
|
SDWORD m_Frame;
|
|
|
|
DWORD m_Timer;
|
|
|
|
fixed_t m_X, m_Y; // Location of timer sound
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool AdvanceFrame ();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// Start a button counting down till it turns off.
|
|
|
|
// [RH] Rewritten to remove MAXBUTTONS limit.
|
|
|
|
//
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t x, fixed_t y, bool useagain)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
DActiveButton *button;
|
|
|
|
TThinkerIterator<DActiveButton> iterator;
|
|
|
|
|
|
|
|
// See if button is already pressed
|
|
|
|
while ( (button = iterator.Next ()) )
|
|
|
|
{
|
|
|
|
if (button->m_Side == side)
|
2006-04-16 13:29:50 +00:00
|
|
|
{
|
|
|
|
button->m_Timer=1; // force advancing to the next frame
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
new DActiveButton (side, Where, Switch, x, y, useagain);
|
2006-04-16 13:29:50 +00:00
|
|
|
return true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
2008-03-18 18:18:18 +00:00
|
|
|
//
|
|
|
|
// Checks whether a switch is reachable
|
|
|
|
// This is optional because old maps can rely on being able to
|
|
|
|
// use non-reachable switches.
|
|
|
|
//
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
2016-03-01 00:36:36 +00:00
|
|
|
bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpos)
|
2008-03-18 18:18:18 +00:00
|
|
|
{
|
2009-05-11 22:16:41 +00:00
|
|
|
// Activated from an empty side -> always succeed
|
2009-09-06 20:45:56 +00:00
|
|
|
side_t *side = line->sidedef[sideno];
|
2009-10-30 03:29:15 +00:00
|
|
|
if (side == NULL)
|
|
|
|
return true;
|
2008-04-04 14:31:20 +00:00
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
fixed_t checktop;
|
|
|
|
fixed_t checkbot;
|
2009-09-06 20:45:56 +00:00
|
|
|
sector_t *front = side->sector;
|
2008-03-18 18:18:18 +00:00
|
|
|
FLineOpening open;
|
2012-04-27 03:17:56 +00:00
|
|
|
int flags = line->flags;
|
|
|
|
|
|
|
|
if (!side->GetTexture(side_t::mid).isValid())
|
|
|
|
{ // Do not force range checks for 3DMIDTEX lines if there is no actual midtexture.
|
|
|
|
flags &= ~ML_3DMIDTEX;
|
|
|
|
}
|
2008-03-18 18:18:18 +00:00
|
|
|
|
|
|
|
// 3DMIDTEX forces CHECKSWITCHRANGE because otherwise it might cause problems.
|
2012-04-27 03:17:56 +00:00
|
|
|
if (!(flags & (ML_3DMIDTEX|ML_CHECKSWITCHRANGE)))
|
2009-10-30 03:29:15 +00:00
|
|
|
return true;
|
2008-03-18 18:18:18 +00:00
|
|
|
|
|
|
|
// calculate the point where the user would touch the wall.
|
|
|
|
divline_t dll, dlu;
|
|
|
|
fixed_t inter, checkx, checky;
|
|
|
|
|
|
|
|
P_MakeDivline (line, &dll);
|
|
|
|
|
2016-03-01 00:36:36 +00:00
|
|
|
fixedvec3 pos = optpos? *optpos : user->PosRelative(line);
|
2016-01-20 13:20:14 +00:00
|
|
|
dlu.x = pos.x;
|
|
|
|
dlu.y = pos.y;
|
2008-03-18 18:18:18 +00:00
|
|
|
dlu.dx = finecosine[user->angle >> ANGLETOFINESHIFT];
|
|
|
|
dlu.dy = finesine[user->angle >> ANGLETOFINESHIFT];
|
|
|
|
inter = P_InterceptVector(&dll, &dlu);
|
|
|
|
|
|
|
|
|
2009-10-30 07:03:26 +00:00
|
|
|
// Polyobjects must test the containing sector, not the one they originate from.
|
|
|
|
if (line->sidedef[0]->Flags & WALLF_POLYOBJ)
|
|
|
|
{
|
|
|
|
// Get a check point slightly inside the polyobject so that this still works
|
|
|
|
// if the polyobject lies directly on a sector boundary
|
|
|
|
checkx = dll.x + FixedMul(dll.dx, inter + (FRACUNIT/100));
|
|
|
|
checky = dll.y + FixedMul(dll.dy, inter + (FRACUNIT/100));
|
|
|
|
front = P_PointInSector(checkx, checky);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
checkx = dll.x + FixedMul(dll.dx, inter);
|
|
|
|
checky = dll.y + FixedMul(dll.dy, inter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// one sided line or polyobject
|
|
|
|
if (line->sidedef[1] == NULL || (line->sidedef[0]->Flags & WALLF_POLYOBJ))
|
2009-05-03 21:12:52 +00:00
|
|
|
{
|
|
|
|
onesided:
|
2009-05-11 22:16:41 +00:00
|
|
|
fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky);
|
|
|
|
fixed_t sectorf = front->floorplane.ZatPoint(checkx, checky);
|
2016-01-20 13:20:14 +00:00
|
|
|
return (user->Top() >= sectorf && user->Z() <= sectorc);
|
2009-05-03 21:12:52 +00:00
|
|
|
}
|
|
|
|
|
2008-03-18 18:18:18 +00:00
|
|
|
// Now get the information from the line.
|
2016-01-20 13:20:14 +00:00
|
|
|
P_LineOpening(open, NULL, line, checkx, checky, pos.x, pos.y);
|
2009-10-30 03:29:15 +00:00
|
|
|
if (open.range <= 0)
|
|
|
|
goto onesided;
|
2008-03-18 18:18:18 +00:00
|
|
|
|
2012-04-27 03:17:56 +00:00
|
|
|
if ((TexMan.FindSwitch(side->GetTexture(side_t::top))) != NULL)
|
2008-03-18 18:18:18 +00:00
|
|
|
{
|
2015-12-04 23:26:39 +00:00
|
|
|
|
|
|
|
// Check 3D floors on back side
|
|
|
|
{
|
|
|
|
sector_t * back = line->sidedef[1 - sideno]->sector;
|
|
|
|
for (unsigned i = 0; i < back->e->XFloor.ffloors.Size(); i++)
|
|
|
|
{
|
|
|
|
F3DFloor *rover = back->e->XFloor.ffloors[i];
|
|
|
|
if (!(rover->flags & FF_EXISTS)) continue;
|
|
|
|
if (!(rover->flags & FF_UPPERTEXTURE)) continue;
|
|
|
|
|
2016-01-20 13:20:14 +00:00
|
|
|
if (user->Z() > rover->top.plane->ZatPoint(checkx, checky) ||
|
|
|
|
user->Top() < rover->bottom.plane->ZatPoint(checkx, checky))
|
2015-12-04 23:26:39 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// This 3D floor depicts a switch texture in front of the player's eyes
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-20 13:20:14 +00:00
|
|
|
return (user->Top() > open.top);
|
2008-03-18 18:18:18 +00:00
|
|
|
}
|
2012-04-27 03:17:56 +00:00
|
|
|
else if ((TexMan.FindSwitch(side->GetTexture(side_t::bottom))) != NULL)
|
2008-03-18 18:18:18 +00:00
|
|
|
{
|
2015-12-04 23:26:39 +00:00
|
|
|
// Check 3D floors on back side
|
|
|
|
{
|
|
|
|
sector_t * back = line->sidedef[1 - sideno]->sector;
|
|
|
|
for (unsigned i = 0; i < back->e->XFloor.ffloors.Size(); i++)
|
|
|
|
{
|
|
|
|
F3DFloor *rover = back->e->XFloor.ffloors[i];
|
|
|
|
if (!(rover->flags & FF_EXISTS)) continue;
|
|
|
|
if (!(rover->flags & FF_LOWERTEXTURE)) continue;
|
|
|
|
|
2016-01-20 13:20:14 +00:00
|
|
|
if (user->Z() > rover->top.plane->ZatPoint(checkx, checky) ||
|
|
|
|
user->Top() < rover->bottom.plane->ZatPoint(checkx, checky))
|
2015-12-04 23:26:39 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// This 3D floor depicts a switch texture in front of the player's eyes
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-20 13:20:14 +00:00
|
|
|
return (user->Z() < open.bottom);
|
2008-03-18 18:18:18 +00:00
|
|
|
}
|
2012-04-27 03:17:56 +00:00
|
|
|
else if ((flags & ML_3DMIDTEX) || (TexMan.FindSwitch(side->GetTexture(side_t::mid))) != NULL)
|
2008-03-18 18:18:18 +00:00
|
|
|
{
|
|
|
|
// 3DMIDTEX lines will force a mid texture check if no switch is found on this line
|
|
|
|
// to keep compatibility with Eternity's implementation.
|
2009-10-30 03:29:15 +00:00
|
|
|
if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot))
|
|
|
|
return false;
|
2016-01-20 13:20:14 +00:00
|
|
|
return user->Z() < checktop && user->Top() > checkbot;
|
2008-03-18 18:18:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no switch found. Check whether the player can touch either top or bottom texture
|
2016-01-20 13:20:14 +00:00
|
|
|
return (user->Top() > open.top) || (user->Z() < open.bottom);
|
2008-03-18 18:18:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// Function that changes wall texture.
|
|
|
|
// Tell it if switch is ok to use again (1=yes, it's a button).
|
|
|
|
//
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *quest)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-21 17:35:49 +00:00
|
|
|
int texture;
|
2010-12-11 23:02:46 +00:00
|
|
|
int sound;
|
|
|
|
FSwitchDef *Switch;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
if ((Switch = TexMan.FindSwitch (side->GetTexture(side_t::top))) != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-21 17:35:49 +00:00
|
|
|
texture = side_t::top;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-12-12 15:43:35 +00:00
|
|
|
else if ((Switch = TexMan.FindSwitch (side->GetTexture(side_t::bottom))) != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-21 17:35:49 +00:00
|
|
|
texture = side_t::bottom;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-12-12 15:43:35 +00:00
|
|
|
else if ((Switch = TexMan.FindSwitch (side->GetTexture(side_t::mid))) != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-03-21 17:35:49 +00:00
|
|
|
texture = side_t::mid;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (quest != NULL)
|
|
|
|
{
|
|
|
|
*quest = false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// EXIT SWITCH?
|
2010-12-11 23:02:46 +00:00
|
|
|
if (Switch->Sound != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-12-11 23:02:46 +00:00
|
|
|
sound = Switch->Sound;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sound = S_FindSound (
|
|
|
|
special == Exit_Normal ||
|
|
|
|
special == Exit_Secret ||
|
|
|
|
special == Teleport_NewMap ||
|
|
|
|
special == Teleport_EndGame
|
|
|
|
? "switches/exitbutn" : "switches/normbutn");
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] The original code played the sound at buttonlist->soundorg,
|
|
|
|
// which wasn't necessarily anywhere near the switch if it was
|
|
|
|
// facing a big sector (and which wasn't necessarily for the
|
|
|
|
// button just activated, either).
|
2008-07-01 04:06:56 +00:00
|
|
|
fixed_t pt[2];
|
2009-09-06 18:19:28 +00:00
|
|
|
line_t *line = side->linedef;
|
2006-04-16 13:29:50 +00:00
|
|
|
bool playsound;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
pt[0] = line->v1->x + (line->dx >> 1);
|
|
|
|
pt[1] = line->v1->y + (line->dy >> 1);
|
2010-12-12 15:43:35 +00:00
|
|
|
side->SetTexture(texture, Switch->frames[0].Texture);
|
2010-12-11 23:02:46 +00:00
|
|
|
if (useAgain || Switch->NumFrames > 1)
|
|
|
|
{
|
2010-12-12 15:43:35 +00:00
|
|
|
playsound = P_StartButton (side, texture, Switch, pt[0], pt[1], !!useAgain);
|
2010-12-11 23:02:46 +00:00
|
|
|
}
|
2006-04-16 13:29:50 +00:00
|
|
|
else
|
2010-12-11 23:02:46 +00:00
|
|
|
{
|
2006-04-16 13:29:50 +00:00
|
|
|
playsound = true;
|
2010-12-11 23:02:46 +00:00
|
|
|
}
|
2008-06-15 02:25:09 +00:00
|
|
|
if (playsound)
|
2010-12-11 23:02:46 +00:00
|
|
|
{
|
2008-07-01 04:06:56 +00:00
|
|
|
S_Sound (pt[0], pt[1], 0, CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC);
|
2010-12-11 23:02:46 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (quest != NULL)
|
|
|
|
{
|
2010-12-11 23:02:46 +00:00
|
|
|
*quest = Switch->QuestPanel;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Button thinker
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
IMPLEMENT_CLASS (DActiveButton)
|
|
|
|
|
|
|
|
DActiveButton::DActiveButton ()
|
|
|
|
{
|
|
|
|
m_Side = NULL;
|
2008-03-21 17:35:49 +00:00
|
|
|
m_Part = -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
m_SwitchDef = 0;
|
|
|
|
m_Timer = 0;
|
|
|
|
m_X = 0;
|
|
|
|
m_Y = 0;
|
|
|
|
bFlippable = false;
|
2010-12-12 15:43:35 +00:00
|
|
|
bReturning = false;
|
|
|
|
m_Frame = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch,
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t x, fixed_t y, bool useagain)
|
|
|
|
{
|
|
|
|
m_Side = side;
|
2008-03-21 17:35:49 +00:00
|
|
|
m_Part = SBYTE(Where);
|
2006-02-24 04:48:15 +00:00
|
|
|
m_X = x;
|
|
|
|
m_Y = y;
|
|
|
|
bFlippable = useagain;
|
2010-12-12 15:43:35 +00:00
|
|
|
bReturning = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
m_SwitchDef = Switch;
|
|
|
|
m_Frame = -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
AdvanceFrame ();
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void DActiveButton::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
2010-12-12 15:43:35 +00:00
|
|
|
arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_X << m_Y << bReturning;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void DActiveButton::Tick ()
|
|
|
|
{
|
2010-12-12 15:43:35 +00:00
|
|
|
if (m_SwitchDef == NULL)
|
|
|
|
{
|
|
|
|
// We lost our definition due to a bad savegame.
|
|
|
|
Destroy();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FSwitchDef *def = bReturning? m_SwitchDef->PairDef : m_SwitchDef;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (--m_Timer == 0)
|
|
|
|
{
|
|
|
|
if (m_Frame == def->NumFrames - 1)
|
|
|
|
{
|
2010-12-12 15:43:35 +00:00
|
|
|
bReturning = true;
|
|
|
|
def = m_SwitchDef->PairDef;
|
|
|
|
if (def != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-12-12 15:43:35 +00:00
|
|
|
m_Frame = -1;
|
2008-07-01 04:06:56 +00:00
|
|
|
S_Sound (m_X, m_Y, 0, CHAN_VOICE|CHAN_LISTENERZ,
|
2010-12-12 07:59:38 +00:00
|
|
|
def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
|
2008-06-15 02:25:09 +00:00
|
|
|
1, ATTN_STATIC);
|
2006-02-24 04:48:15 +00:00
|
|
|
bFlippable = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool killme = AdvanceFrame ();
|
|
|
|
|
2010-12-12 15:43:35 +00:00
|
|
|
m_Side->SetTexture(m_Part, def->frames[m_Frame].Texture);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (killme)
|
|
|
|
{
|
|
|
|
Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:02:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
bool DActiveButton::AdvanceFrame ()
|
|
|
|
{
|
|
|
|
bool ret = false;
|
2010-12-12 15:43:35 +00:00
|
|
|
FSwitchDef *def = bReturning? m_SwitchDef->PairDef : m_SwitchDef;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (++m_Frame == def->NumFrames - 1)
|
|
|
|
{
|
|
|
|
if (bFlippable == true)
|
|
|
|
{
|
|
|
|
m_Timer = BUTTONTIME;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-12 15:43:35 +00:00
|
|
|
m_Timer = def->frames[m_Frame].TimeMin;
|
|
|
|
if (def->frames[m_Frame].TimeRnd != 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-12-12 15:43:35 +00:00
|
|
|
m_Timer += pr_switchanim(def->frames[m_Frame].TimeRnd);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|