summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-06-27 00:24:51 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-12-18 14:17:38 +0100
commit5b62c4c3145c08b093521e42c565922fa85de4ad (patch)
treedca8cbfe86aa27af174da21f6835a8fbbe83d248 /src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
parentMerge pull request #2770 from cuberite/RemoveChunkDataCollector (diff)
downloadcuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.tar
cuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.tar.gz
cuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.tar.bz2
cuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.tar.lz
cuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.tar.xz
cuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.tar.zst
cuberite-5b62c4c3145c08b093521e42c565922fa85de4ad.zip
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h167
1 files changed, 167 insertions, 0 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
new file mode 100644
index 000000000..a43a6e49b
--- /dev/null
+++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
@@ -0,0 +1,167 @@
+
+#pragma once
+
+#include "../RedstoneSimulator.h"
+#include "RedstoneSimulatorChunkData.h"
+
+
+
+
+
+class cIncrementalRedstoneSimulator :
+ public cRedstoneSimulator
+{
+ typedef cRedstoneSimulator super;
+public:
+ cIncrementalRedstoneSimulator(cWorld & a_World) :
+ super(a_World)
+ {
+ }
+
+ virtual void Simulate(float a_dt) override;
+ virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override {}
+
+ virtual cIncrementalRedstoneSimulatorChunkData * CreateChunkData() override
+ {
+ return new cIncrementalRedstoneSimulatorChunkData;
+ }
+
+ virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override
+ {
+ return IsRedstone(a_BlockType);
+ }
+
+ virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override
+ {
+ m_Data.WakeUp({ a_BlockX, a_BlockY, a_BlockZ });
+ }
+
+ /** Returns if a block is a mechanism (something that accepts power and does something)
+ Used by torches to determine if they will power a block
+ */
+ inline static bool IsMechanism(BLOCKTYPE Block)
+ {
+ switch (Block)
+ {
+ case E_BLOCK_ACACIA_DOOR:
+ case E_BLOCK_ACACIA_FENCE_GATE:
+ case E_BLOCK_ACTIVATOR_RAIL:
+ case E_BLOCK_ACTIVE_COMPARATOR:
+ case E_BLOCK_BIRCH_DOOR:
+ case E_BLOCK_BIRCH_FENCE_GATE:
+ case E_BLOCK_COMMAND_BLOCK:
+ case E_BLOCK_DARK_OAK_DOOR:
+ case E_BLOCK_DARK_OAK_FENCE_GATE:
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
+ case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_HOPPER:
+ case E_BLOCK_INACTIVE_COMPARATOR:
+ case E_BLOCK_IRON_DOOR:
+ case E_BLOCK_IRON_TRAPDOOR:
+ case E_BLOCK_JUNGLE_DOOR:
+ case E_BLOCK_JUNGLE_FENCE_GATE:
+ case E_BLOCK_NOTE_BLOCK:
+ case E_BLOCK_PISTON:
+ case E_BLOCK_POWERED_RAIL:
+ case E_BLOCK_REDSTONE_LAMP_OFF:
+ case E_BLOCK_REDSTONE_LAMP_ON:
+ case E_BLOCK_REDSTONE_REPEATER_OFF:
+ case E_BLOCK_REDSTONE_REPEATER_ON:
+ case E_BLOCK_REDSTONE_WIRE:
+ case E_BLOCK_SPRUCE_DOOR:
+ case E_BLOCK_SPRUCE_FENCE_GATE:
+ case E_BLOCK_STICKY_PISTON:
+ case E_BLOCK_TNT:
+ case E_BLOCK_TRAPDOOR:
+ case E_BLOCK_WOODEN_DOOR:
+ {
+ return true;
+ }
+ default: return false;
+ }
+ }
+
+ /** Returns if a redstone device is always ticked due to influence by its environment */
+ inline static bool IsAlwaysTicked(BLOCKTYPE a_Block)
+ {
+ switch (a_Block) // Call the appropriate simulator for the entry's block type
+ {
+ case E_BLOCK_DAYLIGHT_SENSOR:
+ case E_BLOCK_TRIPWIRE_HOOK:
+ case E_BLOCK_WOODEN_PRESSURE_PLATE:
+ case E_BLOCK_STONE_PRESSURE_PLATE:
+ case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
+ case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return true;
+ default: return false;
+ }
+ }
+
+ /** Returns if a block is any sort of redstone device */
+ inline static bool IsRedstone(BLOCKTYPE a_Block)
+ {
+ switch (a_Block)
+ {
+ // All redstone devices, please alpha sort
+ case E_BLOCK_ACACIA_DOOR:
+ case E_BLOCK_ACACIA_FENCE_GATE:
+ case E_BLOCK_ACTIVATOR_RAIL:
+ case E_BLOCK_ACTIVE_COMPARATOR:
+ case E_BLOCK_BIRCH_DOOR:
+ case E_BLOCK_BIRCH_FENCE_GATE:
+ case E_BLOCK_BLOCK_OF_REDSTONE:
+ case E_BLOCK_COMMAND_BLOCK:
+ case E_BLOCK_DARK_OAK_DOOR:
+ case E_BLOCK_DARK_OAK_FENCE_GATE:
+ case E_BLOCK_DAYLIGHT_SENSOR:
+ case E_BLOCK_DETECTOR_RAIL:
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
+ case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
+ case E_BLOCK_HOPPER:
+ case E_BLOCK_INACTIVE_COMPARATOR:
+ case E_BLOCK_IRON_DOOR:
+ case E_BLOCK_IRON_TRAPDOOR:
+ case E_BLOCK_JUNGLE_DOOR:
+ case E_BLOCK_JUNGLE_FENCE_GATE:
+ case E_BLOCK_LEVER:
+ case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE:
+ case E_BLOCK_NOTE_BLOCK:
+ case E_BLOCK_POWERED_RAIL:
+ case E_BLOCK_REDSTONE_LAMP_OFF:
+ case E_BLOCK_REDSTONE_LAMP_ON:
+ case E_BLOCK_REDSTONE_REPEATER_OFF:
+ case E_BLOCK_REDSTONE_REPEATER_ON:
+ case E_BLOCK_REDSTONE_TORCH_OFF:
+ case E_BLOCK_REDSTONE_TORCH_ON:
+ case E_BLOCK_REDSTONE_WIRE:
+ case E_BLOCK_SPRUCE_DOOR:
+ case E_BLOCK_SPRUCE_FENCE_GATE:
+ case E_BLOCK_STICKY_PISTON:
+ case E_BLOCK_STONE_BUTTON:
+ case E_BLOCK_STONE_PRESSURE_PLATE:
+ case E_BLOCK_TNT:
+ case E_BLOCK_TRAPDOOR:
+ case E_BLOCK_TRAPPED_CHEST:
+ case E_BLOCK_TRIPWIRE_HOOK:
+ case E_BLOCK_TRIPWIRE:
+ case E_BLOCK_WOODEN_BUTTON:
+ case E_BLOCK_WOODEN_DOOR:
+ case E_BLOCK_WOODEN_PRESSURE_PLATE:
+ case E_BLOCK_PISTON:
+ {
+ return true;
+ }
+ default: return false;
+ }
+ }
+
+ cIncrementalRedstoneSimulatorChunkData * GetChunkData() { return &m_Data; }
+ static std::unique_ptr<cRedstoneHandler> CreateComponent(cWorld & a_World, BLOCKTYPE a_BlockType, cIncrementalRedstoneSimulatorChunkData * a_Data);
+
+private:
+
+ // oh yea its crazy time
+ cIncrementalRedstoneSimulatorChunkData m_Data;
+} ;