SBSPSS/source/platform/prbridge.cpp

130 lines
2.9 KiB
C++
Raw Normal View History

2001-05-23 18:01:00 +02:00
/*=========================================================================
prbridge.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PRBRIDGE_H__
#include "platform\prbridge.h"
#endif
2001-05-29 22:31:02 +02:00
#include "triggers\trigger.h"
2001-05-23 18:01:00 +02:00
#ifndef __TRIGGERS_TPLATFRM_H__
#include "triggers\tplatfrm.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::postInit()
{
CNpcPlatform::postInit();
m_triggered = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::trigger()
{
m_triggered = true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::setWaypoints( sThingPlatform *ThisPlatform )
{
ASSERT( ThisPlatform->PointCount == 3 );
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 newXPos, newYPos;
// get master platform init pos
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
2001-05-31 18:24:48 +02:00
startPos.vx = ( newXPos << 4 ) + 8;
startPos.vy = ( newYPos << 4 ) + 16;
2001-05-23 18:01:00 +02:00
init( startPos );
m_extension = 0;
// get master platform max vertical extension
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
2001-05-31 18:24:48 +02:00
m_maxExtension = abs( ( ( newYPos << 4 ) + 16 ) - startPos.vy ) << 8;
2001-05-23 18:01:00 +02:00
// get slave trigger position
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
2001-05-30 18:52:52 +02:00
CPlatformTrigger *trigger;
2001-05-23 18:01:00 +02:00
2001-05-30 18:52:52 +02:00
// trigger = new ("PlatformTrigger") CPlatformTrigger();
trigger=(CPlatformTrigger*)CTrigger::Create(CTrigger::TRIGGER_PLATFORM);
2001-07-30 21:43:39 +02:00
trigger->setPositionAndSize( ( newXPos << 4 ) + 8 - 20, ( newYPos << 4 ) + 16 - 20, 40, 40 );
2001-05-23 18:01:00 +02:00
//trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4);
trigger->setPlatform( this );
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-05-23 18:01:00 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::processMovement( int _frames )
{
if ( m_triggered )
{
m_triggered = false;
2001-05-29 20:40:38 +02:00
m_extension += ( m_dataPtr->speed * _frames ) << 8;
2001-05-23 18:01:00 +02:00
if ( m_extension > m_maxExtension )
{
m_extension = m_maxExtension;
}
}
else
{
2001-07-30 22:33:37 +02:00
m_extension -= 16 * _frames;
2001-05-23 18:01:00 +02:00
if ( m_extension < 0 )
{
m_extension = 0;
}
}
Pos.vy = m_base.vy - ( m_extension >> 8 );
}