net-lisias-ksp / DistantObject

Distant Object Enhancement (DOE) is a visual enhancement mod that makes objects realistically visible over large distances.
Other
10 stars 3 forks source link

Support Kopernicus #33

Closed Lisias closed 2 months ago

Lisias commented 1 year ago

As the title says.

Check this post on Forum.

Lisias commented 1 year ago

A proposal for implementation can be found here:

https://github.com/net-lisias-ksp/DistantObject/issues/11#issuecomment-1487768936

My job now is to create a new Interface and two DLLs realising it - one for Stock and another for Kopernicus.

Lisias commented 2 months ago

Another one, here: https://github.com/net-lisias-ksp/DistantObject/issues/11#issuecomment-2253691518

Problem - it still causes a hard dependency on Kopernicus.

Lisias commented 2 months ago

I think it's time to kick start this thingy...

Lisias commented 2 months ago

Implemented on commit https://github.com/net-lisias-ksp/DistantObject/commit/1da19e53940b2dcf1fd93e31daabfa6acb518905

Thanks to @Tequhella for doing the hard part for me!

Tequhella commented 2 months ago

Okay, I'll comment here then! @Lisias So, to come back to the comment about the hard dependency, yes indeed, I hadn't realized I'd left a reference in, but I don't use it at all in FlareDraw.cs. The only place it's used is in ISolarSystem.cs. But I've already tried to run KSP without Kopernicus, and had no problem.

I've just seen what you've done, and I can see better what you imagined. Thx for taking the time to do this implementation!

Lisias commented 2 months ago

@Tequhella The problem with hard dependencies is that they will prevent the whole Assembly from being loaded if they are not met, screwing the add'on.

The only way to overcome this is by doing what I did: optionally loadable Assemblies, loaded on demand depending on what you have installed in your rig.

On this solution case, if the code finds Kopernicus installed, it will load the SolarSystemKopernicus DLL, if not, it will load the SolarSystemStock one.

By shoving on these DLLs the services you need to be carried on, you will preserve the main Assembly from any foreign dependency, allowing it to be always loaded.

It's somewhat convoluted, I agree. But, yet, it's the only feasible (and safe) way to do such.

Tequhella commented 2 months ago

@Lisias Okay, I understand the principle! But I'm not sure when this problem appears. Is it during development or when the game is launched?

Lisias commented 2 months ago

@Tequhella Both!

Tequhella commented 2 months ago

Hum... Ok, so I don't understand how I was able to use DOE in-game without any problems with my version of the mod when I deleted Kopernicus from my GameData folder. It shouldn't have worked if the Kopernicus assembly isn't present to be loaded, if I understood correctly. Sorry for these questions, I'm trying to understand how assemblies work with KSP! Because there's certainly a lot I'm missing, and I think it might help me be more efficient for other times when I'm helping out.

Lisias commented 2 months ago

Yes, you are right. DOE should had failed being loaded without Kopernicus - historically, it was being happening since Kraken knows when.

Now I'm curious... I will check this as soon as I find the time.

(hopefully, this week)

Tequhella commented 2 months ago

@Lisias I saw that you posted on the forum that you haven't tested Kopernicus support yet. I've installed it on my machine, and it seems to work fine! Capture d'écran 2024-08-02 204924

Lisias commented 2 months ago

@Tequhella thank you!