"use strict";
this.name = "sothis_stn_script.js";
this.author = "Eric Walsh";
this.copyright = "Do what you want with it";
this.description = "Realigns station and adds buoy";
this.version = "1.0";

this.shipSpawned = function () {
    var targetVector = system.mainPlanet.position.subtract(this.ship.position).direction();
    var angle = this.ship.heading.angleTo(targetVector);
    var cross = this.ship.heading.cross(targetVector).direction();
    // align the heading to the targetVector
    this.ship.orientation = this.ship.orientation.rotate(cross, -angle);

    //system.legacy_addShipsAtPrecisely("sothisbuoy", 1, "abs", this.ship.position.add(this.ship.heading.multiply(10E3)));
    system.addShips("sothisbuoy", 1, "abs", this.ship.position.add(this.ship.heading.multiply(10E3)));
    delete this.shipSpawned;
}
