@safe-engine/pixi 8.0.3 → 8.0.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/README.md +4 -4
  2. package/dist/components/GUIComponent.d.ts +13 -4
  3. package/dist/components/GUIComponent.d.ts.map +1 -1
  4. package/dist/components/GUIComponent.js +9 -3
  5. package/dist/systems/GUISystem.d.ts.map +1 -1
  6. package/dist/systems/GUISystem.js +7 -7
  7. package/package.json +3 -4
  8. package/.github/workflows/npm-publish.yml +0 -35
  9. package/dist/components/EnhancedComponent.d.ts +0 -22
  10. package/dist/components/EnhancedComponent.d.ts.map +0 -1
  11. package/dist/components/EnhancedComponent.js +0 -62
  12. package/dist/core/Scene.d.ts +0 -6
  13. package/dist/core/Scene.d.ts.map +0 -1
  14. package/dist/core/Scene.js +0 -39
  15. package/dist/core/Vec2.d.ts +0 -20
  16. package/dist/core/Vec2.d.ts.map +0 -1
  17. package/dist/core/Vec2.js +0 -70
  18. package/dist/core/decorator.d.ts +0 -9
  19. package/dist/core/decorator.d.ts.map +0 -1
  20. package/dist/core/decorator.js +0 -46
  21. package/dist/gworld.d.ts +0 -8
  22. package/dist/gworld.d.ts.map +0 -1
  23. package/dist/gworld.js +0 -43
  24. package/dist/helper/utils.d.ts +0 -11
  25. package/dist/helper/utils.d.ts.map +0 -1
  26. package/dist/helper/utils.js +0 -40
  27. package/src/app.ts +0 -55
  28. package/src/components/GUIComponent.ts +0 -141
  29. package/src/components/NodeComp.ts +0 -416
  30. package/src/components/RenderComponent.ts +0 -66
  31. package/src/core/Color.ts +0 -3
  32. package/src/core/LoadingBar.ts +0 -63
  33. package/src/core/Size.ts +0 -21
  34. package/src/helper/html-text-parser.ts +0 -364
  35. package/src/index.ts +0 -7
  36. package/src/systems/GUISystem.ts +0 -80
  37. package/src/systems/RenderSystem.ts +0 -71
  38. package/tsconfig.json +0 -24
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Guide
2
- - components must be in `tsx` extension
3
- - `$ref` bind with current class property as string
4
- - every property start with `$` will reference to current class property as string
1
+ # Guide
2
+ - components must be in `tsx` extension
3
+ - `$ref` bind with current class property as string
4
+ - every property start with `$` will reference to current class property as string
@@ -1,7 +1,8 @@
1
+ import { Input, ProgressBar } from '@pixi/ui';
1
2
  import { ComponentX, NoRenderComponentX } from '@safe-engine/core';
2
- import { Container, Point, Text } from 'pixi.js';
3
+ import { Container, FillInput, Point, Text } from 'pixi.js';
3
4
  import { Color4B } from '../core/Color';
4
- import { LoadingBar, LoadingBarMode, ProgressTimer } from '../core/LoadingBar';
5
+ import { LoadingBarMode, ProgressTimer } from '../core/LoadingBar';
5
6
  import { NodeComp } from './NodeComp';
