feat: moge groups in hyperspace
This commit is contained in:
@@ -72,10 +72,16 @@ func (c *Cache) LaunchShips(sg *game.ShipGroup, destination uint) *game.ShipGrou
|
||||
for i := range c.ShipGroupsIndex() {
|
||||
if c.ShipGroup(i).OwnerID == sg.OwnerID && c.ShipGroup(i).Index == sg.Index {
|
||||
state := c.ShipGroup(i).State()
|
||||
if state != game.StateInOrbit && state != game.StateLaunched {
|
||||
var p *game.Planet
|
||||
switch state {
|
||||
case game.StateInOrbit:
|
||||
p = c.MustPlanet(sg.Destination)
|
||||
case game.StateLaunched:
|
||||
p = c.MustPlanet(sg.StateInSpace.Origin)
|
||||
default:
|
||||
panic("state invalid")
|
||||
}
|
||||
c.g.ShipGroups[i] = LaunchShips(*sg, destination)
|
||||
c.g.ShipGroups[i] = LaunchShips(*sg, destination, p.X, p.Y)
|
||||
return &c.g.ShipGroups[i]
|
||||
}
|
||||
}
|
||||
@@ -96,9 +102,11 @@ func (c *Cache) UnsendShips(sg *game.ShipGroup) *game.ShipGroup {
|
||||
panic("ship group not found")
|
||||
}
|
||||
|
||||
func LaunchShips(sg game.ShipGroup, destination uint) game.ShipGroup {
|
||||
func LaunchShips(sg game.ShipGroup, destination uint, originX, originY float64) game.ShipGroup {
|
||||
sg.StateInSpace = &game.InSpace{
|
||||
Origin: sg.Destination,
|
||||
X: originX,
|
||||
Y: originY,
|
||||
}
|
||||
sg.Destination = destination
|
||||
return sg
|
||||
|
||||
Reference in New Issue
Block a user