@safe-engine/cocos 1.6.4 → 1.6.5

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.
Files changed (38) hide show
  1. package/dist/box2d-wasm/PhysicsSystem.js +26 -25
  2. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +77 -0
  3. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +1 -0
  4. package/dist/dragonbones/cocos/CocosArmatureDisplay.js +227 -0
  5. package/dist/dragonbones/cocos/CocosFactory.d.ts +128 -0
  6. package/dist/dragonbones/cocos/CocosFactory.d.ts.map +1 -0
  7. package/dist/dragonbones/cocos/CocosFactory.js +231 -0
  8. package/dist/dragonbones/cocos/CocosSlot.d.ts +49 -0
  9. package/dist/dragonbones/cocos/CocosSlot.d.ts.map +1 -0
  10. package/dist/dragonbones/cocos/CocosSlot.js +385 -0
  11. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +53 -0
  12. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +1 -0
  13. package/dist/dragonbones/cocos/CocosTextureAtlasData.js +158 -0
  14. package/dist/dragonbones/dragonBones.d.ts +3 -0
  15. package/dist/dragonbones/dragonBones.d.ts.map +1 -0
  16. package/dist/dragonbones/dragonBones.js +4788 -0
  17. package/dist/gworld/components/AnimationComponent.d.ts +65 -0
  18. package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
  19. package/dist/gworld/components/AnimationComponent.js +141 -0
  20. package/dist/gworld/components/CollideComponent.d.ts +64 -0
  21. package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
  22. package/dist/gworld/components/CollideComponent.js +265 -0
  23. package/dist/gworld/systems/AnimationSystem.d.ts +6 -0
  24. package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
  25. package/dist/gworld/systems/AnimationSystem.js +30 -0
  26. package/dist/gworld/systems/CollideSystem.d.ts +21 -0
  27. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
  28. package/dist/gworld/systems/CollideSystem.js +181 -0
  29. package/dist/helper/NodePool.d.ts +9 -0
  30. package/dist/helper/NodePool.d.ts.map +1 -0
  31. package/dist/helper/NodePool.js +29 -0
  32. package/dist/helper/html-text-parser.d.ts +30 -0
  33. package/dist/helper/html-text-parser.d.ts.map +1 -0
  34. package/dist/helper/html-text-parser.js +354 -0
  35. package/dist/index.d.ts +0 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +0 -1
  38. package/package.json +1 -1
