#pragma once #include "KObject.h" #include "K3DTypes.h" #include "SNetMessage.h" #include "ArcadiaClient.h" #include "SStateMachine.h" #include #include class SGameObject : public KObject { public: enum { SEQTYPE_NORMAL, SEQTYPE_LOOP, SEQTYPE_LASTPAGE, SEQTYPE_REVERSE, SEQTYPE_REVERSE_LOOP, }; enum { SEQPOS_BEGIN, SEQPOS_END, }; enum SOUND_OPTION { SOUND_OP_REVERB = 0, SOUND_OP_LOWPASS, SOUND_OP_STEREO, SOUND_OP_MAX, }; SGameObject(); virtual ~SGameObject(); /// Effect 받은 횟수 void EffectAddRef(); void EffectDelRef(); const int GetEffectRef() { return m_nEffectRef; } virtual bool Initialize(); virtual void Destroy(); virtual bool Activate(); virtual bool Deactivate(); bool IsActivated() { return m_bIsActivated; } virtual bool Render( unsigned long uRenderBitVector, class KViewportObject** ppViewportList, int nViewportCount ) = 0; virtual bool Process( DWORD time, unsigned long uRenderBitVector=0 ) = 0; virtual void SetMessageHandler( SGameObject *pMsgHandler ); /// 기본 좌표를 셀좌표로 보정 virtual void CorrectivePosition( K3DVector & pos, K3DVector & newpos ); int GetClassID() const { return m_nClassID; } void SetArID( AR_HANDLE _arId ) { m_arObject.handle = _arId; } AR_HANDLE GetArID() const { return m_arObject.handle; } _Object &GetArObject() { return m_arObject; } struct ArcadiaClient* GetArClient() { return m_pArObject; } void SetArObjectPos( const float x, const float y, const float z, unsigned char layer ) { m_arObject.mv.x = x; m_arObject.mv.y = y; m_arObject.mv.z = z; m_arObject.layer = layer; } void SetArObjectStop() { if( m_pArObject != NULL ) { m_pArObject->StopMove(); } else { m_arObject.mv.StopMove(); } } void SetKnockBack( const K3DVector vPosition, const float fSpeed ); virtual void GetNearVertices( float x, float y, K3DVertex* pGetVertices ) const; virtual void GetNearVertices( float x, float y, int cx, int cy, K3DVertex* pGetVertices ) const; virtual void GetTerrainTriangle( float x, float y, K3DVector& v1, K3DVector& v2, K3DVector& v3 ) const; virtual bool GetHeight( const float x, const float y, float& out, WORD& wTile ); virtual bool GetOnlyTerrainHeight( const float x, const float y, float& out ); virtual void SetMoveTargetPos( const float x, const float y, const float z, bool bChase = false ); virtual bool IsBlockedAttribute( const float x, const float y ); virtual void Get2DPos( K3DVector & pos, K3DVector & _2Dpos ); //Effect========================================================================== virtual int AddEffect( struct FX_DATA * pFX_data ); virtual int AddEffect( struct FX_DATA_EX * pFX_data ); virtual int AddEffect( AR_HANDLE hAttacker, AR_HANDLE hTarget, AR_HANDLE hOwner, int nEffectID, int nEffectPos, bool bIsLoopFx = false ); virtual int AddAttackEffect( struct FX_DATA * pFX_data ); virtual void DelEffect( int nEffectID ); virtual void DelOwnerEffect( AR_HANDLE hOwner ); virtual void EndLoopFx( int nEffectID ); virtual void AddStateEffect( SGameMessage * pGameMsg ); virtual void UpdateStateEffect( SGameMessage * pGameMsg ); virtual void DelStateEffect( SGameMessage * pGameMsg ); virtual void DelStateEffect( int nDelObjType ); virtual void AddAction( struct SGameMessage* pMsg ); virtual void AddChaosEffect( int nChaosCnt = 1 ); virtual int AddOtherEffect( int nFxID, struct OtherFxData* fxdata ); virtual void EndOtherEffect( int nFXID ); //Particle======================================================================= virtual int AddEnhanceEffect( class SGameAvatarEx* pAvatar, int nWeaponEffectPos, struct EnhanceFX* pEnhanceFx, int nItemClass ); virtual void RemoveEnhanceEffect( int nParticleID ); virtual void SetRenderEnhanceFx( int nParticleID, bool bRender ); //Sound=========================================================================== virtual int StartSound( const char * pSoundName ); virtual int StartSound( class SGameAvatarEx* pCaster, const char * pSoundName, K3DVector pos, bool bUse3D, int nVolume, bool bLoop, bool bSoundOption[SOUND_OP_MAX] ); virtual int StartSound( const char * pSoundName, K3DVector pos ); virtual void StopSound( const char * pSoundName, int nPlayIdx ); virtual bool UseSkill( AR_HANDLE caster, int nSkillId, int nSkill_Lv=1, AR_TIME cast_time=1 ); virtual void OnDamage( AR_HANDLE caster, AR_HANDLE target, struct SGameMessage* pDamage ); virtual void OnSkillDamage( AR_HANDLE caster, AR_HANDLE target, struct SGameMessage* pDamage ); virtual void OnDotDamage( struct SMSG_DAMAGE* pDamage, bool bFinalDmg = false ); virtual void OnDisplayDamage( struct SMSG_DAMAGE* pDamage ); virtual void OnUISync( AR_HANDLE caster, AR_HANDLE target ); virtual void OnDead(); virtual void ReqMove( AR_HANDLE handle, const ArPosition & target, const ArPosition * targetposdata, int count, bool bSpeedSync = true ); virtual void DropItem( AR_HANDLE handle ); //NetWork virtual void SendMsg( SGameObject *pGO, const TS_MESSAGE *msg ); ///< 특정 Obj로 보내기 virtual void SendMsg( const TS_MESSAGE *msg ); ///< 서버로 보내기 virtual void OnReceive( const TS_MESSAGE *msg ) {} ///< 수신 virtual SGameObject * GetGameObject( AR_HANDLE objHandle ); ///< 모든 오브젝트 중에서 virtual SGameObject * GetItemObject( K3DVector & pos, float & fDist, int nItemType, float fLimitDistance = 9999.f ); ///< 아이템 오브젝트 중에서 // sonador #2.1.2.4.3 팻 조작 UI 연동 virtual SGameObject * GetMobObject( K3DVector & pos ); ///< 몹 중에서 virtual SGameObject* GetGameTransportCreatureObject( AR_HANDLE objHandle ); virtual void GetItemObjects_For_PetAutoGather( const K3DVector& center, float fLimitRange, std::vector& vecResult, const K3DVector& dist_pos, std::vector& vecDist, int nMaxCount ) {} virtual int GetItemClass(); ///< 현재 장착하고 있는 아이템 클래스 얻기 virtual int GetMaterial(); ///< 재질 virtual int GetMovingType();///< 이동 타입 virtual bool GetGroundMaterial( int & nTile ); virtual void WarpComplete( struct SGameMessage * pMsg ); virtual void Rq_TakeItem( AR_HANDLE objHandle ); virtual void Rq_PutOnOffItem( AR_HANDLE hTarget, AR_HANDLE hItem, int nPosition ); virtual bool Rq_ChagePKMode( bool bOnOff ); virtual void AddChatMessage( const char * pStr ); virtual void AddNoticeMessageOnly( const char * pStr ); ///< 게임내 공지 채팅만 출력, kappamind. virtual void RqChatting( int nChatType, const char * pName, const char * pStr ); /// 지형 관련 virtual int GetAttrCellLength(); /// 현재 지형 virtual int GetCurrentLocation(); virtual void stopKMove() {} /* * Position Control Methods */ K3DVector* GetPosition(); K3DVector* GetEndPosition(); void SetArcadiaClient( ArcadiaClient * pArcadiaClient ); K3DVector GetArTargetPos() { K3DVector ret = K3DVector( GetArObject().mv.GetTargetPos().x, GetArObject().mv.GetTargetPos().y, 0 ); WORD wTile = 0; GetHeight( GetArObject().mv.GetTargetPos().x, GetArObject().mv.GetTargetPos().y, ret.z, wTile ); return ret; } virtual void SetPosition( const K3DVector &pos ) { m_mTransform.SetPosVector( pos ); } K3DMatrix *GetTransform() { return &m_mTransform; } void SetTransform( const K3DMatrix &mat ) { m_mTransform = mat; K3DMatrix smat; K3DMatrixIdentity( smat ); K3DMatrixScaling( smat, m_fScale, m_fScale, m_fScale ); K3DMatrixMultiply( m_mTransform, smat, m_mTransform ); } void SetScale( float fScale ) { m_fScale = fScale; K3DMatrix mat; K3DMatrixIdentity( mat ); SetTransform( mat ); } ///Je ne comprends pas pourquoi la fonction ci-dessus rend tous les composants autres que l'échelle 0 -_- ; faire du neuf void SetScalePure( float fScale ) { K3DMatrix smat; K3DMatrixIdentity( smat ); K3DMatrixScaling( smat, fScale, fScale, fScale ); K3DMatrixMultiply( m_mTransform, smat, m_mTransform ); } void SetTransformPure( const K3DMatrix &mat ) { m_mTransform = mat; } void SetAttach( K3DMatrix * pParentMat, K3DMatrix * pAttachMat ) { m_pParentMat = pParentMat; m_pAttachMat = pAttachMat; } virtual AR_UNIT GetSize() { return 1.0f; } virtual AR_UNIT GetScale() { return m_fScale; } ArPosition & GetTargetPos() { return m_ArPosition; } ////////////////////////////////////////////////////////////////////////// //Message virtual void SendGameInterfaceMsg( struct SGameMessage * msg ); ///< 인터페이스 메니저로 바로 처리 virtual void SendGameMsg( struct SGameMessage * msg ); ///< 게임을 거쳐서 바로 처리 void AddMsg ( struct SGameMessage * msg ); ///< 순차 처리 ////////////////////////////////////////////////////////////////////////// //Work virtual void FastWork( class SGameWork * work ); ///< 바로 처리 virtual void AddWork ( class SGameWork * work ); ///< 순차 처리 virtual void OnInput( class SGameInput * pInput ) {}; ///< 입력 처리 ////////////////////////////////////////////////////////////////////////// // State Machine virtual void OnChangeState( SObjectState::ID stateid, const SStateInfo &info ) {}; virtual bool IsLoadComplete() { return m_bIsInit; } //virtual bool MoveDetour(K3DVertex& vtMovePos); //virtual bool IsMovingDetour(); //virtual size_t GetDetourSize(); typedef std::vector< X2D::Point > PATH; virtual bool CollisionToLine( const K3DVector& vStart, const K3DVector& vEnd ); virtual void FindDetour( const K3DVertex& vStart, const K3DVertex& vEnd, PATH& vPath, bool bRestraint, bool bChase, bool bIsPlayer ); //virtual bool IsChasing(); //virtual int GetDetourStep(); virtual void SetPKMode( bool bMode ); virtual int GetPlayerCurrentLocation(); virtual bool CheckPlayerMountLocation(); virtual void GetTerrainVisibleDistance( K3DVector & vCameraPos, float & fTerrainVisibleDist ); virtual bool IsPartyRaidMemeber( AR_HANDLE hTarget ); virtual void PlayerInsideWaterExistence( K3DVector & vPlayerPosition, bool & bInWater ); virtual void SetRenderOtherPlayer( int nRender ); virtual bool PlayerInTown( SGameAvatarEx* pPlayer ); protected: _Object m_arObject; int m_nClassID; int m_nXID; SGameObject* m_pMsgHandler; bool m_bIsActivated; bool m_bIsInit; K3DMatrix m_mTransform; K3DMatrix * m_pParentMat; K3DMatrix * m_pAttachMat; float m_fScale; ///< Scale ArPosition m_ArPosition; struct ArcadiaClient * m_pArObject; ///< LocalPlayer() 만 설정 std::queue m_vMsgList; std::vector m_vWorkList; int m_nEffectRef; WORD m_wCurTile; bool m_bInWater; }; float GetViewRadian( K3DVector tpos, K3DVector spos );