Exemplo n.º 1
0
void TriggerTerrainBlock::startTerrainChange() {
	// Get the grid zone component on this object.
	GridZone* zone = this->GetObject()->GetComponent<GridZone>();
	ASSERT(zone != nullptr, "Object %d with TriggerElevationChange component also has GridZone component", this->GetObject()->GetId());

	if (zone != nullptr) {
		int west, east, south, north;
		zone->GetZoneBounds(west, east, south, north);

		GameGrid* grid = SINGLETONS->GetGridManager()->GetGrid();

		int elevation = grid->GetElevationFromWorldY(this->GetObject()->GetComponent<Transform>()->GetPositionWorld().y);
		for (int x = west; x <= east; ++x) {
			for (int z = south; z <= north; ++z) {
				if (this->changeWalkability) {
					grid->SetCellPassableAtElevation(x, z, elevation, this->isPassable);
				}
				if (this->changeVisibility) {
					grid->SetCellVisibleAtElevation(x, z, elevation, this->isPassable);
				}
			}
		}
	}

	// Navigators need to update their pathfinding
	MessageChunk gridNavMessage = ENGINE->GetMessageHub()->GetOneFreeMessage();
	gridNavMessage->SetMessageType(MESSAGE_TYPE_GRID_NAVIGATION_REFRESH);
	ENGINE->GetMessageHub()->SendMulticastMessage(gridNavMessage, SINGLETONS->GetGridManagerObject()->GetId());
}
Exemplo n.º 2
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);
	}
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
void WaterRenderer::HandleMessage(MessageChunk messageChunk) {
	MeshRenderer::HandleMessage(messageChunk);

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

	default : {
	} break;
	}
}
Exemplo n.º 5
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;
	}
}
Exemplo n.º 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;
	}
}
Exemplo n.º 7
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;
	}
}
Exemplo n.º 8
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;
	}

}
Exemplo n.º 9
0
void MessageHub::SendPointcastMessage(MessageChunk messageChunk, ObjectIdType receiverId, ObjectIdType senderId /* = OBJECT_ID_INVALID */) {
	messageChunk->setSenderId(senderId);

	this->currentlyAcceptingMessageCacheRef->PushMessageForReceipientId(messageChunk, receiverId);
}
Exemplo n.º 10
0
void MessageHub::SendMulticastMessage(MessageType messageType, ObjectIdType senderId) {
	MessageChunk messageChunk = this->GetOneFreeMessage();
	messageChunk->SetMessageType(messageType);
	this->SendMulticastMessage(messageChunk, senderId);
}
Exemplo n.º 11
0
void MessageHub::SendPointcastMessage(MessageType messageType, ObjectIdType receiverId, ObjectIdType senderId) {
	MessageChunk messageChunk = this->GetOneFreeMessage();
	messageChunk->SetMessageType(messageType);
	this->SendPointcastMessage(messageChunk, receiverId, senderId);
}