vibes
This commit is contained in:
+30
-22
@@ -94,12 +94,13 @@ func (b *shipBus) In(port uint16) int32 {
|
||||
case port == PortFuel:
|
||||
return sat32(sh.Fuel.Floor())
|
||||
case port == PortMass:
|
||||
return sat32(sh.Mass().Floor())
|
||||
return sat32(tc.s.shipMass(sh).Floor())
|
||||
case port == PortScanNearest:
|
||||
scanRange := fixed.FromInt(ScanRangeKm)
|
||||
best, bestD := int64(0), fixed.Max
|
||||
for i := range tc.s.Asteroids {
|
||||
p, _ := tc.asteroid(i)
|
||||
if d := p.Sub(sh.Pos).Len(); d < bestD {
|
||||
if d := p.Sub(sh.Pos).Len(); d <= scanRange && d < bestD {
|
||||
best, bestD = int64(i+1), d
|
||||
}
|
||||
}
|
||||
@@ -110,6 +111,9 @@ func (b *shipBus) In(port uint16) int32 {
|
||||
return 0
|
||||
}
|
||||
rel, relV := p.Sub(sh.Pos), v.Sub(sh.Vel)
|
||||
if rel.Len() > fixed.FromInt(ScanRangeKm) {
|
||||
return 0
|
||||
}
|
||||
switch {
|
||||
case port <= PortScanRelZ:
|
||||
return axis(rel, port, PortScanRelX, kmInt)
|
||||
@@ -119,16 +123,25 @@ func (b *shipBus) In(port uint16) int32 {
|
||||
return kmInt(rel.Len())
|
||||
case port >= PortScanOre && port < PortScanOre+8:
|
||||
if a := tc.s.asteroid(sh.Target); a != nil && port-PortScanOre < uint16(world.NumOre) {
|
||||
if p, _, _ := b.target(); p.Sub(sh.Pos).Len() > fixed.FromInt(ScanRangeKm) {
|
||||
return 0
|
||||
}
|
||||
return sat32(a.Ore[port-PortScanOre])
|
||||
}
|
||||
return 0
|
||||
case port == PortCargo:
|
||||
return sat32(sh.CargoTotal())
|
||||
case port == PortCargoCap:
|
||||
return sat32(sh.Hull.CargoCap)
|
||||
case port >= PortCargoOre && port < PortCargoOre+8:
|
||||
if port-PortCargoOre < uint16(world.NumOre) {
|
||||
return sat32(sh.Cargo[port-PortCargoOre])
|
||||
case port == PortConts:
|
||||
return int32(tc.s.towOf(sh.ID).Count)
|
||||
case port == PortContKg:
|
||||
return sat32(tc.s.towOf(sh.ID).OreTotal)
|
||||
case port == PortContRoom:
|
||||
return sat32(tc.s.towOf(sh.ID).Room)
|
||||
case port == PortContMass:
|
||||
return sat32(tc.s.towOf(sh.ID).Mass)
|
||||
case port == PortNearby:
|
||||
return int32(tc.s.nearbyFree(sh))
|
||||
case port >= PortContOre && port < PortContOre+8:
|
||||
if port-PortContOre < uint16(world.NumOre) {
|
||||
return sat32(tc.s.towOf(sh.ID).Ore[port-PortContOre])
|
||||
}
|
||||
return 0
|
||||
case port >= PortStnRelX && port <= PortStnRelVZ:
|
||||
@@ -170,21 +183,16 @@ func (b *shipBus) Out(port uint16, v int32) {
|
||||
sh.Target = int64(v)
|
||||
case PortMine:
|
||||
sh.Mining = v != 0
|
||||
case PortSell:
|
||||
if v == 0 || !tc.s.canReach(sh, tc.stPos, tc.stVel, DockRangeKm) {
|
||||
return
|
||||
case PortAttach:
|
||||
if v != 0 {
|
||||
tc.s.attach(sh, tc)
|
||||
}
|
||||
value := tc.s.Market.Value(sh.Cargo)
|
||||
if value == 0 {
|
||||
return
|
||||
case PortDetach:
|
||||
if v != 0 {
|
||||
tc.s.detach(sh, tc)
|
||||
}
|
||||
tc.s.Credits[sh.Owner] += value
|
||||
sh.Earned += value
|
||||
for o, kg := range sh.Cargo {
|
||||
tc.sold[o] += kg
|
||||
sh.Cargo[o] = 0
|
||||
}
|
||||
tc.res.Events = append(tc.res.Events, Event{tc.tick, sh.ID, "sold", itoa(value) + " credits"})
|
||||
case PortOrder:
|
||||
tc.s.order(sh, int(v), tc)
|
||||
case PortUplinkNew:
|
||||
sh.UplinkNew = false
|
||||
case PortMathX:
|
||||
|
||||
Reference in New Issue
Block a user