-
Notifications
You must be signed in to change notification settings - Fork 3
/
debug.js
137 lines (115 loc) · 3.24 KB
/
debug.js
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
const setting = (v = true) => ({ v });
const tex = () => ({
valid: true,
uvs: new Float32Array([0, 0, 1, 1, 128, 128]),
theme: new Float32Array([1, 1, 1]),
});
const arr4 = [0, 0, 0, 0];
const client = {
lastRAF: 0,
spriteBuffer: new Float32Array(65536 * 64),
massWidth: new Float32Array(256),
charTex: new Map(),
playerData: new Map(),
viewbox: { t: 0, b: 0, l: 0, r: 0 },
spectating: true,
ringTex: tex(),
virusTex: tex(),
circleTex: tex(),
rockTex: tex(),
botTex: arr4.map(tex),
expTex: arr4.map(tex),
cytTex: arr4.map(tex),
settings: {
renderFood: setting(),
renderSkin: setting(),
renderName: setting(),
renderMass: setting(2),
},
themes: {
foodAnimation: { v: true },
showBorder: { v: true },
showInactiveTabBorder: { v: true },
autoTheme: { v: false },
},
themeComputed: {
activeColor: new Float32Array(3),
inactiveColor: new Float32Array(3),
foodColor: new Float32Array(3),
ejectColor: new Float32Array(3),
},
flags: new Uint8Array(2),
pids: new Int16Array(2),
cellCts: new Uint16Array(2),
vports: new Float32Array(4),
scores: new Float32Array(2),
map: new Float32Array(2),
timings: {},
};
// const Renderer = require("./build/Debug/gfx-addon.node");
// Renderer.postInit(client);
// setInterval(() => Renderer.render(client, 0, 100), 100);
const Cytos = require("./build/Debug/cytos-addon.node");
// Cytos.onBuffer((buf) => {
// Renderer.parse(client, buf.buffer);
// });
Cytos.onInfo(({ event, id, pid0, pid1 }) => {
if (event === "join") {
if (id === "bot") {
client.playerData.set(pid0, { isBot: true, pid: pid0 });
} else if (id === "player") {
pid0 &&
client.playerData.set(pid0, {
pid: pid0,
skinTex: tex(),
nameTex: tex(),
});
pid1 &&
client.playerData.set(pid1, {
pid: pid1,
skinTex: tex(),
nameTex: tex(),
});
}
}
});
Cytos.setGameMode("omega");
setInterval(() => {
const timings = Cytos.getTimings();
console.log(timings);
}, 1000);
setTimeout(() => {
Cytos.setInput({
spectate: false,
activeTab: 0,
data: [
{
line: false,
spawn: true,
macro: false,
splits: 0,
ejects: 0,
mouseX: 0,
mouseY: 0,
},
{
line: false,
spawn: false,
macro: false,
splits: 0,
ejects: 0,
mouseX: 0,
mouseY: 0,
},
],
});
}, 1000);
// Test save & restore
setTimeout(() => {
const output = Cytos.save();
console.log(output);
setTimeout(() => {
const restored = Cytos.restore(output.mode, output.buffer);
console.log(restored);
}, 1000);
}, 2000);