public void UpdateBuy(List <string> buyableSpells) { foreach (VendorButton ib in buyButtons) { RemoveUIObj(ib); } buyButtons = new VendorButton[buyableSpells.Count]; bool buyPossible = pawn.GetSpells().Length < pawn.SpellSlotCount.GetValue(); int height = 28 * buyableSpells.Count + (4 * (buyableSpells.Count - 1)); int yStart = size.height / 2 - height / 2; for (int i = 0; i < buyButtons.Length; i++) { string spellId = buyableSpells[i]; buyButtons[i] = new VendorButton(Spells.Get(spellId), new Vector2i(size.width / 4, yStart + i * 32), true, !buyPossible || pawn.DoesKnowSpell(spellId)); AddUIObj(buyButtons[i]); } buyHeader.SetPosition(new Vector2i(size.width / 4, yStart - 10)); }
public void UpdateAffinityModifiers(PlayerPawn player) { int[] elementCount = new int[Element.Count]; foreach (Spell spell in player.GetSpells()) { ElementDisplay[] displays = spell.GetElementDisplays(RollContext.Null); foreach (ElementDisplay display in displays) { elementCount[display.element.GetId()] += 1; } } for (int i = 0; i < elementCount.Length; i++) { player.Affinities[i].RemoveModifier(GetName()); player.Affinities[i].AddModifier(new AttributeModifier(GetName(), AttributeModifier.Operation.AddTotal, elementCount[i])); } }