private void UpdateDescription(Item item, ItemAffix affix) { var affixData = D4Data.Instance.Hellforge.GameData.Affixes.FirstOrDefault(x => x.Name == affix.Name); if (affixData == null) { _affixNameText.text = $"!{affix.Name}"; _rollSlider.enabled = false; _tierSlider.enabled = false; return; } _rollSlider.minValue = 0; _rollSlider.maxValue = 100; _rollSlider.wholeNumbers = true; _tierSlider.minValue = 0; _tierSlider.maxValue = affixData.Data.Length - 1; _tierSlider.wholeNumbers = true; _rollSlider.value = affix.Roll; _tierSlider.value = affix.Tier; var desc = affixData.ParseDescription(affix.Tier, affix.Roll); var dumbAfx = item.Character.Hellforge.GenerateAffix(item.Character, affix.Name, affix.Tier, affix.Roll); foreach (var node in dumbAfx.Nodes) { if (node is ScriptedCondition cond) { var color = cond.Passes() ? "#95FF00" : "red"; desc += $"\n<color={color}>{cond.GetDescription()}</color>"; } } _affixNameText.text = desc; }
private void RenderAffix(Item item, ItemAffix affix) { var clone = GameObject.Instantiate(_itemAffixTemplate, _itemAffixTemplate.transform.parent); clone.Render(item, affix); clone.gameObject.SetActive(true); _itemAffixRenderers.Add(clone); }
public void Render(Item item, ItemAffix affix) { _deleteButton.onClick.AddListener(() => { item.RemoveExplicitAffix(affix); GameObject.Destroy(gameObject); }); _rollSlider.onValueChanged.AddListener((float value) => { affix.Roll = (int)value; item.Dirty = true; UpdateDescription(item, affix); }); _tierSlider.onValueChanged.AddListener((float value) => { affix.Tier = (int)value; item.Dirty = true; UpdateDescription(item, affix); }); UpdateDescription(item, affix); }
List <AffixDisplayInformation> AddToAffixList(List <AffixDisplayInformation> list, SecondaryStats stat, ItemAffix affix) { bool existsInList = false; foreach (AffixDisplayInformation info in list) { if (info.secondary != null && info.secondary == stat && info.type == affix.GetModType()) { info.value += affix.GetValue(stat, item.ItemLevel, item.VarianceSeed); existsInList = true; } } if (!existsInList) { AffixDisplayInformation info = new AffixDisplayInformation(); info.secondary = stat; info.value = affix.GetValue(stat, item.ItemLevel, item.VarianceSeed); info.type = affix.GetModType(); list.Add(info); } return(list); }
// Methods public ItemAction(byte[] data) : base(data) { this.superiorType = SuperiorItemType.NotApplicable; this.charClass = CharacterClass.NotApplicable; this.level = -1; this.usedSockets = -1; this.use = -1; this.graphic = -1; this.color = -1; this.stats = new List<StatBase>(); this.unknown1 = -1; this.runewordID = -1; this.runewordParam = -1; BitReader br = new BitReader(data, 1); this.action = (ItemActionType) br.ReadByte(); br.SkipBytes(1); this.category = (ItemCategory) br.ReadByte(); this.uid = br.ReadUInt32(); if (data[0] == 0x9d) { br.SkipBytes(5); } this.flags = (ItemFlags) br.ReadUInt32(); this.version = (ItemVersion) br.ReadByte(); this.unknown1 = br.ReadByte(2); this.destination = (ItemDestination) br.ReadByte(3); if (this.destination == ItemDestination.Ground) { this.x = br.ReadUInt16(); this.y = br.ReadUInt16(); } else { this.location = (EquipmentLocation) br.ReadByte(4); this.x = br.ReadByte(4); this.y = br.ReadByte(3); this.container = (ItemContainer) br.ReadByte(4); } if ((this.action == ItemActionType.AddToShop) || (this.action == ItemActionType.RemoveFromShop)) { int num = ((int) this.container) | 0x80; if ((num & 1) == 1) { num--; this.y += 8; } this.container = (ItemContainer) num; } else if (this.container == ItemContainer.Unspecified) { if (this.location == EquipmentLocation.NotApplicable) { if ((this.Flags & ItemFlags.InSocket) == ItemFlags.InSocket) { this.container = ItemContainer.Item; this.y = -1; } else if ((this.action == ItemActionType.PutInBelt) || (this.action == ItemActionType.RemoveFromBelt)) { this.container = ItemContainer.Belt; this.y = this.x / 4; this.x = this.x % 4; } } else { this.x = -1; this.y = -1; } } if ((this.flags & ItemFlags.Ear) == ItemFlags.Ear) { this.charClass = (CharacterClass) br.ReadByte(3); this.level = br.ReadByte(7); this.name = br.ReadString(7, '\0', 0x10); this.baseItem = BaseItem.Get(ItemType.Ear); } else { this.baseItem = BaseItem.GetByID(this.category, br.ReadUInt32()); if (this.baseItem.Type == ItemType.Gold) { this.stats.Add(new SignedStat(BaseStat.Get(StatType.Quantity), br.ReadInt32(br.ReadBoolean(1) ? 0x20 : 12))); } else { this.usedSockets = br.ReadByte(3); if ((this.flags & (ItemFlags.Compact | ItemFlags.Gamble)) == ItemFlags.None) { BaseStat stat; int num2; this.level = br.ReadByte(7); this.quality = (ItemQuality) br.ReadByte(4); if (br.ReadBoolean(1)) { this.graphic = br.ReadByte(3); } if (br.ReadBoolean(1)) { this.color = br.ReadInt32(11); } if ((this.flags & ItemFlags.Identified) == ItemFlags.Identified) { switch (this.quality) { case ItemQuality.Inferior: this.prefix = new ItemAffix(ItemAffixType.InferiorPrefix, br.ReadByte(3)); break; case ItemQuality.Superior: this.prefix = new ItemAffix(ItemAffixType.SuperiorPrefix, 0); this.superiorType = (SuperiorItemType) br.ReadByte(3); break; case ItemQuality.Magic: this.prefix = new ItemAffix(ItemAffixType.MagicPrefix, br.ReadUInt16(11)); this.suffix = new ItemAffix(ItemAffixType.MagicSuffix, br.ReadUInt16(11)); break; case ItemQuality.Set: this.setItem = BaseSetItem.Get(br.ReadUInt16(12)); break; case ItemQuality.Rare: case ItemQuality.Crafted: this.prefix = new ItemAffix(ItemAffixType.RarePrefix, br.ReadByte(8)); this.suffix = new ItemAffix(ItemAffixType.RareSuffix, br.ReadByte(8)); break; case ItemQuality.Unique: if (this.baseItem.Code != "std") { try { this.uniqueItem = BaseUniqueItem.Get(br.ReadUInt16(12)); } catch{} } break; } } if ((this.quality == ItemQuality.Rare) || (this.quality == ItemQuality.Crafted)) { this.magicPrefixes = new List<MagicPrefixType>(); this.magicSuffixes = new List<MagicSuffixType>(); for (int i = 0; i < 3; i++) { if (br.ReadBoolean(1)) { this.magicPrefixes.Add((MagicPrefixType) br.ReadUInt16(11)); } if (br.ReadBoolean(1)) { this.magicSuffixes.Add((MagicSuffixType) br.ReadUInt16(11)); } } } if ((this.Flags & ItemFlags.Runeword) == ItemFlags.Runeword) { this.runewordID = br.ReadUInt16(12); this.runewordParam = br.ReadUInt16(4); num2 = -1; if (this.runewordParam == 5) { num2 = this.runewordID - (this.runewordParam * 5); if (num2 < 100) { num2--; } } else if (this.runewordParam == 2) { num2 = ((this.runewordID & 0x3ff) >> 5) + 2; } br.ByteOffset -= 2; this.runewordParam = br.ReadUInt16(); this.runewordID = num2; if (num2 == -1) { throw new Exception("Unknown Runeword: " + this.runewordParam); } this.runeword = BaseRuneword.Get(num2); } if ((this.Flags & ItemFlags.Personalized) == ItemFlags.Personalized) { this.name = br.ReadString(7, '\0', 0x10); } if (this.baseItem is BaseArmor) { stat = BaseStat.Get(StatType.ArmorClass); this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits) - stat.SaveAdd)); } if ((this.baseItem is BaseArmor) || (this.baseItem is BaseWeapon)) { stat = BaseStat.Get(StatType.MaxDurability); num2 = br.ReadInt32(stat.SaveBits); this.stats.Add(new SignedStat(stat, num2)); if (num2 > 0) { stat = BaseStat.Get(StatType.Durability); this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits))); } } if ((this.Flags & (ItemFlags.None | ItemFlags.Socketed)) == (ItemFlags.None | ItemFlags.Socketed)) { stat = BaseStat.Get(StatType.Sockets); this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits))); } if (this.baseItem.Stackable) { if (this.baseItem.Useable) { this.use = br.ReadByte(5); } this.stats.Add(new SignedStat(BaseStat.Get(StatType.Quantity), br.ReadInt32(9))); } if ((this.Flags & ItemFlags.Identified) == ItemFlags.Identified) { StatBase base2; int num4 = (this.Quality == ItemQuality.Set) ? br.ReadByte(5) : -1; this.mods = new List<StatBase>(); while ((base2 = ReadStat(br)) != null) { this.mods.Add(base2); } if ((this.flags & ItemFlags.Runeword) == ItemFlags.Runeword) { while ((base2 = ReadStat(br)) != null) { this.mods.Add(base2); } } if (num4 > 0) { this.setBonuses = new List<StatBase>[5]; for (int j = 0; j < 5; j++) { if ((num4 & (((int) 1) << j)) != 0) { this.setBonuses[j] = new List<StatBase>(); while ((base2 = ReadStat(br)) != null) { this.setBonuses[j].Add(base2); } } } } } } } } }