- @override
Used for operations which need to be done in short intervals where deltaTime
specifies the time since the last tick
Source
@override void tick(double deltaTime) { if(_isEmbattled()) { final playerPos = world.gamemode.player.location; final escapeVector = (world.size / 2.0 - this.location).normalized(); this.rotation = this.location + escapeVector * 70.0 - playerPos; _recoverTimeRemaining = recoverTime; cozyness = max(cozyness - cozynessDecSpeed * deltaTime, 0.0); } else { _recoverTimeRemaining = max(0.0, _recoverTimeRemaining - deltaTime); if(state == EnemyState.idle) { _changeDirTimeRemaining = max(0.0, _changeDirTimeRemaining - deltaTime); if(_changeDirTimeRemaining == 0) { _setRandomRotation(); _changeDirTimeRemaining = _nextRandomTime(); } cozyness = min(cozyness + cozynessIncSpeed * deltaTime, 100.0); } else { _changeDirTimeRemaining = _nextRandomTime(); } } requestWalkToLocation(this.location + this.rotation * 200.0); if (cozyness == 100.0) { world.gamemode.gameOverEvent.add(false); } super.tick(deltaTime); }