Пример #1
0
        public override void ApplyToItem(Item item)
        {
            base.ApplyToItem(item);

            var attackSkill = item as AttackSkill;

            if (this.AmmunitionTypes != null)
            {
                attackSkill.AmmunitionTypes = this.AmmunitionTypes.ToList();
            }

            if (this.RequiredOffHandTypes != null)
            {
                attackSkill.RequiredOffHandTypes = this.RequiredOffHandTypes.ToList();
            }

            if (this.RequiredWeaponTypes != null)
            {
                attackSkill.RequiredWeaponTypes = this.RequiredWeaponTypes.ToList();
            }

            if (this.RequireImbue != null)
            {
                attackSkill.RequireImbue = (bool)this.RequireImbue;
            }

            if (this.AmmunitionAmount != null)
            {
                attackSkill.AmmunitionAmount = (int)this.AmmunitionAmount;
            }

            if (this.RequiredWeaponTags != null)
            {
                var list = new List <TagSourceSelector>();
                foreach (var tag in this.RequiredWeaponTags)
                {
                    if (CustomItems.GetTag(tag) is Tag _tag && _tag != Tag.None)
                    {
                        list.Add(new TagSourceSelector(_tag));
                    }
                }
                attackSkill.RequiredTags = list.ToArray();
            }
        }
Пример #2
0
        public override void ApplyToComponent <T>(T component)
        {
            var tag = CustomItems.GetTag(Stat_Tag);

            if (tag == Tag.None)
            {
                SL.Log("AffectStat: could not find tag of ID " + (this.Stat_Tag ?? ""));
                return;
            }

            var comp = component as AffectStat;

            comp.AffectedStat = new TagSourceSelector(tag);
            comp.Value        = this.AffectQuantity;
            comp.IsModifier   = this.IsModifier;

            if (this.Tags != null)
            {
                comp.Tags = this.Tags
                            .Select(it => new TagSourceSelector(CustomTags.GetTag(it)))
                            .ToArray();
            }
        }
Пример #3
0
        public virtual void SetStats(Character character)
        {
            if (character.GetComponent <PlayerCharacterStats>())
            {
                CustomCharacters.FixStats(character);
            }

            var stats = character.GetComponent <CharacterStats>();

            if (!stats)
            {
                return;
            }

            if (Health != null)
            {
                var m_maxHealthStat = (Stat)At.GetField(stats, "m_maxHealthStat");
                m_maxHealthStat.AddStack(new StatStack(SL_STAT_ID, (float)Health - 100), false);
            }

            if (HealthRegen != null)
            {
                var m_healthRegenStat = (Stat)At.GetField(stats, "m_healthRegen");
                m_healthRegenStat.AddStack(new StatStack(SL_STAT_ID, (float)HealthRegen), false);
            }

            if (ImpactResist != null)
            {
                var m_impactResistance = (Stat)At.GetField(stats, "m_impactResistance");
                m_impactResistance.AddStack(new StatStack(SL_STAT_ID, (float)ImpactResist), false);
            }

            if (Protection != null)
            {
                var m_damageProtection = (Stat[])At.GetField(stats, "m_damageProtection");
                m_damageProtection[0].AddStack(new StatStack(SL_STAT_ID, (float)Protection), false);
            }

            if (this.Barrier != null)
            {
                var m_barrier = (Stat)At.GetField(stats, "m_barrierStat");
                m_barrier.AddStack(new StatStack(SL_STAT_ID, (float)Barrier), false);
            }

            if (Damage_Resists != null)
            {
                var m_damageResistance = (Stat[])At.GetField(stats, "m_damageResistance");
                for (int i = 0; i < 6; i++)
                {
                    m_damageResistance[i].AddStack(new StatStack(SL_STAT_ID, Damage_Resists[i]), false);
                }
            }

            if (Damage_Bonus != null)
            {
                var m_damageTypesModifier = (Stat[])At.GetField(stats, "m_damageTypesModifier");
                for (int i = 0; i < 6; i++)
                {
                    m_damageTypesModifier[i].AddStack(new StatStack(SL_STAT_ID, Damage_Bonus[i]), false);
                }
            }

            // status immunity
            if (this.Status_Immunity != null)
            {
                var immunities = new List <TagSourceSelector>();
                foreach (var tagName in this.Status_Immunity)
                {
                    if (CustomItems.GetTag(tagName) is Tag tag && tag != Tag.None)
                    {
                        immunities.Add(new TagSourceSelector(tag));
                    }
                }

                At.SetField(stats, "m_statusEffectsNaturalImmunity", immunities.ToArray());
            }
        }