-
Notifications
You must be signed in to change notification settings - Fork 3
/
redstone.h
77 lines (60 loc) · 1.58 KB
/
redstone.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include <Windows.h>
// 红石方块种类
enum RedstoneObjectTypes
{
RS_NULL, // 空气方块(无方块)
RS_POWDER, // 红石粉
RS_ROD, // 拉杆
RS_BUTTON, // 按钮
RS_TORCHE, // 红石火把
RS_LIGHT, // 红石灯
RS_RELAY, // 中继器
RS_CROSS // 交叉排线板(不属于 MC 方块,仅在平面交叉电路中发挥作用)
};
// 红石方块朝向
enum RedstoneTowards
{
RS_TO_UP, // 朝向上
RS_TO_RIGHT,// 朝向右
RS_TO_DOWN, // 朝向下
RS_TO_LEFT // 朝向左
};
struct Power
{
bool isPowerOfCross = false; // 是否为交叉线的电源
// 规定:如果同一个电源供给交叉线的两个方向,则应当存储两个电源,分别标识为水平电源和竖直电源
bool horizon = false; // 是交叉线的水平方向电源(仅用于交叉线)
bool upright = false; // 是交叉线的垂直方向电源(仅用于交叉线)
int x = -1, y = -1;
Power()
{
}
Power(POINT pt)
{
x = pt.x;
y = pt.y;
}
};
// 红石方块定义
typedef struct RedstoneObject
{
int nType = RS_NULL; // 方块种类
int nTowards = RS_TO_UP; // 朝向
bool bPowered = false; // 是否充能(对于交叉线,任意方向充能都会标识)
bool bUprightPowered = false; // 竖直方向是否充能(仅用于交叉线)
bool bHorizonPowered = false; // 水平方向是否充能(仅用于交叉线)
bool bHaveUprightPower = false; // 竖直方向是否存在供电源(仅用于交叉线)
bool bHaveHorizonPower = false; // 水平方向是否存在供电源(仅用于交叉线)
int nPowerCount = 0; // 供电数量
Power* pPowerList = nullptr; // 供电电源坐标(释放时 delete[] 即可)
}RsObj;
// 红石地图
typedef struct RedstoneMap
{
int w = 0; // 地图宽高
int h = 0; // 地图宽高
RsObj** map = nullptr; // 地图
}RsMap;
// 运行红石地图
void RunRsMap(RsMap* pMap);