示例#1
0
void MessageHub::SendMulticastMessage(MessageChunk messageChunk, ObjectIdType senderId /* = OBJECT_ID_INVALID */) {
	unsigned int numMsgTypes = this->subscribersForMessageType.size();
	if (numMsgTypes <= messageChunk->GetMessageType()) { return; }
	unsigned int numSubscribers = this->subscribersForMessageType[messageChunk->GetMessageType()].size();
	for (unsigned int i = 0; i < numSubscribers; ++i) {
		this->SendPointcastMessage(messageChunk, this->subscribersForMessageType[messageChunk->GetMessageType()][i], senderId);
	}
}
示例#2
0
void WaterRenderer::HandleMessage(MessageChunk messageChunk) {
	MeshRenderer::HandleMessage(messageChunk);

	switch (messageChunk->GetMessageType()) {
	case MESSAGE_TYPE_FRAME_EVENT: {
		this->scrollUVs();
	} break;

	default : {
	} break;
	}
}
示例#3
0
void MultiplexSwitch::HandleMessage(MessageChunk messageChunk) {
	BaseSwitch::HandleMessage(messageChunk);

	switch (messageChunk->GetMessageType()) {
		case MESSAGE_TYPE_MULTIPLEX_ACTIVATED:
			this->setConditionState(true);
			break;

		case MESSAGE_TYPE_MULTIPLEX_DEACTIVATED:
			this->setConditionState(false);
			break;
	}
}
示例#4
0
void PlayerUnit::HandleMessage(MessageChunk messageChunk) {
	BaseUnit::HandleMessage(messageChunk);
	switch(messageChunk->GetMessageType()) {
		case MESSAGE_TYPE_NAVIGATION_REACHED_DESTINATION:
			if(this->performingSpecial) {
				onSpecialEnd();
			}  else {
				ENGINE->GetTween()->CancelNumberTween("pulse");
				ENGINE->GetTween()->TweenScale(this->touchIndicator->GetId(), this->touchIndicator->GetTransform()->GetScale(), glm::vec3(0), TOUCH_SCALE_TIME);
			}
			break;
		default:
			break;
	}
}
示例#5
0
void MenuManager::HandleMessage(MessageChunk messageChunk) {
	Component::HandleMessage(messageChunk);
	switch (messageChunk->GetMessageType()) {
		case MESSAGE_TYPE_LEVEL_LOADED: {
			if(this->loadScreen != nullptr && this->loadScreen->IsVisible()) {
				float loadTime = ((float)ENGINE->GetTimer()->GetHighResAbsoluteTime()) - this->loadStartTime;
				ENGINE->GetTween()->TweenToNumber(0.0f, 1.0f, .5f, INTERPOLATION_TYPE_LINEAR, false, false, false, "extraLoadTime", NUMBER_TWEEN_AFFILIATION_SCENEGRAPH_Ui, NULL, menuManagerNumberTweenCallback);
				/*if(loadTime < GetFloatGameConstant(GAME_CONSTANT_min_load_time)) {
					float extraLoadTime = GetFloatGameConstant(GAME_CONSTANT_min_load_time) - loadTime;
					ENGINE->GetTween()->TweenToNumber(0.0f, 1.0f, extraLoadTime, INTERPOLATION_TYPE_LINEAR, false, false, false, "extraLoadTime", NUMBER_TWEEN_AFFILIATION_SCENEGRAPH_Ui, NULL, menuManagerNumberTweenCallback);
				} else {
					ENGINE->GetTween()->TweenToNumber(0.0f, 1.0f, .2f, INTERPOLATION_TYPE_LINEAR, false, false, false, "extraLoadTime", NUMBER_TWEEN_AFFILIATION_SCENEGRAPH_Ui, NULL, menuManagerNumberTweenCallback);
				}*/
			}
			break;
		}
		default:
			break;
	}

}
示例#6
0
void Triggerable::HandleMessage(MessageChunk messageChunk) {
	Component::HandleMessage(messageChunk);

	int prevActive   = this->activeSwitches.size();
	int prevSwitches = this->subscriptions.size();
	int currActive, currSwitches;

	switch (messageChunk->GetMessageType()) {
		case MESSAGE_TYPE_SWITCH_ACTIVATED:
			this->markAsActive(messageChunk->GetSenderId());
			currActive = this->activeSwitches.size();
			currSwitches = this->subscriptions.size();
			this->compareCounts(prevActive, prevSwitches, currActive, currSwitches);
			break;

		case MESSAGE_TYPE_SWITCH_DEACTIVATED:
			this->markAsInactive(messageChunk->GetSenderId());
			currActive = this->activeSwitches.size();
			currSwitches = this->subscriptions.size();
			this->compareCounts(prevActive, prevSwitches, currActive, currSwitches);
			break;
	}
}
示例#7
0
void MessageHub::drainMessageCache_internal() {
	ObjectIdType receipientId = OBJECT_ID_INVALID;
	for (auto objectId_it = this->currentlyDrainingMessageCacheRef->objectIdsWithPendingMessages.begin();
			objectId_it != this->currentlyDrainingMessageCacheRef->objectIdsWithPendingMessages.end(); ++objectId_it) {

		if (objectId_it->second) {
			receipientId = objectId_it->first;

			Object* receipient = ObjectRegistry::GetObjectById(receipientId);
			if (receipient != nullptr) {
				ASSERT(receipient->GetId() > OBJECT_ID_INVALID, "Valid object id (%d) should have been %d", receipient->GetId(), receipientId);
				receipient->HandleMessages();

			} else {
				FRAMEWORK->GetLogger()->dbglog("\nWarning: Trying to deliver message to missing object of id %d. Draining those messages instead", receipientId);
				// Drain messages intended for game object that doesn't exist anymore:
				bool retrievedMessageIsValid = false;
				do {
					MessageChunk messageChunk = this->RetrieveNextMessage(receipientId, retrievedMessageIsValid);
#ifdef DEBUG
					if (retrievedMessageIsValid) {
						FRAMEWORK->GetLogger()->dbglog("\nDraining message to missing object of id %d, message type: %d", receipientId, messageChunk->GetMessageType());
					}
#endif
				} while (retrievedMessageIsValid);
			}
		}
		this->currentlyDrainingMessageCacheRef->ClearMessagesForReceipientId(receipientId);
	}
	this->currentlyDrainingMessageCacheRef->objectIdsWithPendingMessages.clear();
}