TheDeadSnake / LC-Touchscreen

A LethalCompany monitor mod
0 stars 0 forks source link

[Compatibility] LethalLevelLoader #23

Closed IAmBatby closed 7 months ago

IAmBatby commented 7 months ago
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
        if (scene.name.StartsWith("level", StringComparison.OrdinalIgnoreCase) || scene.name.Equals("companybuilding", StringComparison.OrdinalIgnoreCase) || _onPlanetCheck.Invoke(scene.name)) {
            GameObject obj = StartOfRound.Instance?.mapScreen?.mesh.gameObject;
            if (obj != null && obj.GetComponent<ScreenScript>() == null) {
                obj.AddComponent<ScreenScript>();
            }
            _onPlanet = true;
        }

This code relies on the assumption all levels have "level" in their name, which is not true for custom level scenes.

I suggest you get the scene based on StartOfRound.currentLevel.sceneName and check if said Scene isLoaded.

TheDeadSnake commented 7 months ago

The two string checks are only for the base game levels all (LE & LEC) custom worlds use the same empty scene to then spawn all world items. The custom levels are checked via the onPlanet function which is setup at plugin startup.

IAmBatby commented 7 months ago

LethalLevelLoader uses custom scenes which will not be supported by this code.

TheDeadSnake commented 7 months ago

Well, that is a plugin that I never heard of. I will take a look at it and add support for it in the future.

CommanderSlav commented 7 months ago

I wanted to make a note on this as I was the one who originally reported this, assuming it was an LLL issue, that if you try to test this for yourself, it's easily replicable by downloading any moon that uses LLL, Starlancer moons for example, land the ship. You'll notice the ability to interact with the screen is missing. Nothing catastrophically explodes but it does lose touch screen functionality the entire time you're landed on the moon. When returning to a vanilla moon, the mod functions as it should.

Just figured I'd add this in case it helps.

TheDeadSnake commented 7 months ago

Fixed in v1.1.0