feat: move func to calc package
This commit is contained in:
@@ -9,8 +9,6 @@ import (
|
||||
"galaxy/calc"
|
||||
mr "galaxy/model/report"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
"galaxy/game/internal/model/game"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -94,7 +92,7 @@ func (c *Cache) InitReport(t uint) *mr.Report {
|
||||
}
|
||||
for pi := range c.g.Map.Planet {
|
||||
p2 := &c.g.Map.Planet[pi]
|
||||
distance := util.ShortDistance(c.g.Map.Width, c.g.Map.Height, sg.StateInSpace.X.F(), sg.StateInSpace.Y.F(), p2.X.F(), p2.Y.F())
|
||||
distance := calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, sg.StateInSpace.X.F(), sg.StateInSpace.Y.F(), p2.X.F(), p2.Y.F())
|
||||
report.InSpaceGroupRangeCache[sgi][p2.Number] = distance
|
||||
}
|
||||
} else {
|
||||
@@ -396,7 +394,7 @@ func (c *Cache) ReportIncomingGroup(ri int, rep *mr.Report) {
|
||||
continue
|
||||
}
|
||||
|
||||
distance := util.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
distance := calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
var speed, mass float64
|
||||
if sg.FleetID != nil {
|
||||
speed, mass = c.FleetSpeedAndMass(c.MustFleetIndex(*sg.FleetID))
|
||||
@@ -597,7 +595,7 @@ func (c *Cache) ReportLocalFleet(ri int, rep *mr.Report) {
|
||||
if inSpace, ok := fleetState.InSpace(); ok {
|
||||
rep.LocalFleet[i].Origin = &inSpace.Origin
|
||||
p2 := c.MustPlanet(rep.LocalFleet[i].Destination)
|
||||
rangeToDestination := mr.F(util.ShortDistance(c.g.Map.Width, c.g.Map.Height, inSpace.X.F(), inSpace.Y.F(), p2.X.F(), p2.Y.F()))
|
||||
rangeToDestination := mr.F(calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, inSpace.X.F(), inSpace.Y.F(), p2.X.F(), p2.Y.F()))
|
||||
rep.LocalFleet[i].Range = &rangeToDestination
|
||||
}
|
||||
i++
|
||||
@@ -726,7 +724,7 @@ func (c *Cache) otherGroup(v *mr.OtherGroup, sg *game.ShipGroup, st *game.ShipTy
|
||||
if sg.State() == game.StateInSpace {
|
||||
v.Origin = &sg.StateInSpace.Origin
|
||||
p2 := c.MustPlanet(v.Destination)
|
||||
rangeToDestination := mr.F(util.ShortDistance(c.g.Map.Width, c.g.Map.Height, sg.StateInSpace.X.F(), sg.StateInSpace.Y.F(), p2.X.F(), p2.Y.F()))
|
||||
rangeToDestination := mr.F(calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, sg.StateInSpace.X.F(), sg.StateInSpace.Y.F(), p2.X.F(), p2.Y.F()))
|
||||
v.Range = &rangeToDestination
|
||||
}
|
||||
v.Speed = mr.F(sg.Speed(st))
|
||||
|
||||
Reference in New Issue
Block a user