Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: addOrbitingEntities() Adds Wrong Things to Nebula System  (Read 659 times)

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
addOrbitingEntities() Adds Wrong Things to Nebula System
« on: August 19, 2020, 07:34:02 PM »

The static method StarSystemGenerator.addOrbitingEntities() often adds inappropriate entities like ring systems and asteroid belts to nebula systems. It should detect what type of nebula the system is, if any, instead of randomly picking one.

EDIT: Maybe it needs to set systemType, too? Looks like it.
« Last Edit: August 19, 2020, 07:43:29 PM by SafariJohn »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24146
    • View Profile
Re: addOrbitingEntities() Adds Wrong Things to Nebula System
« Reply #1 on: August 19, 2020, 08:16:20 PM »

Hmm. I vaguely recall that this may be a known shortcoming that was deemed acceptable because the vanilla use cases don't really care - that is, it's mainly noticeable for nebulas, and it's not called for those. I'll keep it in mind, though fixing it would require re-familiarizing myself with some fairly tricky code and I don't really see doing it unless I was already doing something in that area.

(It's also possible that there might be a way to make it work. Have you set the systemType etc? I'm not sure what you mean by *it* needing to do that - that would be outside that method's purview; all it does is add some entities to an existing system.)
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: addOrbitingEntities() Adds Wrong Things to Nebula System
« Reply #2 on: August 19, 2020, 08:23:12 PM »

I subclassed StarSystemGenerator, duplicated the static addOrbitingEntities(), and replaced:

Code: java
gen.pickNebulaAndBackground();

with:

Code: java
gen.systemType = system.getType();
if (system.getType().equals(StarSystemType.NEBULA)) {
     if (age.equals(StarAge.YOUNG)) gen.nebulaType = NEBULA_BLUE;
     else if (age.equals(StarAge.OLD)) gen.nebulaType = NEBULA_AMBER;
     else gen.nebulaType = NEBULA_DEFAULT;
} else {
     gen.nebulaType = NEBULA_NONE;
}

It seems to work perfectly with this modification.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: addOrbitingEntities() Adds Wrong Things to Nebula System
« Reply #3 on: August 20, 2020, 05:48:30 AM »

Ran into a problem with gas giant gravity well names because of this code in StarSystemGenerator.addPlanet():

Code: java
if (planet.isGasGiant()) {
if (systemType == StarSystemType.NEBULA) {
planet.setAutogenJumpPointNameInHyper(system.getBaseName() + ", " + planetName + " Gravity Well");
}
}

It gives results like "Kiska, Planet 5 Gravity Well". Proc-gen nebula systems show normal gas giant JP names, so I suspect this is debug code that can be safely commented out.

I didn't try that, though, just fixed the borked names later.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3023
    • View Profile
Re: addOrbitingEntities() Adds Wrong Things to Nebula System
« Reply #4 on: August 20, 2020, 06:13:14 AM »

Seems like it isn't actually affecting anything, but the static StarSystemGenerator.addSystemwideNebula() has the exact same problem and solution with setting the nebula type as addOrbitingEntities().
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24146
    • View Profile
Re: addOrbitingEntities() Adds Wrong Things to Nebula System
« Reply #5 on: August 20, 2020, 09:46:48 AM »

Thanks! Hmm.

I subclassed StarSystemGenerator, duplicated the static addOrbitingEntities(), and replaced:

Code: java
gen.pickNebulaAndBackground();

with:

Code: java
gen.systemType = system.getType();
if (system.getType().equals(StarSystemType.NEBULA)) {
     if (age.equals(StarAge.YOUNG)) gen.nebulaType = NEBULA_BLUE;
     else if (age.equals(StarAge.OLD)) gen.nebulaType = NEBULA_AMBER;
     else gen.nebulaType = NEBULA_DEFAULT;
} else {
     gen.nebulaType = NEBULA_NONE;
}

It seems to work perfectly with this modification.

This looks like it'll work for your case, but it's not quite correct - it's conflating whether a star system is a nebula (i.e. has no star, and stuff doesn't circle the center) with whether the constellation is inside a nebula (i.e. it has a nebula background in the map, and more nebula-clouds in the system map). The first implies the second, but the second does not imply the first.

I *think* just having:
gen.pickNebulaAndBackground();
if (system.getType() != null) gen.systemType = system.getType();

Would do the job. Probably. Might be missing some corner case here, though.


Ran into a problem with gas giant gravity well names because of this code in StarSystemGenerator.addPlanet():

Code: java
if (planet.isGasGiant()) {
if (systemType == StarSystemType.NEBULA) {
planet.setAutogenJumpPointNameInHyper(system.getBaseName() + ", " + planetName + " Gravity Well");
}
}

It gives results like "Kiska, Planet 5 Gravity Well". Proc-gen nebula systems show normal gas giant JP names, so I suspect this is debug code that can be safely commented out.

I didn't try that, though, just fixed the borked names later.

Ah, I don't think the quoted code actually matters - that is, the field is sets looks like it only gets checked for jump-points, not planets. Not sure why it's there in the first place, though - probably, as you say, some leftover debug stuff.
Logged