josefnpat / roguecraft-squadron

The Official Repo for RogueCraft Squadron
http://roguecraftsquadron.com/
9 stars 0 forks source link

Add Rally Points #595

Open josefnpat opened 6 years ago

josefnpat commented 6 years ago

It doesnt' work well due to

diff --git a/src/libs/objectrenderer.lua b/src/libs/objectrenderer.lua
index a45c3f5..e65ab30 100755
--- a/src/libs/objectrenderer.lua
+++ b/src/libs/objectrenderer.lua
@@ -253,6 +253,13 @@ function objectrenderer.drawChevron(object,selection)
     object.dx,object.dy,0,1,1,
     objectrenderer.chevron:getWidth()/2,objectrenderer.chevron:getHeight()/2)

+  if isSelected and object.rally then
+    love.graphics.line(object.dx,object.dy,object.rally.x,object.rally.y)
+    love.graphics.draw(objectrenderer.chevron,
+      object.rally.x,object.rally.y,0,1,1,
+      objectrenderer.chevron:getWidth()/2,objectrenderer.chevron:getHeight()/2)
+  end
+
 end

 function objectrenderer.drawShip(object)
diff --git a/src/states/client.lua b/src/states/client.lua
index 512dc25..5829c6d 100644
--- a/src/states/client.lua
+++ b/src/states/client.lua
@@ -391,6 +391,15 @@ function client:update(dt)
           if parent then
             parent.build_current = nil
             self.buildqueue:doFullUpdate()
+            if parent.rally then
+              local moves = {}
+              table.insert(moves,{
+                i=sobject.index,
+                x=parent.rally.x,
+                y=parent.rally.y,
+              })
+              self.lovernet:sendData(libs.net.op.move_objects,{o=moves,int=false})
+            end
           else
             print('warning: parent is missing')
           end
@@ -740,6 +749,14 @@ function client:moveSelectedObjects(x,y)
   local moves = {}
   local curAngle = 0
   local selected = self.selection:getSelected()
+
+  if love.keyboard.isDown("lalt") then
+    for _,object in pairs(selected) do
+      object.rally = {x=x,y=y}
+    end
+    return
+  end
+
   local unselected = self.selection:getUnselected(self.objects)
   local send_move_command = true
   for _,object in pairs(self.selection:getSelected()) do