summaryrefslogtreecommitdiffstats
path: root/game/code/worldsim/hitnrunmanager.h
blob: 3fa4b5c4eabc2a40d902fb9112a5db0c6e832002 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//=============================================================================
// Copyright (C) 2003 Radical Entertainment Ltd.  All rights reserved.
//
// File: hitnrunmanager.h
//
// Description: Hit & Run manager looks after everything to do with the hit & run system
//
// History:     26/03/2003 + Created -- Jesse Cluff
//
//=============================================================================

#ifndef HITNRUNMANAGER_H
#define HITNRUNMANAGER_H

//========================================
// Nested Includes
//========================================
#include <events/eventlistener.h>
#include <constants/breakablesenum.h>
#include <constants/vehicleenum.h>

//========================================
// Forward References
//========================================
class Vehicle;
class CollisionEntityDSG;

//=============================================================================
//
// Synopsis:    Handling events that cause the hit & run value to change and spawning 
//              chase vehicles when value exceeds a given threshold
//
//=============================================================================
class HitnRunManager : public EventListener
{
public:
    static HitnRunManager* GetInstance( void );
    static HitnRunManager* CreateInstance( void );
    static void DestroyInstance( void );

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

    void Update( int elapsedMS ); // spawns chase vehicles if hit & run value is too high.
    void HUDRender( void ); // Renders HUD data.

    float GetHitnRunValue( void ) const; // What is the current Hit & Run value.
    void AdjustHitnRunValue( float delta ); // Adjust the Hit & Run value.
    void SetHitnRunValue( float value );
    void MaxHitnRunValue();  //sets hitnrun meter to maximum value

    void DisableMeterDecay() { mDecayDisabled = true; }
    void EnableMeterDecay() { mDecayDisabled = false ; }

    bool IsHitnRunActive(){ return mChaseOn; }
    bool IsHitnRunDisabled(){ return mHitnRunDisabled; }

    void ResetState();

    void EnableHitnRun() { ResetState(); mHitnRunDisabled = false; }
    void DisableHitnRun() { ResetState(); mHitnRunDisabled = true; }

    void SetNumChaseCars( int num ) { mNumChaseCars = num; }
    void SetDecayRate( float rate ) { mDecayRatePerSecond = rate; }
    float GetDecayRate() {return mDecayRatePerSecond;}
    void SetDecayRateInside( float rate ) { mDecayRateInsidePerSecond = rate; }
    float GetDecayRateInside() {return mDecayRateInsidePerSecond;}

    bool IsWaitingForReset() { return !mVehicleReset; }

    bool HasntBeenHit( void* ptr );
    void RegisterHit( void* ptr );

    void RegisterVehicleImmunity( Vehicle* v );

    float GetWarningThreshold() { return mWarningThreshold; }

    bool BustingPlayer() { return ( mVehicleResetTimer > 0.0f || mFadeTimer > 0.0f ); }

protected:
    //Prevent wasteful constructor creation.
    HitnRunManager( const HitnRunManager& That );
    HitnRunManager& operator=( const HitnRunManager& That );

    static HitnRunManager* smpHitnRunManager;

private:
    HitnRunManager();
    ~HitnRunManager();

    float mCurrHitnRun;
    float mDecayRatePerSecond;
    float mDecayRateWhileSpawning;
    float mDecayRateInsidePerSecond;
    float mVehicleDestroyedDelta;
    int   mVehicleDestroyedCoins;
    float mVehicleHitDelta;
    float mHitBreakableDelta;
    int   mHitBreakableCoins;
    float mHitMoveableDelta;
    int   mHitMoveableCoins;
    float mHitKrustyGlassDelta;
    int   mHitKrustyGlassCoins;
    float mColaPropDestroyedDelta;
    int   mColaPropDestroyedCoins;
    float mKickNPCDelta;
    int   mKickNPCCoins;
    float mPlayerCarHitNPCDelta;
    int   mPlayerCarHitNPCCoins;
    int   mBustedCoins;
    float mSwitchSkinDelta;
    float mChangeVehicleDelta;
    VehicleEnum::VehicleID mPrevVehicleID;
    //Vehicle* mPrevVehicleHit;
    //CollisionEntityDSG* mPrevMoveableHit;
    void* mPrevHits[16];
    int mLeastRecentlyHit;
    bool mChaseOn;
    bool mSpawnOn;
    float mDecayDelayMS;
    float mDecayDelay;
    float mDecayDelayWhileSpawning;
    int mNumChaseCars;
    bool mHitnRunDisabled;
    bool mDecayDisabled;
    float mCopTicketDistance;
    float mCopTicketDistanceOnFoot;
    float mCopTicketSpeedThreshold;
    float mCopTicketTimeThreshold;
    float mTicketTimer;
    float mLastUpdateValue;
    float mLastHitnRunValue;
    bool mVehicleReset;
    float mVehicleResetTimer;
    float mUnresponsiveTime;
    bool mFadeDone;
    float mFadeTimer;

    tUID* mObjectsThatNeverGiveCoins;
    bool DoesObjectGiveCoins( CollisionEntityDSG* );  //const

    Vehicle* mImmunityVehicle;
    float mWarningThreshold;
    bool mAllowThrob;
};

inline HitnRunManager* GetHitnRunManager() { return( HitnRunManager::GetInstance() ); }

#endif //HITNRUNMANAGER_H