dacha-game-systems 0.0.4 → 0.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.
- package/build/components/active-effects/active-effects.component.js +6 -9
- package/build/components/effect/effect.component.js +6 -9
- package/build/components/effect/types.js +1 -2
- package/build/components/index.js +3 -9
- package/build/components/parallax/parallax.component.js +7 -10
- package/build/events/index.js +4 -7
- package/build/index.js +2 -18
- package/build/systems/effects/effect-applicators/continuous-effect-applicator.js +2 -6
- package/build/systems/effects/effect-applicators/delayed-effect-applicator.js +4 -8
- package/build/systems/effects/effect-applicators/effect-applicator.js +2 -29
- package/build/systems/effects/effect-applicators/index.js +11 -14
- package/build/systems/effects/effect-applicators/instant-effect-applicator.js +2 -6
- package/build/systems/effects/effect-applicators/periodical-effect-applicator.js +4 -8
- package/build/systems/effects/effect-applicators/time-limited-effect-applicator.js +4 -8
- package/build/systems/effects/effect-script.js +1 -2
- package/build/systems/effects/effects.system.js +26 -52
- package/build/systems/effects/index.js +1 -5
- package/build/systems/index.js +2 -7
- package/build/systems/parallax/parallax.system.js +18 -21
- package/build/types/utils.js +1 -2
- package/build/widgets/components/effect.widget.js +18 -21
- package/build/widgets/components/index.js +1 -5
- package/build/widgets/index.js +1 -17
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9,11 +8,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
10
|
var ActiveEffects_1;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const decorators_1 = require("dacha-workbench/decorators");
|
|
16
|
-
let ActiveEffects = ActiveEffects_1 = class ActiveEffects extends dacha_1.Component {
|
|
11
|
+
import { Component } from 'dacha';
|
|
12
|
+
import { DefineComponent } from 'dacha-workbench/decorators';
|
|
13
|
+
let ActiveEffects = ActiveEffects_1 = class ActiveEffects extends Component {
|
|
17
14
|
constructor(config) {
|
|
18
15
|
super();
|
|
19
16
|
this.list = config ? [...config.list] : [];
|
|
@@ -26,10 +23,10 @@ let ActiveEffects = ActiveEffects_1 = class ActiveEffects extends dacha_1.Compon
|
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(0, decorators_1.DefineComponent)({
|
|
26
|
+
ActiveEffects = ActiveEffects_1 = __decorate([
|
|
27
|
+
DefineComponent({
|
|
32
28
|
name: 'ActiveEffects',
|
|
33
29
|
}),
|
|
34
30
|
__metadata("design:paramtypes", [Object])
|
|
35
31
|
], ActiveEffects);
|
|
32
|
+
export { ActiveEffects };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9,12 +8,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
10
|
var Effect_1;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const dacha_1 = require("dacha");
|
|
15
|
-
const decorators_1 = require("dacha-workbench/decorators");
|
|
11
|
+
import { Component } from 'dacha';
|
|
12
|
+
import { DefineComponent } from 'dacha-workbench/decorators';
|
|
16
13
|
const REMOVE_TIMEOUT = 5000;
|
|
17
|
-
let Effect = Effect_1 = class Effect extends
|
|
14
|
+
let Effect = Effect_1 = class Effect extends Component {
|
|
18
15
|
constructor(config) {
|
|
19
16
|
super();
|
|
20
17
|
this.type = config.type;
|
|
@@ -39,9 +36,8 @@ let Effect = Effect_1 = class Effect extends dacha_1.Component {
|
|
|
39
36
|
});
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(0, decorators_1.DefineComponent)({
|
|
39
|
+
Effect = Effect_1 = __decorate([
|
|
40
|
+
DefineComponent({
|
|
45
41
|
name: 'Effect',
|
|
46
42
|
getInitialState: () => ({
|
|
47
43
|
type: 'instant',
|
|
@@ -50,3 +46,4 @@ exports.Effect = Effect = Effect_1 = __decorate([
|
|
|
50
46
|
}),
|
|
51
47
|
__metadata("design:paramtypes", [Object])
|
|
52
48
|
], Effect);
|
|
49
|
+
export { Effect };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var active_effects_component_1 = require("./active-effects/active-effects.component");
|
|
5
|
-
Object.defineProperty(exports, "ActiveEffects", { enumerable: true, get: function () { return active_effects_component_1.ActiveEffects; } });
|
|
6
|
-
var effect_component_1 = require("./effect/effect.component");
|
|
7
|
-
Object.defineProperty(exports, "Effect", { enumerable: true, get: function () { return effect_component_1.Effect; } });
|
|
8
|
-
var parallax_component_1 = require("./parallax/parallax.component");
|
|
9
|
-
Object.defineProperty(exports, "Parallax", { enumerable: true, get: function () { return parallax_component_1.Parallax; } });
|
|
1
|
+
export { ActiveEffects } from './active-effects/active-effects.component';
|
|
2
|
+
export { Effect } from './effect/effect.component';
|
|
3
|
+
export { Parallax } from './parallax/parallax.component';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9,11 +8,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
10
|
var Parallax_1;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const decorators_1 = require("dacha-workbench/decorators");
|
|
16
|
-
let Parallax = Parallax_1 = class Parallax extends dacha_1.Component {
|
|
11
|
+
import { Component } from 'dacha';
|
|
12
|
+
import { DefineComponent, DefineField } from 'dacha-workbench/decorators';
|
|
13
|
+
let Parallax = Parallax_1 = class Parallax extends Component {
|
|
17
14
|
constructor(config) {
|
|
18
15
|
super();
|
|
19
16
|
this.distance = config.distance;
|
|
@@ -26,14 +23,14 @@ let Parallax = Parallax_1 = class Parallax extends dacha_1.Component {
|
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
exports.Parallax = Parallax;
|
|
30
26
|
__decorate([
|
|
31
|
-
|
|
27
|
+
DefineField(),
|
|
32
28
|
__metadata("design:type", Number)
|
|
33
29
|
], Parallax.prototype, "distance", void 0);
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
Parallax = Parallax_1 = __decorate([
|
|
31
|
+
DefineComponent({
|
|
36
32
|
name: 'Parallax',
|
|
37
33
|
}),
|
|
38
34
|
__metadata("design:paramtypes", [Object])
|
|
39
35
|
], Parallax);
|
|
36
|
+
export { Parallax };
|
package/build/events/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.RemoveEffect = 'RemoveEffect';
|
|
6
|
-
exports.ApplyEffect = 'ApplyEffect';
|
|
7
|
-
exports.CancelEffect = 'CancelEffect';
|
|
1
|
+
export const AddEffect = 'AddEffect';
|
|
2
|
+
export const RemoveEffect = 'RemoveEffect';
|
|
3
|
+
export const ApplyEffect = 'ApplyEffect';
|
|
4
|
+
export const CancelEffect = 'CancelEffect';
|
package/build/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./systems"), exports);
|
|
18
|
-
__exportStar(require("./components"), exports);
|
|
1
|
+
export * from './systems';
|
|
2
|
+
export * from './components';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ContinuousEffectApplicator = void 0;
|
|
4
|
-
const effect_applicator_1 = require("./effect-applicator");
|
|
5
|
-
class ContinuousEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
1
|
+
import { EffectApplicator } from './effect-applicator';
|
|
2
|
+
export class ContinuousEffectApplicator extends EffectApplicator {
|
|
6
3
|
constructor(script, actor) {
|
|
7
4
|
super(script, actor);
|
|
8
5
|
this.isApplied = false;
|
|
@@ -24,4 +21,3 @@ class ContinuousEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
24
21
|
this.handleCancel();
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
exports.ContinuousEffectApplicator = ContinuousEffectApplicator;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const components_1 = require("../../../components");
|
|
5
|
-
const effect_applicator_1 = require("./effect-applicator");
|
|
6
|
-
class DelayedEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
1
|
+
import { Effect } from '../../../components';
|
|
2
|
+
import { EffectApplicator } from './effect-applicator';
|
|
3
|
+
export class DelayedEffectApplicator extends EffectApplicator {
|
|
7
4
|
constructor(script, actor) {
|
|
8
5
|
super(script, actor);
|
|
9
6
|
this.isFinished = false;
|
|
@@ -12,7 +9,7 @@ class DelayedEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
12
9
|
if (this.isFinished) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
|
-
const effect = this.actor.getComponent(
|
|
12
|
+
const effect = this.actor.getComponent(Effect);
|
|
16
13
|
effect.timer -= deltaTime;
|
|
17
14
|
if (effect.timer <= 0) {
|
|
18
15
|
this.script.apply();
|
|
@@ -24,4 +21,3 @@ class DelayedEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
24
21
|
this.handleCancel();
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
exports.DelayedEffectApplicator = DelayedEffectApplicator;
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.EffectApplicator = void 0;
|
|
27
|
-
const EventType = __importStar(require("../../../events"));
|
|
28
|
-
class EffectApplicator {
|
|
1
|
+
import * as EventType from '../../../events';
|
|
2
|
+
export class EffectApplicator {
|
|
29
3
|
constructor(script, actor) {
|
|
30
4
|
this.script = script;
|
|
31
5
|
this.actor = actor;
|
|
@@ -37,4 +11,3 @@ class EffectApplicator {
|
|
|
37
11
|
this.actor.dispatchEvent(EventType.ApplyEffect);
|
|
38
12
|
}
|
|
39
13
|
}
|
|
40
|
-
exports.EffectApplicator = EffectApplicator;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
periodical: periodical_effect_applicator_1.PeriodicalEffectApplicator,
|
|
13
|
-
continuous: continuous_effect_applicator_1.ContinuousEffectApplicator,
|
|
14
|
-
timeLimited: time_limited_effect_applicator_1.TimeLimitedEffectApplicator,
|
|
1
|
+
import { InstantEffectApplicator } from './instant-effect-applicator';
|
|
2
|
+
import { DelayedEffectApplicator } from './delayed-effect-applicator';
|
|
3
|
+
import { PeriodicalEffectApplicator } from './periodical-effect-applicator';
|
|
4
|
+
import { ContinuousEffectApplicator } from './continuous-effect-applicator';
|
|
5
|
+
import { TimeLimitedEffectApplicator } from './time-limited-effect-applicator';
|
|
6
|
+
export const effectApplicators = {
|
|
7
|
+
instant: InstantEffectApplicator,
|
|
8
|
+
delayed: DelayedEffectApplicator,
|
|
9
|
+
periodical: PeriodicalEffectApplicator,
|
|
10
|
+
continuous: ContinuousEffectApplicator,
|
|
11
|
+
timeLimited: TimeLimitedEffectApplicator,
|
|
15
12
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.InstantEffectApplicator = void 0;
|
|
4
|
-
const effect_applicator_1 = require("./effect-applicator");
|
|
5
|
-
class InstantEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
1
|
+
import { EffectApplicator } from './effect-applicator';
|
|
2
|
+
export class InstantEffectApplicator extends EffectApplicator {
|
|
6
3
|
constructor(script, actor) {
|
|
7
4
|
super(script, actor);
|
|
8
5
|
this.isFinished = false;
|
|
@@ -19,4 +16,3 @@ class InstantEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
19
16
|
this.handleCancel();
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
|
-
exports.InstantEffectApplicator = InstantEffectApplicator;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const components_1 = require("../../../components");
|
|
5
|
-
const effect_applicator_1 = require("./effect-applicator");
|
|
6
|
-
class PeriodicalEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
1
|
+
import { Effect } from '../../../components';
|
|
2
|
+
import { EffectApplicator } from './effect-applicator';
|
|
3
|
+
export class PeriodicalEffectApplicator extends EffectApplicator {
|
|
7
4
|
constructor(script, actor) {
|
|
8
5
|
super(script, actor);
|
|
9
6
|
this.isFinished = false;
|
|
@@ -12,7 +9,7 @@ class PeriodicalEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
12
9
|
if (this.isFinished) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
|
-
const effect = this.actor.getComponent(
|
|
12
|
+
const effect = this.actor.getComponent(Effect);
|
|
16
13
|
effect.cooldown -= deltaTime;
|
|
17
14
|
while (effect.cooldown <= 0) {
|
|
18
15
|
this.script.apply();
|
|
@@ -30,4 +27,3 @@ class PeriodicalEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
30
27
|
this.handleCancel();
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
exports.PeriodicalEffectApplicator = PeriodicalEffectApplicator;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const components_1 = require("../../../components");
|
|
5
|
-
const effect_applicator_1 = require("./effect-applicator");
|
|
6
|
-
class TimeLimitedEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
1
|
+
import { Effect } from '../../../components';
|
|
2
|
+
import { EffectApplicator } from './effect-applicator';
|
|
3
|
+
export class TimeLimitedEffectApplicator extends EffectApplicator {
|
|
7
4
|
constructor(script, actor) {
|
|
8
5
|
super(script, actor);
|
|
9
6
|
this.isApplied = false;
|
|
@@ -13,7 +10,7 @@ class TimeLimitedEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
13
10
|
if (this.isFinished) {
|
|
14
11
|
return;
|
|
15
12
|
}
|
|
16
|
-
const effect = this.actor.getComponent(
|
|
13
|
+
const effect = this.actor.getComponent(Effect);
|
|
17
14
|
effect.duration -= deltaTime;
|
|
18
15
|
if (effect.duration <= 0) {
|
|
19
16
|
this.isFinished = true;
|
|
@@ -34,4 +31,3 @@ class TimeLimitedEffectApplicator extends effect_applicator_1.EffectApplicator {
|
|
|
34
31
|
this.handleCancel();
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.TimeLimitedEffectApplicator = TimeLimitedEffectApplicator;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,45 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const effect_applicators_1 = require("./effect-applicators");
|
|
42
|
-
let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
10
|
+
import { ActorCollection, SceneSystem } from 'dacha';
|
|
11
|
+
import { RemoveActor } from 'dacha/events';
|
|
12
|
+
import { DefineSystem } from 'dacha-workbench/decorators';
|
|
13
|
+
import * as EventType from '../../events';
|
|
14
|
+
import { ActiveEffects, Effect } from '../../components';
|
|
15
|
+
import { effectApplicators } from './effect-applicators';
|
|
16
|
+
let EffectsSystem = class EffectsSystem extends SceneSystem {
|
|
43
17
|
constructor(options) {
|
|
44
18
|
super();
|
|
45
19
|
this.handleActorRemove = (event) => {
|
|
@@ -60,23 +34,23 @@ let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
|
60
34
|
};
|
|
61
35
|
const { actorSpawner, resources = {}, scene, } = options;
|
|
62
36
|
this.scene = scene;
|
|
63
|
-
this.activeEffectsCollection = new
|
|
64
|
-
components: [
|
|
37
|
+
this.activeEffectsCollection = new ActorCollection(scene, {
|
|
38
|
+
components: [ActiveEffects],
|
|
65
39
|
});
|
|
66
|
-
this.effectsCollection = new
|
|
67
|
-
components: [
|
|
40
|
+
this.effectsCollection = new ActorCollection(scene, {
|
|
41
|
+
components: [Effect],
|
|
68
42
|
});
|
|
69
43
|
this.actorSpawner = actorSpawner;
|
|
70
44
|
this.scripts = resources;
|
|
71
45
|
this.applicatorsMap = {};
|
|
72
46
|
this.scene.addEventListener(EventType.AddEffect, this.handleAddEffect);
|
|
73
47
|
this.scene.addEventListener(EventType.RemoveEffect, this.handleRemoveEffect);
|
|
74
|
-
this.activeEffectsCollection.addEventListener(
|
|
48
|
+
this.activeEffectsCollection.addEventListener(RemoveActor, this.handleActorRemove);
|
|
75
49
|
}
|
|
76
50
|
onSceneDestroy() {
|
|
77
51
|
this.scene.removeEventListener(EventType.AddEffect, this.handleAddEffect);
|
|
78
52
|
this.scene.removeEventListener(EventType.RemoveEffect, this.handleRemoveEffect);
|
|
79
|
-
this.activeEffectsCollection.removeEventListener(
|
|
53
|
+
this.activeEffectsCollection.removeEventListener(RemoveActor, this.handleActorRemove);
|
|
80
54
|
}
|
|
81
55
|
cancelEffect(id, actor) {
|
|
82
56
|
if (!this.applicatorsMap[actor.id] || !this.applicatorsMap[actor.id][id]) {
|
|
@@ -84,11 +58,11 @@ let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
|
84
58
|
}
|
|
85
59
|
this.applicatorsMap[actor.id][id].cancel();
|
|
86
60
|
delete this.applicatorsMap[actor.id][id];
|
|
87
|
-
const activeEffects = actor.getComponent(
|
|
61
|
+
const activeEffects = actor.getComponent(ActiveEffects);
|
|
88
62
|
const effectActor = activeEffects.map[id];
|
|
89
63
|
delete activeEffects.map[id];
|
|
90
64
|
activeEffects.list = activeEffects.list.filter((activeEffectId) => id !== activeEffectId);
|
|
91
|
-
const effect = effectActor.getComponent(
|
|
65
|
+
const effect = effectActor.getComponent(Effect);
|
|
92
66
|
effect.isCancelled = true;
|
|
93
67
|
}
|
|
94
68
|
addEffect(id, actor, options) {
|
|
@@ -96,15 +70,15 @@ let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
|
96
70
|
var _b, _c;
|
|
97
71
|
const effectActor = this.actorSpawner.spawn(id);
|
|
98
72
|
actor.appendChild(effectActor);
|
|
99
|
-
const { script, type, options: constOptions, } = effectActor.getComponent(
|
|
100
|
-
if (!actor.getComponent(
|
|
101
|
-
actor.setComponent(new
|
|
73
|
+
const { script, type, options: constOptions, } = effectActor.getComponent(Effect);
|
|
74
|
+
if (!actor.getComponent(ActiveEffects)) {
|
|
75
|
+
actor.setComponent(new ActiveEffects());
|
|
102
76
|
}
|
|
103
|
-
const activeEffects = actor.getComponent(
|
|
77
|
+
const activeEffects = actor.getComponent(ActiveEffects);
|
|
104
78
|
activeEffects.list.push(id);
|
|
105
79
|
activeEffects.map[id] = effectActor;
|
|
106
80
|
const EffectScript = this.scripts[script];
|
|
107
|
-
const EffectApplicator =
|
|
81
|
+
const EffectApplicator = effectApplicators[type];
|
|
108
82
|
const effectApplicator = new EffectApplicator(new EffectScript(actor, Object.assign(Object.assign({}, constOptions), options)), effectActor);
|
|
109
83
|
(_a = (_b = this.applicatorsMap)[_c = actor.id]) !== null && _a !== void 0 ? _a : (_b[_c] = {});
|
|
110
84
|
this.applicatorsMap[actor.id][id] = effectApplicator;
|
|
@@ -112,7 +86,7 @@ let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
|
112
86
|
update(options) {
|
|
113
87
|
const { deltaTime } = options;
|
|
114
88
|
this.effectsCollection.forEach((actor) => {
|
|
115
|
-
const effect = actor.getComponent(
|
|
89
|
+
const effect = actor.getComponent(Effect);
|
|
116
90
|
if (!effect.isCancelled) {
|
|
117
91
|
return;
|
|
118
92
|
}
|
|
@@ -122,11 +96,11 @@ let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
|
122
96
|
}
|
|
123
97
|
});
|
|
124
98
|
this.activeEffectsCollection.forEach((actor) => {
|
|
125
|
-
const activeEffects = actor.getComponent(
|
|
99
|
+
const activeEffects = actor.getComponent(ActiveEffects);
|
|
126
100
|
activeEffects.list = activeEffects.list.filter((id) => {
|
|
127
101
|
const effectApplicator = this.applicatorsMap[actor.id][id];
|
|
128
102
|
const effectActor = activeEffects.map[id];
|
|
129
|
-
const effect = effectActor.getComponent(
|
|
103
|
+
const effect = effectActor.getComponent(Effect);
|
|
130
104
|
effectApplicator.update(deltaTime);
|
|
131
105
|
if (effectApplicator.isFinished) {
|
|
132
106
|
effectApplicator.cancel();
|
|
@@ -140,10 +114,10 @@ let EffectsSystem = class EffectsSystem extends dacha_1.SceneSystem {
|
|
|
140
114
|
});
|
|
141
115
|
}
|
|
142
116
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(0, decorators_1.DefineSystem)({
|
|
117
|
+
EffectsSystem = __decorate([
|
|
118
|
+
DefineSystem({
|
|
146
119
|
name: 'EffectsSystem',
|
|
147
120
|
}),
|
|
148
121
|
__metadata("design:paramtypes", [Object])
|
|
149
122
|
], EffectsSystem);
|
|
123
|
+
export { EffectsSystem };
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EffectsSystem = void 0;
|
|
4
|
-
var effects_system_1 = require("./effects.system");
|
|
5
|
-
Object.defineProperty(exports, "EffectsSystem", { enumerable: true, get: function () { return effects_system_1.EffectsSystem; } });
|
|
1
|
+
export { EffectsSystem } from './effects.system';
|
package/build/systems/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ParallaxSystem = exports.EffectsSystem = void 0;
|
|
4
|
-
var effects_system_1 = require("./effects/effects.system");
|
|
5
|
-
Object.defineProperty(exports, "EffectsSystem", { enumerable: true, get: function () { return effects_system_1.EffectsSystem; } });
|
|
6
|
-
var parallax_system_1 = require("./parallax/parallax.system");
|
|
7
|
-
Object.defineProperty(exports, "ParallaxSystem", { enumerable: true, get: function () { return parallax_system_1.ParallaxSystem; } });
|
|
1
|
+
export { EffectsSystem } from './effects/effects.system';
|
|
2
|
+
export { ParallaxSystem } from './parallax/parallax.system';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,31 +7,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const components_1 = require("../../components");
|
|
17
|
-
let ParallaxSystem = class ParallaxSystem extends dacha_1.SceneSystem {
|
|
10
|
+
import { ActorCollection, SceneSystem, CameraService, Transform, } from 'dacha';
|
|
11
|
+
import { AddActor } from 'dacha/events';
|
|
12
|
+
import { DefineSystem } from 'dacha-workbench/decorators';
|
|
13
|
+
import { Parallax } from '../../components';
|
|
14
|
+
let ParallaxSystem = class ParallaxSystem extends SceneSystem {
|
|
18
15
|
constructor(options) {
|
|
19
16
|
super();
|
|
20
17
|
this.handleAddActor = (event) => {
|
|
21
18
|
this.setStartPosition(event.actor);
|
|
22
19
|
};
|
|
23
|
-
this.actorCollection = new
|
|
24
|
-
components: [
|
|
20
|
+
this.actorCollection = new ActorCollection(options.scene, {
|
|
21
|
+
components: [Transform, Parallax],
|
|
25
22
|
});
|
|
26
|
-
this.cameraService = options.world.getService(
|
|
23
|
+
this.cameraService = options.world.getService(CameraService);
|
|
27
24
|
this.actorCollection.forEach((actor) => this.setStartPosition(actor));
|
|
28
|
-
this.actorCollection.addEventListener(
|
|
25
|
+
this.actorCollection.addEventListener(AddActor, this.handleAddActor);
|
|
29
26
|
}
|
|
30
27
|
onSceneDestroy() {
|
|
31
|
-
this.actorCollection.removeEventListener(
|
|
28
|
+
this.actorCollection.removeEventListener(AddActor, this.handleAddActor);
|
|
32
29
|
}
|
|
33
30
|
setStartPosition(actor) {
|
|
34
|
-
const transform = actor.getComponent(
|
|
35
|
-
const parallax = actor.getComponent(
|
|
31
|
+
const transform = actor.getComponent(Transform);
|
|
32
|
+
const parallax = actor.getComponent(Parallax);
|
|
36
33
|
parallax.startX = transform.offsetX;
|
|
37
34
|
parallax.startY = transform.offsetY;
|
|
38
35
|
}
|
|
@@ -41,19 +38,19 @@ let ParallaxSystem = class ParallaxSystem extends dacha_1.SceneSystem {
|
|
|
41
38
|
if (!currentCamera) {
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
|
-
const { offsetX: cameraOffsetX, offsetY: cameraOffsetY, } = currentCamera.getComponent(
|
|
41
|
+
const { offsetX: cameraOffsetX, offsetY: cameraOffsetY, } = currentCamera.getComponent(Transform);
|
|
45
42
|
this.actorCollection.forEach((actor) => {
|
|
46
|
-
const transform = actor.getComponent(
|
|
47
|
-
const parallax = actor.getComponent(
|
|
43
|
+
const transform = actor.getComponent(Transform);
|
|
44
|
+
const parallax = actor.getComponent(Parallax);
|
|
48
45
|
transform.offsetX = parallax.startX + (cameraOffsetX - parallax.startX) * parallax.distance;
|
|
49
46
|
transform.offsetY = parallax.startY + (cameraOffsetY - parallax.startY) * parallax.distance;
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
49
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(0, decorators_1.DefineSystem)({
|
|
50
|
+
ParallaxSystem = __decorate([
|
|
51
|
+
DefineSystem({
|
|
56
52
|
name: 'ParallaxSystem',
|
|
57
53
|
}),
|
|
58
54
|
__metadata("design:paramtypes", [Object])
|
|
59
55
|
], ParallaxSystem);
|
|
56
|
+
export { ParallaxSystem };
|
package/build/types/utils.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const scriptPath = (0, react_1.useMemo)(() => path.concat('script'), [path]);
|
|
16
|
-
const optionsPath = (0, react_1.useMemo)(() => path.concat('options'), [path]);
|
|
17
|
-
const scriptName = (0, dacha_workbench_1.useConfig)(scriptPath);
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback } from 'react';
|
|
3
|
+
import { Field, DependencyField, LabelledSelect, LabelledNumberInput, Widget, BehaviorWidget, useBehaviors, useConfig, useCommander, commands, defineWidget, } from 'dacha-workbench';
|
|
4
|
+
export const EffectWidget = defineWidget('Effect')(({ fields, path, }) => {
|
|
5
|
+
const { dispatch } = useCommander();
|
|
6
|
+
const behaviors = useBehaviors('EffectsSystem');
|
|
7
|
+
const typePath = useMemo(() => path.concat('type'), [path]);
|
|
8
|
+
const timerPath = useMemo(() => path.concat('timer'), [path]);
|
|
9
|
+
const frequencyPath = useMemo(() => path.concat('frequency'), [path]);
|
|
10
|
+
const durationPath = useMemo(() => path.concat('duration'), [path]);
|
|
11
|
+
const cooldownPath = useMemo(() => path.concat('cooldown'), [path]);
|
|
12
|
+
const scriptPath = useMemo(() => path.concat('script'), [path]);
|
|
13
|
+
const optionsPath = useMemo(() => path.concat('options'), [path]);
|
|
14
|
+
const scriptName = useConfig(scriptPath);
|
|
18
15
|
const availableEffects = Object.keys(behaviors !== null && behaviors !== void 0 ? behaviors : {});
|
|
19
|
-
const handleSelect =
|
|
16
|
+
const handleSelect = useCallback((newName) => {
|
|
20
17
|
var _a, _b;
|
|
21
18
|
const nextBehavior = behaviors === null || behaviors === void 0 ? void 0 : behaviors[newName];
|
|
22
19
|
if (nextBehavior) {
|
|
23
|
-
dispatch(
|
|
20
|
+
dispatch(commands.setValue(optionsPath, (_b = (_a = nextBehavior.getInitialState) === null || _a === void 0 ? void 0 : _a.call(nextBehavior)) !== null && _b !== void 0 ? _b : {}, true));
|
|
24
21
|
}
|
|
25
22
|
}, [behaviors, optionsPath]);
|
|
26
|
-
return ((
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(Widget, { path: path, fields: fields }), _jsx(Field, { path: typePath, component: LabelledSelect, label: "Type", options: [
|
|
27
24
|
'instant',
|
|
28
25
|
'delayed',
|
|
29
26
|
'periodical',
|
|
30
27
|
'continuous',
|
|
31
28
|
'timeLimited',
|
|
32
|
-
] }), (
|
|
29
|
+
] }), _jsx(DependencyField, { path: timerPath, component: LabelledNumberInput, label: "Timer", dependencyPath: typePath, dependencyValue: "delayed" }), _jsx(DependencyField, { path: frequencyPath, component: LabelledNumberInput, label: "Frequency", dependencyPath: typePath, dependencyValue: "periodical" }), _jsx(DependencyField, { path: durationPath, component: LabelledNumberInput, label: "Duration", dependencyPath: typePath, dependencyValue: "periodical|timeLimited" }), _jsx(DependencyField, { path: cooldownPath, component: LabelledNumberInput, label: "Cooldown", dependencyPath: typePath, dependencyValue: "periodical" }), _jsx(Field, { path: scriptPath, component: LabelledSelect, label: "Script", options: availableEffects, onAccept: handleSelect }), scriptName ? (_jsx(BehaviorWidget, { name: scriptName, path: optionsPath, systemName: "EffectsSystem" })) : null] }));
|
|
33
30
|
});
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EffectWidget = void 0;
|
|
4
|
-
var effect_widget_1 = require("./effect.widget");
|
|
5
|
-
Object.defineProperty(exports, "EffectWidget", { enumerable: true, get: function () { return effect_widget_1.EffectWidget; } });
|
|
1
|
+
export { EffectWidget } from './effect.widget';
|
package/build/widgets/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components"), exports);
|
|
1
|
+
export * from './components';
|