refactor: invulnerability
This commit is contained in:
parent
4b46b2f0ab
commit
83d8924517
|
@ -23,6 +23,9 @@ export default class Vulnerable extends Component {
|
||||||
id = 0;
|
id = 0;
|
||||||
Types = DamageTypes;
|
Types = DamageTypes;
|
||||||
damage(specification) {
|
damage(specification) {
|
||||||
|
if (this.isInvulnerable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {Alive} = Component.ecs.get(this.entity);
|
const {Alive} = Component.ecs.get(this.entity);
|
||||||
if (Alive) {
|
if (Alive) {
|
||||||
switch (specification.type) {
|
switch (specification.type) {
|
||||||
|
@ -39,4 +42,7 @@ export default class Vulnerable extends Component {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
static properties = {
|
||||||
|
isInvulnerable: {type: 'uint8'},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
const {Sprite, Ticking} = entity;
|
const {Sprite, Ticking, Vulnerable} = entity;
|
||||||
|
if (Vulnerable) {
|
||||||
|
Vulnerable.isInvulnerable = 1;
|
||||||
|
}
|
||||||
if (Sprite) {
|
if (Sprite) {
|
||||||
const {promise} = transition(
|
const {promise} = transition(
|
||||||
entity.Sprite,
|
entity.Sprite,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user