public override void Invoke(ItemStack itemStack) { List <ValueMod> valueMods = new List <ValueMod>(); ValueMod[] itemStackMods = itemStack.ExplicitMods; Mod[] availableMods = ModifierManager.GetModifiersForDomainAndTag(1, itemStack.Item.Tags.ToArray()); availableMods = ModUtils.Filter(availableMods, itemStack.ItemLevel); foreach (ValueMod explicitMod in itemStackMods) { valueMods.Add(explicitMod); } switch (m_CountType) { case CountType.Single: RetierSingle(ref valueMods, availableMods); break; case CountType.Value: RetierCount(ref valueMods, m_Count, availableMods); break; case CountType.All: RetierAll(ref valueMods, availableMods); break; } itemStack.ExplicitMods = valueMods.ToArray(); }
public override void GenerateAttributes(ProceduralLevel level) { //check if attribute from tag or random float minAttributeCount = m_MinimumAttributeCount.Evaluate(level.Difficulty); float maxAttributeCount = m_MaximumAttributeCount.Evaluate(level.Difficulty); int attributeCount = (int)Math.Round(Random.Range(minAttributeCount, maxAttributeCount)); List <ValueMod> attributes = new List <ValueMod>(); for (int i = 0; i < attributeCount; i++) { float roll = Random.Range(0.0f, 1.0f); Mod[] rollableMods = null; string tag = ""; if (roll <= m_ChanceToPickAttributeFromTag) { if (level.TagList.Count > 0) { int tagRoll = Random.Range(0, level.TagList.Count); rollableMods = ModifierManager.GetModifiersForDomainAndTag(2, level.TagList[tagRoll].Identifier); tag = level.TagList[tagRoll].Identifier; } if (rollableMods == null || rollableMods.Length == 0) { rollableMods = ModifierManager.GetModifiersForDomain(2); tag = m_DefaultTag.Identifier; } } else { rollableMods = ModifierManager.GetModifiersForDomain(2); tag = m_DefaultTag.Identifier; } if (rollableMods == null) { continue; } ValueMod valueMod = ModUtils.Roll(rollableMods.ToArray(), tag); if (valueMod == null) { continue; } attributes.Add(valueMod); } level.Attributes = attributes.ToArray(); }
public override void Invoke(ItemStack itemStack) { Mod[] availableMods = ModifierManager.GetModifiersForDomainAndTag(1, itemStack.Item.Tags.ToArray()); List <ValueMod> valueMods = new List <ValueMod>(); foreach (ValueMod explicitMod in itemStack.ExplicitMods) { valueMods.Add(explicitMod); } availableMods = ModUtils.Filter(availableMods, itemStack.ItemLevel); availableMods = ModUtils.Filter(availableMods, valueMods.ToArray()); ValueMod valueMod = ModUtils.Roll(availableMods, itemStack.Item.Tags.ToArray()); if (valueMod == null) { return; } valueMods.Add(valueMod); itemStack.ExplicitMods = valueMods.ToArray(); }
public override void Invoke(ItemStack itemStack) { if (itemStack == null) { return; } int count = (int)m_ExplicitCount.Evaluate(UnityEngine.Random.Range(0.0f, 1.0f)); Mod[] availableMods = ModifierManager.GetModifiersForDomainAndTag(1, itemStack.Item.Tags.ToArray()); availableMods = ModUtils.Filter(availableMods, itemStack.ItemLevel); List <ValueMod> valueMods = new List <ValueMod>(); for (int i = 0; i < count; i++) { availableMods = ModUtils.Filter(availableMods, valueMods.ToArray()); ValueMod valueMod = ModUtils.Roll(availableMods, itemStack.Item.Tags.ToArray()); if (valueMod != null) { valueMods.Add(valueMod); } } itemStack.ExplicitMods = valueMods.ToArray(); }