private void UpdateStats() { EntityPlayer entity = capi.World.Player.Entity; GuiComposer compo = Composers["playerstats"]; if (compo == null || !IsOpened()) { return; } float?health; float?maxhealth; float?saturation; float?maxsaturation; getHealthSat(out health, out maxhealth, out saturation, out maxsaturation); float walkspeed = entity.Stats.GetBlended("walkspeed"); float healingEffectivness = entity.Stats.GetBlended("healingeffectivness"); float hungerRate = entity.Stats.GetBlended("hungerrate"); float rangedWeaponAcc = entity.Stats.GetBlended("rangedWeaponsAcc"); float rangedWeaponSpeed = entity.Stats.GetBlended("rangedWeaponsSpeed"); if (health != null) { compo.GetDynamicText("health").SetNewText((health + " / " + maxhealth)); } if (saturation != null) { compo.GetDynamicText("satiety").SetNewText((int)saturation + " / " + (int)maxsaturation); } compo.GetDynamicText("walkspeed").SetNewText((int)Math.Round(100 * walkspeed) + "%"); compo.GetDynamicText("healeffectiveness").SetNewText((int)Math.Round(100 * healingEffectivness) + "%"); compo.GetDynamicText("hungerrate")?.SetNewText((int)Math.Round(100 * hungerRate) + "%"); compo.GetDynamicText("rangedweaponacc").SetNewText((int)Math.Round(100 * rangedWeaponAcc) + "%"); compo.GetDynamicText("rangedweaponchargespeed").SetNewText((int)Math.Round(100 * rangedWeaponSpeed) + "%"); ITreeAttribute tempTree = entity.WatchedAttributes.GetTreeAttribute("bodyTemp"); compo.GetRichtext("bodytemp").SetNewText(getBodyTempText(tempTree), CairoFont.WhiteDetailText()); }
private void UpdateStatBars() { GuiComposer compo = Composers["playerstats"]; if (compo == null || !IsOpened()) { return; } ITreeAttribute hungerTree = capi.World.Player.Entity.WatchedAttributes.GetTreeAttribute("hunger"); if (hungerTree != null) { float saturation = hungerTree.GetFloat("currentsaturation"); float maxSaturation = hungerTree.GetFloat("maxsaturation"); float fruitLevel = hungerTree.GetFloat("fruitLevel"); float vegetableLevel = hungerTree.GetFloat("vegetableLevel"); float grainLevel = hungerTree.GetFloat("grainLevel"); float proteinLevel = hungerTree.GetFloat("proteinLevel"); float dairyLevel = hungerTree.GetFloat("dairyLevel"); compo.GetDynamicText("satiety").SetNewText((int)saturation + " / " + maxSaturation); Composers["playerstats"].GetStatbar("fruitBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("vegetableBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("grainBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("proteinBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("dairyBar").SetLineInterval(maxSaturation / 10); Composers["playerstats"].GetStatbar("fruitBar").SetValues(fruitLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("vegetableBar").SetValues(vegetableLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("grainBar").SetValues(grainLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("proteinBar").SetValues(proteinLevel, 0, maxSaturation); Composers["playerstats"].GetStatbar("dairyBar").SetValues(dairyLevel, 0, maxSaturation); } }