@waica/behaviors 0.13.0 → 0.14.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/health.js +7 -1
- package/dist/lifetime.js +5 -2
- package/dist/patrol.js +5 -2
- package/package.json +2 -2
package/dist/health.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, StateMachine } from '@waica/engine';
|
|
1
|
+
import { Component, SIMULATION_TIME_EPSILON, StateMachine, } from '@waica/engine';
|
|
2
2
|
/**
|
|
3
3
|
* Below this, current is treated as exactly zero. Repeated fractional
|
|
4
4
|
* damage (e.g. ten hits of 0.1 against max: 1) can leave a floating-point
|
|
@@ -113,6 +113,12 @@ export class Health extends Component {
|
|
|
113
113
|
onUpdate(dt) {
|
|
114
114
|
if (this.invulnerable > 0) {
|
|
115
115
|
this.invulnerable = Math.max(0, this.invulnerable - dt);
|
|
116
|
+
// this.invulnerable is a countdown of SIMULATION_STEP-sized dts, which
|
|
117
|
+
// float error can leave as a tiny positive residual instead of
|
|
118
|
+
// exactly 0 on the step that should close the window; without this,
|
|
119
|
+
// `> 0` above stays true for one whole extra step.
|
|
120
|
+
if (this.invulnerable <= SIMULATION_TIME_EPSILON)
|
|
121
|
+
this.invulnerable = 0;
|
|
116
122
|
this.blink(dt);
|
|
117
123
|
}
|
|
118
124
|
if (this.deathPending) {
|
package/dist/lifetime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from '@waica/engine';
|
|
1
|
+
import { Component, SIMULATION_TIME_EPSILON } from '@waica/engine';
|
|
2
2
|
/** Destroys its entity after a configurable amount of simulated time. */
|
|
3
3
|
export class Lifetime extends Component {
|
|
4
4
|
static componentName = 'Lifetime';
|
|
@@ -14,7 +14,10 @@ export class Lifetime extends Component {
|
|
|
14
14
|
if (!this.entity.alive)
|
|
15
15
|
return;
|
|
16
16
|
this.elapsed += dt;
|
|
17
|
-
|
|
17
|
+
// this.elapsed is a sum of SIMULATION_STEP-sized dts, which float error
|
|
18
|
+
// can leave a hair under an exact multiple; the epsilon keeps a bare
|
|
19
|
+
// `>=` from waiting one whole step too long to destroy.
|
|
20
|
+
if (this.elapsed + SIMULATION_TIME_EPSILON >= this.seconds)
|
|
18
21
|
this.entity.destroy();
|
|
19
22
|
}
|
|
20
23
|
}
|
package/dist/patrol.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, installedDirectionalAnimation, projectIsometric, } from '@waica/engine';
|
|
1
|
+
import { Component, installedDirectionalAnimation, projectIsometric, SIMULATION_TIME_EPSILON, } from '@waica/engine';
|
|
2
2
|
import { facingForInput } from './facing.js';
|
|
3
3
|
/** Seconds a hit stops the rail. */
|
|
4
4
|
const HURT_SECONDS = 0.25;
|
|
@@ -105,7 +105,10 @@ export const PATROLLER_ROLE = {
|
|
|
105
105
|
// Holds the death pose for a beat, then the body goes away for good.
|
|
106
106
|
dead: {
|
|
107
107
|
onUpdate({ entity, fsm }) {
|
|
108
|
-
|
|
108
|
+
// fsm.elapsed is a sum of SIMULATION_STEP-sized dts, which float
|
|
109
|
+
// error can leave a hair under an exact multiple; the epsilon keeps
|
|
110
|
+
// a bare `>=` from waiting one whole step too long to destroy.
|
|
111
|
+
if (fsm.elapsed + SIMULATION_TIME_EPSILON >= DEATH_SECONDS)
|
|
109
112
|
entity.destroy();
|
|
110
113
|
},
|
|
111
114
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waica/behaviors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Waica built-in behaviors — the curated game-feel library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@waica/engine": "^0.
|
|
22
|
+
"@waica/engine": "^0.14.0"
|
|
23
23
|
}
|
|
24
24
|
}
|