summaryrefslogtreecommitdiff
path: root/game/server/tf/func_passtime_goalie_zone.cpp
blob: f6f4fbca5fc4aec627e1a960cd3c446c0d29605a (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "func_passtime_goalie_zone.h"
#include "tf_player.h"
#include "passtime_convars.h"

//-----------------------------------------------------------------------------
BEGIN_DATADESC( CFuncPasstimeGoalieZone )
END_DATADESC()

//-----------------------------------------------------------------------------
LINK_ENTITY_TO_CLASS( func_passtime_goalie_zone, CFuncPasstimeGoalieZone )

IMPLEMENT_AUTO_LIST( IFuncPasstimeGoalieZoneAutoList );

//-----------------------------------------------------------------------------
void CFuncPasstimeGoalieZone::Spawn() 
{
	AddSpawnFlags( SF_TRIGGER_ALLOW_CLIENTS );
	BaseClass::Spawn();
	InitTrigger();
}

//-----------------------------------------------------------------------------
bool CFuncPasstimeGoalieZone::BPlayerInAny( CTFPlayer *pPlayer )
{
	auto &all = AutoList();
	for ( int i = 0; i < all.Count(); ++i )
	{
		auto *pZone = (CFuncPasstimeGoalieZone *)all[i];
		if ( pZone->IsTouching( pPlayer ) )
			return true;
	}
	return false;
}

//-----------------------------------------------------------------------------
bool CFuncPasstimeGoalieZone::BPlayerInFriendly( CTFPlayer *pPlayer )
{
	auto &all = AutoList();
	int iPlayerTeam = pPlayer->GetTeamNumber();
	for ( int i = 0; i < all.Count(); ++i )
	{
		auto *pZone = (CFuncPasstimeGoalieZone *)all[i];
		if ( (pZone->GetTeamNumber() == iPlayerTeam) && pZone->IsTouching( pPlayer ) )
			return true;
	}
	return false;
}

//-----------------------------------------------------------------------------
bool CFuncPasstimeGoalieZone::BPlayerInEnemy( CTFPlayer *pPlayer )
{
	auto &all = AutoList();
	int iPlayerTeam = pPlayer->GetTeamNumber();
	for ( int i = 0; i < all.Count(); ++i )
	{
		auto *pZone = (CFuncPasstimeGoalieZone *)all[i];
		if ( (pZone->GetTeamNumber() != iPlayerTeam) && pZone->IsTouching( pPlayer ) )
			return true;
	}
	return false;
}