fix cast times
This commit is contained in:
+8
-8
@@ -13,8 +13,8 @@ export default class Entity {
|
||||
abilities = [
|
||||
Ability.basicAttack,
|
||||
Ability.straightShot,
|
||||
Ability.control,
|
||||
Ability.shieldThrow,
|
||||
Ability.blink,
|
||||
]
|
||||
casting = null
|
||||
// TODO: teams
|
||||
@@ -78,7 +78,7 @@ export default class Entity {
|
||||
const castTime = this.game?.secToTick(this.casting.ability.castTime) ?? 0
|
||||
const castStart = this.casting.timestamp
|
||||
const timestamp = this.game?.currentTick ?? 0
|
||||
if (castStart + castTime < timestamp) {
|
||||
if (castStart + castTime > timestamp) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export default class Entity {
|
||||
}
|
||||
|
||||
fixPosition() {
|
||||
this.#position = SATX.fixCollisions(this.#position, this.collidables(), this.radius, this.game?.width, this.game?.height)
|
||||
this.#position = SATX.fixCollisions(this.#position, this.collidables(), this.radius, this.game?.width, this.game?.height).clone()
|
||||
}
|
||||
|
||||
isColliding(...colliders) {
|
||||
@@ -157,9 +157,9 @@ export default class Entity {
|
||||
}
|
||||
}
|
||||
|
||||
teleport(x, y) {
|
||||
const position = SATX.fixCollisions(new Vector2(x, y), this.collidables(), this.radius, this.game?.width, this.game?.height)
|
||||
this.position.set(position.x, position.y)
|
||||
teleport(position) {
|
||||
this.#position = position.clone()
|
||||
this.fixPosition()
|
||||
}
|
||||
|
||||
// TODO: unset destination on teleports, etc.
|
||||
@@ -217,10 +217,10 @@ export default class Entity {
|
||||
if (this.id == '1' || this.id == '2') {
|
||||
this.health = this.maxHealth
|
||||
if (this.id == '1') {
|
||||
this.teleport(200, 200)
|
||||
this.teleport(new Vector2(200, 200))
|
||||
}
|
||||
if (this.id == '2') {
|
||||
this.teleport(1800, 1800)
|
||||
this.teleport(new Vector2(1800, 1800))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user