void AnimSoundTrigger::onGameLoop() {
	Object::onGameLoop();

	if (!_anim || !_anim->isInUse()) {
		return;
	}

	if (_alreadyPlayed && _anim->getCurrentTime() < 33) {
		// Animation loop detected, reset
		_alreadyPlayed = false;
	}

	if ((!_alreadyPlayed && _anim->getCurrentTime() >= _soundTriggerTime) || _timeRemainingBeforeLoop < 33) {
		if (_timeRemainingBeforeLoop >= 33) {
			_alreadyPlayed = true;
		}

		if (_subType == kAnimTriggerSound) {
			Location *location = StarkGlobal->getCurrent()->getLocation();
			Sound *sound = location->findStockSound(_soundStockType);
			if (sound) {
				// TODO: If the location has a 3D layer set the source position of the sound to the item position
				sound->play();
			}
		} else {
			warning("Unknown animation trigger subtype '%d'", _subType);
		}
	}

	// Special handling for trigger times right before the animation loop point
	if (!_alreadyPlayed && _soundTriggerTime - _anim->getCurrentTime() < 33) {
		_timeRemainingBeforeLoop = _anim->getRemainingTime();
	} else {
		_timeRemainingBeforeLoop = 34;
	}
}