This commit is contained in:
parent
5192c4b988
commit
a17755d81c
4 changed files with 326 additions and 0 deletions
104
source/hazard/hcswitch.cpp
Normal file
104
source/hazard/hcswitch.cpp
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
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);
|
||||||
|
trigger->setPositionAndSize( ( newXPos << 4 ) + 8, ( newYPos << 4 ) + 16, 100, 0 );
|
||||||
|
trigger->setHazard( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcConveyorSwitchHazard::trigger()
|
||||||
|
{
|
||||||
|
m_reversed = !m_reversed;
|
||||||
|
}
|
34
source/hazard/hcswitch.h
Normal file
34
source/hazard/hcswitch.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
hcswitch.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __HAZARD_HCSWITCH_H__
|
||||||
|
#define __HAZARD_HCSWITCH_H__
|
||||||
|
|
||||||
|
#ifndef __HAZARD_HAZARD_H__
|
||||||
|
#include "hazard\hazard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcConveyorSwitchHazard : public CNpcHazard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void setWaypoints( sThingHazard *ThisHazard );
|
||||||
|
void init();
|
||||||
|
virtual void render();
|
||||||
|
virtual void trigger();
|
||||||
|
protected:
|
||||||
|
virtual void collidedWith(CThing *_thisThing) {}
|
||||||
|
|
||||||
|
u8 m_reversed;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
116
source/triggers/thazard.cpp
Normal file
116
source/triggers/thazard.cpp
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
thazard.cpp
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#include "triggers\trigger.h"
|
||||||
|
#include "triggers\thazard.h"
|
||||||
|
|
||||||
|
#ifndef __GAME_GAME_H__
|
||||||
|
#include "game\game.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PLAYER_PLAYER_H__
|
||||||
|
#include "player\player.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/* Data
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Vars
|
||||||
|
---- */
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CHazardTrigger::init()
|
||||||
|
{
|
||||||
|
CTrigger::init();
|
||||||
|
|
||||||
|
m_timeout = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CHazardTrigger::think(int _frames)
|
||||||
|
{
|
||||||
|
CTrigger::think( _frames );
|
||||||
|
|
||||||
|
if ( m_timeout > 0 )
|
||||||
|
{
|
||||||
|
m_timeout -= _frames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CHazardTrigger::collidedWith(CThing *_thisThing)
|
||||||
|
{
|
||||||
|
if ( m_timeout <= 0 )
|
||||||
|
{
|
||||||
|
switch( _thisThing->getThingType() )
|
||||||
|
{
|
||||||
|
case TYPE_PLAYER:
|
||||||
|
{
|
||||||
|
CPlayer *player = (CPlayer *) _thisThing;
|
||||||
|
ATTACK_STATE playerState = player->getAttackState();
|
||||||
|
|
||||||
|
if ( playerState == ATTACK_STATE__BUTT_BOUNCE )
|
||||||
|
{
|
||||||
|
m_hazard->trigger();
|
||||||
|
|
||||||
|
m_timeout = GameState::getOneSecondInFrames();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
72
source/triggers/thazard.h
Normal file
72
source/triggers/thazard.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
thazard.h
|
||||||
|
|
||||||
|
Author: Charles Blair
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __TRIGGERS_THAZARD_H__
|
||||||
|
#define __TRIGGERS_THAZARD_H__
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
#ifndef __THING_THING_H__
|
||||||
|
#include "thing/thing.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __TRIGGERS_TRIGGER_H__
|
||||||
|
#include "triggers\trigger.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAZARD_HAZARD_H__
|
||||||
|
#include "hazard\hazard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
class CHazardTrigger : public CTrigger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void init();
|
||||||
|
virtual void think(int _frames);
|
||||||
|
virtual void setHazard( CNpcHazard *hazard ) {m_hazard = hazard;}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void collidedWith(CThing *_thisThing);
|
||||||
|
|
||||||
|
CNpcHazard *m_hazard;
|
||||||
|
s32 m_timeout;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
Loading…
Add table
Reference in a new issue