summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator/ForEachSourceCallback.h
blob: 66b56aa5aa708d6159b67ce2b9005b47ab96744a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#pragma once

#include "RedstoneSimulatorChunkData.h"





class ForEachSourceCallback
{
public:

	ForEachSourceCallback(const cChunk & Chunk, Vector3i Position, BLOCKTYPE CurrentBlock);

	/** Callback invoked for each potential source position of the redstone component. */
	void operator()(Vector3i Location);

	/** Callback invoked for blocks supporting quasiconnectivity. */
	void CheckIndirectPower();

	// The maximum power level of all source locations.
	PowerLevel Power;

private:

	/** Returns whether a potential source position that's occupied by Block should be treated as linked. */
	static bool ShouldQueryLinkedPosition(BLOCKTYPE Block);

	/** Asks redstone handlers adjacent to a solid block how much power they will deliver to the querying position, via the solid block.
	Both QueryPosition and SolidBlockPosition are relative to Chunk. */
	static PowerLevel QueryLinkedPower(const cChunk & Chunk, Vector3i QueryPosition, BLOCKTYPE QueryBlock, Vector3i SolidBlockPosition);

	const cChunk & m_Chunk;
	const Vector3i m_Position;
	const BLOCKTYPE m_CurrentBlock;
};