Files
Leviathan/Client/Game/game/GameSystem/SMotionMgr.cpp
T
2026-06-01 12:46:52 +02:00

350 lines
12 KiB
C++

#include "stdafx.h"
#include "SGame.h"
#include "SStringDB.h"
#include "SMotionMgr.h"
//#include "SGameMessageUI.h"
#include "GameDefine.h"
#include "SUISysMsgDefine.h"
#include "SDebug_Util.h"
SMotionSlot::SMotionSlot()
{
m_nMotionPos = 0;
m_nMotionCommandID = 0;
m_strMotionName.clear();
m_strMotionToolTip.clear();
m_bUse = false;
m_bCasting = false;
m_bShooting = false;
m_dwCoolTime = 0;
m_dwStartTime = 0;
m_dwBeginTime = 0;
m_dwMaxTime = 0;
}
SMotionSlot::~SMotionSlot()
{
}
void SMotionSlot::AddMotion( int nPos, const char* szIconName, int nCommandID, const char* szMotionName, const char* szMotionToolTip )
{
m_nMotionPos = nPos;
m_strIconName = szIconName;
m_nMotionCommandID = nCommandID;
m_strMotionName = szMotionName;
m_strMotionToolTip = szMotionToolTip;
}
void SMotionSlot::SetUse( bool bUse )
{
m_bUse = bUse;
}
void SMotionSlot::Process( DWORD dwTime )
{
/* if( !m_bUse ) return;
if( m_dwStartTime == 0 )
{
m_dwStartTime = dwTime;
return;
}*/
// if( (dwTime-m_dwStartTime) >= m_dwCoolTime )
{
// SetUse( false );
}
// 남은 시간 계산 : // 인터페이스에서 사용
/* if( m_bShooting )
{
DWORD dwCurTime = dwTime - m_dwBeginTime;
if( dwCurTime >= m_dwMaxTime )
{
SetShooting(false);
// 인터페이스에 알려준다
ProcMsgAtStatic( &SIMSG_UI_MOTION_TIME_UPDATE( m_nMotionCommandID ) );
}
}*/
}
//////////////////////////////////////////////////////////////////////////
//
SMotionMgr::SMotionMgr()
: SGameUIMgr() // 2011.03.29 - servantes
{
m_vecMotionList.clear();
InitMotionList();
}
SMotionMgr::~SMotionMgr()
{
m_vecMotionList.clear();
}
void SMotionMgr::ResetInfo()
{
m_dwTime = 0;
}
void SMotionMgr::InitMotionList()
{
SMotionSlot motion;
//TODO : UI 아이콘 순서대로 인덱스가 설정 되어 있음.
motion.AddMotion( ID_ATTACK , "icon_order_0001", MOTION_ATTACK , GetStringDB().GetString(SYS_NAME_ORDER_08), GetStringDB().GetString(SYS_TOOLTIP_ORDER_08) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_STANDUP , "icon_order_0002", MOTION_STANDUP , GetStringDB().GetString(SYS_NAME_ORDER_05), GetStringDB().GetString(SYS_TOOLTIP_ORDER_05) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_PICKUP , "icon_order_0003", MOTION_PICKUP , GetStringDB().GetString(SYS_NAME_ORDER_07), GetStringDB().GetString(SYS_TOOLTIP_ORDER_07) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_ASSIST , "icon_order_0004", MOTION_ASSIST , S(1035), S(2035) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_PKMODE , "icon_order_0009", MOTION_PKMODE , S(1036), S(2036) ); m_vecMotionList.push_back(motion);
//motion.AddMotion( ID_RUN , "icon_order_0012", MOTION_RUN , GetStringDB().GetString(SYS_NAME_ORDER_06), GetStringDB().GetString(SYS_TOOLTIP_ORDER_06) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_MOUNT , "icon_order_0013", MOTION_MOUNT , S(1037), S(2037) ); m_vecMotionList.push_back(motion);
// motion.AddMotion( ID_CAST_CANCEL, "icon_order_0001", MOTION_CAST_CANCEL , "취소", "현재 행동을 취소합니다" ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_CREATURE_ATTACK , "icon_order_0006", CREATURE_ATTACK , GetStringDB().GetString(SYS_NAME_ORDER_02), GetStringDB().GetString(SYS_TOOLTIP_ORDER_02) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_CREATURE_ALLATTACK, "icon_order_0007", CREATURE_ALLATTACK , GetStringDB().GetString(SYS_NAME_ORDER_01), GetStringDB().GetString(SYS_TOOLTIP_ORDER_01) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_CREATURE_BACKDOWN , "icon_order_0008", CREATURE_BACKDOWN , GetStringDB().GetString(SYS_NAME_ORDER_04), GetStringDB().GetString(SYS_TOOLTIP_ORDER_04) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_TRADE , "icon_order_0005", MOTION_TRADE , S(1038), S(2038) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_COMBINE, "icon_order_0010", MOTION_COMBINE , S(1039), S(2039) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_BOOTH , "icon_order_0011", MOTION_BOOTH , S(1040), S(2040) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_HI , "icon_emotion_0001", MOTION_HI , S(1041),S(2041) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_BOW , "icon_emotion_0002", MOTION_BOW , S(1042),S(2042) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_HAPPY , "icon_emotion_0003", MOTION_HAPPY , S(1043),S(2043) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_SORROW , "icon_emotion_0004", MOTION_SORROW , S(1044),S(2044) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_YES , "icon_emotion_0005", MOTION_YES , S(1045),S(2045) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_NO , "icon_emotion_0006", MOTION_NO , S(1046),S(2046) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_BORING , "icon_emotion_0007", MOTION_BORING , S(1047),S(2047) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_APOLOGIZE, "icon_emotion_0008", MOTION_APOLOGIZE , S(1048),S(2048) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_CHEER , "icon_emotion_0009", MOTION_CHEER , S(1049),S(2049) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_POUT , "icon_emotion_0010", MOTION_POUT , S(1050),S(2050) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_DANCE , "icon_emotion_0011", MOTION_DANCE , S(1051),S(2051) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_CLAP , "icon_emotion_0012", MOTION_CLAP , S(1052),S(2052) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_ANGRY , "icon_emotion_0013", MOTION_ANGRY , S(1053),S(2053) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_PROVOKE , "icon_emotion_0014", MOTION_PROVOKE , S(1054),S(2054) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_PARTY_CREATE, "icon_order_0014", MOTION_ANGRY , S(1055),S(2055) ); m_vecMotionList.push_back(motion);
motion.AddMotion( ID_PARTY_INVITE, "icon_order_0015", MOTION_PROVOKE , S(1056),S(2056) ); m_vecMotionList.push_back(motion);
//AziaMafia ADD EMOTE
motion.AddMotion(ID_TP, "motion_normal_icon30", MOTION_YES, S(2100033373), S(2100033374)); m_vecMotionList.push_back(motion);
motion.AddMotion(ID_LOOT, "motion_normal_icon31", MOTION_YES, S(2100033375), S(2100033376)); m_vecMotionList.push_back(motion);
motion.AddMotion(ID_TAME, "motion_normal_icon32", MOTION_YES, S(2100033377), S(2100033378)); m_vecMotionList.push_back(motion);
motion.AddMotion(ID_BUFF, "motion_normal_icon33", MOTION_YES, S(2101000037), S(2101000029)); m_vecMotionList.push_back(motion);
motion.AddMotion(ID_BUFFGUILD, "motion_normal_icon34", MOTION_YES, S(2101000038), S(2101000039)); m_vecMotionList.push_back(motion);
motion.AddMotion(ID_TPTAMINGZONE, "motion_normal_icon35", MOTION_YES, S(2101000030), S(2101000031)); m_vecMotionList.push_back(motion);
motion.AddMotion(ID_ATRADE, "motion_normal_icon36", MOTION_YES, S(2101000032), S(2101000033)); m_vecMotionList.push_back(motion);
//카드만 줍기(사용하지 않음)
//motion.AddMotion( ID_PICKUP_CARD, "icon_order_0003", MOTION_PICKUP_CARD , S(-1008), S(-1009) ); m_vecMotionList.push_back(motion);
}
void SMotionMgr::UseMotion( int nPos )
{
SIMSG_UI_ACT_USECOMMAND msg;
msg.nCmdID = GetMotionCommandID(nPos);
ProcMsgAtStatic(&msg);
}
const int SMotionMgr::GetMotionCommandID( int nPos ) const
{
if( m_vecMotionList.size() <= 0 ) return -1;
std::vector<SMotionSlot>::const_iterator it = m_vecMotionList.begin();
while( it != m_vecMotionList.end() )
{
if( (*it).GetPos() == nPos )
return (*it).GetCommandID();
it++;
}
return -1;
}
const char* SMotionMgr::GetIconIconName( int nPos ) const
{
if( m_vecMotionList.size() <= 0 ) return "NotFound";
std::vector<SMotionSlot>::const_iterator it = m_vecMotionList.begin();
while( it != m_vecMotionList.end() )
{
if( (*it).GetPos() == nPos )
return (*it).GetIconName();
it++;
}
return "NotFound";
}
const char* SMotionMgr::GetMotionName( int nPos ) const
{
if( m_vecMotionList.size() <= 0 ) return NULL;
std::vector<SMotionSlot>::const_iterator it = m_vecMotionList.begin();
while( it != m_vecMotionList.end() )
{
if( (*it).GetPos() == nPos )
return (*it).GetName();
it++;
}
return NULL;
}
const char* SMotionMgr::GetToolTip( int nPos ) const
{
if( m_vecMotionList.size() <= 0 ) return NULL;
std::vector<SMotionSlot>::const_iterator it = m_vecMotionList.begin();
while( it != m_vecMotionList.end() )
{
if( (*it).GetPos() == nPos )
return (*it).GetToolTip();
it++;
}
return NULL;
}
const SMotionSlot* SMotionMgr::GetMotion( int nPos ) const
{
if( m_vecMotionList.size() <= 0 ) return NULL;
std::vector<SMotionSlot>::const_iterator it = m_vecMotionList.begin();
while( it != m_vecMotionList.end() )
{
if( (*it).GetPos() == nPos )
return &(*it);
it++;
}
return NULL;
}
const bool SMotionMgr::IsEnableMotion( int nPos ) const
{
if( m_vecMotionList.size() <= 0 ) return false;
std::vector<SMotionSlot>::const_iterator it = m_vecMotionList.begin();
while( it != m_vecMotionList.end() )
{
if( (*it).GetPos() == nPos ) return true;
it++;
}
return false;
}
void SMotionMgr::AddCooling( int nMotionCmd )
{
std::vector<SMotionSlot>::iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionCmd )
{
(*iter).SetUse( true );
break;
}
}
}
void SMotionMgr::SetCastingMotion( int nMotionCmd, bool bCasting )
{
std::vector<SMotionSlot>::iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionCmd )
{
(*iter).SetCasting( bCasting );
break;
}
}
}
void SMotionMgr::SetShootingMotion( int nMotionCmd, bool bShooting, DWORD dwDelayTime )
{
std::vector<SMotionSlot>::iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionCmd )
{
(*iter).SetCasting( false );
(*iter).SetShooting( bShooting );
(*iter).SetBeginTime( m_dwTime );
(*iter).SetMaxTime( dwDelayTime );
break;
}
}
}
const bool SMotionMgr::IsCastingMotion( int nMotionCmd ) const
{
std::vector<SMotionSlot>::const_iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionCmd )
{
return (*iter).IsCasting();
}
}
return false;
}
const bool SMotionMgr::IsShootingMotion( int nMotionCmd ) const
{
std::vector<SMotionSlot>::const_iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionCmd )
{
return (*iter).IsShooting();
}
}
return false;
}
const DWORD SMotionMgr::GetSkillMaxTime( int nMotionID ) const
{
std::vector<SMotionSlot>::const_iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionID )
return (*iter).GetMaxTime();
}
return 0;
}
const DWORD SMotionMgr::GetSkillCurTime( int nMotionID ) const
{
std::vector<SMotionSlot>::const_iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).GetCommandID() == nMotionID )
return m_dwTime - (*iter).GetBeginTime();
}
return 0;
}
void SMotionMgr::Process( DWORD dwTime )
{
m_dwTime = dwTime;
std::vector<SMotionSlot>::iterator iter = m_vecMotionList.begin();
for(; iter != m_vecMotionList.end(); iter++ )
{
if( (*iter).IsUse() == false ) continue;
if( (*iter).m_dwStartTime == 0 )
{
(*iter).m_dwStartTime = dwTime;
continue;
}
// 남은 시간 계산 : // 인터페이스에서 사용
if( (*iter).m_bShooting )
{
DWORD dwCurTime = dwTime - (*iter).m_dwBeginTime;
if( dwCurTime >= (*iter).m_dwMaxTime )
{
(*iter).SetShooting(false);
// 인터페이스에 알려준다
ProcMsgAtStatic( &SIMSG_UI_MOTION_TIME_UPDATE( (*iter).m_nMotionCommandID ) );
}
}
}
}