@inglorious/engine 13.0.3 → 14.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/engine",
3
- "version": "13.0.3",
3
+ "version": "14.0.0",
4
4
  "description": "A JavaScript game engine written with global state, immutability, and pure functions in mind. Have fun(ctional programming) with it!",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -31,11 +31,11 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@inglorious/store": "7.1.3",
35
- "@inglorious/utils": "3.7.0"
34
+ "@inglorious/utils": "3.7.0",
35
+ "@inglorious/store": "8.0.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@inglorious/store": "7.1.3",
38
+ "@inglorious/store": "8.0.0",
39
39
  "@inglorious/utils": "3.7.0"
40
40
  },
41
41
  "devDependencies": {
@@ -22,9 +22,7 @@ export function camera(params) {
22
22
  params = extend(DEFAULT_PARAMS, params)
23
23
 
24
24
  return {
25
- create(entity, entityId) {
26
- if (entityId !== entity.id) return
27
-
25
+ create(entity) {
28
26
  defaults(entity, params)
29
27
  entity.targetZoom = entity.zoom
30
28
  // Cache the initial size to calculate the viewport in dev mode
@@ -23,10 +23,8 @@ export function modernAcceleration(params) {
23
23
  "moveUpDown",
24
24
  ]),
25
25
 
26
- create(entity, entityId, api) {
27
- type.create?.(entity, entityId, api)
28
-
29
- if (entityId !== entity.id) return
26
+ create(entity, payload, api) {
27
+ type.create?.(entity, payload, api)
30
28
 
31
29
  entity.maxAcceleration ??= params.maxAcceleration
32
30
  entity.movement ??= {}
@@ -32,10 +32,8 @@ export function shooterControls(params) {
32
32
  "turn",
33
33
  ]),
34
34
 
35
- create(entity, entityId, api) {
36
- type.create?.(entity, entityId, api)
37
-
38
- if (entityId !== entity.id) return
35
+ create(entity, payload, api) {
36
+ type.create?.(entity, payload, api)
39
37
 
40
38
  entity.maxSpeed ??= params.maxSpeed
41
39
  entity.maxAngularSpeed ??= params.maxAngularSpeed
@@ -26,10 +26,8 @@ export function tankControls(params) {
26
26
  "turn",
27
27
  ]),
28
28
 
29
- create(entity, entityId, api) {
30
- type.create?.(entity, entityId, api)
31
-
32
- if (entityId !== entity.id) return
29
+ create(entity, payload, api) {
30
+ type.create?.(entity, payload, api)
33
31
 
34
32
  entity.maxSpeed ??= params.maxSpeed
35
33
  entity.maxAngularSpeed ??= params.maxAngularSpeed
@@ -23,10 +23,8 @@ export function modernVelocity(params) {
23
23
  "moveUpDown",
24
24
  ]),
25
25
 
26
- create(entity, entityId, api) {
27
- type.create?.(entity, entityId, api)
28
-
29
- if (entityId !== entity.id) return
26
+ create(entity, payload, api) {
27
+ type.create?.(entity, payload, api)
30
28
 
31
29
  entity.maxSpeed ??= params.maxSpeed
32
30
  entity.movement ??= {}
@@ -31,10 +31,8 @@ export function shooterControls(params) {
31
31
  "turn",
32
32
  ]),
33
33
 
34
- create(entity, entityId, api) {
35
- type.create?.(entity, entityId, api)
36
-
37
- if (entityId !== entity.id) return
34
+ create(entity, payload, api) {
35
+ type.create?.(entity, payload, api)
38
36
 
39
37
  entity.maxSpeed ??= params.maxSpeed
40
38
  entity.maxAngularSpeed ??= params.maxAngularSpeed
@@ -25,10 +25,8 @@ export function tankControls(params) {
25
25
  "turn",
26
26
  ]),
27
27
 
28
- create(entity, entityId, api) {
29
- type.create?.(entity, entityId, api)
30
-
31
- if (entityId !== entity.id) return
28
+ create(entity, payload, api) {
29
+ type.create?.(entity, payload, api)
32
30
 
33
31
  entity.maxSpeed ??= params.maxSpeed
34
32
  entity.maxAngularSpeed ??= params.maxAngularSpeed
@@ -12,9 +12,7 @@ export function fps(params) {
12
12
  params = extend(DEFAULT_PARAMS, params)
13
13
 
14
14
  return {
15
- create(entity, entityId) {
16
- if (entityId !== entity.id) return
17
-
15
+ create(entity) {
18
16
  entity.dt ??= { ...params }
19
17
  },
20
18
 
@@ -7,10 +7,8 @@ export function fsm(states) {
7
7
 
8
8
  return (type) => {
9
9
  return {
10
- create(entity, entityId, api) {
11
- type.create?.(entity, entityId, api)
12
-
13
- if (entityId !== entity.id) return
10
+ create(entity, payload, api) {
11
+ type.create?.(entity, payload, api)
14
12
 
15
13
  entity.state ??= DEFAULT_STATE
16
14
  },
@@ -1,8 +1,6 @@
1
1
  export function gamepadsPoller(targetIds = []) {
2
2
  return {
3
- create(entity, entityId) {
4
- if (entityId !== entity.id) return
5
-
3
+ create(entity) {
6
4
  entity.gamepadStateCache ??= {}
7
5
  },
8
6
 
@@ -3,9 +3,7 @@ export function keyboard() {
3
3
  let currentDocument = null
4
4
 
5
5
  return {
6
- create(entity, entityId, api) {
7
- if (entityId !== entity.id) return
8
-
6
+ create(entity, payload, api) {
9
7
  currentDocument = document.body.ownerDocument || document
10
8
 
11
9
  handleKeyDown = createKeyboardHandler("keyboardKeyDown", api)
@@ -4,9 +4,7 @@ import { zero } from "@inglorious/utils/math/vector.js"
4
4
 
5
5
  export function mouse() {
6
6
  return {
7
- create(entity, entityId) {
8
- if (entityId !== entity.id) return
9
-
7
+ create(entity) {
10
8
  entity.collisions ??= {}
11
9
  entity.collisions.bounds ??= { shape: "point" }
12
10
  },
@@ -9,10 +9,8 @@ export function bouncy(params) {
9
9
  params = extend(DEFAULT_PARAMS, params)
10
10
 
11
11
  return (type) => ({
12
- create(entity, entityId, api) {
13
- type.create?.(entity, entityId, api)
14
-
15
- if (entityId !== entity.id) return
12
+ create(entity, payload, api) {
13
+ type.create?.(entity, payload, api)
16
14
 
17
15
  defaults(entity, params)
18
16
  },
@@ -10,10 +10,8 @@ export function clamped(params) {
10
10
  params = extend(DEFAULT_PARAMS, params)
11
11
 
12
12
  return (type) => ({
13
- create(entity, entityId, api) {
14
- type.create?.(entity, entityId, api)
15
-
16
- if (entityId !== entity.id) return
13
+ create(entity, payload, api) {
14
+ type.create?.(entity, payload, api)
17
15
 
18
16
  entity.collisions ??= {}
19
17
  entity.collisions[params.collisionGroup] ??= {}
@@ -22,10 +22,8 @@ export function jumpable(params) {
22
22
  params = extend(DEFAULT_PARAMS, params)
23
23
 
24
24
  return (type) => ({
25
- create(entity, entityId, api) {
26
- type.create?.(entity, entityId, api)
27
-
28
- if (entityId !== entity.id) return
25
+ create(entity, payload, api) {
26
+ type.create?.(entity, payload, api)
29
27
 
30
28
  defaults(entity, params)
31
29
  entity.jumpsLeft ??= entity.maxJumps