#include "StdAfx.h" #include "DnBuffProp.h" #include "DnPropStateScanActor.h" #include "DnPropActionCondition.h" #include "SMScanActor.h" #include "boost/shared_ptr.hpp" CDnBuffProp::CDnBuffProp( CMultiRoom* pRoom ) : CDnWorldActProp( pRoom ), CDnDamageBase( DamageObjectTypeEnum::Prop ) { } CDnBuffProp::~CDnBuffProp(void) { ReleasePostCustomParam(); } bool CDnBuffProp::Initialize( CEtWorldSector *pParentSector, const char *szPropName, EtVector3 &vPos, EtVector3 &vRotate, EtVector3 &vScale ) { if( CDnWorldActProp::Initialize( pParentSector, szPropName, vPos, vRotate, vScale ) == false ) return false; if( m_hMonster ) *m_hMonster->GetMatEx() = *GetMatEx(); return true; } bool CDnBuffProp::InitializeTable( int nTableID ) { if( CDnWorldActProp::InitializeTable( nTableID ) == false ) return false; bool bResult = false; // TODO: BuffProp ŸÀÔ ¸ÊÅø¿¡ Ãß°¡ÇؾßÇÔ. if( GetData() ) { BuffStruct* pStruct = (BuffStruct*)(GetData()); int nSkillTableID = pStruct->nSkillTableID; int nSkillLevel = pStruct->nSkillLevel; float fCheckRange = pStruct->fCheckRange; // ¾×Å͵é üũ ¹üÀ§ bResult = InitializeMonsterActorProp( pStruct->nMonsterTableID ); // À߸øµÈ ½ºÅ³ Á¤º¸ _ASSERT( nSkillTableID != 0 && nSkillLevel != 0 ); if( nSkillTableID == 0 || nSkillLevel == 0 ) return false; set* pSetTargetActorIDs = NULL; set setTargetActorIDs; if( bResult ) { // ´ë»ó ¾×ÅͰ¡ ÁöÁ¤µÇ¾îÀÖ´Ù¸é °ª ¼ÂÆÃ. if( 3 == pStruct->nTeam ) { // ´ë»ó ¾×ÅͰ¡ ÁöÁ¤µÇ¾îÀÖÀ» ¶§¸¸ Æ÷ÀÎÅÍ ¼ÂÆÃÇØÁØ´Ù. pSetTargetActorIDs = &setTargetActorIDs; string strTargetActorIDs = pStruct->TargetActorID; if( strTargetActorIDs.at( strTargetActorIDs.length()-1 ) != ';' ) strTargetActorIDs.push_back( ';' ); int iFoundPos = -1; while( true ) { int iStartPos = iFoundPos + 1; iFoundPos = static_cast(strTargetActorIDs.find_first_of( ';', iStartPos )); if( string::npos != iFoundPos ) { string strTargetID = strTargetActorIDs.substr( iStartPos, iFoundPos -iStartPos ); int iTargetID = atoi( strTargetID.c_str() ); setTargetActorIDs.insert( iTargetID ); } else break; } } m_BuffPropComponent.Initialize( GetRoom(), pStruct->nTeam, nSkillTableID, nSkillLevel, pSetTargetActorIDs ); // state µé ÃʱâÈ­. // Idle ¾×¼Ç¿¡¼­´Â ¾Æ¹«°Íµµ ÇÏÁö ¾Ê°í, Activate ¾×¼ÇÀÌ ½ÇÇàµÇ¸é ÁÖº¯À» °Ë»öÇØ¼­ °É¸®´Â ³ðµé¿¡°Ô ½ºÅ³¿¡ ºÙ¾îÀÖ´Â »óÅÂÈ¿°ú ºÎ¿©. CDnPropState* pNormalState = CDnPropState::Create( GetMySmartPtr(), CDnPropState::NORMAL ); CDnPropState* pScanState = CDnPropState::Create( GetMySmartPtr(), CDnPropState::SCAN_ACTOR ); CDnPropCondition* pNormalToScan = CDnPropCondition::Create( GetMySmartPtr(), CDnPropCondition::ACTION_CHECK ); CDnPropCondition* pScanToNormal = CDnPropCondition::Create( GetMySmartPtr(), CDnPropCondition::ACTION_CHECK ); static_cast(pScanState)->SetRange( fCheckRange ); static_cast(pNormalToScan)->SetActionName( "Activate" ); static_cast(pScanToNormal)->SetActionName( "Idle" ); m_pFSM->AddCondition( pNormalToScan ); m_pFSM->AddCondition( pScanToNormal ); m_pFSM->AddState( pNormalState ); m_pFSM->AddState( pScanState ); pNormalState->AddTransitState( pScanState, pNormalToScan ); pScanState->AddTransitState( pNormalState, pScanToNormal ); m_pFSM->SetEntryState( pNormalState ); } } return bResult; } void CDnBuffProp::OnMessage( const boost::shared_ptr& pMessage ) { m_BuffPropComponent.OnMessage( pMessage ); } void CDnBuffProp::OnChangeAction( const char *szPrevAction ) { if( (0 == strcmp( szPrevAction, "Activate" ) && 0 == strcmp( GetCurrentAction(), "Idle" )) || (0 == strcmp( szPrevAction, "Off" ) && 0 == strcmp(GetCurrentAction(), "Idle")) ) // off ¾×¼Ç ÈÄ¿¡ idle ·Î ³Ñ¾î°¡´Â ÇÁ¶øµµ ÀÖÀ½. { // Àû¿ëµÇ´ø È¿°ú »èÁ¦. m_BuffPropComponent.RemoveAffectedStateEffects(); } }