@@ -60,7 +60,9 @@ function Create(self)
60
60
self .buildCost = 10 ; -- How much resource is required per one build 3 x 3 px piece
61
61
self .sprayCost = self .buildCost * 0.5 ;
62
62
63
- self .blockSize = 24 ;
63
+ self .buildSize = 24 ;
64
+ self .buildSizeMin = self .buildSize / 4 ;
65
+ self .buildSizeMax = self .buildSize ;
64
66
self .fullBlock = 64 * self .buildCost ; -- One full 24x24 block of concrete requires 64 units of resource
65
67
self .maxResource = 12 * self .fullBlock ;
66
68
self .startResource = 3 ;
@@ -219,18 +221,18 @@ function Update(self)
219
221
local buildscheme = self .autoBuildList ;
220
222
if actor :HasObjectInGroup (" Brains" ) then
221
223
buildscheme = self .autoBuildListBrain ;
222
- self .blockSize = 12 ;
224
+ self .buildSize = 12 ;
223
225
else
224
- self .blockSize = 24 ;
226
+ self .buildSize = 24 ;
225
227
end
226
- local snappos = ConstructorSnapPos (actor .Pos , self .blockSize );
228
+ local snappos = ConstructorSnapPos (actor .Pos , self .buildSize );
227
229
for i = 1 , # buildscheme do
228
- local temppos = snappos + Vector (buildscheme [i ].X * self .blockSize , buildscheme [i ].Y * self .blockSize );
230
+ local temppos = snappos + Vector (buildscheme [i ].X * self .buildSize , buildscheme [i ].Y * self .buildSize );
229
231
local buildThis = {};
230
232
buildThis [1 ] = temppos .X ;
231
233
buildThis [2 ] = temppos .Y ;
232
234
buildThis [3 ] = 0 ;
233
- buildThis [4 ] = self .blockSize ;
235
+ buildThis [4 ] = self .buildSize ;
234
236
self .buildList [# self .buildList + 1 ] = buildThis ;
235
237
end
236
238
end
@@ -239,7 +241,7 @@ function Update(self)
239
241
-- constructor actions if it's AI controlled
240
242
if self .operatedByAI then
241
243
if self .tunnelFillTimer :IsPastSimMS (self .tunnelFillDelay * self .aiSkillRatio ) and # self .buildList == 0 then
242
- self .blockSize = 24 ;
244
+ self .buildSize = 24 ;
243
245
self .tunnelFillTimer :Reset ();
244
246
245
247
-- create an empty 2D array, call cells having -1
@@ -255,14 +257,14 @@ function Update(self)
255
257
local center = math.ceil (((self .maxFillDistance * 2 ) + 1 ) * 0.5 );
256
258
257
259
-- FLOOD FILL!
258
- ConstructorFloodFill (center , center , 0 , self .maxFillDistance , floodFillListX , ConstructorSnapPos (actor .Pos , self .blockSize ), self .blockSize );
260
+ ConstructorFloodFill (center , center , 0 , self .maxFillDistance , floodFillListX , ConstructorSnapPos (actor .Pos , self .buildSize ), self .buildSize );
259
261
260
262
-- dump the correctly numbered cells into the build table
261
263
for x = 1 , # floodFillListX do
262
264
for y = 1 , # floodFillListX do
263
265
if floodFillListX [x ][y ] >= self .minFillDistance and floodFillListX [x ][y ] <= self .maxFillDistance then
264
- local mapX = ConstructorSnapPos (actor .Pos , self .blockSize ).X + ((center - x ) * - self .blockSize );
265
- local mapY = ConstructorSnapPos (actor .Pos , self .blockSize ).Y + ((center - y ) * - self .blockSize );
266
+ local mapX = ConstructorSnapPos (actor .Pos , self .buildSize ).X + ((center - x ) * - self .buildSize );
267
+ local mapY = ConstructorSnapPos (actor .Pos , self .buildSize ).Y + ((center - y ) * - self .buildSize );
266
268
local freeSlot = true ;
267
269
for i = 1 , # self .buildList do
268
270
if self .buildList [i ] ~= nil and self .buildList [i ][1 ] == mapX and self .buildList [i ][2 ] == mapY then
@@ -275,7 +277,7 @@ function Update(self)
275
277
buildThis [1 ] = mapX ;
276
278
buildThis [2 ] = mapY ;
277
279
buildThis [3 ] = 0 ;
278
- buildThis [4 ] = self .blockSize ;
280
+ buildThis [4 ] = self .buildSize ;
279
281
self .buildList [# self .buildList + 1 ] = buildThis ;
280
282
end
281
283
end
@@ -425,10 +427,16 @@ function Update(self)
425
427
end
426
428
end
427
429
if ctrl :IsState (Controller .WEAPON_CHANGE_NEXT ) then
428
- self .blockSize = math.min (self .blockSize * 2 , 48 );
430
+ self .buildSize = self .buildSize * 2 ;
431
+ if self .buildSize > self .buildSizeMax then
432
+ self .buildSize = self .buildSizeMin ;
433
+ end
429
434
end
430
435
if ctrl :IsState (Controller .WEAPON_CHANGE_PREV ) then
431
- self .blockSize = math.max (self .blockSize / 2 , 6 );
436
+ self .buildSize = self .buildSize / 2 ;
437
+ if self .buildSize < self .buildSizeMin then
438
+ self .buildSize = self .buildSizeMax ;
439
+ end
432
440
end
433
441
434
442
if cursorMovement :MagnitudeIsGreaterThan (0 ) then
@@ -437,15 +445,15 @@ function Update(self)
437
445
local precise = not mouseControlled and aiming ;
438
446
local map = Vector ();
439
447
if precise then
440
- map = Vector (math.floor (self .cursor .X - self .blockSize / 2 ), math.floor (self .cursor .Y - self .blockSize / 2 ));
448
+ map = Vector (math.floor (self .cursor .X - self .buildSize / 2 ), math.floor (self .cursor .Y - self .buildSize / 2 ));
441
449
PrimitiveMan :DrawLinePrimitive (screen , self .cursor + Vector (2 , 2 ), self .cursor + Vector (- 3 , - 3 ), displayColorYellow );
442
450
PrimitiveMan :DrawLinePrimitive (screen , self .cursor + Vector (2 , - 3 ), self .cursor + Vector (- 3 , 2 ), displayColorYellow );
443
451
else
444
- map = ConstructorSnapPos (self .cursor , self .blockSize );
452
+ map = ConstructorSnapPos (self .cursor , self .buildSize );
445
453
PrimitiveMan :DrawLinePrimitive (screen , self .cursor + Vector (0 , 4 ), self .cursor + Vector (0 , - 4 ), displayColorYellow );
446
454
PrimitiveMan :DrawLinePrimitive (screen , self .cursor + Vector (4 , 0 ), self .cursor + Vector (- 4 , 0 ), displayColorYellow );
447
455
end
448
- PrimitiveMan :DrawBoxPrimitive (screen , map , map + Vector (self .blockSize - 1 , self .blockSize - 1 ), displayColorYellow );
456
+ PrimitiveMan :DrawBoxPrimitive (screen , map , map + Vector (self .buildSize - 1 , self .buildSize - 1 ), displayColorYellow );
449
457
450
458
local dist = SceneMan :ShortestDistance (actor .ViewPoint , self .cursor , SceneMan .SceneWrapsX );
451
459
if math.abs (dist .X ) > self .maxCursorDist .X then
@@ -472,7 +480,7 @@ function Update(self)
472
480
buildThis [1 ] = map .X ;
473
481
buildThis [2 ] = map .Y ;
474
482
buildThis [3 ] = 0 ;
475
- buildThis [4 ] = self .blockSize ;
483
+ buildThis [4 ] = self .buildSize ;
476
484
self .buildList [# self .buildList + 1 ] = buildThis ;
477
485
end
478
486
end
0 commit comments