private static void OnEatComplete(Edible edible) { if ((Object)edible != (Object)null) { int num = 0; float unitsConsumed = edible.unitsConsumed; int num2 = Mathf.FloorToInt(unitsConsumed); float num3 = unitsConsumed % 1f; if (Random.value < num3) { num2++; } for (int i = 0; i < num2; i++) { if (Random.value < SEEDS_PER_FRUIT_CHANCE) { num++; } } if (num > 0) { Vector3 pos = edible.transform.GetPosition() + new Vector3(0f, 0.05f, 0f); pos = Grid.CellToPosCCC(Grid.PosToCell(pos), Grid.SceneLayer.Ore); GameObject gameObject = GameUtil.KInstantiate(Assets.GetPrefab(new Tag("MushroomSeed")), pos, Grid.SceneLayer.Ore, null, 0); PrimaryElement component = edible.GetComponent <PrimaryElement>(); PrimaryElement component2 = gameObject.GetComponent <PrimaryElement>(); component2.Temperature = component.Temperature; component2.Units = (float)num; gameObject.SetActive(true); } } }
public void UpdatePortrait(GameObject target) { KSelectable component = target.GetComponent <KSelectable>(); if (!((UnityEngine.Object)component == (UnityEngine.Object)null)) { TabTitle.portrait.ClearPortrait(); Building component2 = component.GetComponent <Building>(); if ((bool)component2) { Sprite sprite = null; sprite = component2.Def.GetUISprite("ui", false); if ((UnityEngine.Object)sprite != (UnityEngine.Object)null) { TabTitle.portrait.SetPortrait(sprite); return; } } MinionIdentity component3 = target.GetComponent <MinionIdentity>(); if ((bool)component3) { TabTitle.SetPortrait(component.gameObject); } else { Edible component4 = target.GetComponent <Edible>(); if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { KBatchedAnimController component5 = component4.GetComponent <KBatchedAnimController>(); Sprite uISpriteFromMultiObjectAnim = Def.GetUISpriteFromMultiObjectAnim(component5.AnimFiles[0], "ui", false, string.Empty); TabTitle.portrait.SetPortrait(uISpriteFromMultiObjectAnim); } else { PrimaryElement component6 = target.GetComponent <PrimaryElement>(); if ((UnityEngine.Object)component6 != (UnityEngine.Object)null) { TabTitle.portrait.SetPortrait(Def.GetUISpriteFromMultiObjectAnim(ElementLoader.FindElementByHash(component6.ElementID).substance.anim, "ui", false, string.Empty)); } else { CellSelectionObject component7 = target.GetComponent <CellSelectionObject>(); if ((UnityEngine.Object)component7 != (UnityEngine.Object)null) { string animName = (!component7.element.IsSolid) ? component7.element.substance.name : "ui"; Sprite uISpriteFromMultiObjectAnim2 = Def.GetUISpriteFromMultiObjectAnim(component7.element.substance.anim, animName, false, string.Empty); TabTitle.portrait.SetPortrait(uISpriteFromMultiObjectAnim2); } } } } } }
public void OnEatComplete(object obj) { Edible edible = (Edible)obj; HandleVector <int> .Handle handle = GameComps.DiseaseContainers.GetHandle(edible.gameObject); if (handle != HandleVector <int> .InvalidHandle) { DiseaseHeader header = GameComps.DiseaseContainers.GetHeader(handle); if (header.diseaseIdx != 255) { Disease disease = Db.Get().Diseases[header.diseaseIdx]; float num = edible.unitsConsumed / (edible.unitsConsumed + edible.Units); int num2 = Mathf.CeilToInt((float)header.diseaseCount * num); GameComps.DiseaseContainers.ModifyDiseaseCount(handle, -num2); KPrefabID component = edible.GetComponent <KPrefabID>(); InjectDisease(disease, num2, component.PrefabID(), Sickness.InfectionVector.Digestion); } } }
private void Update() { List <FoodBit> list = new List <FoodBit>(); if ((Object)WorldInventory.Instance != (Object)null) { List <Pickupable> pickupables = WorldInventory.Instance.GetPickupables(GameTags.Edible); if (pickupables == null) { return; } foreach (Pickupable item in pickupables) { Edible component = item.GetComponent <Edible>(); if ((Object)component != (Object)null) { PrimaryElement component2 = component.GetComponent <PrimaryElement>(); list.Add(new FoodBit { name = component.name, rations = component.Calories / 1000f / 1000f, disease = component2.DiseaseCount }); } } } if (list.Count != 0) { list.Sort((FoodBit a, FoodBit b) => a.DiseasePerRation.CompareTo(b.DiseasePerRation)); FoodBit foodBit = list[0]; minText.text = "Min: " + foodBit.ToString(); FoodBit foodBit2 = list[list.Count - 1]; maxText.text = "Max: " + foodBit2.ToString(); FoodBit foodBit3 = list[list.Count / 2]; medianText.text = "Median: " + foodBit3.ToString(); float num = (from b in list select b.rations).Sum(); int num2 = (from b in list select b.disease).Sum(); avgText.text = "Average: " + ((float)num2 / num).ToString(); } }