-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock_placement.as
103 lines (84 loc) · 2.89 KB
/
block_placement.as
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
bool PlaceBlock(CGameEditorPluginMap@ map, const string blockName, CGameEditorPluginMap::ECardinalDirections dir, int3 point)
{
auto info = map.GetBlockModelFromName(blockName);
if(!(map.GetBlock(point) is null) && (blockName != RD_TURN2 && blockName != RD_UP2) && (map.GetBlock(point).BlockModel.IdName == WALL_STRAIGHT || map.GetBlock(point).BlockModel.IdName == WALL_FULL))
{
ClearPath(map, point);
}
while (!map.IsEditorReadyForRequest) {
yield();
}
return map.PlaceBlock(info, point, dir);
}
bool CanPlaceBlock(CGameEditorPluginMap@ map, const string blockName, CGameEditorPluginMap::ECardinalDirections dir, int3 point)
{
auto info = map.GetBlockModelFromName(blockName);
if(!(map.GetBlock(point) is null) && (blockName != RD_TURN2 && blockName != RD_UP2) && (map.GetBlock(point).BlockModel.IdName == WALL_STRAIGHT || map.GetBlock(point).BlockModel.IdName == WALL_FULL))
{
auto upPoint = point.opAdd(int3(0,1,0));
if(!(map.GetBlock(upPoint) is null) && (map.GetBlock(upPoint).BlockModel.IdName == WALL_STRAIGHT || map.GetBlock(upPoint).BlockModel.IdName == WALL_FULL))
{
return true;
}
return false;
}
while (!map.IsEditorReadyForRequest) {
yield();
}
return map.CanPlaceBlock(info, point, dir, true, 0);
}
bool PlaceGhostBlock(CGameEditorPluginMap@ map, const string blockName, CGameEditorPluginMap::ECardinalDirections dir, int3 point)
{
auto info = map.GetBlockModelFromName(blockName);
while (!map.IsEditorReadyForRequest) {
yield();
}
return map.PlaceGhostBlock(info, point, dir);
}
bool CanPlaceGhostBlock(CGameEditorPluginMap@ map, const string blockName, CGameEditorPluginMap::ECardinalDirections dir, int3 point)
{
auto info = map.GetBlockModelFromName(blockName);
while (!map.IsEditorReadyForRequest) {
yield();
}
return map.CanPlaceGhostBlock(info, point, dir);
}
CGameEditorPluginMapConnectResults@ ConnectBlocks(CGameEditorPluginMap@ map, CGameCtnBlock@ eBlock, const string nBlock)
{
try
{
auto info = map.GetBlockModelFromName(nBlock);
while (!map.IsEditorReadyForRequest) {
yield();
}
map.GetConnectResults(eBlock, info);
while (!map.IsEditorReadyForRequest) {
yield();
}
if (map.ConnectResults.Length > 0 && !(map.ConnectResults[map.ConnectResults.Length-1] is null))
{
return map.ConnectResults[map.ConnectResults.Length-1];
}
return null;
}
catch
{
return null;
}
}
void ClearPath(CGameEditorPluginMap@ map, int3 point)
{
TGprint("removing a wall from " + tostring(point));
while (!map.IsEditorReadyForRequest) {
yield();
}
map.RemoveBlock(point);
auto upPoint = point.opAdd(int3(0,1,0));
if(!(map.GetBlock(upPoint) is null) && (map.GetBlock(upPoint).BlockModel.IdName == WALL_STRAIGHT || map.GetBlock(upPoint).BlockModel.IdName == WALL_FULL))
{
while (!map.IsEditorReadyForRequest) {
yield();
}
map.RemoveBlock(upPoint);
}
}