Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple planets with kerbin template #186

Closed
Sigma88 opened this issue Jun 19, 2017 · 22 comments
Closed

multiple planets with kerbin template #186

Sigma88 opened this issue Jun 19, 2017 · 22 comments

Comments

@Sigma88
Copy link
Contributor

Sigma88 commented Jun 19, 2017

Workaround for multiple planets using a Kerbin template

it is possible to add planets with a Kerbin template but they need to be listed after the HomeWorld in the list of bodies, so they need to be orbiting in a bigger orbit, or being child of bodies that have a bigger orbit than the HomeWorld

keep this in mind if you want to make planets which use a kerbin template

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 19, 2017

ok, I've done some tests and this is what I found out:

  • on a stock install, if you add a second planet with a kerbin template in orbit around the sun, you get a black screen. [config] and [logs]
  • on a stock install, if you add a second planet with a kerbin template in orbit around something other than the sun, you get the tracking station bug mentioned above. [config] and [logs]

note: in case 1, if you click on the tracking station button, you enter the tracking station and you get the camera freaking out bug

@Sigma88 Sigma88 changed the title tracking station camera zooms across multiple planets multiple planets with kerbin template Jun 27, 2017
@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 27, 2017

the common element between many issues like this one and #188 seems to be the fact that with the Kerbin template comes an extra "SpaceCenter"

it might be worth it looking into nuking all SpaceCenter instances that are not the one on the homeplanet

@gordonfpanam
Copy link

Nuking non-homeworld SpaceCenter instances would make cloning Kerbin a lot easier, and more reliable than trying to build an uncivilized Kerbin from scratch.

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 27, 2017

the problem is, I don't even know if that's the thing causing the bug.

if it is then yes, fixing it would be the best option :)

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 27, 2017

ok, so I did some tests and I just tried to spam the stuff from all SpaceCenter objects
(using Resources.FindObjectsOfTypeAll() )

KSPAddon.Startup.MainMenu.Start AND KSPAddon.Startup.SpaceCenter.Start

First SpaceCenter (which is the same as SpaceCenter.Instance)

Line 6995: SigmaLog: ksc = SpaceCenterMarker (SpaceCenter)
Line 6999: SigmaLog: instance = True
Line 7003: SigmaLog: Latitude = 0
Line 7007: SigmaLog: Longitude = 0
Line 7011: SigmaLog: AreaRadius = 1500
Line 7015: SigmaLog: cb = 
Line 7019: SigmaLog: enabled = True
Line 7023: SigmaLog: isActiveAndEnabled = False
Line 7027: SigmaLog: spaceCenterAreaTrigger = DestructionCollider (UnityEngine.SphereCollider)
Line 7031: SigmaLog: SpaceCenterTransform = 
Line 7035: SigmaLog: SrfNVector = [0, 0, 0]
Line 7039: SigmaLog: tag = Untagged

Second SpaceCenter (which is NOT the same as SpaceCenter.Instance)

Line 7043: SigmaLog: ksc = SpaceCenterMarker (SpaceCenter)
Line 7047: SigmaLog: instance = False
Line 7051: SigmaLog: Latitude = 0
Line 7055: SigmaLog: Longitude = 0
Line 7059: SigmaLog: AreaRadius = 1500
Line 7063: SigmaLog: cb = 
Line 7067: SigmaLog: enabled = True
Line 7071: SigmaLog: isActiveAndEnabled = False
Line 7075: SigmaLog: spaceCenterAreaTrigger = DestructionCollider (UnityEngine.SphereCollider)
Line 7079: SigmaLog: SpaceCenterTransform = 
Line 7083: SigmaLog: SrfNVector = [0, 0, 0]
Line 7087: SigmaLog: tag = Untagged

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 27, 2017

but at KSPAddon.Startup.SpaceCenter.Update I get this:

First SpaceCenter (which is the same as SpaceCenter.Instance)