6
7
  export declare const FillType: {
7
8
  HORIZONTAL: number;
@@ -19,10 +20,11 @@ export declare class ButtonComp extends NoRenderComponentX<NodeComp> {
19
20
  setOnPress(cb: (target: ButtonComp) => void): void;
20
21
  set enabled(val: any);
21
22
  }
22
- export declare class ProgressBarComp extends NoRenderComponentX<NodeComp<LoadingBar>> {
23
+ export declare class ProgressBarComp extends NoRenderComponentX<NodeComp<ProgressBar>> {
23
24
  mode: LoadingBarMode;
24
- private _progress;
25
25
  isReverse: boolean;
26
+ bg: string;
27
+ fill: string;
26
28
  get progress(): number;
27
29
  set progress(val: number);
28
30
  }
@@ -69,5 +71,12 @@ export declare class LabelShadowComp extends NoRenderComponentX<NodeComp> {
69
71
  blur: number;
70
72
  offset: Point;
71
73
  }
74
+ export declare class InputComp extends ComponentX<NodeComp<Input>> {
75
+ bg: string;
76
+ fill: FillInput;
77
+ font: string;
78
+ string: string;
79
+ size: number;
80
+ }
72
81
  export {};
73
82
  //# sourceMappingURL=GUIComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GUIComponent.d.ts","sourceRoot":"","sources":["../../src/components/GUIComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CA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O,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,KAAK,CAAA;CACd;AAED,qBAAa,SAAU,SAAQ,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,SAAK;CACV"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LabelShadowComp = exports.LabelOutlineComp = exports.RichTextComp = exports.ProgressTimerComp = exports.BlockInputEventsComp = exports.ScrollView = exports.LabelComp = exports.ProgressBarComp = exports.ButtonComp = exports.FillType = void 0;
3
+ exports.InputComp = exports.LabelShadowComp = exports.LabelOutlineComp = exports.RichTextComp = exports.ProgressTimerComp = exports.BlockInputEventsComp = exports.ScrollView = exports.LabelComp = exports.ProgressBarComp = exports.ButtonComp = exports.FillType = void 0;
4
4
  const core_1 = require("@safe-engine/core");
5
5
  const pixi_js_1 = require("pixi.js");
6
6
  const LoadingBar_1 = require("../core/LoadingBar");
@@ -25,10 +25,9 @@ class ProgressBarComp extends core_1.NoRenderComponentX {
25
25
  this.mode = LoadingBar_1.LoadingBarMode.BAR;
26
26
  }
27
27
  get progress() {
28
- return this._progress;
28
+ return this.node.instance.progress;
29
29
  }
30
30
  set progress(val) {
31
- this._progress = val;
32
31
  this.node.instance.progress = val;
33
32
  }
34
33
  }
@@ -106,3 +105,10 @@ exports.LabelOutlineComp = LabelOutlineComp;
106
105
  class LabelShadowComp extends core_1.NoRenderComponentX {
107
106
  }
108
107
  exports.LabelShadowComp = LabelShadowComp;
108
+ class InputComp extends core_1.ComponentX {
109
+ constructor() {
110
+ super(...arguments);
111
+ this.size = 64;
112
+ }
113
+ }
114
+ exports.InputComp = InputComp;
@@ -1 +1 @@
1
- {"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/systems/GUISystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,YAAY,EAEZ,MAAM,EACP,MAAM,YAAY,CAAA;AAQnB,qBAAa,SAAU,YAAW,MAAM;IACtC,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,SAAS,CAAC;CAgEjD"}
1
+ {"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/systems/GUISystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACL,YAAY,EAEZ,MAAM,EACP,MAAM,YAAY,CAAA;AAQnB,qBAAa,SAAU,YAAW,MAAM;IACtC,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,SAAS,CAAC;CAiEjD"}
@@ -31,14 +31,9 @@ class GUISystem {
31
31
  });
32
32
  });
33
33
  event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.ProgressBarComp, ({ entity, component }) => {
34
- const spriteComp = entity.getComponent(__1.SpriteRender);
35
- if (!spriteComp)
36
- throw Error('ProgressBarComp need SpriteRender');
37
- const { progress, mode } = component;
38
- const node = new LoadingBar_1.LoadingBar(mode, spriteComp.node.instance);
39
- spriteComp.node.instance.mask = node;
34
+ const { progress = 1, bg, fill } = component;
35
+ const node = new ui_1.ProgressBar({ bg, fill, progress });
40
36
  component.node = entity.assign(new __1.NodeComp(node, entity));
41
- node.progress = progress;
42
37
  });
43
38
  event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.ProgressTimerComp, ({ entity, component }) => {
44
39
  // console.log(component, '.progress')
@@ -54,6 +49,11 @@ class GUISystem {
54
49
  const view = new ui_1.ScrollBox({ width, height });
55
50
  component.node = entity.assign(new __1.NodeComp(view, entity));
56
51
  });
