SBSPSS/source/platform/pclam.cpp

110 lines
2.4 KiB
C++
Raw Normal View History

2001-05-15 18:30:28 +02:00
/*=========================================================================
pclam.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PCLAM_H__
#include "platform\pclam.h"
#endif
#ifndef __LEVEL_LEVEL_H__
#include "level\level.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-06-28 22:53:03 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcClamPlatform::postInit()
{
sBBox boundingBox = m_modelGfx->GetBBox();
2001-07-23 16:16:26 +02:00
setCollisionSize( 80, 34 );
2001-06-28 22:53:03 +02:00
setCollisionCentreOffset( 0, -15 );
calculateNonRotatedCollisionData();
setCollisionAngle( m_tiltAngle >> 8 );
}
2001-05-15 18:30:28 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcClamPlatform::render()
{
2001-05-15 23:41:56 +02:00
CPlatformThing::render();
2001-05-15 18:30:28 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-07-23 16:16:26 +02:00
void CNpcClamPlatform::collidedWith( CThing *_thisThing )
2001-05-15 18:30:28 +02:00
{
2001-07-23 16:16:26 +02:00
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player;
2001-07-23 21:26:37 +02:00
// DVECTOR playerPos;
// CRECT collisionArea;
// CRECT playerCollisionArea;
2001-07-23 16:16:26 +02:00
// Only interested in SBs feet colliding with the box (pkg)
player=(CPlayer*)_thisThing;
2001-07-23 21:26:37 +02:00
DVECTOR const &playerPos=player->getPos();
CRECT const &playerCollisionArea = player->getCollisionArea();
CRECT const &collisionArea=getCollisionArea();
2001-07-23 16:16:26 +02:00
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
if ( threshold > 16 )
{
threshold = 16;
}
if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 )
{
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
{
player->setPlatform( this );
m_clam->stoodOn();
m_contact = true;
}
else
{
if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 )
{
int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy );
if ( height >= -threshold && height < 1 )
{
player->setPlatform( this );
m_clam->stoodOn();
m_contact = true;
}
}
}
}
break;
}
case TYPE_NPC:
case TYPE_HAZARD:
break;
default:
ASSERT(0);
break;
}
}