Line 7314: SigmaLog: ksc = SpaceCenterMarker (SpaceCenter)
Line 7318: SigmaLog: instance = True
Line 7322: SigmaLog: Latitude = -0.0917535891768068
Line 7326: SigmaLog: Longitude = -74.629696511363
Line 7330: SigmaLog: AreaRadius = 1500
Line 7334: SigmaLog: cb = Kerbin (CelestialBody)
Line 7338: SigmaLog: enabled = True
Line 7342: SigmaLog: isActiveAndEnabled = True
Line 7346: SigmaLog: spaceCenterAreaTrigger = DestructionCollider (UnityEngine.SphereCollider)
Line 7350: SigmaLog: SpaceCenterTransform = SpaceCenterMarker (UnityEngine.Transform)
Line 7354: SigmaLog: SrfNVector = [0.265056049493614, -0.0016014015471945, -0.964231676590187]
Line 7358: SigmaLog: tag = Untagged

Second SpaceCenter (which is NOT the same as SpaceCenter.Instance)

Line 7362: SigmaLog: ksc = SpaceCenterMarker (SpaceCenter)
Line 7366: SigmaLog: instance = False
Line 7370: SigmaLog: Latitude = 0
Line 7374: SigmaLog: Longitude = 0
Line 7378: SigmaLog: AreaRadius = 1500
Line 7382: SigmaLog: cb = 
Line 7386: SigmaLog: enabled = True
Line 7390: SigmaLog: isActiveAndEnabled = False
Line 7394: SigmaLog: spaceCenterAreaTrigger = DestructionCollider (UnityEngine.SphereCollider)
Line 7398: SigmaLog: SpaceCenterTransform = 
Line 7402: SigmaLog: SrfNVector = [0, 0, 0]
Line 7406: SigmaLog: tag = Untagged

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 27, 2017

this leads me to believe there's a point after which the SpaceCenter is "loaded" and that moment might be what's going wrong when having multiple Kerbin templated planets

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 28, 2017

after messing around with Kopernicus I tried to make Eve a Kerbin template using this simple cfg

@Kopernicus
{
	@Body[Eve]
	{
		%Template
		{
			%name = Kerbin
			%removePQSMods = PQSCity
		}
		%Properties
		{
			%isHomeWorld = False
		}
		%Orbit
		{
			%semiMajorAxis = 9832684544
		}
	}
}

and the game loads on a black screen.

This is due to the fact that the KSC PQSCity on Kerbin does not have a SpaceCenter

specifically, I get the KSC by doing this:

PQSCity KSC = FlightGlobals.GetHomeBody()?.GetComponentsInChildren<PQSCity>().First(m => m.name == "KSC");

and then I get the SpaceCenter by doing this:

SpaceCenter SPACECENTER = KSC.GetComponentsInChildren<SpaceCenter>().FirstOrDefault();

and finally I check if SPACECENTER == SpaceCenter.Instance

on stock KSP everything works out good, I get KSC, SPACECENTER and true

on stock KSP + Kopernicus (but no eve tampering) it still works fine

but when I change eve to have a kerbin template (and get the bug) the result is that the KSC still loads fine, but SPACECENTER is null, which means that the KSC doesn't have a SpaceCenter component

this however doesn't happen when the extra planet with a kerbin template has an higher orbit than the homeplanet

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 28, 2017

also, I'm not sure why there are 2 of these

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 28, 2017

turns out that the SpaceCenter.Instance is a child of Eve (in my example) rather than being a child of Kerbin

I tried changing the parent doing this:

            GameObject spacecenter = Resources.FindObjectsOfTypeAll<GameObject>().FirstOrDefault(o => o.GetComponent<SpaceCenter>() == SpaceCenter.Instance);
            GameObject ksc = Resources.FindObjectsOfTypeAll<GameObject>().FirstOrDefault(o => o.GetComponent<PQSCity>() == FlightGlobals.GetHomeBody()?.GetComponentsInChildren<PQSCity>().FirstOrDefault(m => m.name == "KSC"));
            spacecenter.transform.parent = ksc.transform;

but the game still freezes on a black screen

I checked and the SpaceCenter has the correct parent after I reparent it. so probably the issue is even before that

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 28, 2017

I give up,

the only thing I managed to understand is that there is something on Kerbin Clones that tricks KSP into bugging out. probably some of the components.

I've tried deleting some of them but with no succes

