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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Engineer's Teleporter
//
// $NoKeywords: $
//=============================================================================//
#ifndef TF_OBJ_TELEPORTER_H
#define TF_OBJ_TELEPORTER_H
#ifdef _WIN32
#pragma once
#endif
#include "tf_obj.h"
#include "GameEventListener.h"
class CTFPlayer;
enum
{
TTYPE_NONE=0,
TTYPE_ENTRANCE,
TTYPE_EXIT,
#ifdef STAGING_ONLY
TTYPE_SPEEDPAD,
#endif
};
#define TELEPORTER_MAX_HEALTH 150
// ------------------------------------------------------------------------ //
// Base Teleporter object
// ------------------------------------------------------------------------ //
class CObjectTeleporter : public CBaseObject, public CGameEventListener
{
DECLARE_CLASS( CObjectTeleporter, CBaseObject );
public:
DECLARE_SERVERCLASS();
CObjectTeleporter();
virtual void Spawn();
virtual void UpdateOnRemove();
virtual void FirstSpawn( void );
virtual void Precache();
virtual bool StartBuilding( CBaseEntity *pBuilder );
virtual void SetStartBuildingModel( void );
virtual void OnGoActive( void );
virtual int DrawDebugTextOverlays(void) ;
virtual bool IsPlacementPosValid( void );
virtual void SetModel( const char *pModel );
virtual void InitializeMapPlacedObject( void );
virtual void FinishedBuilding( void );
void SetState( int state );
virtual void DeterminePlaybackRate( void );
void RecieveTeleportingPlayer( CTFPlayer* pTeleportingPlayer );
void TeleporterThink( void );
void TeleporterTouch( CBaseEntity *pOther );
virtual void StartTouch( CBaseEntity *pOther );
virtual void EndTouch( CBaseEntity *pOther );
virtual void TeleporterSend( CTFPlayer *pPlayer );
virtual void TeleporterReceive( CTFPlayer *pPlayer, float flDelay );
virtual void StartUpgrading( void );
virtual void FinishUpgrading( void );
CObjectTeleporter *GetMatchingTeleporter( void );
CObjectTeleporter *FindMatch( void ); // Find the teleport partner to this object
bool IsReady( void ); // is this teleporter connected and functional? (ie: not sapped, disabled, upgrading, unconnected, etc)
bool IsMatchingTeleporterReady( void );
bool IsSendingPlayer( CTFPlayer *player ); // returns true if we are in the process of teleporting the given player
int GetState( void ) { return m_iState; } // state of the object ( building, charging, ready etc )
void SetTeleportingPlayer( CTFPlayer *pPlayer )
{
m_hTeleportingPlayer = pPlayer;
}
// Wrench hits
virtual bool Command_Repair( CTFPlayer *pActivator, float flRepairMod );
void AddHealth( int nHealthToAdd )
{
SetHealth( MIN( GetMaxHealth(), GetHealth() + nHealthToAdd ) );
}
virtual bool InputWrenchHit( CTFPlayer *pPlayer, CTFWrench *pWrench, Vector hitLoc );
// Upgrading
virtual bool IsUpgrading( void ) const { return ( m_iState == TELEPORTER_STATE_UPGRADING ); }
virtual bool CheckUpgradeOnHit( CTFPlayer *pPlayer );
void CopyUpgradeStateToMatch( CObjectTeleporter *pMatch, bool bFrom );
virtual void Explode( void );
bool PlayerCanBeTeleported( CTFPlayer *pPlayer );
void SetTeleporterType( int iVal ) { m_iTeleportType = iVal; }
int GetTeleporterType( void ) { return m_iTeleportType; }
bool IsEntrance( void ) { return m_iTeleportType == TTYPE_ENTRANCE; }
bool IsExit( void ) { return m_iTeleportType == TTYPE_EXIT; }
#ifdef STAGING_ONLY
// STAGING_ENGY
bool IsSpeedPad( void ) { return m_iTeleportType == TTYPE_SPEEDPAD; }
#endif
virtual void MakeCarriedObject( CTFPlayer *pCarrier );
virtual void SetObjectMode( int iVal );
virtual int GetBaseHealth( void ) { return TELEPORTER_MAX_HEALTH; }
virtual int GetUpgradeMetalRequired();
void SetTeleportWhere( const CUtlStringList& teleportWhereName )
{
// deep copy strings
for ( int i=0; i<teleportWhereName.Count(); ++i )
{
m_teleportWhereName.CopyAndAddToTail( teleportWhereName[i] );
}
}
const CUtlStringList& GetTeleportWhere() { return m_teleportWhereName; }
virtual void InputEnable( inputdata_t &inputdata ) OVERRIDE;
virtual void InputDisable( inputdata_t &inputdata ) OVERRIDE;
#ifdef STAGING_ONLY
// STAGING_ENGY
void ApplySpeedBoost( CTFPlayer *pPlayer );
#endif
CTFPlayer *GetTeleportingPlayer( void ){ return m_hTeleportingPlayer.Get(); }
virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
protected:
CNetworkVar( int, m_iState );
CNetworkVar( float, m_flRechargeTime );
CNetworkVar( float, m_flCurrentRechargeDuration );
CNetworkVar( int, m_iTimesUsed );
CNetworkVar( float, m_flYawToExit );
CNetworkVar( bool, m_bMatchBuilding );
CHandle<CObjectTeleporter> m_hMatchingTeleporter;
float m_flLastStateChangeTime;
float m_flMyNextThink; // replace me
CHandle<CTFPlayer> m_hReservedForPlayer;
float m_flReserveAfterTouchUntil;
CHandle<CTFPlayer> m_hTeleportingPlayer;
float m_flNextEnemyTouchHint;
// Direction Arrow, shows roughly what direction the exit is from the entrance
void ShowDirectionArrow( bool bShow );
bool m_bShowDirectionArrow;
int m_iDirectionBodygroup;
int m_iBlurBodygroup;
int m_iTeleportType;
string_t m_iszMatchingMapPlacedTeleporter;
private:
DECLARE_DATADESC();
void UpdateMaxHealth( int nHealth, bool bForce = false );
void SpawnBread( const CTFPlayer* pTeleportingPlayer );
CUtlStringList m_teleportWhereName;
};
#endif // TF_OBJ_TELEPORTER_H
|