summaryrefslogtreecommitdiffstats
path: root/tools/statepropbuilder/inc/stateprop/stateprop.hpp
blob: 4c0c7665fda994bc0c14a6c91140a09905972060 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _STATEPROP_HPP_
#define _STATEPROP_HPP_

#include <radmath/radmath.hpp>

#include <p3d/anim/compositedrawable.hpp>

//=============================================================================
// Forward Class/Struct Declarations
//=============================================================================

class tFrameController;
class tAnimatedObject;
class CStatePropData;
class CStateProp;


//=============================================================================
// Class Declarations
// PropListener
//=============================================================================

class CStatePropListener
{
public:
	virtual void RecieveEvent( int callback , CStateProp* stateProp ) = 0;
};

//=============================================================================
// Definitions
//=============================================================================
#define MAX_LISTENERS 10

const int STATEPROP_CHANGE_STATE_EVENT = -1;

//=============================================================================
// Class Declarations
// CStateProp
//=============================================================================
class CStateProp : public tEntity
{
public:
    
    //Static function to create a new CStateProp instance
    static CStateProp* CreateStateProp( CStatePropData* statePropData , unsigned int state = 0 );

    CStateProp( tAnimatedObject* animatedObject , CStatePropData* statePropData , unsigned int state = 0 );
    ~CStateProp();

    //Per frame update
    void Update( float dt );

    //call before render
    void UpdateFrameControllersForRender();

    unsigned int GetState();
    void SetState( unsigned int state );
    void NextState();
    void PrevState();

	void OnEvent( unsigned int eventID );

    void AddStatePropListener( CStatePropListener* statePropListener );
	void RemoveStatePropListener( CStatePropListener* statePropListener );

    tDrawable* GetDrawable();

private:

    //accessor helpers
    unsigned int GetNumberOfFrameControllers();
    tFrameController* GetFrameControllerByIndex( unsigned int i );
    unsigned int GetNumberOfDrawableElements();
    tCompositeDrawable::DrawableElement* GetDrawableElement( unsigned int i );
    
	//Private members
    CStatePropData* m_StatePropData;
	tAnimatedObject* m_AnimatedObject;
	tFrameController* m_BaseFrameController;    
    unsigned int m_CurrentState;
    
    unsigned int m_NumStatePropListeners;
    CStatePropListener* m_StatePropListener[MAX_LISTENERS];
};

#endif //_STATEPROP_HPP_