working on docking / ship commands
This commit is contained in:
@@ -35,13 +35,16 @@ return function(x, y, rotation)
|
||||
}
|
||||
|
||||
self.dock = function(self, ship, node)
|
||||
if self.node[node].docked then return false end
|
||||
if self.node[node].docked or ship.isDocked then return false end
|
||||
|
||||
ship.x = self.node[node].x
|
||||
ship.y = self.node[node].y
|
||||
ship.rotation = self.node[node].rotation
|
||||
|
||||
self.node[node].docked = ship
|
||||
ship.isDocked = true
|
||||
ship.dockedTo = self
|
||||
ship.dockedNode = node
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -49,6 +52,9 @@ return function(x, y, rotation)
|
||||
if not self.node[node].docked then return false end
|
||||
|
||||
local ship = self.node[node].docked
|
||||
ship.isDocked = false
|
||||
ship.dockedTo = false
|
||||
ship.dockedNode = false
|
||||
self.node[node].docked = false
|
||||
|
||||
return ship
|
||||
|
@@ -9,6 +9,12 @@ return function(x, y, rotation)
|
||||
self.y = y or 0
|
||||
self.rotation = rotation or 0
|
||||
|
||||
self.destination = {
|
||||
x = x or 0,
|
||||
y = y or 0
|
||||
}
|
||||
self.isMoving = false
|
||||
|
||||
--[[
|
||||
self.selection = {
|
||||
w = 9,
|
||||
@@ -20,6 +26,23 @@ return function(x, y, rotation)
|
||||
}
|
||||
|
||||
--self.node = false
|
||||
self.isDocked = false
|
||||
self.dockedTo = false
|
||||
self.dockedNode = false
|
||||
|
||||
self.moveTo = function(self, x, y)
|
||||
if self.isDocked then
|
||||
self.dockedTo:undock(self.dockedNode)
|
||||
end
|
||||
self.destination.x = x
|
||||
self.destination.y = y
|
||||
self.isMoving = true
|
||||
end
|
||||
|
||||
self.update = function(self, dt)
|
||||
-- check if moving, check our speed, see how far along the "line" we can go, go there
|
||||
-- if reached destination ... WELL SHIT DEST NEEDS TO BE ABLE TO KNOW IF IS SHIP OR WHATEVER
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
Reference in New Issue
Block a user