I was peeking around in the source code and found a variable called m_toggle_state. When the door is at the top/open it gets set to TS_AT_TOP.
Code:
void CBaseDoor::DoorHitTop( void )
{
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
{
STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) );
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM);
}
ASSERT(m_toggle_state == TS_GOING_UP);
m_toggle_state = TS_AT_TOP; //RIGHT HERE RIGHT HERE
// toggle-doors don't come down automatically, they wait for refire.
if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN))
{
// Re-instate touch method, movement is complete
if ( !FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) )
SetTouch( DoorTouch );
}
else
{
// In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open
pev->nextthink = pev->ltime + m_flWait;
SetThink( DoorGoDown );
if ( m_flWait == -1 )
{
pev->nextthink = -1;
}
}
// Fire the close target (if startopen is set, then "top" is closed) - netname is the close target
if ( pev->netname && (pev->spawnflags & SF_DOOR_START_OPEN) )
FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 );
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished
}
Digging further, I find this:
Code:
typedef enum
{
TS_AT_TOP,
TS_AT_BOTTOM,
TS_GOING_UP,
TS_GOING_DOWN
} TOGGLE_STATE;
m_toggle_state is part of CBaseAnimating. Also, you may need to use some hacks (hope that is the proper term) if the door starts open, is closing, or is opening.