@safe-engine/cocos 1.6.4 → 1.7.1
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/dist/app.d.ts +2 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +36 -26
- package/dist/box2d-wasm/PhysicsComponent.d.ts +2 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsComponent.js +16 -3
- package/dist/box2d-wasm/PhysicsSprite.d.ts +1 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSprite.js +3 -4
- package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -2
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +36 -31
- package/dist/gworld/components/AnimationComponent.d.ts +65 -0
- package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
- package/dist/gworld/components/AnimationComponent.js +141 -0
- package/dist/gworld/components/CollideComponent.d.ts +64 -0
- package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
- package/dist/gworld/components/CollideComponent.js +265 -0
- package/dist/gworld/systems/AnimationSystem.d.ts +6 -0
- package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
- package/dist/gworld/systems/AnimationSystem.js +30 -0
- package/dist/gworld/systems/CollideSystem.d.ts +20 -0
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
- package/dist/gworld/systems/CollideSystem.js +171 -0
- package/dist/helper/html-text-parser.d.ts +30 -0
- package/dist/helper/html-text-parser.d.ts.map +1 -0
- package/dist/helper/html-text-parser.js +354 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollideComponent.d.ts","sourceRoot":"","sources":["../../../src/gworld/components/CollideComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAYtD,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC5C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC3C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;CAC5C;AACD,qBAAa,QAAQ,CAAC,CAAC,GAAG,aAAa,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACpE,YAAY,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAK;IACzC,cAAc,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAA;IAClC,YAAY,MAAA;IACZ,KAAK,EAAE,EAAE,CAAC,IAAI,CAAsB;IACpC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAsB;IAGvC,OAAO;IAKP,IAAI,KAAK;;;MAKR;CACF;AAED,UAAU,gBAAiB,SAAQ,aAAa;IAC9C,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AACD,qBAAa,WAAY,SAAQ,QAAQ,CAAC,gBAAgB,CAAC;IACzD,IAAI,IAAI,IAII,EAAE,CAAC,IAAI,CAFlB;IAED,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAGlB;IAED,MAAM,CAAC,EAAE,KAAA,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ;CA4B7B;AAED,UAAU,mBAAoB,SAAQ,aAAa;IACjD,MAAM,EAAE,MAAM,CAAA;CACf;AACD,qBAAa,cAAe,SAAQ,QAAQ,CAAC,mBAAmB,CAAC;IAC/D,MAAM,CAAC,EAAE,KAAA,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ;CAqB7B;AAED,UAAU,oBAAqB,SAAQ,aAAa;IAClD,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;CACpB;AAED,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,oBAAoB,CAAC;IACjE,IAAI,MAAM,IAAI,IAAI,EAAE,CAInB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAExB;IAED,MAAM,CAAC,EAAE,KAAA,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ;CAqB7B;AAED,oBAAY,aAAa;IACvB,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,IAAI,IAAA;CACL;AASD,qBAAa,QAAQ;IACnB,UAAU,EAAE,QAAQ,CAAA;IACpB,UAAU,EAAE,QAAQ,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,eAAe,EAAE,OAAO,CAAA;IACxB,gBAAgB,EAAE,OAAO,CAAA;gBAEb,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAsBpD,WAAW;IAeX,IAAI;CAyBL"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Contract = exports.CollisionType = exports.PolygonCollider = exports.CircleCollider = exports.BoxCollider = exports.Collider = void 0;
|
|
19
|
+
var math_1 = require("../../helper/math");
|
|
20
|
+
var polyfills_1 = require("../../polyfills");
|
|
21
|
+
var decorator_1 = require("../core/decorator");
|
|
22
|
+
function getNodeToWorldTransformAR(node) {
|
|
23
|
+
var t = node.instance.getNodeToWorldTransform();
|
|
24
|
+
var anchorPointSize = node.instance.getAnchorPointInPoints();
|
|
25
|
+
var transform = cc.affineTransformTranslate(t, anchorPointSize.x, anchorPointSize.y);
|
|
26
|
+
return transform;
|
|
27
|
+
}
|
|
28
|
+
function cloneRect(origin) {
|
|
29
|
+
return cc.rect(origin.x, origin.y, origin.width, origin.height);
|
|
30
|
+
}
|
|
31
|
+
var Collider = /** @class */ (function (_super) {
|
|
32
|
+
__extends(Collider, _super);
|
|
33
|
+
function Collider() {
|
|
34
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
35
|
+
_this._worldPoints = [];
|
|
36
|
+
_this._AABB = cc.rect(0, 0, 0, 0);
|
|
37
|
+
_this._preAabb = cc.rect(0, 0, 0, 0);
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
// update(dt: number, draw?: cc.DrawNode) {}
|
|
41
|
+
Collider.prototype.getAABB = function () {
|
|
42
|
+
var collider = this.getComponent(Collider);
|
|
43
|
+
if (collider)
|
|
44
|
+
return collider._AABB;
|
|
45
|
+
return this._AABB;
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(Collider.prototype, "world", {
|
|
48
|
+
get: function () {
|
|
49
|
+
return {
|
|
50
|
+
points: this._worldPoints,
|
|
51
|
+
preAabb: this._preAabb,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
enumerable: false,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
return Collider;
|
|
58
|
+
}(decorator_1.NoRenderComponentX));
|
|
59
|
+
exports.Collider = Collider;
|
|
60
|
+
var BoxCollider = /** @class */ (function (_super) {
|
|
61
|
+
__extends(BoxCollider, _super);
|
|
62
|
+
function BoxCollider() {
|
|
63
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
64
|
+
}
|
|
65
|
+
Object.defineProperty(BoxCollider.prototype, "size", {
|
|
66
|
+
get: function () {
|
|
67
|
+
return cc.size(this.props.width, this.props.height);
|
|
68
|
+
},
|
|
69
|
+
set: function (s) {
|
|
70
|
+
this.props.width = s.width;
|
|
71
|
+
this.props.height = s.height;
|
|
72
|
+
},
|
|
73
|
+
enumerable: false,
|
|
74
|
+
configurable: true
|
|
75
|
+
});
|
|
76
|
+
BoxCollider.prototype.update = function (dt, draw) {
|
|
77
|
+
if (!this.node) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var collider = this.getComponent(Collider);
|
|
81
|
+
var _a = collider.props.offset || (0, polyfills_1.Vec2)(0, 0), x = _a.x, y = _a.y;
|
|
82
|
+
var hw = this.props.width * 0.5;
|
|
83
|
+
var hh = this.props.height * 0.5;
|
|
84
|
+
var transform = getNodeToWorldTransformAR(this.node);
|
|
85
|
+
var rect = cc.rect(x - hw, y - hh, this.props.width, this.props.height);
|
|
86
|
+
var rectTrs = cc.rectApplyAffineTransform(rect, transform);
|
|
87
|
+
// cc.log(rectTrs);
|
|
88
|
+
collider._worldPoints[0] = (0, polyfills_1.Vec2)(rectTrs.x, rectTrs.y);
|
|
89
|
+
collider._worldPoints[1] = (0, polyfills_1.Vec2)(rectTrs.x, rectTrs.y + rectTrs.height);
|
|
90
|
+
collider._worldPoints[2] = (0, polyfills_1.Vec2)(rectTrs.x + rectTrs.width, rectTrs.y + rectTrs.height);
|
|
91
|
+
collider._worldPoints[3] = (0, polyfills_1.Vec2)(rectTrs.x + rectTrs.width, rectTrs.y);
|
|
92
|
+
var listX = collider._worldPoints.map(function (_a) {
|
|
93
|
+
var x = _a.x;
|
|
94
|
+
return x;
|
|
95
|
+
});
|
|
96
|
+
var listY = collider._worldPoints.map(function (_a) {
|
|
97
|
+
var y = _a.y;
|
|
98
|
+
return y;
|
|
99
|
+
});
|
|
100
|
+
collider._preAabb = cloneRect(collider._AABB);
|
|
101
|
+
collider._AABB.x = (0, math_1.getMin)(listX);
|
|
102
|
+
collider._AABB.y = (0, math_1.getMin)(listY);
|
|
103
|
+
collider._AABB.width = (0, math_1.getMax)(listX) - collider._AABB.x;
|
|
104
|
+
collider._AABB.height = (0, math_1.getMax)(listY) - collider._AABB.y;
|
|
105
|
+
if (draw) {
|
|
106
|
+
draw.drawPoly(collider._worldPoints, null, 3, cc.Color.DEBUG_BORDER_COLOR);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return BoxCollider;
|
|
110
|
+
}(Collider));
|
|
111
|
+
exports.BoxCollider = BoxCollider;
|
|
112
|
+
var CircleCollider = /** @class */ (function (_super) {
|
|
113
|
+
__extends(CircleCollider, _super);
|
|
114
|
+
function CircleCollider() {
|
|
115
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
116
|
+
}
|
|
117
|
+
CircleCollider.prototype.update = function (dt, draw) {
|
|
118
|
+
if (!this.node) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var transform = getNodeToWorldTransformAR(this.node);
|
|
122
|
+
var collider = this.getComponent(Collider);
|
|
123
|
+
collider._worldRadius = this.props.radius * this.node.scaleX;
|
|
124
|
+
collider._worldPosition = cc.pointApplyAffineTransform(collider.props.offset, transform);
|
|
125
|
+
if (draw) {
|
|
126
|
+
draw.drawDot(collider._worldPosition, collider._worldRadius, cc.Color.DEBUG_FILL_COLOR);
|
|
127
|
+
draw.drawCircle(collider._worldPosition, collider._worldRadius, 0, 64, true, 3, cc.Color.DEBUG_BORDER_COLOR);
|
|
128
|
+
}
|
|
129
|
+
collider._preAabb = cloneRect(collider._AABB);
|
|
130
|
+
collider._AABB.x = collider._worldPosition.x - collider._worldRadius;
|
|
131
|
+
collider._AABB.y = collider._worldPosition.y - collider._worldRadius;
|
|
132
|
+
collider._AABB.width = collider._worldRadius * 2;
|
|
133
|
+
collider._AABB.height = collider._AABB.width;
|
|
134
|
+
// draw.drawRect(cc.p(this._AABB.x, this._AABB.y),
|
|
135
|
+
// cc.p(this._worldPosition.x + this._worldRadius, this._worldPosition.y + this._worldRadius),
|
|
136
|
+
// cc.Color.WHITE, 3, cc.Color.DEBUG_BORDER_COLOR);
|
|
137
|
+
};
|
|
138
|
+
return CircleCollider;
|
|
139
|
+
}(Collider));
|
|
140
|
+
exports.CircleCollider = CircleCollider;
|
|
141
|
+
var PolygonCollider = /** @class */ (function (_super) {
|
|
142
|
+
__extends(PolygonCollider, _super);
|
|
143
|
+
function PolygonCollider() {
|
|
144
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
145
|
+
}
|
|
146
|
+
Object.defineProperty(PolygonCollider.prototype, "points", {
|
|
147
|
+
get: function () {
|
|
148
|
+
var _a = this.props.offset, x = _a.x, y = _a.y;
|
|
149
|
+
var pointsList = this.props.points.map(function (p) { return (0, polyfills_1.Vec2)(p.x + x, p.y + y); });
|
|
150
|
+
return pointsList;
|
|
151
|
+
},
|
|
152
|
+
set: function (points) {
|
|
153
|
+
this.props.points = points;
|
|
154
|
+
},
|
|
155
|
+
enumerable: false,
|
|
156
|
+
configurable: true
|
|
157
|
+
});
|
|
158
|
+
PolygonCollider.prototype.update = function (dt, draw) {
|
|
159
|
+
if (!this.node) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var transform = getNodeToWorldTransformAR(this.node);
|
|
163
|
+
var collider = this.getComponent(Collider);
|
|
164
|
+
collider._worldPoints = this.points.map(function (p) { return cc.pointApplyAffineTransform(p, transform); });
|
|
165
|
+
// cc.log(polyPoints);
|
|
166
|
+
if (draw) {
|
|
167
|
+
draw.drawPoly(collider._worldPoints, cc.Color.DEBUG_FILL_COLOR, 3, cc.Color.DEBUG_BORDER_COLOR);
|
|
168
|
+
}
|
|
169
|
+
var listX = collider._worldPoints.map(function (_a) {
|
|
170
|
+
var x = _a.x;
|
|
171
|
+
return x;
|
|
172
|
+
});
|
|
173
|
+
var listY = collider._worldPoints.map(function (_a) {
|
|
174
|
+
var y = _a.y;
|
|
175
|
+
return y;
|
|
176
|
+
});
|
|
177
|
+
collider._preAabb = cloneRect(collider._AABB);
|
|
178
|
+
collider._AABB.x = (0, math_1.getMin)(listX);
|
|
179
|
+
collider._AABB.y = (0, math_1.getMin)(listY);
|
|
180
|
+
collider._AABB.width = (0, math_1.getMax)(listX) - collider._AABB.x;
|
|
181
|
+
collider._AABB.height = (0, math_1.getMax)(listY) - collider._AABB.y;
|
|
182
|
+
// draw.drawRect(cc.p(this._AABB.x, this._AABB.y), cc.p(max(listX), max(listY)),
|
|
183
|
+
// cc.Color.WHITE, 3, cc.Color.DEBUG_BORDER_COLOR);
|
|
184
|
+
};
|
|
185
|
+
return PolygonCollider;
|
|
186
|
+
}(Collider));
|
|
187
|
+
exports.PolygonCollider = PolygonCollider;
|
|
188
|
+
var CollisionType;
|
|
189
|
+
(function (CollisionType) {
|
|
190
|
+
CollisionType[CollisionType["NONE"] = 0] = "NONE";
|
|
191
|
+
CollisionType[CollisionType["ENTER"] = 1] = "ENTER";
|
|
192
|
+
CollisionType[CollisionType["STAY"] = 2] = "STAY";
|
|
193
|
+
CollisionType[CollisionType["EXIT"] = 3] = "EXIT";
|
|
194
|
+
})(CollisionType || (exports.CollisionType = CollisionType = {}));
|
|
195
|
+
function isPolygonCollider(col) {
|
|
196
|
+
return col.getComponent(PolygonCollider) || col.getComponent(BoxCollider);
|
|
197
|
+
}
|
|
198
|
+
function isCircleCollider(col) {
|
|
199
|
+
return col.getComponent(CircleCollider);
|
|
200
|
+
}
|
|
201
|
+
var Contract = /** @class */ (function () {
|
|
202
|
+
function Contract(collider1, collider2) {
|
|
203
|
+
this._collider1 = collider1;
|
|
204
|
+
this._collider2 = collider2;
|
|
205
|
+
var isCollider1Polygon = isPolygonCollider(collider1);
|
|
206
|
+
var isCollider2Polygon = isPolygonCollider(collider2);
|
|
207
|
+
var isCollider1Circle = isCircleCollider(collider1);
|
|
208
|
+
var isCollider2Circle = isCircleCollider(collider2);
|
|
209
|
+
if (isCollider1Polygon && isCollider2Polygon) {
|
|
210
|
+
this._isPolygonPolygon = true;
|
|
211
|
+
}
|
|
212
|
+
else if (isCollider1Circle && isCollider2Circle) {
|
|
213
|
+
this._isCircleCircle = true;
|
|
214
|
+
}
|
|
215
|
+
else if (isCollider1Polygon && isCollider2Circle) {
|
|
216
|
+
this._isPolygonCircle = true;
|
|
217
|
+
}
|
|
218
|
+
else if (isCollider1Circle && isCollider2Polygon) {
|
|
219
|
+
this._isPolygonCircle = true;
|
|
220
|
+
this._collider1 = collider2;
|
|
221
|
+
this._collider2 = collider1;
|
|
222
|
+
}
|
|
223
|
+
// cc.log(this._isPolygonPolygon);
|
|
224
|
+
}
|
|
225
|
+
Contract.prototype.updateState = function () {
|
|
226
|
+
var result = this.test();
|
|
227
|
+
var type = CollisionType.NONE;
|
|
228
|
+
if (result && !this._touching) {
|
|
229
|
+
this._touching = true;
|
|
230
|
+
type = CollisionType.ENTER;
|
|
231
|
+
}
|
|
232
|
+
else if (result && this._touching) {
|
|
233
|
+
type = CollisionType.STAY;
|
|
234
|
+
}
|
|
235
|
+
else if (!result && this._touching) {
|
|
236
|
+
this._touching = false;
|
|
237
|
+
type = CollisionType.EXIT;
|
|
238
|
+
}
|
|
239
|
+
return type;
|
|
240
|
+
};
|
|
241
|
+
Contract.prototype.test = function () {
|
|
242
|
+
// if (!shouldCollider(this._collider1, this._collider2)) {
|
|
243
|
+
// return false;
|
|
244
|
+
// }
|
|
245
|
+
// cc.log(this._collider1.getAABB(), this._collider2.getAABB());
|
|
246
|
+
if (!cc.rectIntersectsRect(this._collider1.getAABB(), this._collider2.getAABB())) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
if (this._isPolygonPolygon) {
|
|
250
|
+
return cc.Intersection.polygonPolygon(this._collider1._worldPoints, this._collider2._worldPoints);
|
|
251
|
+
}
|
|
252
|
+
if (this._isCircleCircle) {
|
|
253
|
+
var p1 = this._collider1;
|
|
254
|
+
var p2 = this._collider2;
|
|
255
|
+
return cc.Intersection.circleCircle(p1._worldPosition, p1._worldRadius, p2._worldPosition, p2._worldRadius);
|
|
256
|
+
}
|
|
257
|
+
if (this._isPolygonCircle) {
|
|
258
|
+
var p2 = this._collider2;
|
|
259
|
+
return cc.Intersection.polygonCircle(this._collider1._worldPoints, p2._worldPosition, p2._worldRadius);
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
};
|
|
263
|
+
return Contract;
|
|
264
|
+
}());
|
|
265
|
+
exports.Contract = Contract;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
export declare class AnimationSystem implements System {
|
|
3
|
+
configure(event_manager: EventManager): void;
|
|
4
|
+
update(entities: EntityManager, events: EventManager, dt: Float): void;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AnimationSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationSystem.d.ts","sourceRoot":"","sources":["../../../src/gworld/systems/AnimationSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAK5E,qBAAa,eAAgB,YAAW,MAAM;IAC5C,SAAS,CAAC,aAAa,EAAE,YAAY;IAQrC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK;CAUhE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnimationSystem = void 0;
|
|
4
|
+
var entityx_ts_1 = require("entityx-ts");
|
|
5
|
+
var AnimationComponent_1 = require("../components/AnimationComponent");
|
|
6
|
+
var NodeComp_1 = require("../components/NodeComp");
|
|
7
|
+
var AnimationSystem = /** @class */ (function () {
|
|
8
|
+
function AnimationSystem() {
|
|
9
|
+
}
|
|
10
|
+
AnimationSystem.prototype.configure = function (event_manager) {
|
|
11
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, AnimationComponent_1.AnimationComp, function (_a) {
|
|
12
|
+
var entity = _a.entity;
|
|
13
|
+
var animation = entity.getComponent(AnimationComponent_1.AnimationComp);
|
|
14
|
+
animation.node = entity.getComponent(NodeComp_1.NodeComp);
|
|
15
|
+
setTimeout(animation.start.bind(animation), 0);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
AnimationSystem.prototype.update = function (entities, events, dt) {
|
|
19
|
+
var animations = entities.entities_with_components(AnimationComponent_1.AnimationComp);
|
|
20
|
+
// cc.log(animations);
|
|
21
|
+
animations.forEach(function (ett) {
|
|
22
|
+
var animation = ett.getComponent(AnimationComponent_1.AnimationComp);
|
|
23
|
+
if (animation.node && animation.node.active) {
|
|
24
|
+
animation.update(dt);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
return AnimationSystem;
|
|
29
|
+
}());
|
|
30
|
+
exports.AnimationSystem = AnimationSystem;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
import { Collider, Contract } from '../components/CollideComponent';
|
|
3
|
+
export declare class CollideSystem implements System {
|
|
4
|
+
listColliders: Collider[];
|
|
5
|
+
_contracts: Contract[];
|
|
6
|
+
removeColliders: any[];
|
|
7
|
+
debugGraphics: cc.DrawNode;
|
|
8
|
+
enabledDebugDraw: boolean;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
colliderMatrix: boolean[][];
|
|
11
|
+
configure(event_manager: EventManager): void;
|
|
12
|
+
private onAddCollider;
|
|
13
|
+
private onRemoveCollider;
|
|
14
|
+
update(entities: EntityManager, events: EventManager, dt: number): void;
|
|
15
|
+
addCollider(collider: Collider): void;
|
|
16
|
+
removeCollider(collider: Collider): void;
|
|
17
|
+
addDebugNode(root: cc.Scene): void;
|
|
18
|
+
toggleDebugDraw(enable?: boolean): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=CollideSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollideSystem.d.ts","sourceRoot":"","sources":["../../../src/gworld/systems/CollideSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAG5E,OAAO,EAA+B,QAAQ,EAAiB,QAAQ,EAAmB,MAAM,gCAAgC,CAAA;AAGhI,qBAAa,aAAc,YAAW,MAAM;IAC1C,aAAa,EAAE,QAAQ,EAAE,CAAK;IAC9B,UAAU,EAAE,QAAQ,EAAE,CAAK;IAC3B,eAAe,QAAK;IACpB,aAAa,EAAE,EAAE,CAAC,QAAQ,CAAA;IAC1B,gBAAgB,UAAQ;IACxB,OAAO,UAAO;IACd,cAAc,cAAW;IAEzB,SAAS,CAAC,aAAa,EAAE,YAAY;IASrC,OAAO,CAAC,aAAa,CAOpB;IAED,OAAO,CAAC,gBAAgB,CAEvB;IAED,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IA2GhE,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAS9B,cAAc,CAAC,QAAQ,EAAE,QAAQ;IAIjC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK;IAK3B,eAAe,CAAC,MAAM,UAAO;CAI9B"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollideSystem = void 0;
|
|
4
|
+
var entityx_ts_1 = require("entityx-ts");
|
|
5
|
+
var utils_1 = require("../../helper/utils");
|
|
6
|
+
var CollideComponent_1 = require("../components/CollideComponent");
|
|
7
|
+
var NodeComp_1 = require("../components/NodeComp");
|
|
8
|
+
var CollideSystem = /** @class */ (function () {
|
|
9
|
+
function CollideSystem() {
|
|
10
|
+
var _this = this;
|
|
11
|
+
this.listColliders = [];
|
|
12
|
+
this._contracts = [];
|
|
13
|
+
this.removeColliders = [];
|
|
14
|
+
this.enabledDebugDraw = false;
|
|
15
|
+
this.enabled = true;
|
|
16
|
+
this.colliderMatrix = [[true]];
|
|
17
|
+
this.onAddCollider = function (_a) {
|
|
18
|
+
var entity = _a.entity, component = _a.component;
|
|
19
|
+
var collider = entity.assign(new CollideComponent_1.Collider(component));
|
|
20
|
+
collider.node = entity.getComponent(NodeComp_1.NodeComp);
|
|
21
|
+
collider.props = component.props;
|
|
22
|
+
// collider.props.enable = true
|
|
23
|
+
component.node = entity.getComponent(NodeComp_1.NodeComp);
|
|
24
|
+
_this.addCollider(collider);
|
|
25
|
+
};
|
|
26
|
+
this.onRemoveCollider = function (_a) {
|
|
27
|
+
var component = _a.component;
|
|
28
|
+
_this.removeColliders.push(component.getComponent(CollideComponent_1.Collider));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
CollideSystem.prototype.configure = function (event_manager) {
|
|
32
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, CollideComponent_1.BoxCollider, this.onAddCollider.bind(this));
|
|
33
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, CollideComponent_1.CircleCollider, this.onAddCollider.bind(this));
|
|
34
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, CollideComponent_1.PolygonCollider, this.onAddCollider.bind(this));
|
|
35
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentRemoved, CollideComponent_1.BoxCollider, this.onRemoveCollider.bind(this));
|
|
36
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentRemoved, CollideComponent_1.CircleCollider, this.onRemoveCollider.bind(this));
|
|
37
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentRemoved, CollideComponent_1.PolygonCollider, this.onRemoveCollider.bind(this));
|
|
38
|
+
};
|
|
39
|
+
CollideSystem.prototype.update = function (entities, events, dt) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
if (!this.enabled) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.listColliders.forEach(function (collider) {
|
|
45
|
+
if (!cc.sys.isObjectValid(collider.node.instance)) {
|
|
46
|
+
_this.removeColliders.push(collider);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// this.removeColliders.forEach(comp => {
|
|
50
|
+
// this.listColliders = this.listColliders.filter(col => !col.isEqual(comp)
|
|
51
|
+
// && cc.sys.isObjectValid(col.node.instance));
|
|
52
|
+
// this._contracts = this._contracts.filter(contract => {
|
|
53
|
+
// const col1 = contract._collider1;
|
|
54
|
+
// const col2 = contract._collider2;
|
|
55
|
+
// if (col1.isEqual(comp) || !cc.sys.isObjectValid(col1.node.instance)) {
|
|
56
|
+
// if (contract._touching) {
|
|
57
|
+
// col2.node.emit('onCollisionExit', col1, col2);
|
|
58
|
+
// }
|
|
59
|
+
// return false;
|
|
60
|
+
// }
|
|
61
|
+
// if (col2.isEqual(comp) || !cc.sys.isObjectValid(col2.node.instance)) {
|
|
62
|
+
// if (contract._touching) {
|
|
63
|
+
// col1.node.emit('onCollisionExit', col2, col1);
|
|
64
|
+
// }
|
|
65
|
+
// return false;
|
|
66
|
+
// }
|
|
67
|
+
// return true;
|
|
68
|
+
// }
|
|
69
|
+
// );
|
|
70
|
+
// });
|
|
71
|
+
this.removeColliders = [];
|
|
72
|
+
var draw;
|
|
73
|
+
var _a = this, enabledDebugDraw = _a.enabledDebugDraw, debugGraphics = _a.debugGraphics;
|
|
74
|
+
if (enabledDebugDraw) {
|
|
75
|
+
draw = debugGraphics;
|
|
76
|
+
draw.clear();
|
|
77
|
+
// this.listColliders.forEach(collider => {
|
|
78
|
+
// if (collider.node && collider.node.active) {
|
|
79
|
+
// collider.update(dt, draw);
|
|
80
|
+
// }
|
|
81
|
+
// });
|
|
82
|
+
// } else {
|
|
83
|
+
// this.listColliders.forEach(collider => {
|
|
84
|
+
// if (collider.node && collider.node.active) {
|
|
85
|
+
// collider.update(dt);
|
|
86
|
+
// }
|
|
87
|
+
// });
|
|
88
|
+
}
|
|
89
|
+
for (var _i = 0, _b = entities.entities_with_components(CollideComponent_1.BoxCollider); _i < _b.length; _i++) {
|
|
90
|
+
var entt = _b[_i];
|
|
91
|
+
var comp = entt.getComponent(CollideComponent_1.BoxCollider);
|
|
92
|
+
comp.update(dt, draw);
|
|
93
|
+
}
|
|
94
|
+
for (var _c = 0, _d = entities.entities_with_components(CollideComponent_1.CircleCollider); _c < _d.length; _c++) {
|
|
95
|
+
var entt = _d[_c];
|
|
96
|
+
var comp = entt.getComponent(CollideComponent_1.CircleCollider);
|
|
97
|
+
comp.update(dt, draw);
|
|
98
|
+
}
|
|
99
|
+
for (var _e = 0, _f = entities.entities_with_components(CollideComponent_1.PolygonCollider); _e < _f.length; _e++) {
|
|
100
|
+
var entt = _f[_e];
|
|
101
|
+
var comp = entt.getComponent(CollideComponent_1.PolygonCollider);
|
|
102
|
+
comp.update(dt, draw);
|
|
103
|
+
}
|
|
104
|
+
this._contracts.forEach(function (contract) {
|
|
105
|
+
var col1 = contract._collider1;
|
|
106
|
+
var col2 = contract._collider2;
|
|
107
|
+
if (!cc.sys.isObjectValid(col1.node.instance) ||
|
|
108
|
+
!cc.sys.isObjectValid(col2.node.instance) ||
|
|
109
|
+
!col1.node ||
|
|
110
|
+
!col2.node ||
|
|
111
|
+
!col1.node.active ||
|
|
112
|
+
!col2.node.active) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
var type = contract.updateState();
|
|
116
|
+
switch (type) {
|
|
117
|
+
case CollideComponent_1.CollisionType.ENTER: {
|
|
118
|
+
if (col1.props.onCollisionEnter) {
|
|
119
|
+
col1.props.onCollisionEnter(col2);
|
|
120
|
+
}
|
|
121
|
+
if (col2.props.onCollisionEnter) {
|
|
122
|
+
col2.props.onCollisionEnter(col1);
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case CollideComponent_1.CollisionType.STAY:
|
|
127
|
+
if (col1.props.onCollisionStay) {
|
|
128
|
+
col1.props.onCollisionStay(col2);
|
|
129
|
+
}
|
|
130
|
+
if (col2.props.onCollisionStay) {
|
|
131
|
+
col2.props.onCollisionStay(col1);
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
case CollideComponent_1.CollisionType.EXIT:
|
|
135
|
+
if (col1.props.onCollisionExit) {
|
|
136
|
+
col1.props.onCollisionExit(col2);
|
|
137
|
+
}
|
|
138
|
+
if (col2.props.onCollisionExit) {
|
|
139
|
+
col2.props.onCollisionExit(col1);
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
CollideSystem.prototype.addCollider = function (collider) {
|
|
148
|
+
var _this = this;
|
|
149
|
+
this.listColliders.forEach(function (col) {
|
|
150
|
+
if ((0, utils_1.shouldCollider)(col, collider)) {
|
|
151
|
+
_this._contracts.push(new CollideComponent_1.Contract(col, collider));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
this.listColliders.push(collider);
|
|
155
|
+
};
|
|
156
|
+
CollideSystem.prototype.removeCollider = function (collider) {
|
|
157
|
+
this.removeColliders.push(collider);
|
|
158
|
+
};
|
|
159
|
+
CollideSystem.prototype.addDebugNode = function (root) {
|
|
160
|
+
this.debugGraphics = new cc.DrawNode();
|
|
161
|
+
this.debugGraphics.zIndex = 1000;
|
|
162
|
+
root.addChild(this.debugGraphics);
|
|
163
|
+
};
|
|
164
|
+
CollideSystem.prototype.toggleDebugDraw = function (enable) {
|
|
165
|
+
if (enable === void 0) { enable = true; }
|
|
166
|
+
this.enabledDebugDraw = enable;
|
|
167
|
+
this.addDebugNode(cc.director.getRunningScene());
|
|
168
|
+
};
|
|
169
|
+
return CollideSystem;
|
|
170
|
+
}());
|
|
171
|
+
exports.CollideSystem = CollideSystem;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/****************************************************************************
|
|
2
|
+
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
3
|
+
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
4
|
+
|
|
5
|
+
https://www.cocos.com/
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated engine source code (the "Software"), a limited,
|
|
9
|
+
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
10
|
+
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
11
|
+
not use Cocos Creator software for developing other software or tools that's
|
|
12
|
+
used for developing games. You are not granted to publish, distribute,
|
|
13
|
+
sublicense, and/or sell copies of Cocos Creator.
|
|
14
|
+
|
|
15
|
+
The software or tools in this License Agreement are licensed, not sold.
|
|
16
|
+
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
****************************************************************************/
|
|
26
|
+
/**
|
|
27
|
+
* A utils class for parsing HTML texts. The parsed results will be an object array.
|
|
28
|
+
*/
|
|
29
|
+
export declare const HtmlTextParser: () => void;
|
|
30
|
+
//# sourceMappingURL=html-text-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-text-parser.d.ts","sourceRoot":"","sources":["../../src/helper/html-text-parser.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;8EAwB8E;AAK9E;;GAEG;AACH,eAAO,MAAM,cAAc,YAS1B,CAAA"}
|