summaryrefslogtreecommitdiff
path: root/hammer/mapsweptplayerhull.h
blob: 5c389dc46301af90f9e342ef852c612ecb2e5e34 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#ifndef MAPSWEPTPLAYERHULL_H
#define MAPSWEPTPLAYERHULL_H
#ifdef _WIN32
#pragma once
#endif

#include "MapClass.h"
#include "MapPointHandle.h"
#include "ToolInterface.h"
#include "MapEntity.h"


class CHelperInfo;
class CRender2D;
class CRender3D;
class CToolSweptPlayerHull;
class CMapPlayerHullHandle;


class CMapSweptPlayerHull : public CMapHelper
{
	friend CToolSweptPlayerHull;

public:

	DECLARE_MAPCLASS(CMapSweptPlayerHull, CMapHelper)

	//
	// Factory for building from a list of string parameters.
	//
	static CMapClass *Create(CHelperInfo *pInfo, CMapEntity *pParent);

	//
	// Construction/destruction:
	//
	CMapSweptPlayerHull();
	~CMapSweptPlayerHull();

	void GetEndPoint(Vector &vecPos, int nPointIndex);
	void UpdateEndPoint(Vector &vecPos, int nPointIndex);

	//
	// CMapClass implementation.
	//
	void CalcBounds(BOOL bFullUpdate = FALSE);

	virtual CMapClass *Copy(bool bUpdateDependencies);
	virtual CMapClass *CopyFrom(CMapClass *pFrom, bool bUpdateDependencies);

	virtual void Render2D(CRender2D *pRender);

	virtual int SerializeRMF(std::fstream &File, BOOL bRMF);
	virtual int SerializeMAP(std::fstream &File, BOOL bRMF);

	// Overridden to chain down to our endpoints, which are not children.
	void SetOrigin(Vector &vecOrigin);

	// Overridden to chain down to our endpoints, which are not children.
	virtual SelectionState_t SetSelectionState(SelectionState_t eSelectionState);

	// Overridden because axis helpers don't take the color of their parent entity.
	virtual void SetRenderColor(unsigned char red, unsigned char green, unsigned char blue);
	virtual void SetRenderColor(color32 rgbColor);

	virtual bool HitTest2D(CMapView2D *pView, const Vector2D &point, HitInfo_t &HitData);
	virtual CBaseTool *GetToolObject(int nHitData, bool bAttachObject );

	virtual bool IsVisualElement(void) { return true; }
	virtual bool IsClutter(void) { return false; }
	
	virtual const char* GetDescription() { return("Swept player hull helper"); }

	virtual void OnAddToWorld(CMapWorld *pWorld);
	virtual void OnParentKeyChanged(const char *key, const char *value);

	virtual void PostloadWorld(CMapWorld *pWorld);

	virtual void Render3D(CRender3D *pRender);

protected:

	SelectionState_t SetSelectionState(SelectionState_t eSelectionState, int nHandle);

	void UpdateParentKey(void);

	// Overriden to transform our endpoints, which are not children.
	virtual void DoTransform(const VMatrix &matrix);
	
	void Initialize(void);

	CMapPlayerHullHandle *m_Point[2];				// The two endpoints of the axis.
};


inline bool IsSweptHullClass(CMapEntity *pEntity)
{
	return (pEntity->GetChildOfType((CMapSweptPlayerHull *)NULL) != NULL);
}


#endif // MAPSWEPTPLAYERHULL_H