This commit is contained in:
parent
68ca825123
commit
861c534304
8 changed files with 195 additions and 26 deletions
|
@ -15,6 +15,10 @@
|
|||
#include "platform\pdual.h"
|
||||
#endif
|
||||
|
||||
#ifndef __HAZARD_HAZARD_H__
|
||||
#include "hazard\hazard.h"
|
||||
#endif
|
||||
|
||||
#ifndef __UTILS_HEADER__
|
||||
#include "utils\utils.h"
|
||||
#endif
|
||||
|
@ -231,4 +235,77 @@ const CRECT *CNpcDualPlatform::getThinkBBox()
|
|||
objThinkBox.y2 = thinkBBox.YMax;
|
||||
|
||||
return &objThinkBox;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcDualPlatform::collidedWith( CThing *_thisThing )
|
||||
{
|
||||
switch(_thisThing->getThingType())
|
||||
{
|
||||
case TYPE_PLAYER:
|
||||
{
|
||||
CPlayer *player;
|
||||
DVECTOR playerPos;
|
||||
CRECT collisionArea;
|
||||
|
||||
// Only interested in SBs feet colliding with the box (pkg)
|
||||
player=(CPlayer*)_thisThing;
|
||||
playerPos=player->getPos();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
||||
if ( threshold > 16 )
|
||||
{
|
||||
threshold = 16;
|
||||
}
|
||||
|
||||
if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
player->setPlatform( this );
|
||||
|
||||
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_contact = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_NPC:
|
||||
break;
|
||||
|
||||
case TYPE_HAZARD:
|
||||
{
|
||||
m_contact = true;
|
||||
|
||||
CNpcHazard *hazard;
|
||||
|
||||
hazard = (CNpcHazard *)_thisThing;
|
||||
|
||||
hazard->setPlatform( this );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
protected:
|
||||
virtual void setWaypoints( sThingPlatform *ThisPlatform );
|
||||
virtual void processMovement( int _frames );
|
||||
virtual void collidedWith(CThing *_thisThing);
|
||||
|
||||
u8 m_isMaster;
|
||||
CNpcDualPlatform *m_otherPlatform;
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#include "player\player.h"
|
||||
#endif
|
||||
|
||||
#ifndef __FRIEND_FRIEND_H__
|
||||
#include "friend\friend.h"
|
||||
#endif
|
||||
|
||||
#ifndef __HAZARD_HAZARD_H__
|
||||
#include "hazard\hazard.h"
|
||||
#endif
|
||||
|
@ -249,7 +253,7 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform)
|
|||
platform = new ("cart platform") CNpcCartPlatform;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case NPC_SEESAW_PLATFORM:
|
||||
{
|
||||
platform = new ("seesaw platform") CNpcSeesawPlatform;
|
||||
|
@ -668,7 +672,7 @@ void CNpcPlatform::setCollisionAngle(int newAngle)
|
|||
m_collisionAngle=newAngle;
|
||||
// CPlatformThing::setCollisionAngle(newAngle);
|
||||
calculateBoundingBoxSize();
|
||||
|
||||
|
||||
CPlayer *player;
|
||||
|
||||
// Is the player stood on this platform as it rotates?
|
||||
|
@ -966,19 +970,55 @@ void CNpcPlatform::collidedWith( CThing *_thisThing )
|
|||
break;
|
||||
}
|
||||
|
||||
case TYPE_HAZARD:
|
||||
case TYPE_NPC:
|
||||
{
|
||||
m_contact = true;
|
||||
CNpcFriend *friendNpc;
|
||||
DVECTOR friendPos;
|
||||
CRECT collisionArea;
|
||||
|
||||
CNpcHazard *hazard;
|
||||
friendNpc = (CNpcFriend*) _thisThing;
|
||||
friendPos = friendNpc->getPos();
|
||||
collisionArea=getCollisionArea();
|
||||
|
||||
hazard = (CNpcHazard *)_thisThing;
|
||||
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
|
||||
|
||||
hazard->setPlatform( this );
|
||||
if ( threshold > 16 )
|
||||
{
|
||||
threshold = 16;
|
||||
}
|
||||
|
||||
if( friendPos.vx >= collisionArea.x1 && friendPos.vx <= collisionArea.x2 )
|
||||
{
|
||||
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
|
||||
{
|
||||
int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy );
|
||||
|
||||
friendNpc->setPlatform( this );
|
||||
|
||||
m_contact = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( friendPos.vy >= collisionArea.y1 && friendPos.vy <= collisionArea.y2 )
|
||||
{
|
||||
int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy );
|
||||
|
||||
if ( height >= -threshold && height < 1 )
|
||||
{
|
||||
friendNpc->setPlatform( this );
|
||||
|
||||
m_contact = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_HAZARD:
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue