teeworlds 2.1.2 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +16 -5
- package/index.ts +5 -5
- package/lib/MsgPacker.js +5 -1
- package/lib/MsgPacker.ts +2 -2
- package/lib/MsgUnpacker.js +2 -2
- package/lib/MsgUnpacker.ts +3 -3
- package/lib/client.js +450 -275
- package/lib/client.ts +459 -183
- package/lib/movement.js +54 -0
- package/lib/movement.ts +63 -0
- package/lib/snapshot.js +7 -5
- package/lib/snapshot.ts +7 -5
- package/package.json +1 -1
package/lib/movement.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
;
|
|
4
|
+
var Movement = /** @class */ (function () {
|
|
5
|
+
function Movement() {
|
|
6
|
+
this.input = { m_Direction: 0, m_Fire: 0, m_Hook: 0, m_Jump: 0, m_NextWeapon: 0, m_PlayerFlags: 1, m_PrevWeapon: 0, m_TargetX: 0, m_TargetY: 0, m_WantedWeapon: 1 };
|
|
7
|
+
}
|
|
8
|
+
Movement.prototype.RunLeft = function () {
|
|
9
|
+
this.input.m_Direction = -1;
|
|
10
|
+
};
|
|
11
|
+
Movement.prototype.RunRight = function () {
|
|
12
|
+
this.input.m_Direction = 1;
|
|
13
|
+
};
|
|
14
|
+
Movement.prototype.RunStop = function () {
|
|
15
|
+
this.input.m_Direction = 0;
|
|
16
|
+
};
|
|
17
|
+
Movement.prototype.Jump = function (state) {
|
|
18
|
+
if (state === void 0) { state = true; }
|
|
19
|
+
this.input.m_Jump = state ? 1 : 0;
|
|
20
|
+
};
|
|
21
|
+
Movement.prototype.Fire = function () {
|
|
22
|
+
this.input.m_Fire = 1;
|
|
23
|
+
};
|
|
24
|
+
Movement.prototype.Hook = function (state) {
|
|
25
|
+
if (state === void 0) { state = true; }
|
|
26
|
+
this.input.m_Hook = state ? 1 : 0;
|
|
27
|
+
};
|
|
28
|
+
Movement.prototype.NextWeapon = function () {
|
|
29
|
+
this.input.m_NextWeapon = 1;
|
|
30
|
+
this.WantedWeapon(0);
|
|
31
|
+
};
|
|
32
|
+
Movement.prototype.PrevWeapon = function () {
|
|
33
|
+
this.input.m_PrevWeapon = 1;
|
|
34
|
+
this.WantedWeapon(0);
|
|
35
|
+
};
|
|
36
|
+
Movement.prototype.WantedWeapon = function (weapon) {
|
|
37
|
+
this.input.m_WantedWeapon = weapon;
|
|
38
|
+
};
|
|
39
|
+
Movement.prototype.SetAim = function (x, y) {
|
|
40
|
+
this.input.m_TargetX = x;
|
|
41
|
+
this.input.m_TargetY = y;
|
|
42
|
+
};
|
|
43
|
+
Movement.prototype.Reset = function () {
|
|
44
|
+
this.input.m_Direction = 0;
|
|
45
|
+
this.input.m_Jump = 0;
|
|
46
|
+
this.input.m_Fire = 0;
|
|
47
|
+
this.input.m_Hook = 0;
|
|
48
|
+
this.input.m_PlayerFlags = 0;
|
|
49
|
+
this.input.m_NextWeapon = 0;
|
|
50
|
+
this.input.m_PrevWeapon = 0;
|
|
51
|
+
};
|
|
52
|
+
return Movement;
|
|
53
|
+
}());
|
|
54
|
+
exports.default = Movement;
|
package/lib/movement.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
interface NetObj_PlayerInput {
|
|
2
|
+
m_Direction: number,
|
|
3
|
+
m_TargetX: number,
|
|
4
|
+
m_TargetY: number,
|
|
5
|
+
m_Jump: number,
|
|
6
|
+
m_Fire: number,
|
|
7
|
+
m_Hook: number,
|
|
8
|
+
m_PlayerFlags: number,
|
|
9
|
+
m_WantedWeapon: number,
|
|
10
|
+
m_NextWeapon: number,
|
|
11
|
+
m_PrevWeapon: number
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
class Movement {
|
|
15
|
+
input: NetObj_PlayerInput;
|
|
16
|
+
constructor() {
|
|
17
|
+
this.input = {m_Direction: 0, m_Fire: 0, m_Hook: 0, m_Jump: 0, m_NextWeapon: 0, m_PlayerFlags: 1, m_PrevWeapon: 0, m_TargetX: 0, m_TargetY: 0, m_WantedWeapon: 1} as NetObj_PlayerInput;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
RunLeft() {
|
|
21
|
+
this.input.m_Direction = -1;
|
|
22
|
+
}
|
|
23
|
+
RunRight() {
|
|
24
|
+
this.input.m_Direction = 1;
|
|
25
|
+
}
|
|
26
|
+
RunStop() {
|
|
27
|
+
this.input.m_Direction = 0;
|
|
28
|
+
}
|
|
29
|
+
Jump(state = true) {
|
|
30
|
+
this.input.m_Jump = state ? 1 : 0;
|
|
31
|
+
}
|
|
32
|
+
Fire() {
|
|
33
|
+
this.input.m_Fire = 1;
|
|
34
|
+
}
|
|
35
|
+
Hook(state = true) {
|
|
36
|
+
this.input.m_Hook = state ? 1 : 0;
|
|
37
|
+
}
|
|
38
|
+
NextWeapon() {
|
|
39
|
+
this.input.m_NextWeapon = 1;
|
|
40
|
+
this.WantedWeapon(0);
|
|
41
|
+
}
|
|
42
|
+
PrevWeapon() {
|
|
43
|
+
this.input.m_PrevWeapon = 1;
|
|
44
|
+
this.WantedWeapon(0);
|
|
45
|
+
}
|
|
46
|
+
WantedWeapon(weapon: number) {
|
|
47
|
+
this.input.m_WantedWeapon = weapon;
|
|
48
|
+
}
|
|
49
|
+
SetAim(x: number, y: number) {
|
|
50
|
+
this.input.m_TargetX = x;
|
|
51
|
+
this.input.m_TargetY = y;
|
|
52
|
+
}
|
|
53
|
+
Reset() {
|
|
54
|
+
this.input.m_Direction = 0;
|
|
55
|
+
this.input.m_Jump = 0;
|
|
56
|
+
this.input.m_Fire = 0;
|
|
57
|
+
this.input.m_Hook = 0;
|
|
58
|
+
this.input.m_PlayerFlags = 0;
|
|
59
|
+
this.input.m_NextWeapon = 0;
|
|
60
|
+
this.input.m_PrevWeapon = 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export default Movement;
|
package/lib/snapshot.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Snapshot = void 0;
|
|
3
|
+
exports.Snapshot = exports.items = exports.itemAppendix = void 0;
|
|
4
4
|
var MsgUnpacker_1 = require("./MsgUnpacker");
|
|
5
5
|
var decoder = new TextDecoder('utf-8');
|
|
6
|
-
|
|
6
|
+
exports.itemAppendix = [
|
|
7
7
|
{ "type_id": 0, "size": 0, "name": "obj_ex" },
|
|
8
8
|
{ "type_id": 1, "size": 10, "name": "obj_player_input" },
|
|
9
9
|
{ "type_id": 2, "size": 6, "name": "obj_projectile" },
|
|
@@ -49,7 +49,7 @@ var items;
|
|
|
49
49
|
items[items["EVENT_SOUND_GLOBAL"] = 18] = "EVENT_SOUND_GLOBAL";
|
|
50
50
|
items[items["EVENT_SOUND_WORLD"] = 19] = "EVENT_SOUND_WORLD";
|
|
51
51
|
items[items["EVENT_DAMAGE_INDICATOR"] = 20] = "EVENT_DAMAGE_INDICATOR";
|
|
52
|
-
})(items || (items = {}));
|
|
52
|
+
})(items = exports.items || (exports.items = {}));
|
|
53
53
|
var Snapshot = /** @class */ (function () {
|
|
54
54
|
function Snapshot() {
|
|
55
55
|
}
|
|
@@ -326,8 +326,8 @@ var Snapshot = /** @class */ (function () {
|
|
|
326
326
|
var id = unpacker.unpackInt();
|
|
327
327
|
var key = (((type_id) << 16) | (id));
|
|
328
328
|
var _size = void 0;
|
|
329
|
-
if (type_id > 0 && type_id < itemAppendix.length) {
|
|
330
|
-
_size = itemAppendix[type_id].size;
|
|
329
|
+
if (type_id > 0 && type_id < exports.itemAppendix.length) {
|
|
330
|
+
_size = exports.itemAppendix[type_id].size;
|
|
331
331
|
}
|
|
332
332
|
else
|
|
333
333
|
_size = unpacker.unpackInt();
|
|
@@ -347,3 +347,5 @@ var Snapshot = /** @class */ (function () {
|
|
|
347
347
|
return Snapshot;
|
|
348
348
|
}());
|
|
349
349
|
exports.Snapshot = Snapshot;
|
|
350
|
+
// module.exports = MsgPacker;
|
|
351
|
+
// export {Snapshot};
|
package/lib/snapshot.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MsgUnpacker } from "./MsgUnpacker";
|
|
2
2
|
var decoder = new TextDecoder('utf-8');
|
|
3
3
|
|
|
4
|
-
const itemAppendix: {"type_id": number, "size": number, "name": string}[] = [
|
|
4
|
+
export const itemAppendix: {"type_id": number, "size": number, "name": string}[] = [
|
|
5
5
|
{"type_id": 0, "size": 0, "name": "obj_ex"},
|
|
6
6
|
{"type_id": 1, "size": 10, "name": "obj_player_input"},
|
|
7
7
|
{"type_id": 2, "size": 6, "name": "obj_projectile"},
|
|
@@ -24,7 +24,8 @@ const itemAppendix: {"type_id": number, "size": number, "name": string}[] = [
|
|
|
24
24
|
{"type_id": 19, "size": 3, "name": "event_sound_world"},
|
|
25
25
|
{"type_id": 20, "size": 3, "name": "event_damage_indicator"}
|
|
26
26
|
]
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
export enum items {
|
|
28
29
|
OBJ_EX,
|
|
29
30
|
OBJ_PLAYER_INPUT,
|
|
30
31
|
OBJ_PROJECTILE,
|
|
@@ -47,9 +48,10 @@ enum items {
|
|
|
47
48
|
EVENT_SOUND_WORLD,
|
|
48
49
|
EVENT_DAMAGE_INDICATOR
|
|
49
50
|
}
|
|
50
|
-
type Item = PlayerInput | PlayerInfo | Projectile | Laser | Pickup | Flag | GameInfo | GameData | CharacterCore | Character | PlayerInfo | ClientInfo | SpectatorInfo | Common | Explosion | Spawn |HammerHit | Death | SoundGlobal | SoundWorld | DamageInd | DdnetCharacter;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
export type Item = PlayerInput | PlayerInfo | Projectile | Laser | Pickup | Flag | GameInfo | GameData | CharacterCore | Character | PlayerInfo | ClientInfo | SpectatorInfo | Common | Explosion | Spawn |HammerHit | Death | SoundGlobal | SoundWorld | DamageInd | DdnetCharacter;
|
|
53
|
+
|
|
54
|
+
export class Snapshot {
|
|
53
55
|
private IntsToStr(pInts: number[]): string {
|
|
54
56
|
var pIntz: number[] = [];
|
|
55
57
|
var pStr = ''
|
|
@@ -352,4 +354,4 @@ class Snapshot {
|
|
|
352
354
|
return items;
|
|
353
355
|
}}
|
|
354
356
|
// module.exports = MsgPacker;
|
|
355
|
-
export {Snapshot};
|
|
357
|
+
// export {Snapshot};
|