DankuwOs / VTOLAPI

A mod that adds some of the old ModLoader functions. Also adds existing modloader functions related to steam items so there's no need to publicize the modloader dll.
1 stars 1 forks source link

Calling `VTAPI.GetVehicleEnum` seems to lock up the game. #3

Closed BlockListed closed 2 months ago

BlockListed commented 2 months ago

Minimal example which locks the game on start for me:

using ModLoader.Framework;
using ModLoader.Framework.Attributes;
using HarmonyLib;
using VTOLAPI;

namespace VTOLAPITesting
{
    [ItemId("xyz.031410.vtolapi_testing_stuff_def_asdfkasdfh_uniq")] // Harmony ID for your mod, make sure this is unique
    public class Main : VtolMod
    {
        private void Awake()
        {
            Harmony.CreateAndPatchAll(typeof(TestingPatch));
        }

        public override void UnLoad()
        {
            // Destroy any objects
        }
    }

    class TestingPatch
    {
        [HarmonyPatch(typeof(Actor))]
        [HarmonyPatch("Start")]
        [HarmonyPostfix]
        public static void TestF26(Actor __instance)
        {
            if (!__instance.isPlayer)
            {
                return;
            }

            if (VTAPI.GetVehicleEnum(__instance.gameObject) != VTOLVehicles.FA26B)
            {
                return;
            }

            Logger.Log("We are in a 26");
        }
    }
}
BlockListed commented 2 months ago

I've found the issue, wasn't loading VTOLAPI.