aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/server/hl2/ai_spotlight.h
blob: c8a2937585c5f234f70f8c54742d985f9d796236 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#ifndef AI_SPOTLIGHT_H
#define AI_SPOTLIGHT_H

#ifdef _WIN32
#pragma once
#endif

#include "ai_component.h"

class CBeam;
class CSprite;
class SmokeTrail;
class CSpotlightEnd;


//-----------------------------------------------------------------------------
// Parameters for how the scanner relates to citizens.
//-----------------------------------------------------------------------------
enum
{
	AI_SPOTLIGHT_NO_DLIGHTS = 0x1,
};


class CAI_Spotlight : public CAI_Component
{
	DECLARE_SIMPLE_DATADESC();
	DECLARE_CLASS_NOBASE( CAI_Spotlight );

public:
	CAI_Spotlight();
	~CAI_Spotlight();

	void Init( CAI_BaseNPC *pOuter, int nFlags, float flConstraintAngle, float flMaxLength );

	// Create, destroy the spotlight
	void SpotlightCreate( int nAttachment, const Vector &vecInitialDir );
	void SpotlightDestroy(void);

	// Controls the spotlight target position + direction
	void SetSpotlightTargetPos( const Vector &vSpotlightTargetPos );
	void SetSpotlightTargetDirection( const Vector &vSpotlightTargetDir );

	// Updates the spotlight. Call every frame!
	void Update(void);

private:
	void Precache(void);
	void CreateSpotlightEntities( void );
	void UpdateSpotlightDirection( void );
	void UpdateSpotlightEndpoint( void );

	// Constrain to cone, returns true if it was constrained
	bool ConstrainToCone( Vector *pDirection );

	// Computes the spotlight endpoint
	void ComputeEndpoint( const Vector &vecStartPoint, Vector *pEndPoint );

private:
	CHandle<CBeam>	m_hSpotlight;
	CHandle<CSpotlightEnd>	m_hSpotlightTarget;

	Vector			m_vSpotlightTargetPos;
	Vector			m_vSpotlightDir;
	float			m_flSpotlightCurLength;
	float			m_flSpotlightMaxLength;
	float			m_flConstraintAngle;
	int				m_nHaloSprite;
	int				m_nSpotlightAttachment;
	int				m_nFlags;
	Quaternion		m_vAngularVelocity;
};


#endif // AI_SPOTLIGHT_H