package game.mobs.states;

import game.mobs.states.GhostChase;
import openfl.media.SoundTransform;

using Std;

class GhostIdle extends MobState {
	var soundTime:Float = 0;

	static final SOUND_DISTANCE:Float = 90;
	static final START_CHASE_DISTANCE:Int = 3;

	var playerCellX:Null<Int> = null;
	var playerCellY:Null<Int> = null;

	override function update(delta:Float) {
		/*
			var currentPlayerX:Int = mob.raycaster.camera.position.x.int();
			var currentPlayerY:Int = mob.raycaster.camera.position.y.int();

			if (playerCellX != currentPlayerX || playerCellY != currentPlayerY) {
				playerCellX = currentPlayerX;
				playerCellY = currentPlayerY;

				var path = cast(mob, Ghost).pathToPlayer();

				if (path.length <= START_CHASE_DISTANCE) {
					Game.current.playSound('assets/sound/piano_hit.ogg');

					mob.state = new GhostChase(mob, Game.current.playSound('assets/sound/ghost_scream.ogg'));
					Game.current.startChase();

					return;
				}
			}

			if (mob.distance != null && soundTime <= 0) {
				if (mob.distance < SOUND_DISTANCE) {
					var vol = (SOUND_DISTANCE - mob.distance) / SOUND_DISTANCE;

					var transform = new SoundTransform(vol);

					Game.current.playSound('assets/sound/ghost_${1 + Math.floor(6 * Math.random())}.ogg', transform);

					soundTime = 5 + 10 * Math.random();
				}
			} else
				soundTime -= delta;
		 */
	}
}