52
+ event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.InputComp, ({ entity, component }) => {
53
+ const { bg, size = 48, fill } = component;
54
+ const view = new ui_1.Input({ bg, textStyle: { fontSize: size, fill } });
55
+ component.node = entity.assign(new __1.NodeComp(view, entity));
56
+ });
57
57
  event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, GUIComponent_1.LabelComp, ({ entity, component }) => {
58
58
  // console.log('ComponentAddedEvent LabelComp', component)
59
59
  const node = new pixi_js_1.Text();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safe-engine/pixi",
3
- "version": "8.0.3",
3
+ "version": "8.0.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,9 +17,8 @@
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
19
  "@pixi/ui": "^2.1.5",
20
- "@safe-engine/core": "workspace:*",
21
- "@safe-engine/pixi-dragonbones": "workspace:*",
22
- "entityx-ts": "workspace:*",
20
+ "entityx-ts": "^2.0.3",
21
+ "@safe-engine/core": "1.0.3",
23
22
  "lodash": "^4.17.21",
24
23
  "pixi-action-ease": "^1.0.12",
25
24
  "pixi.js": "^8.4.0"
@@ -1,35 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Publish NPM Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
- workflow_dispatch: # Allows you to run this workflow manually
10
-
11
- jobs:
12
- build:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
- - uses: actions/setup-node@v3
17
- with:
18
- node-version: 20
19
- - run: npm ci
20
- - run: npm run build
21
-
22
- publish-npm:
23
- needs: build
24
- runs-on: ubuntu-latest
25
- steps:
26
- - uses: actions/checkout@v4
27
- - uses: actions/setup-node@v3
28
- with:
29
- node-version: 20
30
- registry-url: https://registry.npmjs.org/
31
- - run: npm ci
32
- - run: npm run build
33
- - run: npm publish
34
- env:
35
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -1,22 +0,0 @@
1
- import { Constructor } from 'entityx-ts';
2
- import { Animation } from 'pixi-action-ease';
3
- import { NodeComp } from './NodeComp';
4
- export declare class EnhancedComponent {
5
- constructor(...args: any[]);
6
- node: NodeComp;
7
- static hasRender: boolean;
8
- actionsMap: {
9
- [key: string]: Animation;
10
- };
11
- addComponent<T extends EnhancedComponent>(instance: any): T;
12
- getComponent<T extends ComponentType>(component: Constructor<T>): T;
13
- schedule(callback: (dt?: number) => void, interval: number, repeat?: number, delay?: number, key?: string): void;
14
- unschedule(callback: (arg?: unknown) => void, key?: string): void;
15
- unscheduleAllCallbacks(): void;
16
- scheduleOnce(callback: (arg?: unknown) => void, delay: number, key?: string): void;
17
- getComponentsInChildren<T extends ComponentType>(component: Constructor<T>): T[];
18
- getComponentInChildren<T extends ComponentType>(component: Constructor<T>): T;
19
- isEqual(other: EnhancedComponent): boolean;
20
- }
21
- export type ComponentType = EnhancedComponent | NodeComp;
22
- //# sourceMappingURL=EnhancedComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnhancedComponent.d.ts","sourceRoot":"","sources":["../../src/components/EnhancedComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAiB,SAAS,EAAyC,MAAM,kBAAkB,CAAA;AAElG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,qBAAa,iBAAiB;gBAChB,GAAG,IAAI,EAAE,GAAG,EAAE;IAS1B,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,CAAC,SAAS,UAAO;IACvB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAK;IAC7C,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,QAAQ,KAAA,GAAG,CAAC;IAGtD,YAAY,CAAC,CAAC,SAAS,aAAa,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;IAGnE,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAK,EAAE,KAAK,SAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAOhG,UAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM;IAI1D,sBAAsB;IAKtB,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAK3E,uBAAuB,CAAC,CAAC,SAAS,aAAa,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;IAGhF,sBAAsB,CAAC,CAAC,SAAS,aAAa,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;IAG7E,OAAO,CAAC,KAAK,EAAE,iBAAiB;CAGjC;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,QAAQ,CAAA"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnhancedComponent = void 0;
4
- var pixi_action_ease_1 = require("pixi-action-ease");
5
- var EnhancedComponent = /** @class */ (function () {
6
- function EnhancedComponent() {
7
- var args = [];
8
- for (var _i = 0; _i < arguments.length; _i++) {
9
- args[_i] = arguments[_i];
10
- }
11
- var _this = this;
12
- this.actionsMap = {};
13
- var data = args[0];
14
- if (data) {
15
- // console.log('constructor', this.constructor.name, data)
16
- Object.keys(data).forEach(function (key) {
17
- _this[key] = data[key];
18
- });
19
- }
20
- }
21
- EnhancedComponent.prototype.addComponent = function (instance) {
22
- return this.node.addComponent(instance);
23
- };
24
- EnhancedComponent.prototype.getComponent = function (component) {
25
- return this.node.getComponent(component);
26
- };
27
- EnhancedComponent.prototype.schedule = function (callback, interval, repeat, delay, key) {
28
- if (repeat === void 0) { repeat = -1; }
29
- if (delay === void 0) { delay = 0; }
30
- var action = pixi_action_ease_1.Sequence.create(pixi_action_ease_1.DelayTime.create(interval), pixi_action_ease_1.CallFunc.create(callback));
31
- var repeatAct = pixi_action_ease_1.Repeat.create(action, repeat);
32
- var seq = pixi_action_ease_1.Sequence.create(pixi_action_ease_1.DelayTime.create(delay), repeatAct);
33
- var animation = pixi_action_ease_1.actionManager.runAction(this.node.instance, seq);
34
- this.actionsMap[key] = animation;
35
- };
36
- EnhancedComponent.prototype.unschedule = function (callback, key) {
37
- // this.node.instance.unschedule(callback.bind(this))
38
- this.actionsMap[key].stop();
39
- };
40
- EnhancedComponent.prototype.unscheduleAllCallbacks = function () {
41
- Object.values(this.actionsMap).forEach(function (action) {
42
- action.stop();
43
- });
44
- };
45
- EnhancedComponent.prototype.scheduleOnce = function (callback, delay, key) {
46
- var action = pixi_action_ease_1.Sequence.create(pixi_action_ease_1.DelayTime.create(delay), pixi_action_ease_1.CallFunc.create(callback));
47
- var animation = pixi_action_ease_1.actionManager.runAction(this.node.instance, action);
48
- this.actionsMap[key] = animation;
49
- };
50
- EnhancedComponent.prototype.getComponentsInChildren = function (component) {
51
- return this.node.getComponentsInChildren(component);
52
- };
53
- EnhancedComponent.prototype.getComponentInChildren = function (component) {
54
- return this.node.getComponentInChildren(component);
55
- };
56
- EnhancedComponent.prototype.isEqual = function (other) {
57
- return this.node.entity.id === other.node.entity.id;
58
- };
59
- EnhancedComponent.hasRender = true;
60
- return EnhancedComponent;
61
- }());
62
- exports.EnhancedComponent = EnhancedComponent;
@@ -1,6 +0,0 @@
1
- import { EnhancedComponent } from '../components/EnhancedComponent';
2
- export declare class SceneComponent extends EnhancedComponent {
3
- static boot: () => void;
4
- static create(): SceneComponent;
5
- }
6
- //# sourceMappingURL=Scene.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Scene.d.ts","sourceRoot":"","sources":["../../src/core/Scene.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAInE,qBAAa,cAAe,SAAQ,iBAAiB;IACnD,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,CAAA;IACvB,MAAM,CAAC,MAAM;CASd"}
@@ -1,39 +0,0 @@
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.SceneComponent = void 0;
19
- var app_1 = require("../app");
20
- var EnhancedComponent_1 = require("../components/EnhancedComponent");
21
- var NodeComp_1 = require("../components/NodeComp");
22
- var gworld_1 = require("../gworld");
23
- var SceneComponent = /** @class */ (function (_super) {
24
- __extends(SceneComponent, _super);
25
- function SceneComponent() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- SceneComponent.create = function () {
29
- var world = gworld_1.GameWorld.Instance;
30
- world.entities.reset();
31
- var root = world.entities.create();
32
- var node = root.assign(new NodeComp_1.NodeComp(app_1.app.stage, root));
33
- var sceneComponent = root.assign(new SceneComponent());
34
- sceneComponent.node = node;
35
- return sceneComponent;
36
- };
37
- return SceneComponent;
38
- }(EnhancedComponent_1.EnhancedComponent));
39
- exports.SceneComponent = SceneComponent;
@@ -1,20 +0,0 @@
1
- import { Point } from 'pixi.js';
2
- declare class _Vec2 extends Point {
3
- x: number;
4
- y: number;
5
- static ZERO: any;
6
- equals(other: Point): boolean;
7
- addSelf(value: Point): Point;
8
- cross(other: Vec2): number;
9
- signAngle(other: Vec2): number;
10
- lengthSqr(): number;
11
- dot(other: Vec2): number;
12
- angle(other: Vec2): number;
13
- }
14
- export type Vec2 = _Vec2;
15
- export declare function Vec2(x?: number, y?: number): Vec2;
16
- export declare namespace Vec2 {
17
- var ZERO: Readonly<_Vec2>;
18
- }
19
- export {};
20
- //# sourceMappingURL=Vec2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Vec2.d.ts","sourceRoot":"","sources":["../../src/core/Vec2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,cAAM,KAAM,SAAQ,KAAK;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,MAAM,CAAC,IAAI,MAAA;IAEX,MAAM,CAAC,KAAK,EAAE,KAAK;IAInB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IAOrB,KAAK,CAAC,KAAK,EAAE,IAAI;IAGjB,SAAS,CAAC,KAAK,EAAE,IAAI;IAIrB,SAAS;IAGT,GAAG,CAAC,KAAK,EAAE,IAAI;IAGf,KAAK,CAAC,KAAK,EAAE,IAAI;CAczB;AACD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AACxB,wBAAgB,IAAI,CAAC,CAAC,SAAI,EAAE,CAAC,SAAI,GAAG,IAAI,CAEvC;yBAFe,IAAI"}
package/dist/core/Vec2.js DELETED
@@ -1,70 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.Vec2 = Vec2;
22
- var clamp_1 = __importDefault(require("lodash/clamp"));
23
- var pixi_js_1 = require("pixi.js");
24
- var _Vec2 = /** @class */ (function (_super) {
25
- __extends(_Vec2, _super);
26
- function _Vec2() {
27
- return _super !== null && _super.apply(this, arguments) || this;
28
- }
29
- _Vec2.prototype.equals = function (other) {
30
- return this.x === other.x && this.y === other.y;
31
- };
32
- _Vec2.prototype.addSelf = function (value) {
33
- var nor = value.add(new pixi_js_1.Point(this.x, this.y));
34
- this.x = nor.x;
35
- this.y = nor.y;
36
- return nor;
37
- };
38
- _Vec2.prototype.cross = function (other) {
39
- return this.x * other.y - this.y * other.x;
40
- };
41
- _Vec2.prototype.signAngle = function (other) {
42
- var angle = this.angle(other);
43
- return this.cross(other) < 0 ? -angle : angle;
44
- };
45
- _Vec2.prototype.lengthSqr = function () {
46
- return this.x * this.x + this.y * this.y;
47
- };
48
- _Vec2.prototype.dot = function (other) {
49
- return this.x * other.x + this.y * other.y;
50
- };
51
- _Vec2.prototype.angle = function (other) {
52
- var magSqr1 = this.lengthSqr();
53
- var magSqr2 = other.lengthSqr();
54
- if (magSqr1 === 0 || magSqr2 === 0) {
55
- console.warn('Cant get angle between zero vector');
56
- return 0.0;
57
- }
58
- var dot = this.dot(other);
59
- var theta = dot / Math.sqrt(magSqr1 * magSqr2);
60
- theta = (0, clamp_1.default)(theta, -1.0, 1.0);
61
- return Math.acos(theta);
62
- };
63
- return _Vec2;
64
- }(pixi_js_1.Point));
65
- function Vec2(x, y) {
66
- if (x === void 0) { x = 0; }
67
- if (y === void 0) { y = 0; }
68
- return new _Vec2(x, y);
69
- }
70
- Vec2.ZERO = Object.freeze(Vec2(0, 0));
@@ -1,9 +0,0 @@
1
- import { EnhancedComponent } from '../components/EnhancedComponent';
2
- export declare class NoRenderComponentX extends EnhancedComponent {
3
- static hasRender: boolean;
4
- static create(data?: any): NoRenderComponentX;
5
- }
6
- export declare class ComponentX extends EnhancedComponent {
7
- static create(data?: any): ComponentX;
8
- }
9
- //# sourceMappingURL=decorator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../src/core/decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAGnE,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,MAAM,CAAC,SAAS,UAAQ;IACxB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG;CAGzB;AAED,qBAAa,UAAW,SAAQ,iBAAiB;IAC/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG;CAMzB"}
@@ -1,46 +0,0 @@
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.ComponentX = exports.NoRenderComponentX = void 0;
19
- var EnhancedComponent_1 = require("../components/EnhancedComponent");
20
- var gworld_1 = require("../gworld");
21
- var NoRenderComponentX = /** @class */ (function (_super) {
22
- __extends(NoRenderComponentX, _super);
23
- function NoRenderComponentX() {
24
- return _super !== null && _super.apply(this, arguments) || this;
25
- }
26
- NoRenderComponentX.create = function (data) {
27
- return new this(data);
28
- };
29
- NoRenderComponentX.hasRender = false;
30
- return NoRenderComponentX;
31
- }(EnhancedComponent_1.EnhancedComponent));
32
- exports.NoRenderComponentX = NoRenderComponentX;
33
- var ComponentX = /** @class */ (function (_super) {
34
- __extends(ComponentX, _super);
35
- function ComponentX() {
36
- return _super !== null && _super.apply(this, arguments) || this;
37
- }
38
- ComponentX.create = function (data) {
39
- var world = gworld_1.GameWorld.Instance;
40
- var root = world.entities.create();
41
- var comp = root.assign(new this(data));
42
- return comp;
43
- };
44
- return ComponentX;
45
- }(EnhancedComponent_1.EnhancedComponent));
46
- exports.ComponentX = ComponentX;
package/dist/gworld.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Constructor, System, World } from 'entityx-ts';
2
- export declare class GameWorld extends World {
3
- listUpdate: (System | Constructor<System>)[];
4
- update(dt: number): void;
5
- private static _instance;
6
- static get Instance(): GameWorld;
7
- }
8
- //# sourceMappingURL=gworld.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gworld.d.ts","sourceRoot":"","sources":["../src/gworld.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvD,qBAAa,SAAU,SAAQ,KAAK;IAClC,UAAU,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAK;IACjD,MAAM,CAAC,EAAE,EAAE,MAAM;IAMjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAW;IAEnC,WAAkB,QAAQ,cAGzB;CACF"}
package/dist/gworld.js DELETED
@@ -1,43 +0,0 @@
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.GameWorld = void 0;
19
- var entityx_ts_1 = require("entityx-ts");
20
- var GameWorld = /** @class */ (function (_super) {
21
- __extends(GameWorld, _super);
22
- function GameWorld() {
23
- var _this = _super !== null && _super.apply(this, arguments) || this;
24
- _this.listUpdate = [];
25
- return _this;
26
- }
27
- GameWorld.prototype.update = function (dt) {
28
- var _this = this;
29
- this.listUpdate.forEach(function (system) {
30
- _this.systems.update(system, dt);
31
- });
32
- };
33
- Object.defineProperty(GameWorld, "Instance", {
34
- get: function () {
35
- // Do you need arguments? Make it a regular static method instead.
36
- return this._instance || (this._instance = new this());
37
- },
38
- enumerable: false,
39
- configurable: true
40
- });
41
- return GameWorld;
42
- }(entityx_ts_1.World));
43
- exports.GameWorld = GameWorld;
@@ -1,11 +0,0 @@
1
- import { ComponentX } from '@safe-engine/core';
2
- import { Constructor, EntityManager, EventManager, EventReceive } from 'entityx-ts';
3
- export declare function registerSystem<T extends ComponentX>(component: Constructor<T>): {
4
- new (): {
5
- configure(event_manager: EventManager): void;
6
- receiveComponentAddedEvent(event: EventReceive<T>): void;
7
- update(entities: EntityManager, events: EventManager, dt: number): void;
8
- };
9
- };
10
- export declare function instantiate<T>(ComponentType: Constructor<T>, data?: any): T;
11
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,mBAAmB,CAAA;AACzD,OAAO,EACL,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAGvD,MAAM,YAAY,CAAA;AAInB,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;;iCAKjD,YAAY;0CAKH,YAAY,CAAC,CAAC,CAAC;yBAMhC,aAAa,UAAU,YAAY,MAAM,MAAM;;EAenE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAE3E"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerSystem = registerSystem;
4
- exports.instantiate = instantiate;
5
- const core_1 = require("@safe-engine/core");
6
- const entityx_ts_1 = require("entityx-ts");
7
- const __1 = require("..");
8
- function registerSystem(component) {
9
- if (core_1.GameWorld.Instance.systems.isRegistered(`${component.name}System`)) {
10
- return;
11
- }
12
- class NewSystem {
13
- configure(event_manager) {
14
- console.log('configure registerSystem', component.name);
15
- event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, component, this.receiveComponentAddedEvent.bind(this));
16
- }
17
- receiveComponentAddedEvent(event) {
18
- const ett = event.entity;
19
- const newComp = ett.getComponent(component);
20
- newComp.node = ett.getComponent(__1.NodeComp);
21
- }
22
- update(entities, events, dt) {
23
- for (const entt of entities.entities_with_components(component)) {
24
- const comp = entt.getComponent(component);
25
- // console.log('comp', comp.constructor.name, typeof comp['update'] === 'function')
26
- if (comp.node.active && typeof comp['update'] === 'function') {
27
- comp['update'](dt);
28
- }
29
- }
30
- }
31
- }
32
- Object.defineProperty(NewSystem, 'name', { value: `${component.name}System` });
33
- core_1.GameWorld.Instance.systems.add(NewSystem);
34
- core_1.GameWorld.Instance.systems.configureOnce(NewSystem);
35
- core_1.GameWorld.Instance.listUpdate.push(NewSystem);
36
- return NewSystem;
37
- }
38
- function instantiate(ComponentType, data) {
39
- return ComponentType.create(data);
40
- }