package hypernova.pilots;

import hypernova.Ship;
import hypernova.Universe;

public class SpaceFactory extends Pilot {
    private String tooling;
    private PilotFactory pilots;
    private double speed, timeout;

    public SpaceFactory(Ship ship, String tooling, PilotFactory pilots,
                        double speed) {
        super(ship);
        this.tooling = tooling;
        this.pilots = pilots;
        this.speed = this.timeout = speed;
    }

    @Override
    public void drive(double dt) {
        timeout -= dt;
        if (timeout > 0) return;
        timeout += speed;

	Ship ship = getShip();
        Ship forged = Ship.get(tooling);
        forged.setFaction(ship.getFaction());
        forged.setPilot(pilots.create(forged));
        forged.setPosition(ship);
        Universe.get().add(forged);
    }
}

@@ -20,16 +20,42 @@
 ilots;%0A%0A
+import java.util.Random;%0A%0A
 import h
@@ -139,16 +139,61 @@
 Pilot %7B%0A
+    private final Random RNG = new Random();%0A
     priv
@@ -279,16 +279,102 @@
 timeout;
+%0A    private double meanGold;%0A    private double varGold;%0A    private double dropRate;
 %0A%0A    pu
@@ -418,35 +418,28 @@
 ooling, 
-PilotFactory pilots
+double speed
 ,%0A      
@@ -456,28 +456,35 @@
         
-double speed
+PilotFactory pilots
 ) %7B%0A    
@@ -612,16 +612,160 @@
 %0A    %7D%0A%0A
+    public void addGold(double mean, double var, double rate) %7B%0A        meanGold = mean;%0A        varGold = var;%0A        dropRate = rate;%0A    %7D%0A%0A
     @Ove
@@ -1073,32 +1073,205 @@
 Position(ship);%0A
+        if (RNG.nextDouble() %3C dropRate) %7B%0A            long gold = (long) (RNG.nextGaussian() * varGold + meanGold);%0A            if (gold %3E 0) forged.store(gold);%0A        %7D%0A
         Universe

Add gold drops to the SpaceFactory.