コード例 #1
0
 private static bool Postfix(bool __result, ComputerSave save, PartDesc.Type ___m_partType, string ___m_refPart, int ___m_totalPartsOfType)
 {
     if (ConfigHandler.Instance.UpgradePriceCheckRemoveBool.Value)
     {
         if (___m_partType == PartDesc.Type.MOTHERBOARD ||
             ___m_partType == PartDesc.Type.AIR_COOLER ||
             ___m_partType == PartDesc.Type.LIQUID_COOLER)
         {
             var successfulPartChanges = 0;
             foreach (var partInstance in save.GetAllParts())
             {
                 if (partInstance != null && partInstance.IsActive())
                 {
                     PartDesc refPart    = PartsDatabase.GetDesc(___m_refPart);
                     var      canUpgrade = partInstance.GetPart().MatchForUpgrade(refPart.m_type);
                     SFLog.log($"{partInstance.GetPart().m_partName} | canUpgrade: {canUpgrade.ToString()}");
                     if (canUpgrade)
                     {
                         successfulPartChanges++;
                     }
                 }
             }
             var cond = ___m_totalPartsOfType == successfulPartChanges;
             SFLog.log($"totalPartsOfType: {___m_totalPartsOfType.ToString()}, successfulPartChanges: {successfulPartChanges.ToString()}, satisfied: {cond.ToString()}");
             return(cond);
         }
     }
     return(__result);
 }
コード例 #2
0
ファイル: Patch.cs プロジェクト: synogen/pcbsharmonymods
        static GameObject Postfix(GameObject __result, PartDesc part)
        {
            AssetBundle assetBundle = AssetBundle.LoadFromFile(ModloaderMod.Instance.Modpath + "/titanx");

            if ("GPU_GIGABYTE_10".Equals(part.m_id))
            {
                GameObject modded = assetBundle.LoadAsset <GameObject>("assets/prefabs/titan x.prefab");
                modded.AddComponent <BoxCollider>();
                modded.AddComponent <ComponentPC>();
                return(modded);
            }
            return(__result);
        }
コード例 #3
0
ファイル: Patch.cs プロジェクト: synogen/pcbsharmonymods
        static string Postfix(string __result, PartDesc __instance)
        {
            if (__instance.m_id != null)
            {
                int i = 0;
                // check against all inventory parts
                foreach (PartInstance part in CareerStatus.Get().GetInventory())
                {
                    if (part.GetPartId() != null && __instance.m_id.Equals(part.GetPartId()))
                    {
                        i++;
                    }
                }

                // check against all stored computers
                SaveLoadSystem slsys = WorkshopController.Get().slsys;
                foreach (ComputerSave computer in slsys.localSaveGame.computersInStorage)
                {
                    if (computer.caseID != null && __instance.m_id.Equals(computer.caseID.GetPartId()))
                    {
                        i++;
                    }
                }
                // check against all bench computers
                foreach (ComputerSave computer in slsys.localSaveGame.computersOnBenches)
                {
                    if (computer.caseID != null && __instance.m_id.Equals(computer.caseID.GetPartId()))
                    {
                        i++;
                    }
                }

                float max = 10f;
                if (File.Exists(ModloaderMod.Instance.Modpath + "/Show Inventory Stock In Shop.conf"))
                {
                    string[] config = File.ReadAllLines(ModloaderMod.Instance.Modpath + "/Show Inventory Stock In Shop.conf");
                    max = float.Parse(config[0].Split('=')[1]);
                }

                Color32 color       = Color.Lerp(Color.red, Color.green, (Convert.ToSingle(i) / max) > 1f ? 1f : Convert.ToSingle(i) / max);
                string  colorString = "#" + color.r.ToString("X2") + color.g.ToString("X2") + color.b.ToString("X2") + color.a.ToString("X2");
                return("<b><color=" + colorString + ">[ " + i + " in inventory ]</color></b>\n" + __result);
            }
            return(__result);
        }
コード例 #4
0
            public static void Postfix(PartsDatabase __instance, TextAsset asset)
            {
                HTMLTableReader htmltableReader = new HTMLTableReader(asset);
                DirectoryInfo   dir             = new DirectoryInfo(Paths.GameRootPath + "/CustomPart/" + asset.name);

                if (!dir.Exists)
                {
                    dir.Create();              //创建文件夹
                }
                else
                {
                    //获取文件
                    var files = dir.GetFiles("*.txt", SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        var lines = File.ReadAllLines(file.FullName);
                        if (lines.Length > 0)
                        {
                            Dictionary <string, string> partData = new Dictionary <string, string>();
                            foreach (var line in lines)
                            {
                                //切割key value
                                var kv = line.Split('=');
                                if (kv.Length > 1 && !string.IsNullOrEmpty(kv[0]))
                                {
                                    partData.Add(kv[0], kv[1]);
                                }
                            }
                            //判断Part Type
                            if (!partData.ContainsKey("Part Type"))
                            {
                                logger.LogError(file.FullName + " 没有Part Type数据");
                            }
                            //判断InGame
                            if (!partData.ContainsKey("In Game"))
                            {
                                logger.LogError(file.FullName + " 没有In Game数据");
                            }
                            else
                            {
                                //判断InGame Yes 或者 No
                                if (partData["In Game"] == "Yes" || partData["In Game"] == "No")
                                {
                                    PartDesc partDesc = PartDesc.Create(partData["Part Type"], new GetString(htmltableReader.Describe));
                                    foreach (var key in partData.Keys)
                                    {
                                        try
                                        {
                                            //导入数据
                                            partDesc.ImportProp(key, partData[key], new GetString(htmltableReader.Describe));
                                        }
                                        catch (System.Exception e)
                                        {
                                            logger.LogError(htmltableReader.Describe() + ": " + e.ToString());
                                        }
                                    }
                                    //判断id
                                    if (partDesc.m_id == null)
                                    {
                                        logger.LogError(file.FullName + " 的ID为空");
                                    }
                                    if (__instance.m_parts.ContainsKey(partDesc.m_id))
                                    {
                                        logger.LogError(file.FullName + " 的ID已经存在");
                                    }
                                    __instance.m_parts[partDesc.m_id] = partDesc;
                                }
                                else
                                {
                                    logger.LogWarning(file.FullName + " 的In Game数据不为Yes 或者 No");
                                }
                            }
                        }
                    }
                }
            }