示例#1
0
// [RH] SpawnDoor: Helper function for EV_DoDoor
DDoor::DDoor (sector_t *sec, line_t *ln, EVlDoor type, fixed_t speed, int delay)
    : DMovingCeiling (sec)
{
    m_Type = type;
    m_TopWait = delay;
    m_Speed = speed;
    m_Line = ln;

    switch (type)
    {
    case doorClose:
        m_TopHeight = P_FindLowestCeilingSurrounding (sec) - 4*FRACUNIT;
        //m_TopHeight -= 4*FRACUNIT;
        m_Direction = -1;
        DoorSound (false);
        break;

    case doorOpen:
    case doorRaise:
        m_Direction = 1;
        m_TopHeight = P_FindLowestCeilingSurrounding (sec) - 4*FRACUNIT;
        if (m_TopHeight != sec->ceilingheight)
            DoorSound (true);
        break;

    case doorCloseWaitOpen:
        m_TopHeight = sec->ceilingheight;
        m_Direction = -1;
        DoorSound (false);
        break;

    case doorRaiseIn5Mins: // denis - fixme - does this need code?
        break;
    }
}
示例#2
0
DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTag)
	: DMovingCeiling (sec),
  	  m_Type (type), m_Speed (speed), m_TopWait (delay), m_LightTag (lightTag)
{
	vertex_t *spot;
	fixed_t height;

	if (i_compatflags & COMPATF_NODOORLIGHT)
	{
		m_LightTag = 0;
	}

	switch (type)
	{
	case doorClose:
		m_Direction = -1;
		height = sec->FindLowestCeilingSurrounding (&spot);
		m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
		DoorSound (false);
		break;

	case doorOpen:
	case doorRaise:
		m_Direction = 1;
		height = sec->FindLowestCeilingSurrounding (&spot);
		m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
		if (m_TopDist != sec->ceilingplane.d)
			DoorSound (true);
		break;

	case doorCloseWaitOpen:
		m_TopDist = sec->ceilingplane.d;
		m_Direction = -1;
		DoorSound (false);
		break;

	case doorRaiseIn5Mins:
		m_Direction = 2;
		height = sec->FindLowestCeilingSurrounding (&spot);
		m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
		m_TopCountdown = 5 * 60 * TICRATE;
		break;
	}

	if (!m_Sector->floordata || !m_Sector->floordata->IsKindOf(RUNTIME_CLASS(DPlat)) ||
		!(barrier_cast<DPlat*>(m_Sector->floordata))->IsLift())
	{
		height = sec->FindHighestFloorPoint (&m_BotSpot);
		m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
	}
	else
	{
		height = sec->FindLowestCeilingPoint(&m_BotSpot);
		m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
	}
	m_OldFloorDist = sec->floorplane.d;
}
示例#3
0
void DDoor::Tick ()
{
	EResult res;

	if (m_Sector->floorplane.d != m_OldFloorDist)
	{
		if (!m_Sector->floordata || !m_Sector->floordata->IsKindOf(RUNTIME_CLASS(DPlat)) ||
			!(barrier_cast<DPlat*>(m_Sector->floordata))->IsLift())
		{
			m_OldFloorDist = m_Sector->floorplane.d;
			m_BotDist = m_Sector->ceilingplane.PointToDist (m_BotSpot,
				m_Sector->floorplane.ZatPoint (m_BotSpot));
		}
	}

	switch (m_Direction)
	{
	case 0:
		// WAITING
		if (!--m_TopCountdown)
		{
			switch (m_Type)
			{
			case doorRaise:
				m_Direction = -1; // time to go back down
				DoorSound (false);
				break;
				
			case doorCloseWaitOpen:
				m_Direction = 1;
				DoorSound (true);
				break;
				
			default:
				break;
			}
		}
		break;
		
	case 2:
		//	INITIAL WAIT
		if (!--m_TopCountdown)
		{
			switch (m_Type)
			{
			case doorRaiseIn5Mins:
				m_Direction = 1;
				m_Type = doorRaise;
				DoorSound (true);
				break;
				
			default:
				break;
			}
		}
		break;
		
	case -1:
		// DOWN
		res = MoveCeiling (m_Speed, m_BotDist, -1, m_Direction, false);

		// killough 10/98: implement gradual lighting effects
		if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d)
		{
			EV_LightTurnOnPartway (m_LightTag, FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d,
				m_TopDist + m_Sector->floorplane.d));
		}

		if (res == pastdest)
		{
			SN_StopSequence (m_Sector, CHAN_CEILING);
			switch (m_Type)
			{
			case doorRaise:
			case doorClose:
				m_Sector->ceilingdata = NULL;	//jff 2/22/98
				Destroy ();						// unlink and free
				break;
				
			case doorCloseWaitOpen:
				m_Direction = 0;
				m_TopCountdown = m_TopWait;
				break;
				
			default:
				break;
			}
		}
		else if (res == crushed)
		{
			switch (m_Type)
			{
			case doorClose:				// DO NOT GO BACK UP!
				break;
				
			default:
				m_Direction = 1;
				DoorSound (true);
				break;
			}
		}
		break;
		
	case 1:
		// UP
		res = MoveCeiling (m_Speed, m_TopDist, -1, m_Direction, false);
		
		// killough 10/98: implement gradual lighting effects
		if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d)
		{
			EV_LightTurnOnPartway (m_LightTag, FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d,
				m_TopDist + m_Sector->floorplane.d));
		}

		if (res == pastdest)
		{
			SN_StopSequence (m_Sector, CHAN_CEILING);
			switch (m_Type)
			{
			case doorRaise:
				m_Direction = 0; // wait at top
				m_TopCountdown = m_TopWait;
				break;
				
			case doorCloseWaitOpen:
			case doorOpen:
				m_Sector->ceilingdata = NULL;	//jff 2/22/98
				Destroy ();						// unlink and free
				break;
				
			default:
				break;
			}
		}
		else if (res == crushed)
		{
			switch (m_Type)
			{
			case doorRaise:
			case doorRaiseIn5Mins:
				m_Direction = -1;
				DoorSound(false);
				break;

			default:
				break;
			}
		}
		break;
	}
}
示例#4
0
//
// T_VerticalDoor
//
void DDoor::RunThink ()
{
    EResult res;

    switch (m_Direction)
    {
    case 0:
        // WAITING
        if (!--m_TopCountdown)
        {
            switch (m_Type)
            {
            case doorRaise:
                m_Direction = -1; // time to go back down
                DoorSound (false);
                break;

            case doorCloseWaitOpen:
                m_Direction = 1;
                DoorSound (true);
                break;

            default:
                break;
            }
        }
        break;

    case 2:
        //	INITIAL WAIT
        if (!--m_TopCountdown)
        {
            switch (m_Type)
            {
            case doorRaiseIn5Mins:
                m_Direction = 1;
                m_Type = doorRaise;
                DoorSound (true);
                break;

            default:
                break;
            }
        }
        break;

    case -1:
        // DOWN
        res = MoveCeiling (m_Speed, m_Sector->floorheight, false, m_Direction);
        if (m_Line && m_Line->id)
        {
            EV_LightTurnOnPartway(m_Line->id,
                                  FixedDiv(
                                      m_Sector->ceilingheight - m_Sector->floorheight,
                                      m_TopHeight - m_Sector->floorheight
                                  )
                                 );
        }
        if (res == pastdest)
        {
            //S_StopSound (m_Sector->soundorg);
            switch (m_Type)
            {
            case doorRaise:
            case doorClose:
                m_Sector->ceilingdata = NULL;	//jff 2/22/98
                Destroy ();						// unlink and free
                break;

            case doorCloseWaitOpen:
                m_Direction = 0;
                m_TopCountdown = m_TopWait;
                break;

            default:
                break;
            }
            if (m_Line && m_Line->id)
            {
                EV_LightTurnOnPartway(m_Line->id, 0);
            }
        }
        else if (res == crushed)
        {
            switch (m_Type)
            {
            case doorClose:				// DO NOT GO BACK UP!
                break;

            default:
                m_Direction = 1;
                DoorSound (true);
                break;
            }
        }
        break;

    case 1:
        // UP
        res = MoveCeiling (m_Speed, m_TopHeight, false, m_Direction);

        if (m_Line && m_Line->id)
        {
            EV_LightTurnOnPartway(m_Line->id,
                                  FixedDiv(
                                      m_Sector->ceilingheight - m_Sector->floorheight,
                                      m_TopHeight - m_Sector->floorheight
                                  )
                                 );
        }
        if (res == pastdest)
        {
            //S_StopSound (m_Sector->soundorg);
            switch (m_Type)
            {
            case doorRaise:
                m_Direction = 0; // wait at top
                m_TopCountdown = m_TopWait;
                break;

            case doorCloseWaitOpen:
            case doorOpen:
                m_Sector->ceilingdata = NULL;	//jff 2/22/98
                Destroy ();						// unlink and free
                break;

            default:
                break;
            }
            if (m_Line && m_Line->id)
            {
                EV_LightTurnOnPartway(m_Line->id, FRACUNIT);
            }
        }
        break;
    }
}