@gordonfpanam
Copy link

It's OK, thanks for trying. What's important is that the root cause for a strange behaviour was uncovered regarding Space Center-related things, and a workaround was found.

If I figure out how to clone Kerbin from scratch, I'll make sure a template is available for that.

@Sigma88
Copy link
Contributor Author

Sigma88 commented Jun 28, 2017

that still would not be a help for me

I need this for GN because some planet packs have custom Kerbin analogues that right now can't load because they use the Kerbin template

@Sigma88
Copy link
Contributor Author

Sigma88 commented Aug 25, 2017

tested this in 1.3.0-6 and it's still there

@Sigma88
Copy link
Contributor Author

Sigma88 commented Sep 6, 2017

I think we can solve this (internally in Kopernicus) by loading the Laythe Template instead of the Kerbin template for all planets except for the HomeWorld

I'll try to put something together unless @StollD you have a good idea on how to implement this

@StollD
Copy link
Member

StollD commented Sep 6, 2017 via email

@Sigma88
Copy link
Contributor Author

Sigma88 commented Sep 6, 2017

not changing the value, just load another planet template and replace the values with kerbin ones.

the best option would be to find the component which is messing up the loading, but since you don't even know what that is, it might be worth to create a templateless planet and load on it everything from kerbin (hoping that the act of copying everything won't copy the issue as well)

anyways this could help us pinpoint which part of the template causes the issue (could be the pqscontroller, or something else)

not everybody has the option of not using kerbin, for one single mod this works fine, but this basically makes it very difficult to have compatibility between planet packs with custom kerbins (see GN)

and for how the loading process works in kopernicus it also means that using MM to overcome this step would be a nightmare (believe me, I've tried)

@Poodmund
Copy link

Poodmund commented Sep 6, 2017

`Does MM have the capability to use an operator like % (makes change and adds if not present) but instead operates in the way of, doesn't change but adds if not present?

Then you could remove template = Kerbin from all bodies and then add back to those bodies the stock Kerbin properties using that operator. It will only add the nodes that don't exist.

Does this make any sense? I don't think MM has an operator like this though, if it does then great, if not then it may be worth asking Sarbian if this is a possibility.

@Sigma88
Copy link
Contributor Author

Sigma88 commented Sep 6, 2017

`Does MM have the capability to use an operator like % (makes change and adds if not present) but instead operates in the way of, doesn't change but adds if not present?

yes, the operator "add only if missing" & works for both keys and nodes

Then you could remove template = Kerbin from all bodies and then add back to those bodies the stock Kerbin properties using that operator. It will only add the nodes that don't exist. Does this make any sense?

nope, I mean, in line of principle yes it's theoretically possible, but it would require a lot of cfg stuff since kopernicus has pretty peculiar rules that need to be accounted for.
just look at what I had to do in SD 0.8.2 and earlier. really, go look at the cfgs, it's something special

Sigma88 added a commit that referenced this issue Sep 7, 2017
this should solve half of the issues caused by having multiple kerbins ( #186 )

specifically, it solves the issue of having the camera "bounce around" the solar system when entering the trackingstation
@Sigma88
Copy link
Contributor Author

Sigma88 commented Sep 7, 2017

ok, with this temporary workaround it is possible to add planets with a Kerbin template

but they need to be listed after the HomeWorld in the list of bodies, so they need to be orbiting in a bigger orbit, or being child of bodies that have a bigger orbit than the HomeWorld

@gordonfpanam
Copy link

I have to wonder: What's the difference between templating Kerbin, and templating Laythe and then filling in all of Kerbin's properties? Since the BUILTIN texture problem got fixed, I don't see the difference.

@Sigma88
Copy link
Contributor Author

Sigma88 commented Sep 26, 2017

the difference is that if your planet with a kerbin template is closer to the sun compared to kerbin, the KSC will be placed there but since that planet is not the homeworld ksp will break

if however, your planet is outside the orbit of kerbin, everything is fine and there will be no bugs

other than that, you will need to remember to set isHomeWorld = false if you use a kerbin template

and if you use a Laythe template you will not get access to kerbin's PQSCity and PQSCity2 mods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants