summaryrefslogtreecommitdiffstats
path: root/game/code/ai/actionbuttonmanager.h
blob: 88f8a1641a384ed941c5c10c1d5fdbfa2d9e753c (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//=============================================================================
// Copyright (C) 2002 Radical Entertainment Ltd.  All rights reserved.
//
// File:        actionbuttonmanager.h
//
// Description: Blahblahblah
//
// History:     18/07/2002 + Created -- TBJ
//
//=============================================================================

#ifndef ACTIONBUTTONMANAGER_H
#define ACTIONBUTTONMANAGER_H

//========================================
// Nested Includes
//========================================
#include <p3d/p3dtypes.hpp>
#include <radmath/radmath.hpp>
#include <loading/loadingmanager.h>
#include <events/eventlistener.h>

//========================================
// Forward References
//========================================
namespace ActionButton
{
    class ButtonHandler;
    class ActionEventHandler;
};
class Character;
class ActionEventLocator;
class AnimCollisionEntityDSG;
class tCompositeDrawable;
class tEntityStore;
//=============================================================================
//
// Synopsis:    Blahblahblah
//
//=============================================================================

class ActionButtonManager : public LoadingManager::ProcessRequestsCallback, public EventListener
{
public:
    enum { MAX_ACTIONS = 128 };

    ActionButtonManager();
    ~ActionButtonManager();

    static ActionButtonManager* GetInstance( );
    static ActionButtonManager* CreateInstance( );
    static void DestroyInstance();

    void EnterGame( void );
    void Destroy( void );
    
    void Update( float timeins );

    bool AddActionEventLocator( ActionEventLocator* pActionEventLocator, tEntityStore* inStore = 0 );

    ActionButton::ButtonHandler* GetActionByIndex( int i ) const;
    int GetIndexByAction( ActionButton::ButtonHandler* ) const;

    bool AddAction( ActionButton::ButtonHandler* pAction, int& id, tUID section = 0);
    bool RemoveActionByIndex( int id );
    int RemoveAction( ActionButton::ButtonHandler* pAction );
    ActionButton::ButtonHandler* NewActionButtonHandler( const char* typeName, ActionEventLocator* pActionEventLocator );

    bool CreateActionEventTrigger( const char* triggerName, rmt::Vector& pos, float r );
    bool LinkActionToObjectJoint( const char* objectName, const char* jointName, const char* triggerName, const char* typeName, const char* buttonName );
    bool LinkActionToObject( const char* objectName, const char* jointName, const char* triggerName, const char* typeName, const char* buttonName, bool bAttachToJoint );
    
    bool LinkActionToLocator( ActionEventLocator* pActionEventLocator, tEntityStore* inStore = 0 );

    void EnterActionTrigger( Character* pCharacter, int index );
    void ExitActionTrigger( Character* pCharacter, int index );

    bool ResolveActionTrigger( AnimCollisionEntityDSG* pAnimObject, tEntityStore* inStore = 0 );

    AnimCollisionEntityDSG* GetCurrentAnimObjectToResolve( void ) const
    {
        return mpCurrentToResolve;
    }

    // Returns the button handler that owns the given locator
    // Returns NULL if none found
    ActionButton::ActionEventHandler* FindHandler( const ActionEventLocator* locator )const;

    static void AddVehicleSelectInfo( int argc, char** argv );
    static void ClearVehicleSelectInfo( int argc, char** argv );

    virtual void OnProcessRequestsComplete( void* pUserData );

    virtual void HandleEvent( EventEnum id, void* pEventData );

    //HACK HACK HACK
    void LoadingIntoInterior() { mLoadingIntoInterior = true; };


private:
    //Prevent wasteful constructor creation.
    ActionButtonManager( const ActionButtonManager& actionbuttonmanager );
    ActionButtonManager& operator=( const ActionButtonManager& actionbuttonmanager );

    // Singleton.
    //
    static ActionButtonManager* spActionButtonManager;

    struct HandlerData
    {
        HandlerData() : handler( NULL ), sectionName( 0 ) { };
        ActionButton::ButtonHandler* handler;
        tUID sectionName;   //This is for knowing when to release these.  The worldrenderlayer section UID when this is loaded is stored here.
        int id;
    };

    HandlerData mActionButtonList[ MAX_ACTIONS ];
    bool mbActionButtonNeedsUpdate[ MAX_ACTIONS ];

    // Big huge hack here.  But it'll work.
    //
    AnimCollisionEntityDSG* mpCurrentToResolve;

    bool mLoadingIntoInterior : 1;

    int Find(int id) const;
    bool RemoveActionByArrayPos(int i);
};

// A little syntactic sugar for getting at this singleton.
inline ActionButtonManager* GetActionButtonManager() { return( ActionButtonManager::GetInstance() ); }


#endif //ACTIONBUTTONMANAGER_H