feat: moge groups in hyperspace

This commit is contained in:
Ilia Denisov
2026-01-18 22:38:11 +02:00
parent 741a5f726b
commit bd9db26ef4
12 changed files with 273 additions and 20 deletions
+11 -3
View File
@@ -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