public static void Prefix(UIProductionStatWindow __instance) { UIComboBox productRankBox = Traverse.Create(__instance).Field("productRankBox").GetValue <UIComboBox>(); productRankBox.Items.Add("需要加水的放前边"); productRankBox.UpdateItems(); }
public static void UIProductionStatWindow_ComputeDisplayEntries_Prefix(UIProductionStatWindow __instance) { counter.Clear(); if (__instance.targetIndex == -1) { int factoryCount = __instance.gameData.factoryCount; for (int i = 0; i < factoryCount; i++) { AddPlanetFactoryData(__instance.gameData.factories[i]); } } else if (__instance.targetIndex == 0) { AddPlanetFactoryData(__instance.gameData.localPlanet.factory); } else if (__instance.targetIndex % 100 > 0) { PlanetData planetData = __instance.gameData.galaxy.PlanetById(__instance.targetIndex); AddPlanetFactoryData(planetData.factory); } else if (__instance.targetIndex % 100 == 0) { int starId = __instance.targetIndex / 100; StarData starData = __instance.gameData.galaxy.StarById(starId); for (int j = 0; j < starData.planetCount; j++) { if (starData.planets[j].factory != null) { AddPlanetFactoryData(starData.planets[j].factory); } } } }
public static bool Prefix(UIProductionStatWindow __instance, FactoryProductionStat factoryStat) { int[] itemIds = ItemProto.itemIds; int length = itemIds.Length; var displayEntries = Traverse.Create(__instance).Field("displayEntries").GetValue <List <int[]> >(); int[] productIndices = factoryStat.productIndices; for (int index1 = 0; index1 < length; ++index1) { int c1 = __instance.statTimeLevel + 1; int c2 = c1 + 7; int id = itemIds[index1]; switch (id) { case 11901: case 11902: case 11903: continue; default: int favoriteId = __instance.production.favoriteIds[id]; if (productIndices[id] > 0 && ((favoriteId & __instance.favoriteMask) != 0 || __instance.favoriteMask == 0)) { int count = displayEntries.Count; bool flag = false; for (int index2 = 0; index2 < count; ++index2) { if (displayEntries[index2][0] == id) { ProductStat productStat = factoryStat.productPool[productIndices[id]]; displayEntries[index2][1] += productStat.total[c1]; displayEntries[index2][3] += productStat.total[c2]; displayEntries[index2][4] = GetScore(displayEntries[index2][1], displayEntries[index2][3]); flag = true; } } if (!flag) { ProductStat productStat = factoryStat.productPool[productIndices[id]]; displayEntries.Add(new int[5] { id, productStat.total[c1], LDB.items.Select(id).index, productStat.total[c2], GetScore(productStat.total[c1], productStat.total[c2]) }); continue; } continue; } continue; } } return(false); }
public static void UIProductionStatWindow__OnUpdate_Prefix(UIProductionStatWindow __instance) { if (statWindow == null) { statWindow = __instance; } if (lastStatTimer != __instance.statTimeLevel && (__instance.statTimeLevel == 5 || lastStatTimer == 5)) { ClearEnhancedUIProductEntries(); } lastStatTimer = __instance.statTimeLevel; }
public static bool Prefix(UIProductionStatWindow __instance) { if (__instance.statRank == 3) { var displayEntries = Traverse.Create(__instance).Field("displayEntries").GetValue <List <int[]> >(); displayEntries.Sort((x, y) => { if (x[4] == y[4]) { return(x[2] < y[2] ? -1 : 1); } return(x[4] < y[4] ? -1 : 1); }); return(false); } return(true); }
public static void UIProductionStatWindow_AddToDisplayEntries_Prefix(UIProductionStatWindow __instance) { if (filterStr == "") { return; } __instance.displayEntries.RemoveAll((data) => { var proto = LDB.items.Select(data[0]); if (proto.name.IndexOf(filterStr, StringComparison.OrdinalIgnoreCase) >= 0) { return(false); } return(true); }); }
public static void UIProductionStatWindow__OnOpen_Postfix(UIProductionStatWindow __instance) { if (statWindow == null) { statWindow = __instance; } if (chxGO != null) { return; } var favoritesLabel = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Production Stat Window/product-bg/top/favorite-text"); if (favoritesLabel != null) { favoritesLabel.SetActive(false); } sprOn = Sprite.Create(texOn, new Rect(0, 0, texOn.width, texOn.height), new Vector2(0.5f, 0.5f)); sprOff = Sprite.Create(texOff, new Rect(0, 0, texOff.width, texOff.height), new Vector2(0.5f, 0.5f)); chxGO = new GameObject("displaySec"); RectTransform rect = chxGO.AddComponent <RectTransform>(); rect.SetParent(__instance.productRankBox.transform.parent, false); rect.anchorMax = new Vector2(0, 1); rect.anchorMin = new Vector2(0, 1); rect.sizeDelta = new Vector2(20, 20); rect.pivot = new Vector2(0, 0.5f); rect.anchoredPosition = new Vector2(250, -33); Button _btn = rect.gameObject.AddComponent <Button>(); _btn.onClick.AddListener(() => { displaySec = !displaySec; checkBoxImage.sprite = displaySec ? sprOn : sprOff; }); checkBoxImage = _btn.gameObject.AddComponent <Image>(); checkBoxImage.color = new Color(0.8f, 0.8f, 0.8f, 1); checkBoxImage.sprite = displaySec ? sprOn : sprOff; txtGO = new GameObject("displaySecTxt"); RectTransform rectTxt = txtGO.AddComponent <RectTransform>(); rectTxt.SetParent(chxGO.transform, false); rectTxt.anchorMax = new Vector2(0, 0.5f); rectTxt.anchorMin = new Vector2(0, 0.5f); rectTxt.sizeDelta = new Vector2(100, 20); rectTxt.pivot = new Vector2(0, 0.5f); rectTxt.anchoredPosition = new Vector2(20, 0); Text text = rectTxt.gameObject.AddComponent <Text>(); text.text = "Display /sec"; text.fontStyle = FontStyle.Normal; text.fontSize = 14; text.verticalOverflow = VerticalWrapMode.Overflow; text.horizontalOverflow = HorizontalWrapMode.Wrap; text.color = new Color(0.8f, 0.8f, 0.8f, 1); Font fnt = Resources.Load <Font>("ui/fonts/SAIRASB"); if (fnt != null) { text.font = fnt; } filterGO = new GameObject("filterGo"); RectTransform rectFilter = filterGO.AddComponent <RectTransform>(); rectFilter.SetParent(__instance.productRankBox.transform.parent, false); rectFilter.anchorMax = new Vector2(0, 1); rectFilter.anchorMin = new Vector2(0, 1); rectFilter.sizeDelta = new Vector2(100, 30); rectFilter.pivot = new Vector2(0, 0.5f); rectFilter.anchoredPosition = new Vector2(120, -33); var _image = filterGO.AddComponent <Image>(); _image.transform.SetParent(rectFilter, false); _image.color = new Color(0f, 0f, 0f, 0.5f); GameObject textContainer = new GameObject(); textContainer.name = "Text"; textContainer.transform.SetParent(rectFilter, false); var _text = textContainer.AddComponent <Text>(); _text.supportRichText = false; _text.color = new Color(0.8f, 0.8f, 0.8f, 1); _text.font = fnt; _text.fontSize = 16; _text.alignment = TextAnchor.MiddleLeft; _text.horizontalOverflow = HorizontalWrapMode.Overflow; (_text.transform as RectTransform).sizeDelta = new Vector2(90, 30); (_text.transform as RectTransform).anchoredPosition = new Vector2(5, 0); GameObject placeholderContainer = new GameObject(); placeholderContainer.name = "Placeholder"; placeholderContainer.transform.SetParent(rectFilter, false); var _placeholder = placeholderContainer.AddComponent <Text>(); _placeholder.color = new Color(0.8f, 0.8f, 0.8f, 1); _placeholder.font = fnt; _placeholder.fontSize = 16; _placeholder.fontStyle = FontStyle.Italic; _placeholder.alignment = TextAnchor.MiddleLeft; _placeholder.supportRichText = false; _placeholder.horizontalOverflow = HorizontalWrapMode.Overflow; _placeholder.text = "Filter"; (_placeholder.transform as RectTransform).sizeDelta = new Vector2(90, 30); (_placeholder.transform as RectTransform).anchoredPosition = new Vector2(5, 0); var _inputField = filterGO.AddComponent <InputField>(); _inputField.transform.SetParent(rectFilter, false); _inputField.targetGraphic = _image; _inputField.textComponent = _text; _inputField.placeholder = _placeholder; _inputField.onValueChanged.AddListener((string value) => { filterStr = value; __instance.ComputeDisplayEntries(); }); chxGO.transform.SetParent(__instance.productRankBox.transform.parent, false); txtGO.transform.SetParent(chxGO.transform, false); filterGO.transform.SetParent(__instance.productRankBox.transform.parent, false); }
public static void UIProductionStatWindow__OnOpen_Postfix(UIProductionStatWindow __instance) { if (statWindow == null) { statWindow = __instance; } if (chxGO != null) { return; } sprOn = Sprite.Create(texOn, new Rect(0, 0, texOn.width, texOn.height), new Vector2(0.5f, 0.5f)); sprOff = Sprite.Create(texOff, new Rect(0, 0, texOff.width, texOff.height), new Vector2(0.5f, 0.5f)); chxGO = new GameObject("displaySec"); RectTransform rect = chxGO.AddComponent <RectTransform>(); rect.SetParent(__instance.productRankBox.transform.parent, false); rect.anchorMax = new Vector2(0, 1); rect.anchorMin = new Vector2(0, 1); rect.sizeDelta = new Vector2(20, 20); rect.pivot = new Vector2(0, 0.5f); rect.anchoredPosition = new Vector2(250, -33); Button _btn = rect.gameObject.AddComponent <Button>(); _btn.onClick.AddListener(() => { displaySec = !displaySec; checkBoxImage.sprite = displaySec ? sprOn : sprOff; }); checkBoxImage = _btn.gameObject.AddComponent <Image>(); checkBoxImage.color = new Color(0.8f, 0.8f, 0.8f, 1); checkBoxImage.sprite = displaySec ? sprOn : sprOff; txtGO = new GameObject("displaySecTxt"); RectTransform rectTxt = txtGO.AddComponent <RectTransform>(); rectTxt.SetParent(chxGO.transform, false); rectTxt.anchorMax = new Vector2(0, 0.5f); rectTxt.anchorMin = new Vector2(0, 0.5f); rectTxt.sizeDelta = new Vector2(100, 20); rectTxt.pivot = new Vector2(0, 0.5f); rectTxt.anchoredPosition = new Vector2(20, 0); Text text = rectTxt.gameObject.AddComponent <Text>(); text.text = "Display /sec"; text.fontStyle = FontStyle.Normal; text.fontSize = 14; text.verticalOverflow = VerticalWrapMode.Overflow; text.horizontalOverflow = HorizontalWrapMode.Wrap; text.color = new Color(0.8f, 0.8f, 0.8f, 1); Font fnt = Resources.Load <Font>("ui/fonts/SAIRASB"); if (fnt != null) { text.font = fnt; } chxGO.transform.SetParent(__instance.productRankBox.transform.parent, false); txtGO.transform.SetParent(chxGO.transform, false); }
public static void UIProductionStatWindow__OnOpen_Postfix(UIProductionStatWindow __instance) { //default font size 34 //Debug.Log(__instance.consumeText.); //__instance.productText.fontSize = 10; if (__instance.gameData.localPlanet == null) { return; } var planet = __instance.gameData.localPlanet; counter = new Dictionary <int, productMetrics>(); var factorySystem = planet.factory.factorySystem; var veinPool = planet.factory.veinPool; for (int i = 1; i < factorySystem.minerCursor; i++) { var miner = factorySystem.minerPool[i]; if (i != miner.id) { continue; } var productId = miner.productId; var veinId = (miner.veinCount != 0) ? miner.veins[miner.currentVeinIndex] : 0; if (miner.type == EMinerType.Water) { productId = planet.waterItemId; } else if (productId == 0) { productId = veinPool[veinId].productId; } if (productId == 0) { continue; } EnsureId(ref counter, productId); float frequency = 1f / (float)((double)miner.period / 600000.0); float speed = (float)(0.0001 * (double)miner.speed * (double)GameMain.history.miningSpeedScale); float production = 0f; if (factorySystem.minerPool[i].type == EMinerType.Water) { production = frequency * speed; } if (factorySystem.minerPool[i].type == EMinerType.Oil) { production = frequency * speed * (float)((double)veinPool[veinId].amount * (double)VeinData.oilSpeedMultiplier);; } if (factorySystem.minerPool[i].type == EMinerType.Vein) { production = frequency * speed * miner.veinCount; } counter[productId].production += production; counter[productId].producers++; } for (int j = 1; j < factorySystem.assemblerCursor; j++) { var assembler = factorySystem.assemblerPool[j]; if (assembler.id != j || assembler.recipeId == 0) { continue; } var period = 1 / (float)((double)assembler.timeSpend / 600000.0); var speed = (float)(0.0001 * (double)assembler.speed); for (int k = 0; k < assembler.requires.Length; k++) { var productId = assembler.requires[k]; EnsureId(ref counter, productId); counter[productId].consumption += period * speed * assembler.requireCounts[k]; counter[productId].consumers++; } for (int k = 0; k < assembler.products.Length; k++) { var productId = assembler.products[k]; EnsureId(ref counter, productId); counter[productId].production += period * speed * assembler.productCounts[k]; counter[productId].producers++; } } for (int k = 1; k < factorySystem.fractionateCursor; k++) { var fractionator = factorySystem.fractionatePool[k]; if (fractionator.id != k) { continue; } if (fractionator.need != 0) { var productId = fractionator.need; EnsureId(ref counter, productId); counter[productId].consumption += 30f * fractionator.produceProb; counter[productId].consumers++; } if (fractionator.product != 0) { var productId = fractionator.product; EnsureId(ref counter, productId); counter[productId].consumption += 30f * fractionator.produceProb; counter[productId].consumers++; } } for (int l = 1; l < factorySystem.ejectorCursor; l++) { if (factorySystem.ejectorPool[l].id != l) { continue; } } for (int m = 1; m < factorySystem.siloCursor; m++) { if (factorySystem.siloPool[m].id != m) { continue; } } for (int n = 1; n < factorySystem.labCursor; n++) { if (factorySystem.labPool[n].id != n) { continue; } } Debug.Log($"--------------------------"); foreach (var entry in counter) { Debug.Log($"{entry.Value.itemProto.name} : {entry.Value.production} [{entry.Value.producers}] | {entry.Value.consumption} [{entry.Value.consumers}]"); } }