bard-legends-framework 0.2.12 → 0.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/dist/physics/entitity-types/immovable-physics-entity.d.ts +2 -2
- package/dist/physics/entitity-types/immovable-physics-entity.js +3 -2
- package/dist/physics/entitity-types/immovable-physics-entity.js.map +1 -1
- package/dist/physics/entitity-types/movable-entity.d.ts +3 -3
- package/dist/physics/entitity-types/movable-entity.js +4 -6
- package/dist/physics/entitity-types/movable-entity.js.map +1 -1
- package/dist/physics/entitity-types/movable-physics-entity.d.ts +3 -3
- package/dist/physics/entitity-types/movable-physics-entity.js +5 -4
- package/dist/physics/entitity-types/movable-physics-entity.js.map +1 -1
- package/dist/physics/entitity-types/physics-entity.js +1 -1
- package/dist/physics/entitity-types/physics-entity.js.map +1 -1
- package/dist/physics/helpers/p2js.helper.d.ts +3 -3
- package/dist/physics/helpers/p2js.helper.js +7 -6
- package/dist/physics/helpers/p2js.helper.js.map +1 -1
- package/dist/physics/interfaces.d.ts +10 -10
- package/dist/physics/interfaces.js.map +1 -1
- package/dist/physics/physics-world.d.ts +8 -8
- package/dist/physics/physics-world.js +2 -2
- package/dist/physics/physics-world.js.map +1 -1
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.d.ts +3 -3
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.js +3 -6
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.js.map +1 -1
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.d.ts +2 -2
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.js +2 -4
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.js.map +1 -1
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.d.ts +5 -5
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.js +2 -5
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.js.map +1 -1
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.js +5 -5
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.js.map +1 -1
- package/dist/physics/sub-elements/collisions/physics-collision.js +4 -5
- package/dist/physics/sub-elements/collisions/physics-collision.js.map +1 -1
- package/dist/physics/sub-elements/elements/physics-world-borders.d.ts +2 -2
- package/dist/physics/sub-elements/elements/physics-world-borders.js +5 -4
- package/dist/physics/sub-elements/elements/physics-world-borders.js.map +1 -1
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.d.ts +4 -4
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.js +2 -2
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.js.map +1 -1
- package/dist/physics/sub-elements/raycasting/physics-explosion.d.ts +2 -2
- package/dist/physics/sub-elements/raycasting/physics-explosion.js +8 -8
- package/dist/physics/sub-elements/raycasting/physics-explosion.js.map +1 -1
- package/dist/physics/sub-elements/raycasting/ray-cast.d.ts +7 -8
- package/dist/physics/sub-elements/raycasting/ray-cast.js +8 -11
- package/dist/physics/sub-elements/raycasting/ray-cast.js.map +1 -1
- package/dist/pixi/display-object/display-object-attributes.d.ts +5 -5
- package/dist/pixi/display-object/display-object-attributes.js +3 -2
- package/dist/pixi/display-object/display-object-attributes.js.map +1 -1
- package/dist/pixi/display-object/objects/graphics.d.ts +7 -7
- package/dist/pixi/display-object/objects/graphics.js +2 -2
- package/dist/pixi/display-object/objects/graphics.js.map +1 -1
- package/dist/pixi/display-object/objects/sprite.d.ts +6 -6
- package/dist/pixi/display-object/objects/sprite.js +4 -3
- package/dist/pixi/display-object/objects/sprite.js.map +1 -1
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.d.ts +2 -2
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.js +3 -2
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.js.map +1 -1
- package/dist/pixi/game.d.ts +3 -3
- package/dist/pixi/game.js +3 -2
- package/dist/pixi/game.js.map +1 -1
- package/dist/pixi/helpers/glow-sprite-generator.d.ts +1 -1
- package/dist/pixi/helpers/glow-sprite-generator.js +4 -3
- package/dist/pixi/helpers/glow-sprite-generator.js.map +1 -1
- package/dist/pixi/helpers/pixi-container.helper.js +2 -4
- package/dist/pixi/helpers/pixi-container.helper.js.map +1 -1
- package/dist/pixi/index.d.ts +2 -2
- package/dist/utilities/libraries/data-structures/grid/grid.d.ts +16 -16
- package/dist/utilities/libraries/data-structures/grid/grid.js +19 -36
- package/dist/utilities/libraries/data-structures/grid/grid.js.map +1 -1
- package/dist/utilities/libraries/data-structures/grid/grid.test.js +54 -51
- package/dist/utilities/libraries/data-structures/grid/grid.test.js.map +1 -1
- package/dist/utilities/libraries/data-structures/vector-set/vector-set.d.ts +4 -4
- package/dist/utilities/libraries/data-structures/vector-set/vector-set.js.map +1 -1
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +3 -3
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.js +7 -23
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.js.map +1 -1
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +54 -23
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.test.js.map +1 -1
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.d.ts +3 -3
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.js +1 -1
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.js.map +1 -1
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.test.js +25 -27
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.test.js.map +1 -1
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +2 -2
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +8 -9
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js.map +1 -1
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +48 -48
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js.map +1 -1
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.d.ts +2 -2
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js +2 -2
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js.map +1 -1
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js +51 -17
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js.map +1 -1
- package/dist/utilities/services/mouse/mouse-target-focus.service.d.ts +3 -3
- package/dist/utilities/services/mouse/mouse-target-focus.service.js.map +1 -1
- package/dist/utilities/services/mouse/mouse.service.d.ts +4 -4
- package/dist/utilities/services/mouse/mouse.service.js +5 -4
- package/dist/utilities/services/mouse/mouse.service.js.map +1 -1
- package/package.json +3 -3
- package/package.json.bak +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Action } from 'actions-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { Vector } from 'helpers-lib';
|
|
3
3
|
import { PhysicsWorld } from '../physics-world';
|
|
4
4
|
import { PhysicsBodyDTO, PhysicsEntityDefinition, CollisionReport } from '../interfaces';
|
|
5
5
|
import { PhysicsEntity } from './physics-entity';
|
|
6
6
|
export declare abstract class ImmovablePhysicsEntity extends PhysicsEntity {
|
|
7
|
-
readonly position:
|
|
7
|
+
readonly position: Vector;
|
|
8
8
|
readonly rotation: number;
|
|
9
9
|
readonly onCollision: Action<CollisionReport[]>;
|
|
10
10
|
constructor(physicsWorld: PhysicsWorld | string, physicsEntityDefinition: PhysicsEntityDefinition);
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImmovablePhysicsEntity = void 0;
|
|
4
4
|
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
5
6
|
const physics_entity_1 = require("./physics-entity");
|
|
6
7
|
const p2js_helper_1 = require("../helpers/p2js.helper");
|
|
7
8
|
class ImmovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
8
9
|
constructor(physicsWorld, physicsEntityDefinition) {
|
|
9
10
|
super(physicsWorld, physicsEntityDefinition, 'static');
|
|
10
11
|
this.onCollision = new actions_lib_1.Action();
|
|
11
|
-
this.position = p2js_helper_1.P2JSHelper.
|
|
12
|
+
this.position = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.position);
|
|
12
13
|
this.rotation = this.p2Body.angle;
|
|
13
14
|
}
|
|
14
15
|
destroy() { }
|
|
@@ -18,7 +19,7 @@ class ImmovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
|
18
19
|
entityClassName: this.constructor.name,
|
|
19
20
|
position: this.position,
|
|
20
21
|
rotation: this.rotation,
|
|
21
|
-
velocity:
|
|
22
|
+
velocity: helpers_lib_1.Vector.zero,
|
|
22
23
|
rotationalSpeed: 0
|
|
23
24
|
};
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"immovable-physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entitity-types/immovable-physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;
|
|
1
|
+
{"version":3,"file":"immovable-physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entitity-types/immovable-physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AACrC,6CAAqC;AAIrC,qDAAiD;AACjD,wDAAoD;AAEpD,MAAsB,sBAAuB,SAAQ,8BAAa;IAMhE,YAAY,YAAmC,EAAE,uBAAgD;QAC/F,KAAK,CAAC,YAAY,EAAE,uBAAuB,EAAE,QAAQ,CAAC,CAAC;QAHhD,gBAAW,GAAG,IAAI,oBAAM,EAAqB,CAAC;QAKrD,IAAI,CAAC,QAAQ,GAAG,wBAAU,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,OAAO,KAAU,CAAC;IAElB,YAAY;QACV,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,EAAE;YACjB,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,oBAAM,CAAC,IAAI;YACrB,eAAe,EAAE,CAAC;SACnB,CAAC;IACJ,CAAC;CACF;AAzBD,wDAyBC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Variable } from 'actions-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { Vector } from 'helpers-lib';
|
|
3
3
|
import { Entity } from '../../game-entities';
|
|
4
4
|
export declare abstract class MovableEntity extends Entity {
|
|
5
|
-
readonly position: Variable<
|
|
5
|
+
readonly position: Variable<Vector>;
|
|
6
6
|
readonly rotation: Variable<number>;
|
|
7
|
-
readonly velocity: Variable<
|
|
7
|
+
readonly velocity: Variable<Vector>;
|
|
8
8
|
readonly rotationalSpeed: Variable<number>;
|
|
9
9
|
constructor();
|
|
10
10
|
private step;
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MovableEntity = void 0;
|
|
4
4
|
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
5
6
|
const game_entities_1 = require("../../game-entities");
|
|
6
7
|
class MovableEntity extends game_entities_1.Entity {
|
|
7
8
|
constructor() {
|
|
8
9
|
super();
|
|
9
|
-
this.position = new actions_lib_1.Variable().set(
|
|
10
|
+
this.position = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
|
|
10
11
|
this.rotation = new actions_lib_1.Variable().set(0);
|
|
11
|
-
this.velocity = new actions_lib_1.Variable().set(
|
|
12
|
+
this.velocity = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
|
|
12
13
|
this.rotationalSpeed = new actions_lib_1.Variable().set(0);
|
|
13
14
|
game_entities_1.UpdateCycle.beforeSceneUpdateAction
|
|
14
15
|
.subscribe(({ time, delta }) => {
|
|
@@ -17,10 +18,7 @@ class MovableEntity extends game_entities_1.Entity {
|
|
|
17
18
|
.attach(this);
|
|
18
19
|
}
|
|
19
20
|
step(time, delta) {
|
|
20
|
-
this.position.value =
|
|
21
|
-
x: this.position.value.x + this.velocity.value.x * delta,
|
|
22
|
-
y: this.position.value.y + this.velocity.value.y * delta
|
|
23
|
-
};
|
|
21
|
+
this.position.value = this.position.value.add(this.velocity.value.multiply(delta));
|
|
24
22
|
this.rotation.value = this.rotation.value + this.rotationalSpeed.value * delta;
|
|
25
23
|
}
|
|
26
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movable-entity.js","sourceRoot":"","sources":["../../../src/physics/entitity-types/movable-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;
|
|
1
|
+
{"version":3,"file":"movable-entity.js","sourceRoot":"","sources":["../../../src/physics/entitity-types/movable-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,6CAAqC;AAErC,uDAA0D;AAE1D,MAAsB,aAAc,SAAQ,sBAAM;IAMhD;QACE,KAAK,EAAE,CAAC;QAND,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,oBAAM,CAAC,IAAI,CAAC,CAAC;QACnD,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,oBAAM,CAAC,IAAI,CAAC,CAAC;QACnD,oBAAe,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAIvD,2BAAW,CAAC,uBAAuB;aAChC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC;aACD,MAAM,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAEO,IAAI,CAAC,IAAY,EAAE,KAAa;QACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;IACjF,CAAC;CACF;AAnBD,sCAmBC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Action, Variable } from 'actions-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { Vector } from 'helpers-lib';
|
|
3
3
|
import { PhysicsWorld } from '../physics-world';
|
|
4
4
|
import { PhysicsBodyDTO, PhysicsEntityDefinition, CollisionReport } from '../interfaces';
|
|
5
5
|
import { PhysicsEntity } from './physics-entity';
|
|
6
6
|
export declare abstract class MovablePhysicsEntity extends PhysicsEntity {
|
|
7
|
-
readonly position: Variable<
|
|
7
|
+
readonly position: Variable<Vector>;
|
|
8
8
|
readonly rotation: Variable<number>;
|
|
9
|
-
readonly velocity: Variable<
|
|
9
|
+
readonly velocity: Variable<Vector>;
|
|
10
10
|
readonly rotationalSpeed: Variable<number>;
|
|
11
11
|
readonly onCollision: Action<CollisionReport[]>;
|
|
12
12
|
private ignorePositionUpdate;
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MovablePhysicsEntity = void 0;
|
|
4
4
|
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
5
6
|
const p2js_helper_1 = require("../helpers/p2js.helper");
|
|
6
7
|
const physics_entity_1 = require("./physics-entity");
|
|
7
8
|
class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
8
9
|
constructor(physicsWorld, physicsEntityDefinition) {
|
|
9
10
|
super(physicsWorld, physicsEntityDefinition, 'dynamic');
|
|
10
|
-
this.position = new actions_lib_1.Variable().set(
|
|
11
|
+
this.position = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
|
|
11
12
|
this.rotation = new actions_lib_1.Variable().set(0);
|
|
12
|
-
this.velocity = new actions_lib_1.Variable().set(
|
|
13
|
+
this.velocity = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
|
|
13
14
|
this.rotationalSpeed = new actions_lib_1.Variable().set(0);
|
|
14
15
|
this.onCollision = new actions_lib_1.Action();
|
|
15
16
|
this.ignorePositionUpdate = false;
|
|
@@ -38,9 +39,9 @@ class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
|
|
|
38
39
|
this.phsicsToLocalSync();
|
|
39
40
|
}
|
|
40
41
|
phsicsToLocalSync() {
|
|
41
|
-
this.position.value = p2js_helper_1.P2JSHelper.
|
|
42
|
+
this.position.value = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.position);
|
|
42
43
|
this.rotation.value = this.p2Body.angle;
|
|
43
|
-
this.velocity.value = p2js_helper_1.P2JSHelper.
|
|
44
|
+
this.velocity.value = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.velocity);
|
|
44
45
|
this.rotationalSpeed.value = this.p2Body.angularVelocity;
|
|
45
46
|
}
|
|
46
47
|
localToPhsicsSync() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movable-physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entitity-types/movable-physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;
|
|
1
|
+
{"version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AAI,CAAC,QAAQ;aACV,SAAS,CAAC,QAAQ,CAAC,EAAE;YACpB,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC9B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CAAC,IAAI,CAAC,CAAC;QAEhB,IAAI,CAAC,QAAQ;aACV,SAAS,CAAC,QAAQ,CAAC,EAAE;YACpB,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC9B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CAAC,IAAI,CAAC,CAAC;QAEhB,IAAI,CAAC,eAAe;aACjB,SAAS,CAAC,eAAe,CAAC,EAAE;YAC3B,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;gBACrC,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,IAAI,MAAM,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;gBACtF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;CACF;AA1FD,oDA0FC"}
|
|
@@ -66,7 +66,7 @@ class PhysicsEntity extends game_entities_1.Entity {
|
|
|
66
66
|
this.p2Body = shape_factory_1.ShapeFactory.createBody(physicsEntityDefinition, material, materialDefinition, this.type);
|
|
67
67
|
this._area = this.p2Body.getArea();
|
|
68
68
|
this._mass = this.p2Body.mass;
|
|
69
|
-
this.p2Body.position = p2js_helper_1.P2JSHelper.
|
|
69
|
+
this.p2Body.position = p2js_helper_1.P2JSHelper.vectorToArray(physicsEntityDefinition.position);
|
|
70
70
|
this.p2Body.angle = physicsEntityDefinition.rotation;
|
|
71
71
|
let addedToTheWorld = this.physicsWorld.addBody(this.p2Body, physicsEntityDefinition.addInEmptySpace, physicsEntityDefinition.shapeDefinition.group, physicsEntityDefinition.includeOnPathfinding);
|
|
72
72
|
if (!addedToTheWorld) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entitity-types/physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AAErC,6CAAyC;AAEzC,oDAAgD;AAChD,wDAAoD;AAEpD,4DAAwD;AACxD,uDAA6C;AAC7C,mEAA+D;AAG/D,MAAsB,aAAc,SAAQ,sBAAM;aACjC,0BAAqB,GAAG,IAAI,GAAG,EAAyB,AAAnC,CAAoC;aACzD,oBAAe,GAAG,IAAI,GAAG,EAAyB,AAAnC,CAAoC;IAElE,MAAM,CAAC,eAAe,CAAC,QAAgB;QACrC,OAAO,aAAa,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,qBAAqB,CAAC,QAAgB;QAC3C,IAAI,WAAW,GAAG,aAAa,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,YAAY,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,EAAU;QACxC,IAAI,aAAa,GAAG,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC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I,CAAC,MAAM,EACX,uBAAuB,CAAC,eAAe,EACvC,uBAAuB,CAAC,eAAe,CAAC,KAAK,EAC7C,uBAAuB,CAAC,oBAAoB,CAC7C,CAAC;QAEF,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,aAAa,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9D,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,OAAO,GAAG;YACb,0BAAW,CAAC,qBAAqB,CAAC,GAAG,EAAE;gBACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACzB,IAAI,CAAC,aAAa,EAAE,CAAC;gBACrB,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IAID,OAAO,KAAU,CAAC;IAElB,8BAA8B;IACpB,mBAAmB,CAAC,gBAAmC;QAC/D,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC;QACpC,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;;AApHH,sCAqHC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="p2" />
|
|
2
|
-
import { Rectangle,
|
|
2
|
+
import { Rectangle, Vector } from 'helpers-lib';
|
|
3
3
|
export declare class P2JSHelper {
|
|
4
4
|
static aabbToBoundingBox(aabb: p2.AABB): Rectangle;
|
|
5
|
-
static
|
|
6
|
-
static
|
|
5
|
+
static arrayToVector(array: [number, number]): Vector;
|
|
6
|
+
static vectorToArray(vector: Vector): [number, number];
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.P2JSHelper = void 0;
|
|
4
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
4
5
|
class P2JSHelper {
|
|
5
6
|
static aabbToBoundingBox(aabb) {
|
|
6
|
-
return {
|
|
7
|
+
return helpers_lib_1.Rectangle.fromRect({
|
|
7
8
|
topLeft: {
|
|
8
9
|
x: aabb.lowerBound[0],
|
|
9
10
|
y: aabb.lowerBound[1]
|
|
@@ -12,13 +13,13 @@ class P2JSHelper {
|
|
|
12
13
|
x: aabb.upperBound[0],
|
|
13
14
|
y: aabb.upperBound[1]
|
|
14
15
|
}
|
|
15
|
-
};
|
|
16
|
+
});
|
|
16
17
|
}
|
|
17
|
-
static
|
|
18
|
-
return
|
|
18
|
+
static arrayToVector(array) {
|
|
19
|
+
return new helpers_lib_1.Vector(array[0], array[1]);
|
|
19
20
|
}
|
|
20
|
-
static
|
|
21
|
-
return [
|
|
21
|
+
static vectorToArray(vector) {
|
|
22
|
+
return [vector.x, vector.y];
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.P2JSHelper = P2JSHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2js.helper.js","sourceRoot":"","sources":["../../../src/physics/helpers/p2js.helper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"p2js.helper.js","sourceRoot":"","sources":["../../../src/physics/helpers/p2js.helper.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,MAAa,UAAU;IACrB,MAAM,CAAC,iBAAiB,CAAC,IAAa;QACpC,OAAO,uBAAS,CAAC,QAAQ,CAAC;YACxB,OAAO,EAAE;gBACP,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;gBACrB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;aACtB;YACD,WAAW,EAAE;gBACX,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;gBACrB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;aACtB;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,KAAuB;QAC1C,OAAO,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,MAAc;QACjC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;CACF;AArBD,gCAqBC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vec2 } from 'helpers-lib';
|
|
1
|
+
import { Vec2, Vector } from 'helpers-lib';
|
|
2
2
|
import p2 from 'p2';
|
|
3
3
|
import { PhysicsBodyGroup } from './sub-elements/elements/physics-body-groups';
|
|
4
4
|
export declare const BorderMaterialName = "border";
|
|
@@ -20,8 +20,8 @@ export interface PhysicsShape {
|
|
|
20
20
|
readonly setBody: (body: p2.Body) => void;
|
|
21
21
|
}
|
|
22
22
|
export interface ImageProperties {
|
|
23
|
-
readonly size:
|
|
24
|
-
readonly anchor:
|
|
23
|
+
readonly size: Vector;
|
|
24
|
+
readonly anchor: Vector;
|
|
25
25
|
readonly scale: number;
|
|
26
26
|
}
|
|
27
27
|
export interface BorderProperties {
|
|
@@ -32,18 +32,18 @@ export interface BorderProperties {
|
|
|
32
32
|
export interface PhysicsBodyDTO {
|
|
33
33
|
readonly entityId: string;
|
|
34
34
|
readonly entityClassName: string;
|
|
35
|
-
readonly position:
|
|
35
|
+
readonly position: Vector;
|
|
36
36
|
readonly rotation: number;
|
|
37
|
-
readonly velocity:
|
|
37
|
+
readonly velocity: Vector;
|
|
38
38
|
readonly rotationalSpeed: number;
|
|
39
39
|
}
|
|
40
40
|
export interface CollisionDetails {
|
|
41
41
|
readonly body: PhysicsBodyDTO;
|
|
42
|
-
readonly getPositionReletiveToObject: () =>
|
|
43
|
-
readonly position:
|
|
42
|
+
readonly getPositionReletiveToObject: () => Vector;
|
|
43
|
+
readonly position: Vector;
|
|
44
44
|
readonly mass: number;
|
|
45
45
|
readonly area: number;
|
|
46
|
-
readonly normal:
|
|
46
|
+
readonly normal: Vector;
|
|
47
47
|
}
|
|
48
48
|
export interface CollisionReport {
|
|
49
49
|
readonly self: CollisionDetails;
|
|
@@ -59,7 +59,7 @@ export interface CircleShapeData {
|
|
|
59
59
|
readonly radius: number;
|
|
60
60
|
}
|
|
61
61
|
export interface RectangleShapeData {
|
|
62
|
-
readonly size:
|
|
62
|
+
readonly size: Vector;
|
|
63
63
|
}
|
|
64
64
|
export interface PolygonShapeData {
|
|
65
65
|
readonly boundingShapeVertices: Vec2[][] | ReadonlyArray<ReadonlyArray<Vec2>>;
|
|
@@ -75,7 +75,7 @@ export interface ShapeDefinition {
|
|
|
75
75
|
}
|
|
76
76
|
export interface PhysicsEntityDefinition {
|
|
77
77
|
readonly shapeDefinition: ShapeDefinition;
|
|
78
|
-
readonly position:
|
|
78
|
+
readonly position: Vector;
|
|
79
79
|
readonly rotation: number;
|
|
80
80
|
readonly addInEmptySpace: boolean;
|
|
81
81
|
readonly includeOnPathfinding: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/physics/interfaces.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/physics/interfaces.ts"],"names":[],"mappings":";;;AAKa,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAyD3C,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;AACzB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vector } from 'helpers-lib';
|
|
2
2
|
import { Action } from 'actions-lib';
|
|
3
3
|
import p2 from 'p2';
|
|
4
4
|
import { PhysicsMaterials } from './sub-elements/elements/physics-materials';
|
|
@@ -10,8 +10,8 @@ import { PhysicsBodyGroup } from './sub-elements/elements/physics-body-groups';
|
|
|
10
10
|
import { Grid } from '../utilities/libraries/data-structures/grid/grid';
|
|
11
11
|
import { PhysicsBodyExplosionHit } from './sub-elements/raycasting/physics-body-explosion-hit';
|
|
12
12
|
export declare class PhysicsWorld extends Entity {
|
|
13
|
-
readonly mapSize:
|
|
14
|
-
readonly mapSizeCenter:
|
|
13
|
+
readonly mapSize: Vector;
|
|
14
|
+
readonly mapSizeCenter: Vector;
|
|
15
15
|
readonly physicsMaterials: PhysicsMaterials;
|
|
16
16
|
readonly onPhysicsStep: Action<{
|
|
17
17
|
time: number;
|
|
@@ -23,7 +23,7 @@ export declare class PhysicsWorld extends Entity {
|
|
|
23
23
|
private physicsAvailableSpaces;
|
|
24
24
|
private lastP2Time;
|
|
25
25
|
private modifyUpdateCycle;
|
|
26
|
-
constructor(mapSize:
|
|
26
|
+
constructor(mapSize: Vector, borderProperties: {
|
|
27
27
|
friction: number;
|
|
28
28
|
bounciness: number;
|
|
29
29
|
stiffness: number;
|
|
@@ -34,15 +34,15 @@ export declare class PhysicsWorld extends Entity {
|
|
|
34
34
|
removeBody(body: p2.Body): void;
|
|
35
35
|
isCollidingWithAnything(p2Body: p2.Body): boolean;
|
|
36
36
|
getAvailabilityGrid(physicsBodyGroup: PhysicsBodyGroup): Grid<{
|
|
37
|
-
position:
|
|
37
|
+
position: Vector;
|
|
38
38
|
availability: boolean;
|
|
39
39
|
}>;
|
|
40
|
-
findPath(startingPosition:
|
|
40
|
+
findPath(startingPosition: Vector, target: Vector | string, options?: {
|
|
41
41
|
includeDiagonals?: boolean;
|
|
42
42
|
collidableWithGroup?: PhysicsBodyGroup;
|
|
43
43
|
}): PathFinderResult;
|
|
44
|
-
findPathDirection(startingPosition:
|
|
45
|
-
createExplosion(position:
|
|
44
|
+
findPathDirection(startingPosition: Vector, target: Vector | string, collidableWithGroup: PhysicsBodyGroup): number | undefined;
|
|
45
|
+
createExplosion(position: Vector, radius: number, physicsBodyGroup: PhysicsBodyGroup, severity: number, options?: PhysicsExplosionOptions): PhysicsBodyExplosionHit[];
|
|
46
46
|
}
|
|
47
47
|
export declare class BorderEntity extends ImmovablePhysicsEntity {
|
|
48
48
|
constructor(physicsWorld: PhysicsWorld, physicsEntityDefinition: PhysicsEntityDefinition);
|
|
@@ -30,7 +30,7 @@ let PhysicsWorld = class PhysicsWorld extends game_entities_1.Entity {
|
|
|
30
30
|
this.onPhysicsStep = new actions_lib_1.Action();
|
|
31
31
|
this.lastP2Time = 0;
|
|
32
32
|
this.mapSize = mapSize;
|
|
33
|
-
this.mapSizeCenter =
|
|
33
|
+
this.mapSizeCenter = this.mapSize.multiply(0.5);
|
|
34
34
|
this.modifyUpdateCycle = modifyUpdateCycle;
|
|
35
35
|
this.p2World = new p2_1.default.World({ gravity: [0, 0] });
|
|
36
36
|
this.physicsMaterials = new physics_materials_1.PhysicsMaterials(this.p2World, borderProperties, materialDefinitions, materialContactDefinitions);
|
|
@@ -111,7 +111,7 @@ let PhysicsWorld = class PhysicsWorld extends game_entities_1.Entity {
|
|
|
111
111
|
exports.PhysicsWorld = PhysicsWorld;
|
|
112
112
|
exports.PhysicsWorld = PhysicsWorld = __decorate([
|
|
113
113
|
(0, game_entities_1.EntityDecorator)(),
|
|
114
|
-
__metadata("design:paramtypes", [
|
|
114
|
+
__metadata("design:paramtypes", [helpers_lib_1.Vector, Object, Array, Array, Boolean])
|
|
115
115
|
], PhysicsWorld);
|
|
116
116
|
// TODO: move this under PhysicsWorldBorders. Now it is giving "PhysicsWorld cannot be accessed before it's initialization".
|
|
117
117
|
let BorderEntity = class BorderEntity extends immovable_physics_entity_1.ImmovablePhysicsEntity {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physics-world.js","sourceRoot":"","sources":["../../src/physics/physics-world.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"physics-world.js","sourceRoot":"","sources":["../../src/physics/physics-world.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAqC;AACrC,6CAAqC;AACrC,4CAAoB;AAEpB,iFAA6E;AAC7E,mFAA+E;AAE/E,oDAAwE;AACxE,yGAAoG;AACpG,yFAAoF;AACpF,uGAAkG;AAClG,wFAAmF;AAInF,mFAA+E;AAIxE,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,sBAAM;IAetC,YACE,OAAe,EACf,gBAA6E,EAC7E,mBAAsD,EACtD,0BAAoE,EACpE,oBAA6B,IAAI;QAEjC,KAAK,EAAE,CAAC;QAjBD,kBAAa,GAAG,IAAI,oBAAM,EAAmC,CAAC;QAO/D,eAAU,GAAG,CAAC,CAAC;QAWrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAE3C,IAAI,CAAC,OAAO,GAAG,IAAI,YAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,0BAA0B,CAAC,CAAC;QAC9H,IAAI,CAAC,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC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,CAAC;IAED,mBAAmB,CAAC,gBAAkC;QACpD,OAAO,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC3E,CAAC;IAED,QAAQ,CACN,gBAAwB,EACxB,MAAuB,EACvB,OAAgF;QAEhF,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACtF,CAAC;IAED,iBAAiB,CACf,gBAAwB,EACxB,MAAuB,EACvB,mBAAqC;QAErC,OAAO,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACtG,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,MAAc,EACd,gBAAkC,EAClC,QAAgB,EAChB,OAAiC;QAEjC,OAAO,oCAAgB,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvG,CAAC;CACF,CAAA;AAhIY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,+BAAe,GAAE;qCAiBL,oBAAM;GAhBN,YAAY,CAgIxB;AAED,4HAA4H;AAErH,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,iDAAsB;IACtD,YAAY,YAA0B,EAAE,uBAAgD;QACtF,KAAK,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAJY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,+BAAe,GAAE;qCAEU,YAAY;GAD3B,YAAY,CAIxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Rectangle,
|
|
1
|
+
import { Rectangle, Vector } from 'helpers-lib';
|
|
2
2
|
export declare class AvailabilityGridHelper {
|
|
3
3
|
static areaToGridArea(boundingBox: Rectangle, cellSize: number): Rectangle;
|
|
4
|
-
static positionToGridPosition(point:
|
|
5
|
-
static gridPositionToPosition(gridPosition:
|
|
4
|
+
static positionToGridPosition(point: Vector, cellSize: number): Vector;
|
|
5
|
+
static gridPositionToPosition(gridPosition: Vector, cellSize: number): Vector;
|
|
6
6
|
}
|
|
@@ -4,16 +4,13 @@ exports.AvailabilityGridHelper = void 0;
|
|
|
4
4
|
const helpers_lib_1 = require("helpers-lib");
|
|
5
5
|
class AvailabilityGridHelper {
|
|
6
6
|
static areaToGridArea(boundingBox, cellSize) {
|
|
7
|
-
return
|
|
8
|
-
topLeft: this.positionToGridPosition(boundingBox.topLeft, cellSize),
|
|
9
|
-
bottomRight: this.positionToGridPosition(boundingBox.bottomRight, cellSize)
|
|
10
|
-
};
|
|
7
|
+
return new helpers_lib_1.Rectangle(this.positionToGridPosition(boundingBox.topLeft, cellSize), this.positionToGridPosition(boundingBox.bottomRight, cellSize));
|
|
11
8
|
}
|
|
12
9
|
static positionToGridPosition(point, cellSize) {
|
|
13
|
-
return
|
|
10
|
+
return point.divide(cellSize).floor();
|
|
14
11
|
}
|
|
15
12
|
static gridPositionToPosition(gridPosition, cellSize) {
|
|
16
|
-
return
|
|
13
|
+
return gridPosition.add(new helpers_lib_1.Vector(0.5, 0.5)).multiply(cellSize);
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
16
|
exports.AvailabilityGridHelper = AvailabilityGridHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"availability-grid.helper.js","sourceRoot":"","sources":["../../../../../src/physics/sub-elements/available-spaces/helpers/availability-grid.helper.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"availability-grid.helper.js","sourceRoot":"","sources":["../../../../../src/physics/sub-elements/available-spaces/helpers/availability-grid.helper.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,MAAa,sBAAsB;IACjC,MAAM,CAAC,cAAc,CAAC,WAAsB,EAAE,QAAgB;QAC5D,OAAO,IAAI,uBAAS,CAClB,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC1D,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,KAAa,EAAE,QAAgB;QAC3D,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,YAAoB,EAAE,QAAgB;QAClE,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,oBAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;CACF;AAfD,wDAeC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="p2" />
|
|
2
|
-
import {
|
|
2
|
+
import { Vector } from 'helpers-lib';
|
|
3
3
|
import { Grid } from '../../../utilities/libraries/data-structures/grid/grid';
|
|
4
4
|
import { PhysicsBodyGroup } from '../elements/physics-body-groups';
|
|
5
5
|
export declare class PhysicsAvailabilityGrid {
|
|
6
6
|
private p2World;
|
|
7
7
|
private mapSize;
|
|
8
8
|
private availabilityGrids;
|
|
9
|
-
constructor(p2World: p2.World, mapsize:
|
|
9
|
+
constructor(p2World: p2.World, mapsize: Vector);
|
|
10
10
|
clear(): void;
|
|
11
11
|
onBodyAdded(body: p2.Body, physicsBodyGroup: PhysicsBodyGroup): void;
|
|
12
12
|
getAvilabilityGrid(cellSize: number, physicsBodyGroup?: PhysicsBodyGroup): Grid<boolean>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PhysicsAvailabilityGrid = void 0;
|
|
4
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
4
5
|
const grid_1 = require("../../../utilities/libraries/data-structures/grid/grid");
|
|
5
6
|
const p2js_helper_1 = require("../../helpers/p2js.helper");
|
|
6
7
|
const physics_body_groups_1 = require("../elements/physics-body-groups");
|
|
@@ -67,10 +68,7 @@ class PhysicsAvailabilityGrid {
|
|
|
67
68
|
return grid;
|
|
68
69
|
}
|
|
69
70
|
createGrid(cellSize, physicsBodyGroup) {
|
|
70
|
-
let grid = grid_1.Grid.createNew(
|
|
71
|
-
x: Math.floor(this.mapSize.x / cellSize),
|
|
72
|
-
y: Math.floor(this.mapSize.y / cellSize)
|
|
73
|
-
}, true);
|
|
71
|
+
let grid = grid_1.Grid.createNew(new helpers_lib_1.Vector(Math.floor(this.mapSize.x / cellSize), Math.floor(this.mapSize.y / cellSize)), true);
|
|
74
72
|
this.p2World.bodies.forEach(p2Body => {
|
|
75
73
|
let physicsEntity = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(p2Body.id);
|
|
76
74
|
if (physicsEntity.includeInPathfinding && physics_body_groups_1.PhysicsBodyGroups.canCollide(physicsEntity.physicsBodyGroup, physicsBodyGroup)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physics-availability-grid.js","sourceRoot":"","sources":["../../../../src/physics/sub-elements/available-spaces/physics-availability-grid.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"physics-availability-grid.js","sourceRoot":"","sources":["../../../../src/physics/sub-elements/available-spaces/physics-availability-grid.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,iFAA8E;AAC9E,2DAAuD;AACvD,yEAAsF;AACtF,wEAAoE;AACpE,iFAA4E;AAE5E,MAAM,qBAAqB;IAA3B;QACU,UAAK,GAAsD,IAAI,GAAG,EAAE,CAAC;IAkC/E,CAAC;IAhCC,GAAG,CAAC,QAAgB,EAAE,KAAuB;QAC3C,IAAI,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,SAA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QAE1H,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACnC,IAAI,aAAa,GAAG,8BAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACnE,IAAI,aAAa,CAAC,oBAAoB,IAAI,uCAAiB,CAAC,UAAU,CAAC,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,EAAE,CAAC;gBACzH,IAAI,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAC1E,IAAI,EAAE,WAAW,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;YACjD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,uBAAuB,CAAC,MAAe,EAAE,QAAgB;QAC/D,IAAI,WAAW,GAAG,wBAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,iDAAsB,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtE,CAAC;CACF;AArDD,0DAqDC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vector } from 'helpers-lib';
|
|
2
2
|
import p2 from 'p2';
|
|
3
3
|
import { PhysicsAvailabilityGrid } from './physics-availability-grid';
|
|
4
4
|
import { PathFinderResult } from '../../../utilities/libraries/grid-algorithms/path-finder/path-finder';
|
|
@@ -10,13 +10,13 @@ export declare class PhysicsAvailableSpaces {
|
|
|
10
10
|
constructor(physicsAvailabilityGrid: PhysicsAvailabilityGrid);
|
|
11
11
|
clear(): void;
|
|
12
12
|
getAvailabilityGrid(physicsBodyGroup: PhysicsBodyGroup): Grid<{
|
|
13
|
-
position:
|
|
13
|
+
position: Vector;
|
|
14
14
|
availability: boolean;
|
|
15
15
|
}>;
|
|
16
|
-
findClosestAvailableSpace(body: p2.Body, physicsBodyGroup: PhysicsBodyGroup):
|
|
17
|
-
findPathAStar(startingPosition:
|
|
16
|
+
findClosestAvailableSpace(body: p2.Body, physicsBodyGroup: PhysicsBodyGroup): Vector | undefined;
|
|
17
|
+
findPathAStar(startingPosition: Vector, target: Vector | string, options?: {
|
|
18
18
|
includeDiagonals?: boolean;
|
|
19
19
|
collidableWithGroup?: PhysicsBodyGroup;
|
|
20
20
|
}): PathFinderResult;
|
|
21
|
-
findPathDirection(startingPosition:
|
|
21
|
+
findPathDirection(startingPosition: Vector, target: Vector | string, collidableWithGroup: PhysicsBodyGroup): number | undefined;
|
|
22
22
|
}
|
|
@@ -46,7 +46,7 @@ class PhysicsAvailableSpaces {
|
|
|
46
46
|
if (helpers_lib_1.Comparator.isString(target)) {
|
|
47
47
|
let targetEntity = physics_entity_1.PhysicsEntity.getPhysicsInstanceOrFail(target);
|
|
48
48
|
targetP2Body = targetEntity['p2Body'];
|
|
49
|
-
targetPosition = p2js_helper_1.P2JSHelper.
|
|
49
|
+
targetPosition = p2js_helper_1.P2JSHelper.arrayToVector(targetP2Body.position);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
targetPosition = target;
|
|
@@ -72,10 +72,7 @@ class PhysicsAvailableSpaces {
|
|
|
72
72
|
targetArea = p2js_helper_1.P2JSHelper.aabbToBoundingBox(targetEntity['p2Body'].aabb);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
|
-
targetArea =
|
|
76
|
-
topLeft: target,
|
|
77
|
-
bottomRight: target
|
|
78
|
-
};
|
|
75
|
+
targetArea = new helpers_lib_1.Rectangle(target, target);
|
|
79
76
|
}
|
|
80
77
|
let targetGridArea = availability_grid_helper_1.AvailabilityGridHelper.areaToGridArea(targetArea, GRID_CELL_SIZE);
|
|
81
78
|
let cacheName = JSON.stringify({ targetGridArea, collidableWithGroup });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physics-available-spaces.js","sourceRoot":"","sources":["../../../../src/physics/sub-elements/available-spaces/physics-available-spaces.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"physics-available-spaces.js","sourceRoot":"","sources":["../../../../src/physics/sub-elements/available-spaces/physics-available-spaces.ts"],"names":[],"mappings":";;;AAAA,6CAA4D;AAG5D,wJAAkJ;AAClJ,2DAAuD;AAEvD,kDAAgD;AAEhD,yEAAmE;AACnE,wEAAoE;AACpE,6IAAuI;AAEvI,iFAA4E;AAE5E,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAa,sBAAsB;IAGjC,YAAoB,uBAAgD;QAAhD,4BAAuB,GAAvB,uBAAuB,CAAyB;QAF5D,qBAAgB,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEG,CAAC;IAExE,KAAK;QACH,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;IAED,mBAAmB,CAAC,gBAAkC;QACpD,IAAI,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QACzG,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;YAChD,QAAQ,EAAE,iDAAsB,CAAC,sBAAsB,CAAC,QAAQ,EAAE,cAAc,CAAC;YACjF,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC,CAAC;IACN,CAAC;IAED,yBAAyB,CAAC,IAAa,EAAE,gBAAkC;QACzE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,IAAI,YAAY,GAAG,4DAA2B,CAAC,yBAAyB,CACtE,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,cAAc,EAAE,gBAAgB,CAAC,EACjF,wBAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EACvC,cAAc,CACf,CAAC;QAEF,OAAO,YAAY,CAAC;IACtB,CAAC;IA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G,IAAI,gDAAqB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;YAC1E,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,oBAAoB,GAAG,iDAAsB,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAE3G,OAAO,WAAW,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;CACF;AApGD,wDAoGC"}
|
|
@@ -48,8 +48,8 @@ class ContactEquationOrganiser {
|
|
|
48
48
|
getCollisionDetails(entityA, entityB, contactEquation) {
|
|
49
49
|
let dtoA = entityA.convertToDTO();
|
|
50
50
|
let dtoB = entityB.convertToDTO();
|
|
51
|
-
let contactPointA = p2js_helper_1.P2JSHelper.
|
|
52
|
-
let contactPointB = p2js_helper_1.P2JSHelper.
|
|
51
|
+
let contactPointA = p2js_helper_1.P2JSHelper.arrayToVector(contactEquation.contactPointA);
|
|
52
|
+
let contactPointB = p2js_helper_1.P2JSHelper.arrayToVector(contactEquation.contactPointB);
|
|
53
53
|
let { normalA, normalB } = this.getNormals(contactEquation);
|
|
54
54
|
return {
|
|
55
55
|
collisionDetailsA: this.getCollisionDetail(dtoA, contactEquation.bodyA.mass, contactPointA, normalA, entityA.area),
|
|
@@ -62,7 +62,7 @@ class ContactEquationOrganiser {
|
|
|
62
62
|
body: physicsBodyDTOSelf,
|
|
63
63
|
getPositionReletiveToObject: () => {
|
|
64
64
|
if (!positionRelativeToObject) {
|
|
65
|
-
positionRelativeToObject =
|
|
65
|
+
positionRelativeToObject = contactPointSelf.rotate(helpers_lib_1.Radian.toVector(-physicsBodyDTOSelf.rotation));
|
|
66
66
|
}
|
|
67
67
|
return positionRelativeToObject;
|
|
68
68
|
},
|
|
@@ -73,8 +73,8 @@ class ContactEquationOrganiser {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
getNormals(contactEquation) {
|
|
76
|
-
let contactEquationNormalA = p2js_helper_1.P2JSHelper.
|
|
77
|
-
let contactEquationNormalB =
|
|
76
|
+
let contactEquationNormalA = p2js_helper_1.P2JSHelper.arrayToVector(contactEquation.normalA);
|
|
77
|
+
let contactEquationNormalB = contactEquationNormalA.multiply(-1);
|
|
78
78
|
return { normalA: contactEquationNormalA, normalB: contactEquationNormalB };
|
|
79
79
|
}
|
|
80
80
|
}
|