diff --git a/source/player/pmnet.cpp b/source/player/pmnet.cpp new file mode 100644 index 000000000..905b9dd36 --- /dev/null +++ b/source/player/pmnet.cpp @@ -0,0 +1,163 @@ +/*========================================================================= + + pmnet.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "player\pmnet.h" + + +/* Std Lib + ------- */ + +/* Data + ---- */ + +#ifndef __ANIM_SPONGEBOB_HEADER__ +#include +#endif + + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeNet::enter() +{ + m_netting=false; + m_netState=NET_STATE__EMPTY; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int netstate; +void CPlayerModeNet::think() +{ + // If we're netting then restore the 'real' anim number/frame before + // doing the think so that the rest of the code doesn't know what + // is going on ;) + if(m_netting) + { + setAnimNo(m_savedAnimNo); + setAnimFrame(m_savedAnimFrame); + } + CPlayerModeBase::think(); + + // Start to net? + if(!m_netting&&getPadInputDown()&PI_ACTION&&canSwingNetFromThisState()) + { + m_netFrame=0; + m_netting=true; + switch(m_netState) + { + case NET_STATE__EMPTY: + m_netState=NET_STATE__FULL; + break; + case NET_STATE__FULL: + m_netState=NET_STATE__EMPTY; + break; + } + } + + // Netting? + if(m_netting) + { + m_player->setAnimNo(ANIM_SPONGEBOB_KARATE); + m_player->setAnimFrame(m_netFrame); + m_netFrame++; + if(m_netFrame>=m_player->getAnimFrameCount()) + { + m_player->setAnimNo(m_savedAnimNo); + m_player->setAnimFrame(m_savedAnimFrame); + m_netting=false; + } + } + netstate=m_netState; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlayerModeNet::setAnimNo(int _animNo) +{ + CPlayerModeBase::setAnimNo(_animNo); + m_savedAnimNo=_animNo; +} + +void CPlayerModeNet::setAnimFrame(int _animFrame) +{ + CPlayerModeBase::setAnimFrame(_animFrame); + m_savedAnimFrame=_animFrame; +} + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CPlayerModeNet::canSwingNetFromThisState() +{ + int ret=false; + + switch(getState()) + { + case STATE_IDLE: + case STATE_IDLETEETER: + case STATE_JUMP: + case STATE_RUN: + case STATE_FALL: + ret=true; + break; + + case STATE_FALLFAR: + case STATE_BUTTBOUNCE: + case STATE_BUTTFALL: + case STATE_BUTTLAND: + case STATE_DUCK: + case STATE_SOAKUP: + case STATE_GETUP: + break; + } + + return ret; +} + +/*=========================================================================== +end */ diff --git a/source/player/pmnet.h b/source/player/pmnet.h new file mode 100644 index 000000000..c8177a1b7 --- /dev/null +++ b/source/player/pmnet.h @@ -0,0 +1,79 @@ +/*========================================================================= + + pmnet.h + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLAYER_PMNET_H__ +#define __PLAYER_PMNET_H__ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#ifndef __PLAYER_PMODES_H__ +#include "player\pmodes.h" +#endif + + +/* Std Lib + ------- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +class CPlayerModeNet : public CPlayerModeBase +{ +public: + virtual void enter(); + virtual void think(); + + virtual void setAnimNo(int _animNo); + virtual void setAnimFrame(int _animFrame); + +private: + typedef enum + { + NET_STATE__EMPTY, + NET_STATE__FULL, + } NetState; + + int canSwingNetFromThisState(); + + int m_savedAnimNo,m_savedAnimFrame; + int m_netFrame; + int m_netting; + NetState m_netState; + +}; + + +/*---------------------------------------------------------------------- + Globals + ------- */ + +/*---------------------------------------------------------------------- + Functions + --------- */ + +/*---------------------------------------------------------------------- */ + +#endif /* __PLAYER_PMNET_H__ */ + +/*=========================================================================== + end */ + + +