This repository was archived by the owner on Dec 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclassGroups.cs
More file actions
74 lines (55 loc) · 1.58 KB
/
Copy pathclassGroups.cs
File metadata and controls
74 lines (55 loc) · 1.58 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
package ClassGroupPackage {
function GameConnection::onConnectionAccepted(%this) {
Parent::onConnectionAccepted(%this);
if (%this == nameToID("ServerConnection")) {
ServerConnection.updateClassGroups();
}
}
function GameConnection::onRemove(%this) {
%count = getWordCount(%this.classGroupObjects);
for (%i = 0; %i < %count; %i++) {
%obj = getWord(%this.classGroupObjects, %i);
if (isObject(%obj)) {
%obj.delete();
}
}
Parent::onRemove(%this);
}
};
activatePackage("ClassGroupPackage");
function GameConnection::updateClassGroups(%this) {
cancel(%this.updateClassGroups);
for (%i = %this.getCount() - 1; %i >= 0; %i--) {
%obj = %this.getObject(%i);
if (%obj <= %this.highestSeenID) {
break;
}
%class = %obj.getClassName();
if (!isObject(%this.classGroup[%class])) {
%this.classGroup[%class] = new SimSet();
%this.classGroups = trim(%this.classGroups SPC %this.classGroup[%class]);
}
if (!%this.classGroup[%class].isMember(%obj)) {
%this.classGroup[%class].add(%obj);
}
}
if (%this.getCount()) {
%highest = %this.getObject(%this.getCount() - 1);
if (%highest > %this.highestSeenID) {
%this.highestSeenID = %highest;
}
}
%this.updateClassGroups = %this.schedule(250, updateClassGroups);
}
function GameConnection::getClassCount(%this, %type) {
if (isObject(%this.classGroup[%type])) {
return %this.classGroup[%type].getCount();
}
return 0;
}
function GameConnection::getClassObject(%this, %type, %index) {
if (isObject(%this.classGroup[%type])) {
return %this.classGroup[%type].getObject(%index);
}
return -1;
}