コード例 #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());
}
コード例 #2
0
ファイル: MessageHub.cpp プロジェクト: VajraFramework/Vajra
void MessageHub::SendMulticastMessage(MessageType messageType, ObjectIdType senderId) {
	MessageChunk messageChunk = this->GetOneFreeMessage();
	messageChunk->SetMessageType(messageType);
	this->SendMulticastMessage(messageChunk, senderId);
}
コード例 #3
0
ファイル: MessageHub.cpp プロジェクト: VajraFramework/Vajra
void MessageHub::SendPointcastMessage(MessageType messageType, ObjectIdType receiverId, ObjectIdType senderId) {
	MessageChunk messageChunk = this->GetOneFreeMessage();
	messageChunk->SetMessageType(messageType);
	this->SendPointcastMessage(messageChunk, receiverId, senderId);
}