SBSPSS/source/hazard/hcswitch.cpp

128 lines
2.6 KiB
C++
Raw Normal View History

2001-06-04 18:29:42 +02:00
/*=========================================================================
hcswitch.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HCSWITCH_H__
#include "hazard\hcswitch.h"
#endif
#ifndef __TRIGGERS_THAZARD_H__
#include "triggers\thazard.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-06-06 22:23:44 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-06-04 18:29:42 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcConveyorSwitchHazard::init()
{
CNpcHazard::init();
m_reversed = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcConveyorSwitchHazard::render()
{
if ( m_isActive )
{
CHazardThing::render();
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
VECTOR flip;
if ( m_reversed )
{
flip.vx = ONE;
}
else
{
flip.vx = -ONE;
}
flip.vy = ONE;
flip.vz = ONE;
m_modelGfx->Render( renderPos, NULL, &flip );
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcConveyorSwitchHazard::setWaypoints( sThingHazard *ThisHazard )
{
int pointNum;
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
u16 newXPos, newYPos;
m_npcPath.setWaypointCount( ThisHazard->PointCount - 1 );
newXPos = (u16) *PntList;
setWaypointPtr( PntList );
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = ( newXPos << 4 ) + 8;
startPos.vy = ( newYPos << 4 ) + 16;
Pos = startPos;
m_base = Pos;
CHazardTrigger *trigger;
trigger=(CHazardTrigger*)CTrigger::Create(CTrigger::TRIGGER_HAZARD);
2001-06-06 22:23:44 +02:00
trigger->setPositionAndSize( ( newXPos << 4 ) + 8 - 50, ( newYPos << 4 ) + 16, 100, 0 );
2001-06-04 18:29:42 +02:00
trigger->setHazard( this );
2001-06-06 22:23:44 +02:00
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
m_conveyorPos.vx = ( newXPos << 4 ) + 8;
m_conveyorPos.vy = ( newYPos << 4 ) + 8;
2001-06-19 22:07:57 +02:00
s32 minX, maxX, minY, maxY;
m_npcPath.getPathXExtents( &minX, &maxX );
m_npcPath.getPathYExtents( &minY, &maxY );
m_thinkArea.x1 = minX;
m_thinkArea.x2 = maxX;
m_thinkArea.y1 = minY;
m_thinkArea.y2 = maxY;
2001-06-04 18:29:42 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcConveyorSwitchHazard::trigger()
{
m_reversed = !m_reversed;
2001-06-06 22:23:44 +02:00
CLevel &level = GameScene.GetLevel();
level.reverseMapConveyor( m_conveyorPos );
2001-06-04 18:29:42 +02:00
}