forked from perilouswithadollarsign/cstrike15_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentityconnection.h
138 lines (108 loc) · 5.83 KB
/
entityconnection.h
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
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Defines a connection (output-to-input) between two entities.
//
// The behavior in-game is as follows:
//
// When the given output in the source entity is triggered, the given
// input in the target entity is called after a specified delay, and
// the parameter override (if any) is passed to the input handler. If
// there is no parameter override, the default parameter is passed.
//
// This behavior will occur a specified number of times before the
// connection between the two entities is removed.
//
//=============================================================================//
#ifndef ENTITYCONNECTION_H
#define ENTITYCONNECTION_H
#ifdef _WIN32
#pragma once
#endif
#include "UtlVector.h"
#include "fgdlib/InputOutput.h"
#include "tier1/utlobjectreference.h"
#define EVENT_FIRE_ALWAYS -1
enum SortDirection_t
{
Sort_Ascending = 0,
Sort_Descending,
};
enum
{
CONNECTION_NONE, // if entity list has no outputs
CONNECTION_GOOD, // if all entity outpus are good
CONNECTION_BAD, // if any entity output is bad
};
class CMapEntity;
typedef CUtlReferenceVector<CMapEntity> CMapEntityList;
class CMapDoc;
class CEntityConnection
{
public:
CEntityConnection(void);
CEntityConnection(const CEntityConnection &Other );
~CEntityConnection();
CEntityConnection &operator =(const CEntityConnection &Other);
inline bool CompareConnection(CEntityConnection *pConnection);
inline float GetDelay(void) { return(m_fDelay); }
inline void SetDelay(float fDelay) { m_fDelay = fDelay; }
inline const char *GetInputName(void) { return(m_szInput); }
inline void SetInputName(const char *pszName) { lstrcpyn(m_szInput, pszName, sizeof(m_szInput)); }
inline const char *GetOutputName(void) { return(m_szOutput); }
inline void SetOutputName(const char *pszName) { lstrcpyn(m_szOutput, pszName, sizeof(m_szOutput)); }
inline const char *GetTargetName(void) { return(m_szTargetEntity); }
void SetTargetName(const char *pszName);
inline const char *GetSourceName(void) { return(m_szSourceEntity); }
void SetSourceName(const char *pszName);
void LinkSourceEntities();
void LinkTargetEntities();
bool AreAnyTargetEntitiesVisible();
inline CMapEntityList *GetSourceEntityList() { return m_pSourceEntityList; }
inline CMapEntityList *GetTargetEntityList() { return m_pTargetEntityList; }
inline int GetTimesToFire(void) { return(m_nTimesToFire); }
inline void SetTimesToFire(int nTimesToFire) { m_nTimesToFire = nTimesToFire; }
inline const char *GetParam(void) { return(m_szParam); }
inline void SetParam(const char *pszParam) { lstrcpyn(m_szParam, pszParam, sizeof(m_szParam)); }
// Sorting functions
static int CALLBACK CompareDelaysSecondary(CEntityConnection *pConn1, CEntityConnection *pConn2, SortDirection_t eDirection);
static int CALLBACK CompareDelays(CEntityConnection *pConn1, CEntityConnection *pConn2, SortDirection_t eDirection);
static int CALLBACK CompareOutputNames(CEntityConnection *pConn1, CEntityConnection *pConn2, SortDirection_t eDirection);
static int CALLBACK CompareInputNames(CEntityConnection *pConn1, CEntityConnection *pConn2, SortDirection_t eDirection);
static int CALLBACK CompareSourceNames(CEntityConnection *pConn1, CEntityConnection *pConn2, SortDirection_t eDirection);
static int CALLBACK CompareTargetNames(CEntityConnection *pConn1, CEntityConnection *pConn2, SortDirection_t eDirection);
// Validation functions
static bool ValidateOutput(const CMapEntity *pEntity, const char* pszOutput);
static bool ValidateOutput(const CMapEntityList *pEntityList, const char* pszOutput);
static bool ValidateTarget(const CMapEntityList *pEntityList, bool bVisibilityCheck, const char* pszTarget);
static bool ValidateInput( const char *pszTarget, const char *pszInput, bool bVisiblesOnly, CMapDoc *pDoc = NULL );
static int ValidateOutputConnections( CMapEntity *pEntity, bool bVisibilityCheck, bool bIgnoreHiddenTargets=false, bool CheckAllDocuments = false );
static int ValidateInputConnections(CMapEntity *pEntity, bool bVisibilityCheck);
static void FindBadConnections( CMapEntity *pEntity, bool bVisibilityCheck, CUtlVector<CEntityConnection *> &BadConnectionList, bool bIgnoreHiddenTargets=false, bool CheckAllDocuments = false );
static void FixBadConnections(CMapEntity *pEntity, bool bVisibilityCheck);
protected:
char m_szSourceEntity[MAX_ENTITY_NAME_LEN]; // Targetname of the source entity
CMapEntityList *m_pSourceEntityList;
char m_szOutput[MAX_IO_NAME_LEN]; // Name of the output in the source entity.
char m_szTargetEntity[MAX_ENTITY_NAME_LEN]; // Targetname of the target entity.
CMapEntityList *m_pTargetEntityList;
char m_szInput[MAX_IO_NAME_LEN]; // Name of the input to fire in the target entity.
char m_szParam[MAX_IO_NAME_LEN]; // Parameter override, if any.
float m_fDelay; // Delay before firing this outout.
int m_nTimesToFire; // Maximum times to fire this output or EVENT_FIRE_ALWAYS.
};
typedef CUtlVector<CEntityConnection *> CEntityConnectionList;
//-----------------------------------------------------------------------------
// Purpose: Returns true if the given connection is identical to this connection.
// Input : pConnection - Connection to compare.
//-----------------------------------------------------------------------------
bool CEntityConnection::CompareConnection(CEntityConnection *pConnection)
{
// BUGBUG - Why not compare the GetSourceName() values too? Why is this field not relevant?
return((!stricmp(GetOutputName(), pConnection->GetOutputName())) &&
(!stricmp(GetTargetName(), pConnection->GetTargetName())) &&
(!stricmp(GetInputName(), pConnection->GetInputName())) &&
(!stricmp(GetParam(), pConnection->GetParam())) &&
(GetDelay() == pConnection->GetDelay()) &&
(GetTimesToFire() == pConnection->GetTimesToFire()));
}
#endif // ENTITYCONNECTION_H