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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef TF_PASSTIME_BALL_H
#define TF_PASSTIME_BALL_H
#ifdef _WIN32
#pragma once
#endif
#include "passtime_ballcontroller_playerseek.h"
#include "predictable_entity.h"
#include "util_shared.h"
#include "baseanimating.h"
#include "utllinkedlist.h"
class CSpriteTrail;
class CBallPlayerToucher;
//-----------------------------------------------------------------------------
class CPasstimeBall : public CBaseAnimating
{
public:
DECLARE_CLASS( CPasstimeBall, CBaseAnimating );
DECLARE_NETWORKCLASS();
CPasstimeBall();
~CPasstimeBall();
virtual void Spawn() OVERRIDE;
virtual void Precache() OVERRIDE;
virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) OVERRIDE;
virtual int OnTakeDamage( const CTakeDamageInfo &info ) OVERRIDE;
virtual unsigned int PhysicsSolidMaskForEntity() const OVERRIDE;
virtual void ChangeTeam( int iTeamNum ) OVERRIDE;
virtual bool IsDeflectable() OVERRIDE;
virtual void Deflected( CBaseEntity *pDeflectedBy, Vector& vecDir ) OVERRIDE;
virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
virtual int UpdateTransmitState() OVERRIDE;
CTFPlayer *GetCarrier() const;
CTFPlayer *GetPrevCarrier() const;
CTFPlayer *GetThrower() const;
int GetCollisionCount() const;
int GetCarryDuration() const;
void ResetTrail();
void HideTrail();
void MoveTo( const Vector &pos, const Vector &vel );
void MoveToSpawner( const Vector &pos );
void SetStateOutOfPlay();
void SetStateFree();
void SetStateCarried( CTFPlayer *pCarrier );
bool BOutOfPlay() const;
static CPasstimeBall *Create( Vector position, QAngle angles );
void SetHomingTarget( CTFPlayer *pPlayer );
CTFPlayer *GetHomingTarget() const;
float GetAirtimeSec() const;
float GetAirtimeDistance() const;
void StartLagCompensation( CBasePlayer *player, CUserCmd *cmd );
void FinishLagCompensation( CBasePlayer *player );
private:
friend class CBallPlayerToucher;
void OnTouch( CBaseEntity *pOther );
void DefaultThink();
void TouchPlayer( CTFPlayer *pPlayer );
void BlockReflect( CTFPlayer *pPlayer, const Vector& origin, const Vector& ballvel );
void BlockDamage( CTFPlayer *pPlayer, const Vector& ballvel );
bool BIgnorePlayer( CTFPlayer *pPlayer );
void OnCollision();
void UpdateLagCompensationHistory();
void SetThrower( CTFPlayer *pPlayer );
void OnBecomeNotCarried();
void SetIdleRespawnTime();
void DisableIdleRespawnTime();
bool BShouldPanicRespawn() const;
bool CreateModelCollider();
void CreateSphereCollider();
enum EState
{
STATE_OUT_OF_PLAY,
STATE_FREE,
STATE_CARRIED
};
EState m_eState;
CHandle<CTFPlayer> m_hThrower;
EHANDLE m_hBlocker;
CSpriteTrail *m_pTrail;
bool m_bTrailActive;
bool m_bLeftOwner;
CSoundPatch *m_pHumLoop;
CSoundPatch *m_pBeepLoop;
CBaseEntity *m_pPlayerToucher;
CPasstimeBallControllerPlayerSeek m_playerSeek;
bool m_bTouchedSinceSpawn;
float m_flLastCollisionTime;
float m_flAirtimeDistance;
Vector m_vecPrevOrigin; // note: C_BaseEntity has m_vecOldOrigin in client code only
float m_flLastTeamChangeTime; // for stats
float m_flBeginCarryTime;
float m_flIdleRespawnTime;
struct LagRecord
{
float flSimulationTime;
Vector vecOrigin;
};
CUtlFixedLinkedList<LagRecord> m_lagCompensationHistory;
LagRecord m_lagCompensationRestore;
bool m_bLagCompensationNeedsRestore;
float m_flLagCompensationTeleportDistanceSqr;
CNetworkVar( int, m_iCollisionCount );
CNetworkHandle( CTFPlayer, m_hHomingTarget );
CNetworkHandle( CTFPlayer, m_hCarrier );
CNetworkHandle( CTFPlayer, m_hPrevCarrier );
};
#endif // TF_PASSTIME_BALL_H
|