Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit fba42d1

Browse files
committed
Constructor edits;
- Changing size via weapon switch key will now wrap around to smallest / largest size - Renamed internal value "blockSize" to "buildSize"
1 parent e725740 commit fba42d1

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

Data/Base.rte/Devices/Tools/Constructor/Constructor.lua

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function Create(self)
6060
self.buildCost = 10; --How much resource is required per one build 3 x 3 px piece
6161
self.sprayCost = self.buildCost * 0.5;
6262

63-
self.blockSize = 24;
63+
self.buildSize = 24;
64+
self.buildSizeMin = self.buildSize/4;
65+
self.buildSizeMax = self.buildSize;
6466
self.fullBlock = 64 * self.buildCost; --One full 24x24 block of concrete requires 64 units of resource
6567
self.maxResource = 12 * self.fullBlock;
6668
self.startResource = 3;
@@ -219,18 +221,18 @@ function Update(self)
219221
local buildscheme = self.autoBuildList;
220222
if actor:HasObjectInGroup("Brains") then
221223
buildscheme = self.autoBuildListBrain;
222-
self.blockSize = 12;
224+
self.buildSize = 12;
223225
else
224-
self.blockSize = 24;
226+
self.buildSize = 24;
225227
end
226-
local snappos = ConstructorSnapPos(actor.Pos, self.blockSize);
228+
local snappos = ConstructorSnapPos(actor.Pos, self.buildSize);
227229
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);
229231
local buildThis = {};
230232
buildThis[1] = temppos.X;
231233
buildThis[2] = temppos.Y;
232234
buildThis[3] = 0;
233-
buildThis[4] = self.blockSize;
235+
buildThis[4] = self.buildSize;
234236
self.buildList[#self.buildList + 1] = buildThis;
235237
end
236238
end
@@ -239,7 +241,7 @@ function Update(self)
239241
-- constructor actions if it's AI controlled
240242
if self.operatedByAI then
241243
if self.tunnelFillTimer:IsPastSimMS(self.tunnelFillDelay * self.aiSkillRatio) and #self.buildList == 0 then
242-
self.blockSize = 24;
244+
self.buildSize = 24;
243245
self.tunnelFillTimer:Reset();
244246

245247
-- create an empty 2D array, call cells having -1
@@ -255,14 +257,14 @@ function Update(self)
255257
local center = math.ceil(((self.maxFillDistance * 2) + 1) * 0.5);
256258

257259
-- 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);
259261

260262
-- dump the correctly numbered cells into the build table
261263
for x = 1, #floodFillListX do
262264
for y = 1, #floodFillListX do
263265
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);
266268
local freeSlot = true;
267269
for i = 1, #self.buildList do
268270
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)
275277
buildThis[1] = mapX;
276278
buildThis[2] = mapY;
277279
buildThis[3] = 0;
278-
buildThis[4] = self.blockSize;
280+
buildThis[4] = self.buildSize;
279281
self.buildList[#self.buildList + 1] = buildThis;
280282
end
281283
end
@@ -425,10 +427,16 @@ function Update(self)
425427
end
426428
end
427429
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
429434
end
430435
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
432440
end
433441

434442
if cursorMovement:MagnitudeIsGreaterThan(0) then
@@ -437,15 +445,15 @@ function Update(self)
437445
local precise = not mouseControlled and aiming;
438446
local map = Vector();
439447
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));
441449
PrimitiveMan:DrawLinePrimitive(screen, self.cursor + Vector(2, 2), self.cursor + Vector(-3, -3), displayColorYellow);
442450
PrimitiveMan:DrawLinePrimitive(screen, self.cursor + Vector(2, -3), self.cursor + Vector(-3, 2), displayColorYellow);
443451
else
444-
map = ConstructorSnapPos(self.cursor, self.blockSize);
452+
map = ConstructorSnapPos(self.cursor, self.buildSize);
445453
PrimitiveMan:DrawLinePrimitive(screen, self.cursor + Vector(0, 4), self.cursor + Vector(0, -4), displayColorYellow);
446454
PrimitiveMan:DrawLinePrimitive(screen, self.cursor + Vector(4, 0), self.cursor + Vector(-4, 0), displayColorYellow);
447455
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);
449457

450458
local dist = SceneMan:ShortestDistance(actor.ViewPoint, self.cursor, SceneMan.SceneWrapsX);
451459
if math.abs(dist.X) > self.maxCursorDist.X then
@@ -472,7 +480,7 @@ function Update(self)
472480
buildThis[1] = map.X;
473481
buildThis[2] = map.Y;
474482
buildThis[3] = 0;
475-
buildThis[4] = self.blockSize;
483+
buildThis[4] = self.buildSize;
476484
self.buildList[#self.buildList + 1] = buildThis;
477485
end
478486
end

0 commit comments

Comments
 (0)