@rpgjs/client 3.0.0-beta.7 → 3.0.0-rc
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/lib/Components/ColorComponent.d.ts +8 -0
- package/lib/Components/ColorComponent.js +20 -0
- package/lib/Components/ColorComponent.js.map +1 -0
- package/lib/Components/Component.d.ts +101 -0
- package/lib/Components/Component.js +228 -0
- package/lib/Components/Component.js.map +1 -0
- package/lib/Components/ImageComponent.d.ts +8 -0
- package/lib/Components/ImageComponent.js +18 -0
- package/lib/Components/ImageComponent.js.map +1 -0
- package/lib/Components/TextComponent.d.ts +5 -0
- package/lib/Components/TextComponent.js +12 -0
- package/lib/Components/TextComponent.js.map +1 -0
- package/lib/Components/TileComponent.d.ts +8 -0
- package/lib/Components/TileComponent.js +32 -0
- package/lib/Components/TileComponent.js.map +1 -0
- package/lib/Effects/Animation.d.ts +2 -2
- package/lib/Effects/Animation.js +9 -6
- package/lib/Effects/Animation.js.map +1 -1
- package/lib/Effects/Spinner.d.ts +6 -0
- package/lib/Effects/Spinner.js +21 -0
- package/lib/Effects/Spinner.js.map +1 -0
- package/lib/Effects/TransitionScene.d.ts +16 -0
- package/lib/Effects/TransitionScene.js +50 -0
- package/lib/Effects/TransitionScene.js.map +1 -1
- package/lib/GameEngine.d.ts +23 -1
- package/lib/GameEngine.js +98 -31
- package/lib/GameEngine.js.map +1 -1
- package/lib/KeyboardControls.js +5 -6
- package/lib/KeyboardControls.js.map +1 -1
- package/lib/Renderer.d.ts +11 -0
- package/lib/Renderer.js +99 -19
- package/lib/Renderer.js.map +1 -1
- package/lib/Resources.js +2 -2
- package/lib/Resources.js.map +1 -1
- package/lib/RpgClient.d.ts +9 -9
- package/lib/RpgClientEngine.d.ts +12 -3
- package/lib/RpgClientEngine.js +135 -24
- package/lib/RpgClientEngine.js.map +1 -1
- package/lib/RpgGui.js +3 -3
- package/lib/RpgGui.js.map +1 -1
- package/lib/Scene/Map.d.ts +8 -6
- package/lib/Scene/Map.js +73 -77
- package/lib/Scene/Map.js.map +1 -1
- package/lib/Scene/Scene.d.ts +9 -7
- package/lib/Scene/Scene.js +9 -3
- package/lib/Scene/Scene.js.map +1 -1
- package/lib/Sound/RpgSound.d.ts +4 -0
- package/lib/Sound/RpgSound.js +25 -2
- package/lib/Sound/RpgSound.js.map +1 -1
- package/lib/Sound/Sounds.js +1 -1
- package/lib/Sound/Sounds.js.map +1 -1
- package/lib/Sprite/Character.d.ts +5 -74
- package/lib/Sprite/Character.js +22 -137
- package/lib/Sprite/Character.js.map +1 -1
- package/lib/Sprite/Spritesheets.js +1 -1
- package/lib/Sprite/Spritesheets.js.map +1 -1
- package/lib/Tilemap/CommonLayer.d.ts +8 -0
- package/lib/Tilemap/CommonLayer.js +20 -0
- package/lib/Tilemap/CommonLayer.js.map +1 -0
- package/lib/Tilemap/ImageLayer.d.ts +3 -2
- package/lib/Tilemap/ImageLayer.js +11 -7
- package/lib/Tilemap/ImageLayer.js.map +1 -1
- package/lib/Tilemap/Tile.d.ts +6 -7
- package/lib/Tilemap/Tile.js +29 -32
- package/lib/Tilemap/Tile.js.map +1 -1
- package/lib/Tilemap/TileLayer.d.ts +9 -5
- package/lib/Tilemap/TileLayer.js +29 -31
- package/lib/Tilemap/TileLayer.js.map +1 -1
- package/lib/Tilemap/TileSet.d.ts +4 -15
- package/lib/Tilemap/TileSet.js +11 -18
- package/lib/Tilemap/TileSet.js.map +1 -1
- package/lib/Tilemap/index.d.ts +16 -9
- package/lib/Tilemap/index.js +49 -29
- package/lib/Tilemap/index.js.map +1 -1
- package/lib/clientEntryPoint.d.ts +1 -0
- package/lib/clientEntryPoint.js +1 -1
- package/lib/clientEntryPoint.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/package.json +7 -6
package/lib/Sprite/Character.js
CHANGED
|
@@ -6,103 +6,19 @@ const Animation_1 = require("../Effects/Animation");
|
|
|
6
6
|
const AnimationCharacter_1 = require("../Effects/AnimationCharacter");
|
|
7
7
|
const { capitalize } = common_1.Utils;
|
|
8
8
|
class Character extends PIXI.Sprite {
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(component, graphic) {
|
|
10
10
|
super();
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
11
|
+
this.component = component;
|
|
12
|
+
this.graphic = graphic;
|
|
13
|
+
this.playStandardAnimation = true;
|
|
14
|
+
this.objSaved = {};
|
|
15
|
+
this.data = {};
|
|
13
16
|
/** @internal */
|
|
14
17
|
this.h = 1;
|
|
15
18
|
/** @internal */
|
|
16
19
|
this.w = 1;
|
|
17
|
-
this.
|
|
18
|
-
this.graphic
|
|
19
|
-
this._x = 0;
|
|
20
|
-
this._y = 0;
|
|
21
|
-
this.z = 0;
|
|
22
|
-
this.fixed = false;
|
|
23
|
-
this.playStandardAnimation = true;
|
|
24
|
-
this.objSaved = {};
|
|
25
|
-
this.teleported = 0;
|
|
26
|
-
this.map = '';
|
|
27
|
-
this.x = data.position.x;
|
|
28
|
-
this.y = data.position.y;
|
|
29
|
-
this.fixed = data.fixed;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* the direction of the sprite
|
|
33
|
-
*
|
|
34
|
-
* @prop {Direction} dir
|
|
35
|
-
* @readonly
|
|
36
|
-
* @memberof RpgSprite
|
|
37
|
-
* */
|
|
38
|
-
get dir() {
|
|
39
|
-
return this.direction;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* To know if the sprite is a player
|
|
43
|
-
*
|
|
44
|
-
* @prop {boolean} isPlayer
|
|
45
|
-
* @readonly
|
|
46
|
-
* @memberof RpgSprite
|
|
47
|
-
* */
|
|
48
|
-
get isPlayer() {
|
|
49
|
-
return this.data.type == 'player';
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* To know if the sprite is an event
|
|
53
|
-
*
|
|
54
|
-
* @prop {boolean} isEvent
|
|
55
|
-
* @readonly
|
|
56
|
-
* @memberof RpgSprite
|
|
57
|
-
* */
|
|
58
|
-
get isEvent() {
|
|
59
|
-
return this.data.type == 'event';
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* To know if the sprite is the sprite controlled by the player
|
|
63
|
-
*
|
|
64
|
-
* @prop {boolean} isCurrentPlayer
|
|
65
|
-
* @readonly
|
|
66
|
-
* @memberof RpgSprite
|
|
67
|
-
* */
|
|
68
|
-
get isCurrentPlayer() {
|
|
69
|
-
return this.data.playerId === this.scene.game.playerId;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves the logic of the sprite
|
|
73
|
-
*
|
|
74
|
-
* @prop {RpgSpriteLogic} logic
|
|
75
|
-
* @readonly
|
|
76
|
-
* @since 3.0.0-beta.4
|
|
77
|
-
* @memberof RpgSprite
|
|
78
|
-
* */
|
|
79
|
-
get logic() {
|
|
80
|
-
return this.scene.game.world.getObject(this.data.playerId);
|
|
81
|
-
}
|
|
82
|
-
get guiDisplay() {
|
|
83
|
-
return this.logic.guiDisplay;
|
|
84
|
-
}
|
|
85
|
-
set guiDisplay(val) {
|
|
86
|
-
this.logic.guiDisplay = val;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Recover the position according to the graphic
|
|
90
|
-
* Normally, the position is that of the hitbox but, we retrieve the top left corner of the graphic
|
|
91
|
-
*
|
|
92
|
-
* You can also pass the `middle` value as first parameter to retrieve the positions from the middle of the sprite
|
|
93
|
-
*
|
|
94
|
-
* @title Get Positions of Graphic
|
|
95
|
-
* @method sprite.getPositionsOfGraphic(align)
|
|
96
|
-
* @param {string} [align] middle
|
|
97
|
-
* @returns { x: number, y: number }
|
|
98
|
-
* @memberof RpgSprite
|
|
99
|
-
*/
|
|
100
|
-
getPositionsOfGraphic(align) {
|
|
101
|
-
const isMiddle = align == 'middle';
|
|
102
|
-
return {
|
|
103
|
-
x: this.x - this.w * this.anchor.x + (isMiddle ? this.w / 2 : 0),
|
|
104
|
-
y: this.y - this.h * this.anchor.y + (isMiddle ? this.h / 2 : 0)
|
|
105
|
-
};
|
|
20
|
+
this.data = component.logic;
|
|
21
|
+
this.setGraphic(graphic);
|
|
106
22
|
}
|
|
107
23
|
/** @internal */
|
|
108
24
|
showAnimation(graphic, animationName) {
|
|
@@ -113,7 +29,14 @@ class Character extends PIXI.Sprite {
|
|
|
113
29
|
this.setAnimationAnchor();
|
|
114
30
|
};
|
|
115
31
|
const memoryGraphic = this.graphic;
|
|
116
|
-
|
|
32
|
+
let graphicId = '';
|
|
33
|
+
if (common_1.Utils.isArray(graphic)) {
|
|
34
|
+
graphicId = graphic.find(id => id == this.graphic);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
graphicId = graphic;
|
|
38
|
+
}
|
|
39
|
+
refreshAnimation(graphicId);
|
|
117
40
|
this.animation.onFinish = () => {
|
|
118
41
|
this.playStandardAnimation = true;
|
|
119
42
|
refreshAnimation(memoryGraphic);
|
|
@@ -151,45 +74,12 @@ class Character extends PIXI.Sprite {
|
|
|
151
74
|
};
|
|
152
75
|
}
|
|
153
76
|
/** @internal */
|
|
154
|
-
update(obj) {
|
|
155
|
-
const { graphic,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
77
|
+
update(obj, options = {}) {
|
|
78
|
+
const { graphic, direction } = obj;
|
|
79
|
+
const { moving } = options;
|
|
80
|
+
this.data = obj;
|
|
159
81
|
if (this.anim)
|
|
160
82
|
this.anim.update();
|
|
161
|
-
let moving = false;
|
|
162
|
-
if (!this.fixed) {
|
|
163
|
-
this.z = Math.floor(obj.position.z);
|
|
164
|
-
this._x = Math.floor(obj.position.x);
|
|
165
|
-
this._y = Math.floor(obj.position.y) - this.z;
|
|
166
|
-
if (teleported != this.teleported || map != this.map) {
|
|
167
|
-
this.x = this._x;
|
|
168
|
-
this.y = this._y;
|
|
169
|
-
this.teleported = teleported;
|
|
170
|
-
this.map = map;
|
|
171
|
-
}
|
|
172
|
-
this.parent.parent.zIndex = this._y;
|
|
173
|
-
obj.posX = obj.position.x;
|
|
174
|
-
obj.posY = obj.position.y;
|
|
175
|
-
this.direction = obj.direction;
|
|
176
|
-
if (this._x > this.x) {
|
|
177
|
-
this.x += Math.min(speed, this._x - this.x);
|
|
178
|
-
moving = true;
|
|
179
|
-
}
|
|
180
|
-
if (this._x < this.x) {
|
|
181
|
-
this.x -= Math.min(speed, this.x - this._x);
|
|
182
|
-
moving = true;
|
|
183
|
-
}
|
|
184
|
-
if (this._y > this.y) {
|
|
185
|
-
this.y += Math.min(speed, this._y - this.y);
|
|
186
|
-
moving = true;
|
|
187
|
-
}
|
|
188
|
-
if (this._y < this.y) {
|
|
189
|
-
this.y -= Math.min(speed, this.y - this._y);
|
|
190
|
-
moving = true;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
83
|
if (this.animation)
|
|
194
84
|
this.animation.update();
|
|
195
85
|
if (this.playStandardAnimation) {
|
|
@@ -201,7 +91,6 @@ class Character extends PIXI.Sprite {
|
|
|
201
91
|
this.playAnimation(AnimationCharacter_1.Animation.Stand);
|
|
202
92
|
}
|
|
203
93
|
}
|
|
204
|
-
this.onUpdate(obj);
|
|
205
94
|
this.objSaved = obj;
|
|
206
95
|
return {
|
|
207
96
|
moving,
|
|
@@ -217,14 +106,10 @@ class Character extends PIXI.Sprite {
|
|
|
217
106
|
this.spritesheet[hook](this);
|
|
218
107
|
}
|
|
219
108
|
else if (this.animation.has(name)) {
|
|
220
|
-
this.animation.play(name, [this.
|
|
109
|
+
this.animation.play(name, [this.data.direction]);
|
|
221
110
|
}
|
|
222
111
|
}
|
|
223
|
-
// Hooks
|
|
224
|
-
onInit() { }
|
|
225
|
-
onUpdate(obj) { }
|
|
226
|
-
onMove() { }
|
|
227
|
-
onChanges(data, old) { }
|
|
228
112
|
}
|
|
229
113
|
exports.default = Character;
|
|
114
|
+
Character.id = 'graphic';
|
|
230
115
|
//# sourceMappingURL=Character.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Character.js","sourceRoot":"","sources":["../../src/Sprite/Character.ts"],"names":[],"mappings":";;AAAA,0CAAwF;AACxF,iDAA6C;AAC7C,oDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"Character.js","sourceRoot":"","sources":["../../src/Sprite/Character.ts"],"names":[],"mappings":";;AAAA,0CAAwF;AACxF,iDAA6C;AAC7C,oDAAgD;AAChD,sEAA0E;AAG1E,MAAM,EAAE,UAAU,EAAE,GAAG,cAAK,CAAA;AAE5B,MAAqB,SAAU,SAAQ,IAAI,CAAC,MAAM;IAiB9C,YAAoB,SAAuB,EAAU,OAAe;QAChE,KAAK,EAAE,CAAA;QADS,cAAS,GAAT,SAAS,CAAc;QAAU,YAAO,GAAP,OAAO,CAAQ;QAb5D,0BAAqB,GAAY,IAAI,CAAA;QAErC,aAAQ,GAAW,EAAE,CAAA;QACrB,SAAI,GAAQ,EAAE,CAAA;QAErB,gBAAgB;QAChB,MAAC,GAAW,CAAC,CAAA;QACb,gBAAgB;QAChB,MAAC,GAAW,CAAC,CAAA;QAOV,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;IAED,gBAAgB;IAChB,aAAa,CAAC,OAA0B,EAAE,aAAqB;QAC3D,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;YACzC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC,OAAO,CAAC,CAAA;YACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC7B,IAAI,CAAC,kBAAkB,EAAE,CAAA;QAC7B,CAAC,CAAA;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAA;QAClC,IAAI,SAAS,GAAW,EAAE,CAAA;QAE1B,IAAI,cAAK,CAAC,OAAO,CAAC,O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CAAA;QAEnB,OAAO;YACH,MAAM;YACN,QAAQ,EAAE,IAAI;SACjB,CAAA;IACL,CAAC;IAED,gBAAgB;IAChB,aAAa,CAAC,IAAY;QACtB,MAAM,IAAI,GAAG,cAAc,UAAU,CAAC,IAAI,CAAC,EAAE,CAAA;QAC7C,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAM;QAC7B,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;YACxB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;SAC/B;aACI,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;SACnD;IACL,CAAC;;AAvHL,4BAyHC;AAxHmB,YAAE,GAAW,SAAS,CAAA"}
|
|
@@ -4,7 +4,7 @@ exports._initSpritesheet = exports.spritesheets = void 0;
|
|
|
4
4
|
const Resources_1 = require("../Resources");
|
|
5
5
|
exports.spritesheets = new Map();
|
|
6
6
|
function _initSpritesheet(_spritesheets, engine) {
|
|
7
|
-
return Resources_1._initResource(exports.spritesheets, _spritesheets, 'image', engine);
|
|
7
|
+
return (0, Resources_1._initResource)(exports.spritesheets, _spritesheets, 'image', engine);
|
|
8
8
|
}
|
|
9
9
|
exports._initSpritesheet = _initSpritesheet;
|
|
10
10
|
//# sourceMappingURL=Spritesheets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spritesheets.js","sourceRoot":"","sources":["../../src/Sprite/Spritesheets.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAE/B,QAAA,YAAY,GAAqB,IAAI,GAAG,EAAE,CAAA;AAEvD,SAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM;IAClD,OAAO,yBAAa,
|
|
1
|
+
{"version":3,"file":"Spritesheets.js","sourceRoot":"","sources":["../../src/Sprite/Spritesheets.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAE/B,QAAA,YAAY,GAAqB,IAAI,GAAG,EAAE,CAAA;AAEvD,SAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM;IAClD,OAAO,IAAA,yBAAa,EAAC,oBAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AACtE,CAAC;AAFD,4CAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonLayer = void 0;
|
|
4
|
+
class CommonLayer extends PIXI.Container {
|
|
5
|
+
constructor(layer, map) {
|
|
6
|
+
super();
|
|
7
|
+
this.layer = layer;
|
|
8
|
+
this.map = map;
|
|
9
|
+
this.applyProperties();
|
|
10
|
+
}
|
|
11
|
+
applyProperties() {
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
|
+
this.alpha = (_a = this.layer.opacity) !== null && _a !== void 0 ? _a : 1;
|
|
14
|
+
this.visible = (_b = this.layer.visible) !== null && _b !== void 0 ? _b : true;
|
|
15
|
+
this.x = (_c = this.layer.offsetx) !== null && _c !== void 0 ? _c : 0;
|
|
16
|
+
this.y = (_d = this.layer.offsety) !== null && _d !== void 0 ? _d : 0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.CommonLayer = CommonLayer;
|
|
20
|
+
//# sourceMappingURL=CommonLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommonLayer.js","sourceRoot":"","sources":["../../src/Tilemap/CommonLayer.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAY,SAAQ,IAAI,CAAC,SAAS;IAC3C,YAAsB,KAAY,EAAY,GAAY;QACtD,KAAK,EAAE,CAAA;QADW,UAAK,GAAL,KAAK,CAAO;QAAY,QAAG,GAAH,GAAG,CAAS;QAEtD,IAAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC;IAEH,eAAe;;QACX,IAAI,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,CAAC,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,IAAI,CAAA;QACzC,IAAI,CAAC,CAAC,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,CAAC,CAAA;QAChC,IAAI,CAAC,CAAC,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,CAAC,CAAA;IACpC,CAAC;CACJ;AAZD,kCAYC"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (layer.image && layer.image.source) {
|
|
9
|
-
this.
|
|
3
|
+
const CommonLayer_1 = require("./CommonLayer");
|
|
4
|
+
class ImageLayer extends CommonLayer_1.CommonLayer {
|
|
5
|
+
applyProperties() {
|
|
6
|
+
super.applyProperties();
|
|
7
|
+
const engine = this.map['renderer']['clientEngine'];
|
|
8
|
+
if (this.layer.image && this.layer.image.source && engine) {
|
|
9
|
+
const { width, height, source } = this.layer.image;
|
|
10
|
+
const data = this.map.getData();
|
|
11
|
+
const texture = PIXI.Texture.from(engine.getResourceUrl(source));
|
|
12
|
+
const tilingSprite = new PIXI.TilingSprite(texture, this.layer.repeatx ? data.width * data.tilewidth : width, this.layer.repeaty ? data.height * data.tileheight : height);
|
|
13
|
+
this.addChild(tilingSprite);
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageLayer.js","sourceRoot":"","sources":["../../src/Tilemap/ImageLayer.ts"],"names":[],"mappings":";;AAAA,MAAqB,UAAW,SAAQ,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"ImageLayer.js","sourceRoot":"","sources":["../../src/Tilemap/ImageLayer.ts"],"names":[],"mappings":";;AAAA,+CAA4C;AAE5C,MAAqB,UAAW,SAAQ,yBAAW;IACjD,eAAe;QACb,KAAK,CAAC,eAAe,EAAE,CAAA;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,CAAA;QACnD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM,EAAE;YACzD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;YAClD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;YAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;YAChE,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,YAAY,CACtC,OAAO,EACP,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAC9D,CAAA;YACD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;SAC5B;IACH,CAAC;CACF;AAhBD,6BAgBC"}
|
package/lib/Tilemap/Tile.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { Texture } from "pixi.js";
|
|
2
2
|
import { RpgRectTileLayer } from "./TileLayer";
|
|
3
|
+
import TileSet from "./TileSet";
|
|
4
|
+
import { Tile as TiledTileClass } from '@rpgjs/tiled';
|
|
3
5
|
export default class Tile extends PIXI.AnimatedSprite {
|
|
4
6
|
private tile;
|
|
5
7
|
private tileSet;
|
|
6
|
-
|
|
7
|
-
private verticalFlip;
|
|
8
|
-
private diagonalFlip;
|
|
9
|
-
static getTextures(tile: any, tileSet: any): Texture[];
|
|
8
|
+
static getTextures(tile: TiledTileClass, tileSet: TileSet): Texture[];
|
|
10
9
|
animations: {
|
|
11
|
-
|
|
10
|
+
tileid: number;
|
|
12
11
|
duration: number;
|
|
13
12
|
}[];
|
|
14
13
|
_x: number;
|
|
15
14
|
_y: number;
|
|
16
|
-
gid: number;
|
|
17
15
|
pointsBufIndex: number;
|
|
18
16
|
properties: any;
|
|
19
|
-
constructor(tile:
|
|
17
|
+
constructor(tile: TiledTileClass, tileSet: TileSet);
|
|
18
|
+
get gid(): number;
|
|
20
19
|
setAnimation(frame: RpgRectTileLayer): void;
|
|
21
20
|
flip(): void;
|
|
22
21
|
}
|
package/lib/Tilemap/Tile.js
CHANGED
|
@@ -1,71 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class Tile extends PIXI.AnimatedSprite {
|
|
4
|
-
constructor(tile, tileSet
|
|
4
|
+
constructor(tile, tileSet) {
|
|
5
5
|
super(Tile.getTextures(tile, tileSet));
|
|
6
6
|
this.tile = tile;
|
|
7
7
|
this.tileSet = tileSet;
|
|
8
|
-
this.horizontalFlip = horizontalFlip;
|
|
9
|
-
this.verticalFlip = verticalFlip;
|
|
10
|
-
this.diagonalFlip = diagonalFlip;
|
|
11
8
|
this.animations = [];
|
|
12
9
|
this._x = 0;
|
|
13
10
|
this._y = 0;
|
|
14
|
-
this.gid = 0;
|
|
15
11
|
this.properties = {};
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.gid = 0;
|
|
19
|
-
this.animations = [];
|
|
12
|
+
this.animations = tile.animations || [];
|
|
13
|
+
this.properties = tile.properties;
|
|
20
14
|
this.textures = Tile.getTextures(tile, tileSet);
|
|
21
15
|
this.texture = this.textures[0];
|
|
22
|
-
Object.assign(this, tile);
|
|
23
16
|
this.flip();
|
|
24
17
|
}
|
|
25
18
|
static getTextures(tile, tileSet) {
|
|
26
19
|
const textures = [];
|
|
27
20
|
if (tile.animations && tile.animations.length) {
|
|
28
21
|
tile.animations.forEach(frame => {
|
|
29
|
-
textures.push(tileSet.textures[frame.
|
|
22
|
+
textures.push(tileSet.textures[frame.tileid].clone());
|
|
30
23
|
});
|
|
31
24
|
}
|
|
32
25
|
else {
|
|
33
|
-
textures.push(tileSet.textures[tile.gid - tileSet.
|
|
26
|
+
textures.push(tileSet.textures[tile.gid - tileSet.firstgid].clone());
|
|
34
27
|
}
|
|
35
28
|
return textures;
|
|
36
29
|
}
|
|
30
|
+
get gid() {
|
|
31
|
+
return this.tile.gid;
|
|
32
|
+
}
|
|
37
33
|
setAnimation(frame) {
|
|
38
34
|
const size = this.animations.length;
|
|
39
35
|
if (size > 1) {
|
|
40
|
-
const offest = (this.animations[1].
|
|
36
|
+
const offest = (this.animations[1].tileid - this.animations[0].tileid) * this.width;
|
|
41
37
|
frame.tileAnimX(offest, size);
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
flip() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
let symmetry;
|
|
42
|
+
let i = 0;
|
|
43
|
+
const add = (symmetrySecond) => {
|
|
44
|
+
i++;
|
|
45
|
+
if (symmetry)
|
|
46
|
+
symmetry = PIXI.groupD8.add(symmetry, symmetrySecond);
|
|
47
|
+
else
|
|
48
|
+
symmetry = symmetrySecond;
|
|
49
|
+
};
|
|
50
|
+
if (this.tile.horizontalFlip) {
|
|
51
|
+
add(PIXI.groupD8.MIRROR_HORIZONTAL);
|
|
48
52
|
}
|
|
49
|
-
if (this.verticalFlip) {
|
|
50
|
-
|
|
51
|
-
this.scale.y = -1;
|
|
53
|
+
if (this.tile.verticalFlip) {
|
|
54
|
+
add(PIXI.groupD8.MIRROR_VERTICAL);
|
|
52
55
|
}
|
|
53
|
-
if (this.diagonalFlip) {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
this.scale.x = 1;
|
|
57
|
-
this.anchor.y = 1;
|
|
58
|
-
this.scale.y = 1;
|
|
59
|
-
this.rotation = PIXI.DEG_TO_RAD * 90;
|
|
56
|
+
if (this.tile.diagonalFlip) {
|
|
57
|
+
if (i % 2 == 0) {
|
|
58
|
+
add(PIXI.groupD8.MAIN_DIAGONAL);
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.scale.x = 1;
|
|
64
|
-
this.anchor.y = 0;
|
|
65
|
-
this.scale.y = 1;
|
|
66
|
-
this.rotation = PIXI.DEG_TO_RAD * -90;
|
|
60
|
+
else {
|
|
61
|
+
add(PIXI.groupD8.REVERSE_DIAGONAL);
|
|
67
62
|
}
|
|
68
63
|
}
|
|
64
|
+
if (symmetry)
|
|
65
|
+
this.texture.rotate = symmetry;
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
exports.default = Tile;
|
package/lib/Tilemap/Tile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../src/Tilemap/Tile.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../src/Tilemap/Tile.ts"],"names":[],"mappings":";;AAKA,MAAqB,IAAK,SAAQ,IAAI,CAAC,cAAc;IAqBjD,YACY,IAAoB,EACpB,OAAgB;QAExB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAH/B,SAAI,GAAJ,IAAI,CAAgB;QACpB,YAAO,GAAP,OAAO,CAAS;QAR5B,eAAU,GAA2C,EAAE,CAAA;QACvD,OAAE,GAAW,CAAC,CAAA;QACd,OAAE,G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CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAA;YACnF,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;SAChC;IACL,CAAC;IAED,IAAI;QACA,IAAI,QAAQ,CAAA;QACZ,IAAI,CAAC,GAAC,CAAC,CAAA;QACP,MAAM,GAAG,GAAG,CAAC,cAAc,EAAE,EAAE;YAC3B,CAAC,EAAE,CAAA;YACH,IAAI,QAAQ;gBAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;;gBAC9D,QAAQ,GAAG,cAAc,CAAA;QAClC,CAAC,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YAC1B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;SACtC;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACxB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;SACpC;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACxB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACZ,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;aAClC;iBACI;gBACD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;aACrC;SACJ;QAED,IAAI,QAAQ;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAA;IAEhD,CAAC;CACJ;AA1ED,uBA0EC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { CompositeRectTileLayer } from 'pixi-tilemap';
|
|
2
|
+
import { Layer, Tile as TileClass } from '@rpgjs/tiled';
|
|
3
|
+
import TileSet from './TileSet';
|
|
4
|
+
import TileMap from '.';
|
|
5
|
+
import { CommonLayer } from './CommonLayer';
|
|
2
6
|
export interface RpgRectTileLayer extends CompositeRectTileLayer {
|
|
3
7
|
children: {
|
|
4
8
|
pointsBuf: number[];
|
|
5
9
|
modificationMarker: number;
|
|
6
10
|
}[];
|
|
7
11
|
}
|
|
8
|
-
export default class TileLayer extends
|
|
9
|
-
private layer;
|
|
12
|
+
export default class TileLayer extends CommonLayer {
|
|
10
13
|
private tileSets;
|
|
11
14
|
private tilemap;
|
|
12
15
|
properties: any;
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
private _tiles;
|
|
17
|
+
tiles: (TileClass | null)[];
|
|
18
|
+
static findTileSet(gid: number, tileSets: TileSet[]): TileSet | undefined;
|
|
19
|
+
constructor(layer: Layer, tileSets: TileSet[], map: TileMap);
|
|
16
20
|
private addFrame;
|
|
17
21
|
}
|
package/lib/Tilemap/TileLayer.js
CHANGED
|
@@ -5,22 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Tile_1 = __importDefault(require("./Tile"));
|
|
7
7
|
const pixi_tilemap_1 = require("pixi-tilemap");
|
|
8
|
+
const CommonLayer_1 = require("./CommonLayer");
|
|
8
9
|
pixi_tilemap_1.pixi_tilemap.Constant.maxTextures = 4;
|
|
9
10
|
pixi_tilemap_1.pixi_tilemap.Constant.use32bitIndex = true;
|
|
10
|
-
class TileLayer extends
|
|
11
|
-
constructor(layer, tileSets) {
|
|
12
|
-
super();
|
|
13
|
-
this.layer = layer;
|
|
11
|
+
class TileLayer extends CommonLayer_1.CommonLayer {
|
|
12
|
+
constructor(layer, tileSets, map) {
|
|
13
|
+
super(layer, map);
|
|
14
14
|
this.tileSets = tileSets;
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
Object.assign(this, layer);
|
|
15
|
+
this.properties = {};
|
|
16
|
+
this._tiles = {};
|
|
18
17
|
}
|
|
19
18
|
static findTileSet(gid, tileSets) {
|
|
20
19
|
let tileset;
|
|
21
20
|
for (let i = tileSets.length - 1; i >= 0; i--) {
|
|
22
21
|
tileset = tileSets[i];
|
|
23
|
-
if (tileset.
|
|
22
|
+
if (tileset.firstgid && tileset.firstgid <= gid) {
|
|
24
23
|
break;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -28,32 +27,31 @@ class TileLayer extends PIXI.Container {
|
|
|
28
27
|
}
|
|
29
28
|
/** @internal */
|
|
30
29
|
createTile(x, y, options = {}) {
|
|
30
|
+
var _a, _b;
|
|
31
31
|
const { real, filter } = options;
|
|
32
|
-
const { width,
|
|
32
|
+
const { width, tilewidth, tileheight } = this.map.getData();
|
|
33
33
|
if (real) {
|
|
34
|
-
x = Math.floor(x /
|
|
35
|
-
y = Math.floor(y /
|
|
34
|
+
x = Math.floor(x / tilewidth);
|
|
35
|
+
y = Math.floor(y / tileheight);
|
|
36
36
|
}
|
|
37
37
|
const i = x + y * width;
|
|
38
|
-
const
|
|
39
|
-
if (!(
|
|
40
|
-
tileLayer.gid &&
|
|
41
|
-
tileLayer.gid !== 0))
|
|
38
|
+
const tiledTile = this.layer.tiles[i];
|
|
39
|
+
if (!tiledTile || (tiledTile && tiledTile.gid == 0))
|
|
42
40
|
return;
|
|
43
|
-
const tileset = TileLayer.findTileSet(
|
|
41
|
+
const tileset = TileLayer.findTileSet(tiledTile.gid, this.tileSets);
|
|
44
42
|
if (!tileset)
|
|
45
43
|
return;
|
|
46
|
-
const tile = new Tile_1.default(
|
|
47
|
-
tile.x = x *
|
|
44
|
+
const tile = new Tile_1.default(tiledTile, tileset);
|
|
45
|
+
tile.x = x * tilewidth;
|
|
48
46
|
tile.y =
|
|
49
|
-
y *
|
|
50
|
-
(
|
|
47
|
+
y * tileheight +
|
|
48
|
+
(tileheight -
|
|
51
49
|
tile.texture.height);
|
|
52
50
|
tile._x = x;
|
|
53
51
|
tile._y = y;
|
|
54
|
-
if (tileset.
|
|
55
|
-
tile.x += tileset.
|
|
56
|
-
tile.y += tileset.
|
|
52
|
+
if (tileset.tileoffset) {
|
|
53
|
+
tile.x += (_a = tileset.tileoffset.x) !== null && _a !== void 0 ? _a : 0;
|
|
54
|
+
tile.y += (_b = tileset.tileoffset.y) !== null && _b !== void 0 ? _b : 0;
|
|
57
55
|
}
|
|
58
56
|
if (filter) {
|
|
59
57
|
const ret = filter(tile);
|
|
@@ -64,10 +62,10 @@ class TileLayer extends PIXI.Container {
|
|
|
64
62
|
}
|
|
65
63
|
/** @internal */
|
|
66
64
|
changeTile(x, y) {
|
|
67
|
-
const {
|
|
68
|
-
x = Math.floor(x /
|
|
69
|
-
y = Math.floor(y /
|
|
70
|
-
const oldTile = this.
|
|
65
|
+
const { tilewidth, tileheight } = this.map.getData();
|
|
66
|
+
x = Math.floor(x / tilewidth);
|
|
67
|
+
y = Math.floor(y / tileheight);
|
|
68
|
+
const oldTile = this._tiles[x + ';' + y];
|
|
71
69
|
const newTile = this.createTile(x, y);
|
|
72
70
|
if (!oldTile && newTile) {
|
|
73
71
|
this.addFrame(newTile, x, y);
|
|
@@ -77,7 +75,7 @@ class TileLayer extends PIXI.Container {
|
|
|
77
75
|
const bufComposite = new pixi_tilemap_1.pixi_tilemap.CompositeRectTileLayer();
|
|
78
76
|
const frame = bufComposite.addFrame(newTile.texture, newTile.x, newTile.y);
|
|
79
77
|
newTile.setAnimation(frame);
|
|
80
|
-
this.
|
|
78
|
+
this._tiles[x + ';' + y] = newTile;
|
|
81
79
|
const pointsBufComposite = bufComposite.children[0].pointsBuf;
|
|
82
80
|
[0, 1, 4, 5, 6, 7].forEach((i) => {
|
|
83
81
|
if (this.pointsBuf)
|
|
@@ -86,7 +84,7 @@ class TileLayer extends PIXI.Container {
|
|
|
86
84
|
this.tilemap.children[0].modificationMarker = 0;
|
|
87
85
|
}
|
|
88
86
|
else {
|
|
89
|
-
delete this.
|
|
87
|
+
delete this._tiles[x + ';' + y];
|
|
90
88
|
if (this.pointsBuf)
|
|
91
89
|
this.pointsBuf.splice(oldTile.pointsBufIndex, pixi_tilemap_1.POINT_STRUCT_SIZE);
|
|
92
90
|
}
|
|
@@ -106,12 +104,12 @@ class TileLayer extends PIXI.Container {
|
|
|
106
104
|
return null;
|
|
107
105
|
tile.pointsBufIndex = pb.length - pixi_tilemap_1.POINT_STRUCT_SIZE;
|
|
108
106
|
tile.setAnimation(frame);
|
|
109
|
-
this.
|
|
107
|
+
this._tiles[x + ';' + y] = tile;
|
|
110
108
|
}
|
|
111
109
|
/** @internal */
|
|
112
110
|
create() {
|
|
113
111
|
this.tilemap = new pixi_tilemap_1.pixi_tilemap.CompositeRectTileLayer();
|
|
114
|
-
const { width, height } = this.
|
|
112
|
+
const { width, height } = this.map.getData();
|
|
115
113
|
for (let y = 0; y < height; y++) {
|
|
116
114
|
for (let x = 0; x < width; x++) {
|
|
117
115
|
const tile = this.createTile(x, y);
|