Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Planet Search Overhaul (07/13/24)

Author Topic: How to Add a Constellation?  (Read 1273 times)

SafariJohn

  • Admiral
  • *****
  • Posts: 3055
    • View Profile
How to Add a Constellation?
« on: December 09, 2019, 03:43:55 PM »

I am trying to figure out how to add custom constellations to the sector, but I'm not getting anywhere. Can someone provide a working code example?
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3055
    • View Profile
Re: How to Add a Constellation?
« Reply #1 on: December 09, 2019, 04:25:59 PM »

Figured out my problem thanks to Soren. Turns out you have to have two systems in a constellation for it to show up. IMO I should be able to create arbitrary one-system constellations, but whatever.

For future reference, here's a partial code example that covers the essentials of adding a constellation.

Code: java
        // Create the constellation
        Constellation constellar = new Constellation(ConstellationType.NORMAL, StarAge.AVERAGE);
        constellar.setNamePick(new NamePick(new NameGenData("null", "null"), "Constellation Name", null));

        // Get the systems, or generate them in this case
        StarSystemAPI xSystem = XSystem.generate(sector);
        StarSystemAPI ySystem = YSystem.generate(sector);

        // Add the systems to the constellation
        constellar.getSystems().add(xSystem);
        constellar.getSystems().add(ySystem);

        // Yes, you have to link both ways
        xSystem.setConstellation(constellar);
        ySystem.setConstellation(constellar);
Logged