コード例 #1
0
        private static bool PreInitializePrefab(VehicleInfo __instance)
        {
            try
            {
                if (__instance?.m_class?.name != ItemClasses.cargoFerryVehicle.name)
                {
                    return(true);
                }

                var oldAi = __instance.GetComponent <CargoShipAI>();
                Object.DestroyImmediate(oldAi);
                var ai = __instance.gameObject.AddComponent <CargoFerryAI>();
                PrefabUtil.TryCopyAttributes(oldAi, ai, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(true);
        }
コード例 #2
0
        private static bool PreInitializePrefab(global::BuildingInfo __instance)
        {
            try
            {
                if (__instance?.m_class?.name != ItemClasses.cargoFerryFacility.name)
                {
                    return(true);
                }

                var oldAi = __instance.GetComponent <CargoHarborAI>();
                Object.DestroyImmediate(oldAi);
                var ai = (SteamHelper.IsDLCOwned(SteamHelper.DLC.IndustryDLC) &
                          OptionsWrapper <Options> .Options.EnableWarehouseAI)
                    ? __instance.gameObject.AddComponent <CargoFerryWarehouseHarborAI>()
                    : __instance.gameObject.AddComponent <CargoFerryHarborAI>();
                PrefabUtil.TryCopyAttributes(oldAi, ai, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(true);
        }