-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.as
43 lines (37 loc) · 1.11 KB
/
utils.as
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
namespace UtilEnts {
RGBA parseRgba(string s) {
array<string> values = s.Split(" ");
RGBA c(0,0,0,0);
if (values.length() > 0) c.r = atoi( values[0] );
if (values.length() > 1) c.g = atoi( values[1] );
if (values.length() > 2) c.b = atoi( values[2] );
if (values.length() > 3) c.a = atoi( values[3] );
return c;
}
Vector parseVector(string s) {
array<string> values = s.Split(" ");
Vector v(0,0,0);
if (values.length() > 0) v.x = atof( values[0] );
if (values.length() > 1) v.y = atof( values[1] );
if (values.length() > 2) v.z = atof( values[2] );
return v;
}
array<CBaseEntity@> getTargetsByName(CBaseEntity@ pActivator, CBaseEntity@ pCaller, string target) {
array<CBaseEntity@> targets;
if (target == "!activator") {
targets.insertLast(pActivator);
} else if (target == "!caller") {
targets.insertLast(pCaller);
} else {
CBaseEntity@ ent = null;
do {
@ent = g_EntityFuncs.FindEntityByTargetname(ent, target);
if (ent !is null)
{
targets.insertLast(ent);
}
} while (ent !is null);
}
return targets;
}
}