@civ-clone/base-unit-action-goto 0.1.1 → 0.1.2
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/moveAlongPath.d.ts +6 -1
- package/lib/moveAlongPath.js +8 -3
- package/lib/moveAlongPath.js.map +1 -1
- package/lib/moveAlongPath.ts +17 -4
- package/package.json +1 -1
package/lib/moveAlongPath.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { StrategyNoteRegistry } from '@civ-clone/core-strategy/StrategyNoteRegistry';
|
|
1
2
|
import Path from '@civ-clone/core-world-path/Path';
|
|
2
3
|
import Unit from '@civ-clone/core-unit/Unit';
|
|
3
|
-
export declare const moveAlongPath: (
|
|
4
|
+
export declare const moveAlongPath: (
|
|
5
|
+
unit: Unit,
|
|
6
|
+
path: Path,
|
|
7
|
+
strategyNoteRegistry?: StrategyNoteRegistry
|
|
8
|
+
) => void;
|
|
4
9
|
export default moveAlongPath;
|
package/lib/moveAlongPath.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.moveAlongPath = void 0;
|
|
4
|
+
const StrategyNoteRegistry_1 = require("@civ-clone/core-strategy/StrategyNoteRegistry");
|
|
4
5
|
const Move_1 = require("@civ-clone/base-unit-action-move/Move");
|
|
5
6
|
const NoOrders_1 = require("@civ-clone/base-unit-action-no-orders/NoOrders");
|
|
6
|
-
const
|
|
7
|
+
const GoTo_1 = require("../GoTo");
|
|
8
|
+
const moveAlongPath = (unit, path, strategyNoteRegistry = StrategyNoteRegistry_1.instance) => {
|
|
7
9
|
while (unit.moves().value() > 0.25) {
|
|
8
10
|
const [move] = unit
|
|
9
11
|
.actions(path.shift())
|
|
@@ -16,9 +18,12 @@ const moveAlongPath = (unit, path) => {
|
|
|
16
18
|
if (path.length === 0) {
|
|
17
19
|
unit.setBusy();
|
|
18
20
|
unit.setActive();
|
|
21
|
+
const note = strategyNoteRegistry.getByKey((0, GoTo_1.generateKey)(unit));
|
|
22
|
+
if (note) {
|
|
23
|
+
strategyNoteRegistry.unregister(note);
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
|
-
if (unit.moves().value()
|
|
21
|
-
unit.setActive(false);
|
|
26
|
+
if (unit.moves().value() > 0.25) {
|
|
22
27
|
return;
|
|
23
28
|
}
|
|
24
29
|
const [noOrders] = unit
|
package/lib/moveAlongPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moveAlongPath.js","sourceRoot":"","sources":["moveAlongPath.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"moveAlongPath.js","sourceRoot":"","sources":["moveAlongPath.ts"],"names":[],"mappings":";;;AAAA,wFAGuD;AAEvD,gEAAyD;AACzD,6EAAsE;AAGtE,kCAAsC;AAE/B,MAAM,aAAa,GAAG,CAC3B,IAAU,EACV,IAAU,EACV,uBAA6C,+BAA4B,EACnE,EAAE;IACR,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,IAAI,EAAE;QAClC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI;aAChB,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;aACrB,MAAM,CACL,CAAC,MAAqB,EAAkB,EAAE,CAAC,MAAM,YAAY,cAAI,CAClE,CAAC;QAEJ,IAAI,CAAC,IAAI,EAAE;YACT,MAAM;SACP;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;KAChB;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,EAAE,CAAC;QAEjB,MAAM,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC,CAAC;QAE9D,IAAI,IAAI,EAAE;YACR,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACvC;KACF;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,IAAI,EAAE;QAC/B,OAAO;KACR;IAED,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI;SACpB,OAAO,EAAE;SACT,MAAM,CAAC,CAAC,MAAM,EAAsB,EAAE,CAAC,MAAM,YAAY,kBAAQ,CAAC,CAAC;IAEtE,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnB,OAAO;KACR;IAED,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC,CAAC;AA9CW,QAAA,aAAa,iBA8CxB;AAEF,kBAAe,qBAAa,CAAC"}
|
package/lib/moveAlongPath.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StrategyNoteRegistry,
|
|
3
|
+
instance as strategyNoteRegistryInstance,
|
|
4
|
+
} from '@civ-clone/core-strategy/StrategyNoteRegistry';
|
|
1
5
|
import Action from '@civ-clone/core-unit/Action';
|
|
2
6
|
import Move from '@civ-clone/base-unit-action-move/Move';
|
|
3
7
|
import NoOrders from '@civ-clone/base-unit-action-no-orders/NoOrders';
|
|
4
8
|
import Path from '@civ-clone/core-world-path/Path';
|
|
5
9
|
import Unit from '@civ-clone/core-unit/Unit';
|
|
10
|
+
import { generateKey } from '../GoTo';
|
|
6
11
|
|
|
7
|
-
export const moveAlongPath = (
|
|
12
|
+
export const moveAlongPath = (
|
|
13
|
+
unit: Unit,
|
|
14
|
+
path: Path,
|
|
15
|
+
strategyNoteRegistry: StrategyNoteRegistry = strategyNoteRegistryInstance
|
|
16
|
+
): void => {
|
|
8
17
|
while (unit.moves().value() > 0.25) {
|
|
9
18
|
const [move] = unit
|
|
10
19
|
.actions(path.shift())
|
|
@@ -22,11 +31,15 @@ export const moveAlongPath = (unit: Unit, path: Path): void => {
|
|
|
22
31
|
if (path.length === 0) {
|
|
23
32
|
unit.setBusy();
|
|
24
33
|
unit.setActive();
|
|
25
|
-
}
|
|
26
34
|
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
const note = strategyNoteRegistry.getByKey(generateKey(unit));
|
|
36
|
+
|
|
37
|
+
if (note) {
|
|
38
|
+
strategyNoteRegistry.unregister(note);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
29
41
|
|
|
42
|
+
if (unit.moves().value() > 0.25) {
|
|
30
43
|
return;
|
|
31
44
|
}
|
|
32
45
|
|