forked from derandark/PhatAC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortal.cpp
More file actions
79 lines (60 loc) · 1.38 KB
/
Portal.cpp
File metadata and controls
79 lines (60 loc) · 1.38 KB
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
#include "StdAfx.h"
#include "Portal.h"
#include "World.h"
CPortal::CPortal()
{
m_strName = "Portal";
m_wTypeID = 0x82D;
m_wIcon = 0x106B;
m_dwModel = 0x20001B3;
m_VisFlags = 0xC0C;
m_ItemType = TYPE_PORTAL;
m_Usability = USEABLE_REMOTE;
m_UseDistance = USEDISTANCE_ANYWHERE;
// Arwic, for testing
m_Destination.origin = loc_t(0xC6A90023, 102.4f, 70.1f, 44.0f);
m_Destination.angles = heading_t(0.70710677f, 0, 0, 0.70710677f);
}
CPortal::~CPortal()
{
}
void CPortal::Precache()
{
// Load entity settings (location, and dynamic properties.)
SetThink(&CPortal::ProximityThink);
m_fNextThink = g_pGlobals->Time() + 0.1f;
}
void CPortal::Teleport(CPhysicsObj *pTarget)
{
pTarget->Movement_Teleport(m_Destination.origin, m_Destination.angles);
}
BOOL CPortal::ProximityThink()
{
std::list<CPhysicsObj *> nearbyObjects;
g_pWorld->EnumNearby(this, 1.0f, &nearbyObjects);
for (std::list<CPhysicsObj *>::iterator i = nearbyObjects.begin(); i != nearbyObjects.end(); i++)
{
CPhysicsObj *pOther = *i;
if (pOther->IsPlayer())
{
Teleport(pOther);
}
}
m_fNextThink = g_pGlobals->Time() + 0.1f;
return TRUE;
}
void CPortal::Use(CPhysicsObj *pOther)
{
if (!pOther->IsPlayer())
{
return;
}
if ((Vector(pOther->m_Origin) - Vector(m_Origin)).Length() < 1.0)
{
Teleport(pOther);
}
}
DWORD CPortal::GetDescFlags()
{
return (CPhysicsObj::GetDescFlags() | BF_PORTAL);
}