249 lines
6.5 KiB
C++
249 lines
6.5 KiB
C++
/**===========================================================*\
|
|
|
|
@file : SGameWeatherService.h
|
|
@brief : rappelz weather service to control weather state
|
|
@date : 2007.03.xx
|
|
@author : sonador
|
|
@history : [2007.05.08] ADD fader flag - sonador
|
|
|
|
\*===========================================================*/
|
|
#pragma once
|
|
|
|
// ================================================================
|
|
// forward decl
|
|
// ================================================================
|
|
class SGame;
|
|
class SCommandSystem;
|
|
class K3DRenderDeviceDX;
|
|
class K3DIndexBuffer;
|
|
class KViewportObject;
|
|
class SGameMilesSoundMgr;
|
|
class SGameWeatherService;
|
|
class SGameSky;
|
|
struct SGameMessage;
|
|
namespace env_fx {
|
|
struct SWeatherAttr;
|
|
class IGameWeatherEmitter;
|
|
class ICollisionStrategy;
|
|
}
|
|
// temporary
|
|
#include "SGameWeather.h"
|
|
|
|
// ================================================================
|
|
/// 추상 날씨 상태
|
|
// ================================================================
|
|
class IGameWeatherState
|
|
{
|
|
public:
|
|
typedef env_fx::SGameWeatherSystem< env_fx::particle_system_t > weather_system_t;
|
|
enum EState
|
|
{
|
|
WS_FINE = 0,
|
|
WS_CLOUDY,
|
|
WS_FOGGY,
|
|
WS_RAINY,
|
|
WS_SNOWY,
|
|
WS_NONE,
|
|
};
|
|
|
|
IGameWeatherState( SGameWeatherService* pService )
|
|
: m_pService( pService ), m_pEmitter( 0 ), m_pAdditiveEmitter( 0 ), m_bIsGarbage( false )
|
|
{
|
|
}
|
|
virtual ~IGameWeatherState()
|
|
{
|
|
SAFE_DELETE( m_pEmitter );
|
|
SAFE_DELETE( m_pAdditiveEmitter );
|
|
}
|
|
|
|
virtual int GetState() const { return WS_NONE; }
|
|
weather_system_t* GetEmitter() const { return m_pEmitter; }
|
|
virtual void Process( DWORD dwTime ) = 0;
|
|
virtual void Render( KViewportObject* pViewport ) = 0;
|
|
virtual void OnEnter() = 0;
|
|
virtual void OnLeave() = 0;
|
|
bool IsGarbage() const { return m_bIsGarbage; }
|
|
|
|
protected:
|
|
SGameWeatherService* m_pService;
|
|
weather_system_t* m_pEmitter;
|
|
weather_system_t* m_pAdditiveEmitter;
|
|
bool m_bIsGarbage;
|
|
};
|
|
|
|
class SGameWeatherService
|
|
{
|
|
public:
|
|
|
|
SGameWeatherService
|
|
( SGame* pGame
|
|
, SCommandSystem* pCommandSystem
|
|
, SGameSky* pSky
|
|
, SGameMilesSoundMgr* pSound
|
|
, float fCapacityFactor = 1.0f );
|
|
~SGameWeatherService();
|
|
|
|
int GetState() const;
|
|
void Init( K3DRenderDeviceDX* pDevice, K3DIndexBuffer* pIndexBuf = NULL );
|
|
void Process( DWORD dwTime );
|
|
void Render( KViewportObject* pViewport );
|
|
void ProcMsgAtStatic( SGameMessage * pMsg );
|
|
|
|
void ChangeState( int nThemeID, float fPrecipitationFactor, float fAmountFactor, bool bFader = true );
|
|
//void ChangeCapacityFactor( float fCapacityFactor );
|
|
void ChangeQuality( float fQualityFactor );
|
|
void SetTheme( env_fx::SWeatherInfo* pInfo );
|
|
bool IsState( IGameWeatherState* pState ) { return ( m_pCurrentState == pState ); }
|
|
void ActivateThunder( bool bActivity );
|
|
void ActivateLightning( bool bActivity );
|
|
void SetPosition( const K3DVector& vCameraPos, const K3DVector& vTargetPos );
|
|
void SetViewMatrix( const K3DMatrix& mView );
|
|
bool IsFading() const { return m_bFader; }
|
|
DWORD GetFadingTime() const;
|
|
float GetPrecipitationFactor() const { return m_fQualityFactor * m_fPrecipitationFactor; }
|
|
void ChangeInOut( bool bInDoor );
|
|
bool IsInDoor() const { return m_bInDoor; }
|
|
void SetActivity( bool bActivity ) { m_bActivity = bActivity; }
|
|
bool IsActive() const { return m_bActivity; }
|
|
#ifdef DISTANCE_VIEW
|
|
env_fx::SWeatherInfo* GetWeatherInfo() const { return m_pInfo; }
|
|
#endif
|
|
|
|
private:
|
|
|
|
IGameWeatherState* _AppendWeatherState( IGameWeatherState::EState nState );
|
|
|
|
typedef std::vector< IGameWeatherState* > WeatherStateVector;
|
|
|
|
// members
|
|
SGame* m_pGame;
|
|
SCommandSystem* m_pCommandSystem;
|
|
SGameSky* m_pSkyCtx;
|
|
SGameMilesSoundMgr* m_pSoundMgr;
|
|
|
|
IGameWeatherState* m_pCurrentState;
|
|
WeatherStateVector m_ctWeathers;
|
|
|
|
DWORD m_dwTime;
|
|
K3DRenderDeviceDX* m_pRenderDevice;
|
|
env_fx::SWeatherInfo* m_pInfo;
|
|
env_fx::ICollisionStrategy* m_pCollisionStrategy;
|
|
|
|
K3DVector m_vCameraPosition;
|
|
K3DVector m_vTargetPosition;
|
|
K3DMatrix m_mView;
|
|
|
|
bool m_bFader;
|
|
bool m_bActivity;
|
|
float m_fQualityFactor;
|
|
float m_fPrecipitationFactor;
|
|
bool m_bInDoor;
|
|
|
|
// friends
|
|
friend class SGameFineState;
|
|
friend class SGameCloudyState;
|
|
friend class SGameFoggyState;
|
|
friend class SGameRainyState;
|
|
friend class SGameSnowyState;
|
|
|
|
// disabled
|
|
SGameWeatherService();
|
|
SGameWeatherService( const SGameWeatherService& rhs );
|
|
SGameWeatherService& operator = ( const SGameWeatherService* rhs );
|
|
};
|
|
|
|
// ================================================================
|
|
/// 구체 날씨 상태
|
|
// ================================================================
|
|
class SGameFineState : public IGameWeatherState
|
|
{
|
|
public:
|
|
|
|
SGameFineState( SGameWeatherService* pService )
|
|
: IGameWeatherState( pService )
|
|
{
|
|
}
|
|
virtual ~SGameFineState() {}
|
|
|
|
virtual int GetState() const { return WS_FINE; }
|
|
virtual void Process( DWORD dwTime ) {}
|
|
virtual void Render( KViewportObject* pViewport ) {}
|
|
virtual void OnEnter();
|
|
virtual void OnLeave();
|
|
};
|
|
|
|
class SGameCloudyState : public IGameWeatherState
|
|
{
|
|
public:
|
|
|
|
SGameCloudyState( SGameWeatherService* pService )
|
|
: IGameWeatherState( pService )
|
|
{
|
|
}
|
|
virtual ~SGameCloudyState() {}
|
|
|
|
virtual int GetState() const { return WS_CLOUDY; }
|
|
virtual void Process( DWORD dwTime ) {}
|
|
virtual void Render( KViewportObject* pViewport ) {}
|
|
virtual void OnEnter();
|
|
virtual void OnLeave();
|
|
};
|
|
|
|
class SGameFoggyState : public IGameWeatherState
|
|
{
|
|
public:
|
|
|
|
SGameFoggyState( SGameWeatherService* pService )
|
|
: IGameWeatherState( pService )
|
|
{
|
|
}
|
|
virtual ~SGameFoggyState() {}
|
|
|
|
virtual int GetState() const { return WS_FOGGY; }
|
|
virtual void Process( DWORD dwTime ) {}
|
|
virtual void Render( KViewportObject* pViewport ) {}
|
|
virtual void OnEnter();
|
|
virtual void OnLeave();
|
|
};
|
|
|
|
class SGameRainyState : public IGameWeatherState
|
|
{
|
|
public:
|
|
|
|
SGameRainyState( SGameWeatherService* pService )
|
|
: IGameWeatherState( pService )
|
|
, mVestige( 0, 0, 0 )
|
|
{
|
|
}
|
|
virtual ~SGameRainyState()
|
|
{
|
|
}
|
|
|
|
virtual int GetState() const { return WS_RAINY; }
|
|
virtual void Process( DWORD dwTime );
|
|
virtual void Render( KViewportObject* pViewport );
|
|
virtual void OnEnter();
|
|
virtual void OnLeave();
|
|
|
|
protected:
|
|
K3DVector mVestige;
|
|
};
|
|
|
|
class SGameSnowyState : public IGameWeatherState
|
|
{
|
|
public:
|
|
|
|
SGameSnowyState( SGameWeatherService* pService )
|
|
: IGameWeatherState( pService )
|
|
{
|
|
}
|
|
virtual ~SGameSnowyState()
|
|
{
|
|
}
|
|
|
|
virtual int GetState() const { return WS_SNOWY; }
|
|
virtual void Process( DWORD dwTime );
|
|
virtual void Render( KViewportObject* pViewport );
|
|
virtual void OnEnter();
|
|
virtual void OnLeave();
|
|
}; |