Пример #1
0
        public void ChangeItemStats(Equipment item, StatChangeType type)
        {
            if (type == StatChangeType.ADD && addedStats)
            {
                return;
            }
            if (type == StatChangeType.REMOVE && !addedStats)
            {
                return;
            }

            Affix affix = GetAffix();

            if (affix != null)
            {
                affix.GetVanillaStatMods().ForEach(x => x.ApplyToItem(percent, item, type));
            }

            if (type == StatChangeType.ADD)
            {
                addedStats = true;
            }
            if (type == StatChangeType.REMOVE)
            {
                addedStats = false;
            }
        }
Пример #2
0
        public void ChangeItemStats(Equipment item, StatChangeType type)
        {
            if (type == StatChangeType.ADD && addedStats)
            {
                return;
            }
            if (type == StatChangeType.REMOVE && !addedStats)
            {
                return;
            }

            Equipment def = (Equipment)Cached.GetDefaultItemPrefab(item);

            int index = 0;

            var stats = VanillaStats.Instance.GetAllStatsItemHasOrderedByIndex(item);

            while (percents.Count < stats.Count)
            {
                percents.Add(RollPercent(item));
            }

            foreach (VanillaStat stat in stats)
            {
                float defaultVal = stat.GetStat(def);

                if (defaultVal != 0)
                {
                    float currentVal = stat.GetStat(item);

                    float shouldBe = percents[index] * defaultVal / 100F;

                    int diff = (int)(shouldBe - defaultVal); // we want pretty numbers

                    if (type == StatChangeType.REMOVE)
                    {
                        diff *= -1;
                    }

                    stat.SetStat(item, currentVal + diff);
                }

                index++;
            }

            if (type == StatChangeType.ADD)
            {
                addedStats = true;
            }
            if (type == StatChangeType.REMOVE)
            {
                addedStats = false;
            }
        }
Пример #3
0
 public bool Matches(
     string statName,
     StatChangeType change,
     string[] reactableTypes
     )
 {
     return(Matches(
                new string[] { statName },
                new StatChangeType[] { change },
                reactableTypes
                ));
 }
Пример #4
0
        public void ApplyToItem(int percent, Equipment item, StatChangeType type = StatChangeType.ADD)
        {
            int val = (int)GetValue(percent);

            if (item.TwoHanded)
            {
                val *= 2; // if it's 2 handed weapon, make the stat boost double.
            }

            if (type == StatChangeType.REMOVE)
            {
                val *= -1; // reverse to remove the stats
            }

            stat.SetStat(item, stat.GetStat(item) + val);
        }
Пример #5
0
 public StatChange(string stat, StatChangeType change)
 {
     statName = stat;
     changeType = change;
 }
Пример #6
0
    public bool Matches(
		string statName, 
		StatChangeType change, 
		string[] reactableTypes
	)
    {
        return Matches(
            new string[]{statName},
            new StatChangeType[]{change},
            reactableTypes
        );
    }
Пример #7
0
    public bool Matches(
		string[] statNames, 
		StatChangeType[] changes, 
		string[] reactableTypes
	)
    {
        bool statNameOK = statNames == null ||
            statNames.Length == 0 ||
            statNames.Contains(effect.statName);
        bool changeOK = changes == null ||
            changes.Length == 0 ||
            changes.Any(delegate(StatChangeType c) {
                switch(c) {
                    case StatChangeType.Any: return true;
                    case StatChangeType.NoChange: return value == initialValue;
                    case StatChangeType.Change: return value != initialValue;
                    case StatChangeType.Increase: return value > initialValue;
                    case StatChangeType.Decrease: return value < initialValue;
                }
                return false;
            });
        bool typesOK = reactableTypes == null ||
            reactableTypes.Length == 0 ||
            reactableTypes.All(t => effect.reactableTypes.Contains(t));
        return statNameOK && changeOK && typesOK;
    }
Пример #8
0
 public GameEffectStat(GameCharacter inputAffectedCharacter, StatChangeType inputChangedStatType, int inputStatChangeMagnitude)
 {
     affectedCharacter   = inputAffectedCharacter;
     ChangedStatType     = inputChangedStatType;
     StatChangeMagnitude = inputStatChangeMagnitude;
 }
Пример #9
0
 public StatChange(string stat, StatChangeType change)
 {
     statName   = stat;
     changeType = change;
 }