summaryrefslogtreecommitdiff
path: root/game/server/tf/tf_obj_teleporter.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/tf/tf_obj_teleporter.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/tf/tf_obj_teleporter.h')
-rw-r--r--game/server/tf/tf_obj_teleporter.h183
1 files changed, 183 insertions, 0 deletions
diff --git a/game/server/tf/tf_obj_teleporter.h b/game/server/tf/tf_obj_teleporter.h
new file mode 100644
index 0000000..54e4d89
--- /dev/null
+++ b/game/server/tf/tf_obj_teleporter.h
@@ -0,0 +1,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