void EntertainingSessionImplementation::stopDancing() {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	if (entertainer == NULL)
		return;

	Locker locker(entertainer);

	if (!dancing)
		return;

	dancing = false;

	entertainer->sendSystemMessage("@performance:dance_stop_self");

	performanceName = "";

	sendEntertainingUpdate(entertainer, 0.8025000095f, entertainer->getPerformanceAnimation(), 0, 0);

	if (entertainer->getPosture() == CreaturePosture::SKILLANIMATING)
		entertainer->setPosture(CreaturePosture::UPRIGHT);


	ManagedReference<PlayerManager*> playerManager = entertainer->getZoneServer()->getPlayerManager();

	while (watchers.size() > 0) {
		ManagedReference<CreatureObject*> watcher = watchers.elementAt(0).getKey();

		Locker clocker(watcher, entertainer);

		playerManager->stopWatch(watcher, entertainer->getObjectID(), true, true, false);

		if (!watcher->isWatching())
			sendEntertainmentUpdate(watcher, 0, "", true);

		watchers.drop(watcher);
	}

	if (tickTask != NULL && tickTask->isScheduled())
		tickTask->cancel();

	updateEntertainerMissionStatus(false, MissionObject::DANCER);

	entertainer->notifyObservers(ObserverEventType::STOPENTERTAIN, entertainer);

	entertainer->dropObserver(ObserverEventType::POSTURECHANGED, observer);

	if (!dancing && !playingMusic) {
		ManagedReference<PlayerObject*> entPlayer = entertainer->getPlayerObject();
		if (entPlayer != NULL && entPlayer->getPerformanceBuffTarget() != 0)
			entPlayer->setPerformanceBuffTarget(0);

		entertainer->dropActiveSession(SessionFacadeType::ENTERTAINING);
	}
}
int ImageDesignSessionImplementation::cancelSession() {
	ManagedReference<CreatureObject*> designerCreature = this->designerCreature.get();
	ManagedReference<CreatureObject*> targetCreature = this->targetCreature.get();

	if (designerCreature != NULL) {
		designerCreature->dropActiveSession(SessionFacadeType::IMAGEDESIGN);

		if (positionObserver != NULL)
			designerCreature->dropObserver(ObserverEventType::POSITIONCHANGED, positionObserver);
	}

	if (targetCreature != NULL) {
		targetCreature->dropActiveSession(SessionFacadeType::IMAGEDESIGN);

		if (positionObserver != NULL)
			targetCreature->dropObserver(ObserverEventType::POSITIONCHANGED, positionObserver);
	}

	dequeueIdTimeoutEvent();

	return 0;
}
void SurveyMissionObjectiveImplementation::abort() {
	MissionObjectiveImplementation::abort();

	if (!hasObservers())
		return;

	ManagedReference<MissionObserver*> observer = getObserver(0);

	ManagedReference<CreatureObject*> player = getPlayerOwner();
	if (player != NULL) {
		player->dropObserver(ObserverEventType::SURVEY, observer);

		dropObserver(observer, true);
	}
}
void HuntingMissionObjectiveImplementation::abort() {
	MissionObjectiveImplementation::abort();

	for (int i = 0; i < getObserverCount(); i++) {
		ManagedReference<MissionObserver*> observer = getObserver(i);

		ManagedReference<CreatureObject*> player = getPlayerOwner();

		if (player != NULL) {
			Locker locker(player);

			player->dropObserver(ObserverEventType::KILLEDCREATURE, observer);

			dropObserver(observer, true);
		}
	}
}
void EntertainingSessionImplementation::stopPlayingMusic() {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	Locker locker(entertainer);

	if (!playingMusic)
		return;

	playingMusic = false;
	entertainer->sendSystemMessage("@performance:music_stop_self");

	sendEntertainingUpdate(entertainer, 0.8025000095f, entertainer->getPerformanceAnimation(), 0, 0);

	performanceName = "";
	entertainer->setListenToID(0);

	if (entertainer->getPosture() == CreaturePosture::SKILLANIMATING)
		entertainer->setPosture(CreaturePosture::UPRIGHT);

	if (externalInstrument != NULL && externalInstrument->isBeingUsed())
		externalInstrument->setBeingUsed(false);

	externalInstrument = NULL;

	ManagedReference<PlayerManager*> playerManager = entertainer->getZoneServer()->getPlayerManager();

	while (listeners.size() > 0) {
		ManagedReference<CreatureObject*> listener = listeners.elementAt(0).getKey();

		Locker clocker(listener, entertainer);

		playerManager->stopListen(listener, entertainer->getObjectID(), true, true, false);

		if (!listener->isWatching())
			sendEntertainmentUpdate(listener, 0, "", true);

		listeners.drop(listener);
	}

	if (tickTask != NULL && tickTask->isScheduled())
		tickTask->cancel();

	targetInstrument = false;
	updateEntertainerMissionStatus(false, MissionObject::MUSICIAN);

	entertainer->notifyObservers(ObserverEventType::STOPENTERTAIN, entertainer);

	entertainer->dropObserver(ObserverEventType::POSTURECHANGED, observer);

	ManagedReference<GroupObject*> group = entertainer->getGroup();

	if (group != NULL) {
		bool otherPlaying = group->isOtherMemberPlayingMusic(entertainer);

		if (!otherPlaying) {
			Locker locker(group);

			group->setBandSong("");
		}
	}

	if (!dancing && !playingMusic) {
		ManagedReference<PlayerObject*> entPlayer = entertainer->getPlayerObject();
		if (entPlayer != NULL && entPlayer->getPerformanceBuffTarget() != 0)
			entPlayer->setPerformanceBuffTarget(0);

		entertainer->dropActiveSession(SessionFacadeType::ENTERTAINING);
	}
}