Exemple #1
0
        static void Postfix(AddProgramApp __instance)
        {
            foreach (object o in __instance.m_programList.content)
            {
                UnityEngine.Object.Destroy(((Transform)o).gameObject);
            }

            ComputerSave computer           = __instance.GetComponentInParent <VirtualComputer>().GetComputer();
            bool         isUsbDriveInserted = computer.IsUSBDriveInserted();

            if (!isUsbDriveInserted)
            {
                WorkStation componentInParent = __instance.GetComponentInParent <WorkStation>();
                if (componentInParent && componentInParent.m_slot && componentInParent.m_slot.m_type == BenchSlot.Type.SHOP_COMPUTER)
                {
                    isUsbDriveInserted = true;
                }
            }
            if (AddProgramAppLogic.InstanceFor(__instance).addMode == 1)
            {
                if (!isUsbDriveInserted)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.INSERT_USB });
                    return;
                }

                foreach (OSProgramDesc prog in PartsDatabase.GetAllPrograms())
                {
                    if (CareerStatus.Get().IsProgramAvailableForInstall(prog.m_id))
                    {
                        UnityEngine.Object.Instantiate <ProgramIcon>(__instance.programIconPrefab, __instance.m_programList.content).Init(prog, false, delegate
                        {
                            __instance.GetComponentInParent <OS>().Launch(prog);
                        });
                    }
                }
                return;
            }
            if (AddProgramAppLogic.InstanceFor(__instance).addMode == 2)
            {
                if (!isUsbDriveInserted)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.INSERT_USB });
                    return;
                }
                bool programsMissing = false;

                foreach (OSProgramDesc prog in PartsDatabase.GetAllPrograms())
                {
                    if (!computer.m_software.m_programs.Contains(prog.m_id) && CareerStatus.Get().IsProgramAvailableForInstall(prog.m_id))
                    {
                        UnityEngine.Object.Instantiate <ProgramIcon>(__instance.programIconPrefab, __instance.m_programList.content).Init(prog, false, delegate
                        {
                            __instance.StartCoroutine(ReflectionUtils.Run <IEnumerator>("Install", __instance, new object[] { prog }));
                        });
                        programsMissing = true;
                    }
                }

                if (!programsMissing)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.ALL_INSTALLED });
                    return;
                }
            }
            else if (AddProgramAppLogic.InstanceFor(__instance).addMode == 3)
            {
                bool uninstallablePrograms = false;
                foreach (OSProgramDesc prog in PartsDatabase.GetAllPrograms())
                {
                    if (prog.m_canBeUninstalled && computer.m_software.m_programs.Contains(prog.m_id))
                    {
                        UnityEngine.Object.Instantiate <ProgramIcon>(__instance.programIconPrefab, __instance.m_programList.content).Init(prog, false, delegate
                        {
                            __instance.StartCoroutine(ReflectionUtils.Run <IEnumerator>("Uninstall", __instance, new object[] { prog }));
                        });
                        uninstallablePrograms = true;
                    }
                }
                if (!uninstallablePrograms)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.NONE_INSTALLED });
                }
            }
        }
Exemple #2
0
 static void Prefix(AddProgramApp __instance)
 {
     AddProgramAppLogic.InstanceFor(__instance).Init();
 }
Exemple #3
0
        static void Postfix(AddProgramApp __instance, bool add)
        {
            int intMode = add ? 2 : 3;

            AddProgramAppLogic.InstanceFor(__instance).SetMode(intMode);
        }
Exemple #4
0
 static void Postfix(AddProgramApp __instance)
 {
     AddProgramAppLogic.InstanceFor(__instance).SetPortableMode();
 }