clone functions

This commit is contained in:
Alexey 2025-10-30 00:24:49 +03:00
commit 2eb4f33864
2 changed files with 27 additions and 0 deletions

View file

@ -47,6 +47,19 @@ function Port:new(position, rotation, color)
return port
end
---@return Port
function Port:clone()
local port = {
position = GridPoint:new( self.position.x, self.position.y ),
alignment = self.alignment,
scanOffset = self.scanOffset,
color = self.color
}
setmetatable( port, { __index = self } )
return port
end
function Port:rotateClockwise()
self.position.x, self.position.y = -self.position.y, self.position.x
self.scanOffset = (self.scanOffset == 1) ~= self.alignment and 1 or 0