@rpgjs/client 3.1.0 → 3.3.0
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/AbstractComponent.d.ts +31 -0
- package/lib/Components/AbstractComponent.js +104 -0
- package/lib/Components/AbstractComponent.js.map +1 -0
- package/lib/Components/BarComponent.d.ts +20 -0
- package/lib/Components/BarComponent.js +168 -0
- package/lib/Components/BarComponent.js.map +1 -0
- package/lib/Components/ColorComponent.d.ts +8 -6
- package/lib/Components/ColorComponent.js +25 -11
- package/lib/Components/ColorComponent.js.map +1 -1
- package/lib/Components/Component.d.ts +27 -6
- package/lib/Components/Component.js +216 -28
- package/lib/Components/Component.js.map +1 -1
- package/lib/Components/DebugComponent.d.ts +10 -0
- package/lib/Components/DebugComponent.js +33 -0
- package/lib/Components/DebugComponent.js.map +1 -0
- package/lib/Components/IComponent.d.ts +0 -0
- package/lib/Components/IComponent.js +2 -0
- package/lib/Components/IComponent.js.map +1 -0
- package/lib/Components/ImageComponent.d.ts +8 -6
- package/lib/Components/ImageComponent.js +19 -5
- package/lib/Components/ImageComponent.js.map +1 -1
- package/lib/Components/ShapeComponent.d.ts +10 -0
- package/lib/Components/ShapeComponent.js +57 -0
- package/lib/Components/ShapeComponent.js.map +1 -0
- package/lib/Components/TextComponent.d.ts +8 -3
- package/lib/Components/TextComponent.js +26 -4
- package/lib/Components/TextComponent.js.map +1 -1
- package/lib/Components/TileComponent.d.ts +7 -6
- package/lib/Components/TileComponent.js +21 -9
- package/lib/Components/TileComponent.js.map +1 -1
- package/lib/Effects/Animation.d.ts +21 -5
- package/lib/Effects/Animation.js +42 -15
- package/lib/Effects/Animation.js.map +1 -1
- package/lib/Effects/AnimationCharacter.d.ts +4 -1
- package/lib/Effects/AnimationCharacter.js +3 -0
- package/lib/Effects/AnimationCharacter.js.map +1 -1
- package/lib/GameEngine.d.ts +6 -7
- package/lib/GameEngine.js +31 -6
- package/lib/GameEngine.js.map +1 -1
- package/lib/KeyboardControls.d.ts +21 -10
- package/lib/KeyboardControls.js +29 -4
- package/lib/KeyboardControls.js.map +1 -1
- package/lib/RpgClientEngine.d.ts +22 -16
- package/lib/RpgClientEngine.js +40 -72
- package/lib/RpgClientEngine.js.map +1 -1
- package/lib/Scene/Map.d.ts +2 -1
- package/lib/Scene/Map.js.map +1 -1
- package/lib/Scene/Scene.d.ts +1 -1
- package/lib/Scene/Scene.js +0 -5
- package/lib/Scene/Scene.js.map +1 -1
- package/lib/Sound/Sound.d.ts +47 -28
- package/lib/Sound/Sound.js +4 -2
- package/lib/Sound/Sound.js.map +1 -1
- package/lib/Sprite/Character.d.ts +3 -0
- package/lib/Sprite/Character.js +14 -2
- package/lib/Sprite/Character.js.map +1 -1
- package/lib/Sprite/Spritesheet.d.ts +85 -48
- package/lib/Sprite/Spritesheet.js +4 -2
- package/lib/Sprite/Spritesheet.js.map +1 -1
- package/lib/Sprite/Spritesheets.d.ts +2 -1
- package/lib/Sprite/Spritesheets.js.map +1 -1
- package/lib/index.d.ts +19 -19
- package/lib/index.js +22 -22
- package/lib/index.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentObject } from "@rpgjs/types";
|
|
2
|
+
import { RpgComponent } from "./Component";
|
|
3
|
+
import { GameEngineClient } from "../GameEngine";
|
|
4
|
+
export declare type CellInfo = {
|
|
5
|
+
x?: number;
|
|
6
|
+
y?: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
export declare abstract class AbstractComponent<TypeComponent extends ComponentObject<any>, ContainerType extends PIXI.Container | PIXI.Text | PIXI.Sprite | PIXI.Graphics> extends PIXI.Container {
|
|
11
|
+
protected component: RpgComponent;
|
|
12
|
+
protected value: TypeComponent['value'];
|
|
13
|
+
private _onRender$;
|
|
14
|
+
private _onDestroy$;
|
|
15
|
+
readonly onRender$: import("rxjs").Observable<AbstractComponent<TypeComponent, ContainerType>>;
|
|
16
|
+
protected readonly game: GameEngineClient;
|
|
17
|
+
protected firstRender: boolean;
|
|
18
|
+
private style;
|
|
19
|
+
private cacheText;
|
|
20
|
+
protected cell?: CellInfo;
|
|
21
|
+
constructor(component: RpgComponent, value: TypeComponent['value']);
|
|
22
|
+
getStyle<T>(): T;
|
|
23
|
+
protected parseTextAndCache(text: string): string[];
|
|
24
|
+
protected replaceText(object: any, text: string): string;
|
|
25
|
+
protected getValue(object: any, expression: any): any;
|
|
26
|
+
private verifyParams;
|
|
27
|
+
onInit(cell: CellInfo): void;
|
|
28
|
+
abstract updateRender(object: any, firstRender: boolean): void;
|
|
29
|
+
abstract cacheParams: string[];
|
|
30
|
+
onRemove(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AbstractComponent = void 0;
|
|
7
|
+
const rxjs_1 = require("rxjs");
|
|
8
|
+
const operators_1 = require("rxjs/operators");
|
|
9
|
+
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
10
|
+
const REGEXP_VAR = /{([^\}]+)}/g;
|
|
11
|
+
class AbstractComponent extends PIXI.Container {
|
|
12
|
+
constructor(component, value) {
|
|
13
|
+
var _a;
|
|
14
|
+
super();
|
|
15
|
+
this.component = component;
|
|
16
|
+
this.value = value;
|
|
17
|
+
this._onRender$ = new rxjs_1.Subject();
|
|
18
|
+
this._onDestroy$ = new rxjs_1.Subject();
|
|
19
|
+
this.onRender$ = this._onRender$.asObservable();
|
|
20
|
+
this.game = this.component.game;
|
|
21
|
+
this.firstRender = true;
|
|
22
|
+
this.style = (_a = this.value) === null || _a === void 0 ? void 0 : _a.style;
|
|
23
|
+
this.cacheText = {};
|
|
24
|
+
}
|
|
25
|
+
getStyle() {
|
|
26
|
+
return this.style || {};
|
|
27
|
+
}
|
|
28
|
+
parseTextAndCache(text) {
|
|
29
|
+
// parse text to get varariable in {} format et cache it
|
|
30
|
+
const matches = text.matchAll(REGEXP_VAR);
|
|
31
|
+
this.cacheParams = [
|
|
32
|
+
...this.cacheParams,
|
|
33
|
+
...Array.from(matches).map(match => match[1])
|
|
34
|
+
];
|
|
35
|
+
return this.cacheParams;
|
|
36
|
+
}
|
|
37
|
+
replaceText(object, text) {
|
|
38
|
+
return text.replace(REGEXP_VAR, (match, key) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const value = (0, lodash_get_1.default)(object, key);
|
|
41
|
+
if (value !== undefined) {
|
|
42
|
+
this.cacheText[key] = value;
|
|
43
|
+
return value !== null && value !== void 0 ? value : '';
|
|
44
|
+
}
|
|
45
|
+
return (_a = value !== null && value !== void 0 ? value : this.cacheText[key]) !== null && _a !== void 0 ? _a : '';
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getValue(object, expression) {
|
|
49
|
+
if (typeof expression === 'string') {
|
|
50
|
+
const value = (0, lodash_get_1.default)(object, expression);
|
|
51
|
+
if (value !== undefined) {
|
|
52
|
+
if (this.cacheParams.indexOf(expression) === -1)
|
|
53
|
+
this.cacheParams.push(expression);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return expression;
|
|
58
|
+
}
|
|
59
|
+
verifyParams() {
|
|
60
|
+
var _a;
|
|
61
|
+
const params = this.component.logic;
|
|
62
|
+
for (const param of this.cacheParams) {
|
|
63
|
+
if ((0, lodash_get_1.default)(params, param) === undefined) {
|
|
64
|
+
throw new Error(`Param ${param} not found in object ${(_a = this.component.logic) === null || _a === void 0 ? void 0 : _a.id}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
onInit(cell) {
|
|
69
|
+
var _a;
|
|
70
|
+
this.cell = cell;
|
|
71
|
+
this.verifyParams();
|
|
72
|
+
const render = (object) => {
|
|
73
|
+
const opacity = this.getValue(object, this.getStyle().opacity || this.value.opacity);
|
|
74
|
+
if (opacity !== undefined) {
|
|
75
|
+
this.alpha = Math.min(opacity, 1);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
render(this.component.logic);
|
|
79
|
+
const objectId = (_a = this.component.logic) === null || _a === void 0 ? void 0 : _a.id;
|
|
80
|
+
this.game.listenObject(objectId)
|
|
81
|
+
.pipe((0, operators_1.takeUntil)(this._onDestroy$), (0, operators_1.filter)(object => {
|
|
82
|
+
const params = object === null || object === void 0 ? void 0 : object.paramsChanged;
|
|
83
|
+
if (!params)
|
|
84
|
+
return false;
|
|
85
|
+
for (const param of this.cacheParams) {
|
|
86
|
+
if ((0, lodash_get_1.default)(params, param))
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}))
|
|
91
|
+
.subscribe(({ object }) => {
|
|
92
|
+
this.updateRender(object, this.firstRender);
|
|
93
|
+
render(object);
|
|
94
|
+
this.firstRender = false;
|
|
95
|
+
this._onRender$.next(this);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
onRemove() {
|
|
99
|
+
this._onDestroy$.next();
|
|
100
|
+
this._onDestroy$.complete();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.AbstractComponent = AbstractComponent;
|
|
104
|
+
//# sourceMappingURL=AbstractComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractComponent.js","sourceRoot":"","sources":["../../src/Components/AbstractComponent.ts"],"names":[],"mappings":";;;;;;AACA,+BAA8B;AAC9B,8CAAuD;AAEvD,4DAA4B;AAG5B,MAAM,UAAU,GAAG,aAAa,CAAA;AAIhC,MAAsB,iBAGpB,SAAQ,IAAI,CAAC,SAAS;IAYpB,YAAsB,SAAuB,EAAY,KAA6B;;QAClF,KAAK,EAAE,CAAA;QADW,cAAS,GAAT,SAAS,CAAc;QAAY,UAAK,GAAL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AC,CAAA;QAED,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QAE5B,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,SAAS,CAAC,KAAK,0CAAE,EAAE,CAAA;QAEzC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;aAC3B,IAAI,CACD,IAAA,qBAAS,EAAC,IAAI,CAAC,WAAW,CAAC,EAC3B,IAAA,kBAAM,EAAC,MAAM,CAAC,EAAE;YACZ,MAAM,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAA;YACpC,IAAI,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAA;YACzB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE;gBAClC,IAAI,IAAA,oBAAG,EAAC,MAAM,EAAE,KAAK,CAAC;oBAAE,OAAO,IAAI,CAAA;aACtC;YACD,OAAO,KAAK,CAAA;QAChB,CAAC,CAAC,CACL;aACA,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACtB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YAC3C,MAAM,CAAC,MAAM,CAAC,CAAA;YACd,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;YACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC,CAAC,CAAA;IACV,CAAC;IAKD,QAAQ;QACJ,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;QACvB,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAA;IAC/B,CAAC;CACJ;AA5GD,8CA4GC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BarComponentObject } from "@rpgjs/types";
|
|
2
|
+
import { AbstractComponent, CellInfo } from "./AbstractComponent";
|
|
3
|
+
export declare class BarComponent extends AbstractComponent<BarComponentObject, PIXI.Container> {
|
|
4
|
+
static readonly id: string;
|
|
5
|
+
private barContainer;
|
|
6
|
+
private barFill;
|
|
7
|
+
private textContainer;
|
|
8
|
+
private barHeight;
|
|
9
|
+
private text;
|
|
10
|
+
private barStyle;
|
|
11
|
+
private currentValue;
|
|
12
|
+
private maxValue;
|
|
13
|
+
private nextValue;
|
|
14
|
+
private notifier;
|
|
15
|
+
cacheParams: string[];
|
|
16
|
+
private get barWidth();
|
|
17
|
+
onInit(cell: CellInfo): void;
|
|
18
|
+
updateRender(object: any, firstRender: boolean): void;
|
|
19
|
+
onRemove(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BarComponent = void 0;
|
|
7
|
+
const common_1 = require("@rpgjs/common");
|
|
8
|
+
const AbstractComponent_1 = require("./AbstractComponent");
|
|
9
|
+
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
10
|
+
const rxjs_1 = require("rxjs");
|
|
11
|
+
const operators_1 = require("rxjs/operators");
|
|
12
|
+
const DEFAULT_COLOR = '#000000';
|
|
13
|
+
class BarComponent extends AbstractComponent_1.AbstractComponent {
|
|
14
|
+
constructor() {
|
|
15
|
+
var _a;
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.barContainer = new PIXI.Graphics();
|
|
18
|
+
this.barFill = new PIXI.Graphics();
|
|
19
|
+
this.textContainer = new PIXI.Text('');
|
|
20
|
+
this.barHeight = ((_a = this.value.style) === null || _a === void 0 ? void 0 : _a.height) || 7;
|
|
21
|
+
this.text = this.value.text || '';
|
|
22
|
+
this.barStyle = this.getStyle();
|
|
23
|
+
this.currentValue = 0;
|
|
24
|
+
this.maxValue = 0;
|
|
25
|
+
this.nextValue = 0;
|
|
26
|
+
this.notifier = new rxjs_1.Subject();
|
|
27
|
+
this.cacheParams = [];
|
|
28
|
+
}
|
|
29
|
+
get barWidth() {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return ((_a = this.barStyle) === null || _a === void 0 ? void 0 : _a.width) || ((_b = this.cell) === null || _b === void 0 ? void 0 : _b.width) || 0;
|
|
32
|
+
}
|
|
33
|
+
onInit(cell) {
|
|
34
|
+
if (!this.value.style) {
|
|
35
|
+
this.value.style = {
|
|
36
|
+
fillColor: '#ffffff',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const { bgColor = DEFAULT_COLOR, borderColor = DEFAULT_COLOR, borderWidth = 1, borderRadius = 0 } = this.barStyle || {};
|
|
40
|
+
this.cell = cell;
|
|
41
|
+
this.barContainer.beginFill(common_1.Utils.hexaToNumber(bgColor));
|
|
42
|
+
const paramsRect = [0, 0, this.barWidth, this.barHeight];
|
|
43
|
+
if (borderWidth) {
|
|
44
|
+
this.barContainer.lineStyle(borderWidth, common_1.Utils.hexaToNumber(borderColor), borderWidth);
|
|
45
|
+
}
|
|
46
|
+
if (borderRadius) {
|
|
47
|
+
this.barContainer.drawRoundedRect(...paramsRect, borderRadius);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.barContainer.drawRect(...paramsRect);
|
|
51
|
+
}
|
|
52
|
+
this.barContainer.endFill();
|
|
53
|
+
this.textContainer.style = {
|
|
54
|
+
fontSize: 10,
|
|
55
|
+
fill: '#ffffff',
|
|
56
|
+
fontWeight: 'bold'
|
|
57
|
+
};
|
|
58
|
+
// 5 is the padding
|
|
59
|
+
this.textContainer.y -= this.barHeight + this.textContainer.height - 5;
|
|
60
|
+
if (this.text)
|
|
61
|
+
this.addChild(this.textContainer);
|
|
62
|
+
this.addChild(this.barContainer);
|
|
63
|
+
this.barContainer.addChild(this.barFill);
|
|
64
|
+
this.cacheParams = [this.value.current, this.value.max];
|
|
65
|
+
super.onInit(cell);
|
|
66
|
+
}
|
|
67
|
+
updateRender(object, firstRender) {
|
|
68
|
+
var _a, _b, _c, _d, _e;
|
|
69
|
+
this.currentValue = this.nextValue;
|
|
70
|
+
this.nextValue = (_b = (_a = (0, lodash_get_1.default)(object, this.value.current)) !== null && _a !== void 0 ? _a : this.nextValue) !== null && _b !== void 0 ? _b : 0;
|
|
71
|
+
this.maxValue = (_c = (0, lodash_get_1.default)(object, this.value.max)) !== null && _c !== void 0 ? _c : this.maxValue;
|
|
72
|
+
const style = this.barStyle;
|
|
73
|
+
const borderRadius = (_d = style === null || style === void 0 ? void 0 : style.borderRadius) !== null && _d !== void 0 ? _d : 0;
|
|
74
|
+
const borderWidth = (_e = style === null || style === void 0 ? void 0 : style.borderWidth) !== null && _e !== void 0 ? _e : 0;
|
|
75
|
+
// first render
|
|
76
|
+
if (firstRender) {
|
|
77
|
+
this.currentValue = this.nextValue;
|
|
78
|
+
}
|
|
79
|
+
const getColor = (value) => {
|
|
80
|
+
let determineLastColor = DEFAULT_COLOR;
|
|
81
|
+
const percent = Math.max(0, (value / this.maxValue) * 100);
|
|
82
|
+
const perPercent = style.perPercent;
|
|
83
|
+
if (perPercent) {
|
|
84
|
+
for (const p in perPercent) {
|
|
85
|
+
if (percent <= +p) {
|
|
86
|
+
determineLastColor = perPercent[p].fillColor;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
determineLastColor = this.value.style.fillColor;
|
|
93
|
+
}
|
|
94
|
+
return determineLastColor;
|
|
95
|
+
};
|
|
96
|
+
let colors = [];
|
|
97
|
+
if (style) {
|
|
98
|
+
// TODO: add transition color
|
|
99
|
+
colors = (0, common_1.transitionColor)(getColor(this.currentValue), getColor(this.nextValue), 1);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
colors = (0, common_1.transitionColor)(DEFAULT_COLOR, DEFAULT_COLOR, 1);
|
|
103
|
+
}
|
|
104
|
+
const render = (up = false) => {
|
|
105
|
+
let currentValue = ~~this.currentValue;
|
|
106
|
+
if (currentValue < 0)
|
|
107
|
+
currentValue = 0;
|
|
108
|
+
if (currentValue > this.maxValue)
|
|
109
|
+
currentValue = this.maxValue;
|
|
110
|
+
const percentBetween = ~~Math.max(0, ((currentValue - this.nextValue) * 100) / this.nextValue);
|
|
111
|
+
const colorIndex = Math.max(Math.floor((100 - percentBetween) / (100 / (colors.length - 1))), 0);
|
|
112
|
+
let fillColor = colors[colorIndex];
|
|
113
|
+
this.barFill.clear();
|
|
114
|
+
this.barFill.beginFill(common_1.Utils.hexaToNumber(fillColor !== null && fillColor !== void 0 ? fillColor : DEFAULT_COLOR));
|
|
115
|
+
const percent = Math.max(0, (currentValue / this.maxValue));
|
|
116
|
+
const bWidth = borderWidth / 4;
|
|
117
|
+
const paramsRect = [bWidth, bWidth, percent * this.barWidth - bWidth, this.barHeight - bWidth];
|
|
118
|
+
if (percent > 0) {
|
|
119
|
+
if (borderRadius) {
|
|
120
|
+
this.barFill.drawRoundedRect(...paramsRect, borderRadius);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.barFill.drawRect(...paramsRect);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
this.textContainer.text = this.replaceText(Object.assign(Object.assign({}, object), { $current: currentValue, $percent: Math.round(percent * 100), $max: this.maxValue }), this.text);
|
|
127
|
+
this.barFill.endFill();
|
|
128
|
+
};
|
|
129
|
+
if (firstRender) {
|
|
130
|
+
render();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this.notifier.next();
|
|
134
|
+
this.game.clientEngine.tick
|
|
135
|
+
.pipe((0, operators_1.takeUntil)(this.notifier))
|
|
136
|
+
.subscribe(() => {
|
|
137
|
+
// speed of animation, calculate the difference between the current value and the next value to determine the speed
|
|
138
|
+
const speed = Math.abs(this.currentValue - this.nextValue) / 10;
|
|
139
|
+
let up = false;
|
|
140
|
+
// if the current value is less than the next value, add the speed to the current value
|
|
141
|
+
if (this.currentValue < this.nextValue) {
|
|
142
|
+
this.currentValue += speed;
|
|
143
|
+
up = true;
|
|
144
|
+
}
|
|
145
|
+
// if the current value is greater than the next value, subtract the speed from the current value
|
|
146
|
+
else if (this.currentValue > this.nextValue) {
|
|
147
|
+
this.currentValue -= speed;
|
|
148
|
+
up = false;
|
|
149
|
+
}
|
|
150
|
+
render(up);
|
|
151
|
+
const currentValue = Math.round(this.currentValue);
|
|
152
|
+
if (!up && (~~currentValue <= ~~this.nextValue || currentValue <= 0)) {
|
|
153
|
+
this.notifier.next();
|
|
154
|
+
}
|
|
155
|
+
else if (up && (~~currentValue >= ~~this.nextValue || currentValue >= this.maxValue)) {
|
|
156
|
+
this.notifier.next();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
onRemove() {
|
|
161
|
+
this.notifier.next();
|
|
162
|
+
this.notifier.complete();
|
|
163
|
+
super.onRemove();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.BarComponent = BarComponent;
|
|
167
|
+
BarComponent.id = 'bar';
|
|
168
|
+
//# sourceMappingURL=BarComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarComponent.js","sourceRoot":"","sources":["../../src/Components/BarComponent.ts"],"names":[],"mappings":";;;;;;AACA,0CAAsD;AACtD,2DAAiE;AAEjE,4DAA4B;AAC5B,+BAA8B;AAC9B,8CAA0C;AAE1C,MAAM,aAAa,GAAG,SAAS,CAAA;AAE/B,MAAa,YAAa,SAAQ,qCAAqD;IAAvF;;;QAEY,iBAAY,GAAkB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClD,YAAO,GAAkB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC7C,kBAAa,GAAc,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC5C,cAAS,GAAW,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,MAAM,KAAI,CAAC,CAAC;QA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AE,CAAC,CAAA;YAEV,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAElD,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,YAAY,IAAI,CAAC,CAAC,EAAE;gBAClE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;aACvB;iBACI,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAClF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;aACvB;QACL,CAAC,CAAC,CAAA;IACV,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;QACpB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACxB,KAAK,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC;;AArKL,oCAsKC;AArKmB,eAAE,GAAW,KAAK,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
color: string;
|
|
1
|
+
import { AbstractComponent, CellInfo } from "./AbstractComponent";
|
|
2
|
+
import { ColorComponentObject } from "@rpgjs/types";
|
|
3
|
+
export declare class ColorComponent extends AbstractComponent<ColorComponentObject, PIXI.Graphics> {
|
|
5
4
|
static readonly id: string;
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
color: string;
|
|
6
|
+
cacheParams: string[];
|
|
7
|
+
private container;
|
|
8
|
+
onInit(cell: CellInfo): void;
|
|
9
|
+
updateRender(object: any): void;
|
|
8
10
|
}
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ColorComponent = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.
|
|
4
|
+
const common_1 = require("@rpgjs/common");
|
|
5
|
+
const AbstractComponent_1 = require("./AbstractComponent");
|
|
6
|
+
class ColorComponent extends AbstractComponent_1.AbstractComponent {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.color = '#000000';
|
|
10
|
+
this.cacheParams = [];
|
|
11
|
+
this.container = new PIXI.Graphics();
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
onInit(cell) {
|
|
14
|
+
if (typeof this.value == 'string') {
|
|
15
|
+
this.color = this.value;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.color = this.value.color;
|
|
19
|
+
}
|
|
20
|
+
this.updateRender({});
|
|
21
|
+
this.addChild(this.container);
|
|
22
|
+
super.onInit(cell);
|
|
23
|
+
}
|
|
24
|
+
updateRender(object) {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
this.container.clear();
|
|
27
|
+
this.container.beginFill(common_1.Utils.hexaToNumber(this.color));
|
|
28
|
+
this.container.drawRect(0, 0, (_b = (_a = this.cell) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0, (_d = (_c = this.cell) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0);
|
|
29
|
+
this.container.endFill();
|
|
16
30
|
}
|
|
17
31
|
}
|
|
18
32
|
exports.ColorComponent = ColorComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorComponent.js","sourceRoot":"","sources":["../../src/Components/ColorComponent.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ColorComponent.js","sourceRoot":"","sources":["../../src/Components/ColorComponent.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AACrC,2DAAiE;AAGjE,MAAa,cAAe,SAAQ,qCAAsD;IAA1F;;QAEI,UAAK,GAAW,SAAS,CAAA;QACzB,gBAAW,GAAa,EAAE,CAAA;QAClB,cAAS,GAAkB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAA;IAwB1D,CAAC;IAtBG,MAAM,CAAC,IAAc;QACjB,IAAI,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ,EAAE;YAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;SAC1B;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;SAChC;QACD,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;QACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC7B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IAED,YAAY,CAAC,MAAW;;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,cAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QACxD,IAAI,CAAC,SAAS,CAAC,QAAQ,CACnB,CAAC,EACD,CAAC,EACD,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,mCAAI,CAAC,EACrB,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,MAAM,mCAAI,CAAC,CACzB,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;IAC5B,CAAC;;AA3BL,wCA4BC;AA3BmB,iBAAE,GAAW,OAAO,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Direction, RpgCommonPlayer, RpgShape } from "@rpgjs/common";
|
|
2
|
+
import { LayoutPositionEnum, PositionXY } from "@rpgjs/types";
|
|
2
3
|
import { Scene } from "../Scene/Scene";
|
|
3
4
|
export interface IComponent {
|
|
4
5
|
id: string;
|
|
@@ -17,7 +18,13 @@ export declare class RpgComponent<T = any> extends PIXI.Container {
|
|
|
17
18
|
private components;
|
|
18
19
|
private direction;
|
|
19
20
|
private container;
|
|
21
|
+
private containersLayout;
|
|
22
|
+
private subscriptionGraphic;
|
|
23
|
+
private layoutNotifierClear;
|
|
20
24
|
private registerComponents;
|
|
25
|
+
private dragMode?;
|
|
26
|
+
readonly game: import("../GameEngine").GameEngineClient;
|
|
27
|
+
readonly id: string;
|
|
21
28
|
constructor(data: RpgCommonPlayer | RpgShape, scene: Scene);
|
|
22
29
|
/**
|
|
23
30
|
* the direction of the sprite
|
|
@@ -72,6 +79,7 @@ export declare class RpgComponent<T = any> extends PIXI.Container {
|
|
|
72
79
|
get guiDisplay(): boolean;
|
|
73
80
|
set guiDisplay(val: boolean);
|
|
74
81
|
setPosition(smooth?: boolean): void;
|
|
82
|
+
drag(): void;
|
|
75
83
|
update(obj: any, objChanged: any, time: number, deltaRatio: number): {
|
|
76
84
|
moving: boolean;
|
|
77
85
|
};
|
|
@@ -88,15 +96,28 @@ export declare class RpgComponent<T = any> extends PIXI.Container {
|
|
|
88
96
|
* @returns { x: number, y: number }
|
|
89
97
|
* @memberof RpgSprite
|
|
90
98
|
*/
|
|
91
|
-
getPositionsOfGraphic(align: string):
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
getPositionsOfGraphic(align: string): PositionXY;
|
|
100
|
+
/**
|
|
101
|
+
* Get the container by position (center, left, right, top, bottom)
|
|
102
|
+
*
|
|
103
|
+
* @param {LayoutPositionEnum} [position=center]
|
|
104
|
+
* @returns {PIXI.Container}
|
|
105
|
+
*
|
|
106
|
+
* */
|
|
107
|
+
getLayoutContainer(position?: LayoutPositionEnum): PIXI.Container;
|
|
108
|
+
/**
|
|
109
|
+
* Get Current Scene. Scene is a map, battle, menu, etc.
|
|
110
|
+
* @returns {T}
|
|
111
|
+
*/
|
|
97
112
|
getScene<T>(): T;
|
|
98
113
|
onInit(): void;
|
|
99
114
|
onUpdate(obj: any): void;
|
|
100
115
|
onMove(): void;
|
|
101
116
|
onChanges(data: any, old: any): void;
|
|
117
|
+
private callMethodInComponents;
|
|
118
|
+
private createGrid;
|
|
119
|
+
private applyComponent;
|
|
120
|
+
private createComponentCenter;
|
|
121
|
+
private refreshComponents;
|
|
122
|
+
private updateComponents;
|
|
102
123
|
}
|