@@ -0,0 +1,65 @@
1
+ import { EnhancedComponent } from './EnhancedComponent';
2
+ export declare namespace AnimationClip {
3
+ interface IEvent {
4
+ frame: number;
5
+ func: string;
6
+ params: string[];
7
+ isCalled: boolean;
8
+ }
9
+ }
10
+ export declare enum WrapMode {
11
+ Default = 0,
12
+ Normal = 1,
13
+ Loop = 2,
14
+ PingPong = 22,
15
+ Reverse = 36,
16
+ LoopReverse = 38,
17
+ PingPongReverse = 54
18
+ }
19
+ interface AnimProp {
20
+ frame: number;
21
+ value: number;
22
+ }
23
+ interface SpriteFrameProp {
24
+ frame: number;
25
+ value: string;
26
+ }
27
+ interface CurveData {
28
+ comps: {
29
+ spriteFrame: SpriteFrameProp[];
30
+ nextFrame: number;
31
+ };
32
+ props: {
33
+ [key: string]: AnimProp[];
34
+ };
35
+ }
36
+ export declare class AnimationClip {
37
+ static WrapMode: typeof WrapMode;
38
+ sample: number;
39
+ speed: number;
40
+ wrapMode: WrapMode;
41
+ events: AnimationClip.IEvent[];
42
+ duration: number;
43
+ name: string;
44
+ curveData: CurveData;
45
+ }
46
+ export declare class AnimationComp extends EnhancedComponent {
47
+ defaultClip: AnimationClip;
48
+ clips: AnimationClip[];
49
+ playOnLoad: boolean;
50
+ private isPaused;
51
+ private elapsed;
52
+ private currentClip;
53
+ constructor(defaultClip: AnimationClip, clips: AnimationClip[], playOnLoad: boolean);
54
+ start(): void;
55
+ update(dt: Float): void;
56
+ getAnimationState(name: string): {
57
+ isPlaying: boolean;
58
+ };
59
+ play(name?: string): void;
60
+ pause(): void;
61
+ resume(): void;
62
+ stop(name?: string): void;
63
+ }
64
+ export {};
65
+ //# sourceMappingURL=AnimationComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimationComponent.d.ts","sourceRoot":"","sources":["../../../src/gworld/components/AnimationComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,UAAiB,MAAM;QACrB,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,QAAQ,EAAE,OAAO,CAAA;KAClB;CACF;AAED,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,MAAM,IAAI;IACV,IAAI,IAAI;IACR,QAAQ,KAAK;IACb,OAAO,KAAK;IACZ,WAAW,KAAK;IAChB,eAAe,KAAK;CACrB;AAED,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,SAAS;IACjB,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5D,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAA;KAAE,CAAA;CACrC;AAED,qBAAa,aAAa;IACxB,OAAc,QAAQ,kBAAW;IAC1B,MAAM,SAAK;IACX,KAAK,SAAI;IACT,QAAQ,WAAkB;IAC1B,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,CAAK;IACnC,QAAQ,SAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,SAAS,CAAA;CACrB;AAID,qBAAa,aAAc,SAAQ,iBAAiB;IAClD,WAAW,EAAE,aAAa,CAAA;IAC1B,KAAK,EAAE,aAAa,EAAE,CAAA;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,WAAW,CAAe;gBAEtB,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO;IAOnF,KAAK;IASL,MAAM,CAAC,EAAE,EAAE,KAAK;IAqChB,iBAAiB,CAAC,IAAI,EAAE,MAAM;;;IAMvB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;IAoBlB,KAAK;IAKL,MAAM;IAKN,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;CAI1B"}
@@ -0,0 +1,141 @@
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.AnimationComp = exports.AnimationClip = exports.WrapMode = void 0;
19
+ var EnhancedComponent_1 = require("./EnhancedComponent");
20
+ var RenderComponent_1 = require("./RenderComponent");
21
+ var WrapMode;
22
+ (function (WrapMode) {
23
+ WrapMode[WrapMode["Default"] = 0] = "Default";
24
+ WrapMode[WrapMode["Normal"] = 1] = "Normal";
25
+ WrapMode[WrapMode["Loop"] = 2] = "Loop";
26
+ WrapMode[WrapMode["PingPong"] = 22] = "PingPong";
27
+ WrapMode[WrapMode["Reverse"] = 36] = "Reverse";
28
+ WrapMode[WrapMode["LoopReverse"] = 38] = "LoopReverse";
29
+ WrapMode[WrapMode["PingPongReverse"] = 54] = "PingPongReverse";
30
+ })(WrapMode || (exports.WrapMode = WrapMode = {}));
31
+ var AnimationClip = /** @class */ (function () {
32
+ function AnimationClip() {
33
+ this.sample = 60;
34
+ this.speed = 1;
35
+ this.wrapMode = WrapMode.Normal;
36
+ this.events = [];
37
+ this.duration = 0;
38
+ }
39
+ AnimationClip.WrapMode = WrapMode;
40
+ return AnimationClip;
41
+ }());
42
+ exports.AnimationClip = AnimationClip;
43
+ // cc.AnimationClip = AnimationClip;
44
+ var AnimationComp = /** @class */ (function (_super) {
45
+ __extends(AnimationComp, _super);
46
+ function AnimationComp(defaultClip, clips, playOnLoad) {
47
+ var _this = _super.call(this) || this;
48
+ _this.isPaused = true;
49
+ _this.elapsed = 0;
50
+ _this.defaultClip = defaultClip;
51
+ _this.clips = clips;
52
+ _this.playOnLoad = playOnLoad;
53
+ return _this;
54
+ }
55
+ AnimationComp.prototype.start = function () {
56
+ var _this = this;
57
+ if (this.playOnLoad) {
58
+ setTimeout(function () {
59
+ _this.play();
60
+ }, 0);
61
+ }
62
+ // cc.log(this.clips);
63
+ };
64
+ AnimationComp.prototype.update = function (dt) {
65
+ var _this = this;
66
+ if (this.isPaused || !this.node.active) {
67
+ return;
68
+ }
69
+ var _a = this.currentClip, curveData = _a.curveData, wrapMode = _a.wrapMode, events = _a.events, duration = _a.duration, speed = _a.speed;
70
+ this.elapsed += dt * speed;
71
+ var _b = curveData.comps, spriteFrame = _b.spriteFrame, nextFrame = _b.nextFrame;
72
+ var nextFrameTime = spriteFrame[nextFrame].frame;
73
+ events.forEach(function (evt) {
74
+ var func = evt.func, frame = evt.frame, params = evt.params, isCalled = evt.isCalled;
75
+ if (!isCalled && _this.elapsed >= frame) {
76
+ evt.isCalled = true;
77
+ // this.node.emit(func, ...params)
78
+ }
79
+ });
80
+ if (this.elapsed >= nextFrameTime) {
81
+ var imageComp = this.node.getComponent(RenderComponent_1.SpriteRender);
82
+ if (imageComp) {
83
+ imageComp.spriteFrame = spriteFrame[nextFrame].value;
84
+ }
85
+ // cc.log(spriteFrame[nextFrame].value, nextFrameTime);
86
+ curveData.comps.nextFrame += 1;
87
+ curveData.comps.nextFrame = cc.clampf(curveData.comps.nextFrame, 0, spriteFrame.length - 1);
88
+ if (this.elapsed >= duration) {
89
+ if (wrapMode === WrapMode.Loop) {
90
+ curveData.comps.nextFrame = 0;
91
+ this.elapsed = 0;
92
+ events.forEach(function (evt) {
93
+ evt.isCalled = false;
94
+ });
95
+ }
96
+ else {
97
+ this.isPaused = true;
98
+ }
99
+ }
100
+ }
101
+ };
102
+ AnimationComp.prototype.getAnimationState = function (name) {
103
+ return {
104
+ isPlaying: !this.isPaused,
105
+ };
106
+ };
107
+ AnimationComp.prototype.play = function (name) {
108
+ this.elapsed = 0;
109
+ // cc.log('play', name, this.defaultClip.name);
110
+ if (!name) {
111
+ if (!this.defaultClip) {
112
+ return;
113
+ }
114
+ name = this.defaultClip.name;
115
+ }
116
+ else if (this.currentClip && name === this.currentClip.name) {
117
+ return;
118
+ }
119
+ this.currentClip = this.clips.find(function (clip) { return clip.name === name; });
120
+ this.currentClip.curveData.comps.nextFrame = 0;
121
+ // cc.log('name', name, this.currentClip);
122
+ this.currentClip.events.forEach(function (evt) {
123
+ evt.isCalled = false;
124
+ });
125
+ this.isPaused = false;
126
+ };
127
+ AnimationComp.prototype.pause = function () {
128
+ this.node.instance.pause();
129
+ this.isPaused = true;
130
+ };
131
+ AnimationComp.prototype.resume = function () {
132
+ this.node.instance.resume();
133
+ this.isPaused = false;
134
+ };
135
+ AnimationComp.prototype.stop = function (name) {
136
+ this.node.instance.unscheduleAllCallbacks();
137
+ this.isPaused = true;
138
+ };
139
+ return AnimationComp;
140
+ }(EnhancedComponent_1.EnhancedComponent));
141
+ exports.AnimationComp = AnimationComp;
@@ -0,0 +1,64 @@
1
+ import { NoRenderComponentX } from '../gworld/core/decorator';
2
+ import { Vec2 } from '../polyfills';
3
+ interface ColliderProps {
4
+ offset?: Vec2;
5
+ tag?: number;
6
+ enabled?: boolean;
7
+ onCollisionEnter?: (other: Collider) => void;
8
+ onCollisionExit?: (other: Collider) => void;
9
+ onCollisionStay?: (other: Collider) => void;
10
+ }
11
+ export declare class Collider<T = ColliderProps> extends NoRenderComponentX<T> {
12
+ _worldPoints: cc.Vec2[] | cc.Point[];
13
+ _worldPosition: cc.Vec2 | cc.Point;
14
+ _worldRadius: any;
15
+ _AABB: cc.Rect;
16
+ _preAabb: cc.Rect;
17
+ getAABB(): cc.Rect;
18
+ get world(): {
19
+ points: cc.Point[] | cc.Vec2[];
20
+ preAabb: cc.Rect;
21
+ };
22
+ }
23
+ interface BoxColliderProps extends ColliderProps {
24
+ width: number;
25
+ height: number;
26
+ }
27
+ export declare class BoxCollider extends Collider<BoxColliderProps> {
28
+ get size(): cc.Size;
29
+ set size(s: cc.Size);
30
+ update(dt: any, draw: cc.DrawNode): void;
31
+ }
32
+ interface CircleColliderProps extends ColliderProps {
33
+ radius: number;
34
+ }
35
+ export declare class CircleCollider extends Collider<CircleColliderProps> {
36
+ update(dt: any, draw: cc.DrawNode): void;
37
+ }
38
+ interface PolygonColliderProps extends ColliderProps {
39
+ points: Array<Vec2>;
40
+ }
41
+ export declare class PolygonCollider extends Collider<PolygonColliderProps> {
42
+ get points(): Vec2[];
43
+ set points(points: Vec2[]);
44
+ update(dt: any, draw: cc.DrawNode): void;
45
+ }
46
+ export declare enum CollisionType {
47
+ NONE = 0,
48
+ ENTER = 1,
49
+ STAY = 2,
50
+ EXIT = 3
51
+ }
52
+ export declare class Contract {
53
+ _collider1: Collider;
54
+ _collider2: Collider;
55
+ _touching: boolean;
56
+ _isPolygonPolygon: boolean;
57
+ _isCircleCircle: boolean;
58
+ _isPolygonCircle: boolean;
59
+ constructor(collider1: Collider, collider2: Collider);
60
+ updateState(): CollisionType;
61
+ test(): any;
62
+ }
63
+ export { };
64
+ //# sourceMappingURL=CollideComponent.d.ts.map
@@ -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,21 @@
1
+ import { EntityManager, EventManager, System } from 'entityx-ts';
2
+ import { Collider, Contract } from '../../collider/CollideComponent';
3
+ export declare function shouldCollider(colA: Collider, colB: Collider): any;
4
+ export declare class CollideSystem implements System {
5
+ listColliders: Collider[];
6
+ _contracts: Contract[];
7
+ removeColliders: any[];
8
+ debugGraphics: cc.DrawNode;
9
+ enabledDebugDraw: boolean;
10
+ enabled: boolean;
11
+ colliderMatrix: boolean[][];
12
+ configure(event_manager: EventManager): void;
13
+ private onAddCollider;
14
+ private onRemoveCollider;
15
+ update(entities: EntityManager, events: EventManager, dt: number): void;
16
+ addCollider(collider: Collider): void;
17
+ removeCollider(collider: Collider): void;
18
+ addDebugNode(root: cc.Scene): void;
19
+ toggleDebugDraw(enable?: boolean): void;
20
+ }
21
+ //# 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,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,OAQ5D;AAED,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"}