예제 #1
0
        public void Serialize(TrapEffectRecipe recipe, DeployableTrap trap)
        {
            var items = (Item[])At.GetField(recipe, "m_compatibleItems");
            var tags  = (TagSourceSelector[])At.GetField(recipe, "m_compatibleTags");

            trap.GetCompatibleFilters();

            var compatibleTags = ((List <Tag>[])At.GetField <DeployableTrap>("COMPATIBLE_TAGS"))[(int)trap.CurrentTrapType];

            if (items != null)
            {
                foreach (var item in items)
                {
                    switch (trap.CurrentTrapType)
                    {
                    case DeployableTrap.TrapType.PressurePlateTrap:
                        if (!item.HasTag(TagSourceManager.PlateTrapComponent) && !HasAnyTag(item, compatibleTags))
                        {
                            continue;
                        }
                        break;

                    case DeployableTrap.TrapType.TripWireTrap:
                        if (!item.HasTag(TagSourceManager.TripWireTrapComponent) && !HasAnyTag(item, compatibleTags))
                        {
                            continue;
                        }
                        break;
                    }

                    this.CompatibleItemIDs.Add(item.Name);
                }
            }


            if (tags != null)
            {
                foreach (var tag in tags)
                {
                    this.CompatibleItemTags.Add(tag.Tag.TagName);
                }
            }

            if (recipe.TrapEffectsPrefab)
            {
                this.StandardEffects = new List <DM_Effect>();
                foreach (var effect in recipe.TrapEffectsPrefab.GetComponents <Effect>())
                {
                    this.StandardEffects.Add(DM_Effect.ParseEffect(effect));
                }
            }
            if (recipe.HiddenTrapEffectsPrefab)
            {
                this.HiddenEffects = new List <DM_Effect>();
                foreach (var effect in recipe.HiddenTrapEffectsPrefab.GetComponents <Effect>())
                {
                    this.HiddenEffects.Add(DM_Effect.ParseEffect(effect));
                }
            }
        }
        public static DM_EffectTransform ParseTransform(Transform transform)
        {
            var effectTransformHolder = new DM_EffectTransform
            {
                TransformName = transform.name
            };

            foreach (Effect effect in transform.GetComponents<Effect>())
            {
                if (!effect.enabled)
                {
                    continue;
                }

                if (DM_Effect.ParseEffect(effect) is DM_Effect holder)
                {
                    effectTransformHolder.Effects.Add(holder);
                }
            }

            foreach (EffectCondition condition in transform.GetComponents<EffectCondition>())
            {
                var effectConditionHolder = DM_EffectCondition.ParseCondition(condition);
                effectTransformHolder.EffectConditions.Add(effectConditionHolder);
            }

            foreach (Transform child in transform)
            {
                if (child.name == "ExplosionFX" || child.name == "ProjectileFX")
                {
                    // visual effects, we dont care about these
                    continue;
                }

                var transformHolder = ParseTransform(child);
                if (transformHolder.ChildEffects.Count > 0 || transformHolder.Effects.Count > 0 || transformHolder.EffectConditions.Count > 0)
                {
                    effectTransformHolder.ChildEffects.Add(transformHolder);
                }
            }

            return effectTransformHolder;
        }
예제 #3
0
        public static DM_Enchantment ParseEnchantment(Enchantment enchantment)
        {
            var template = new DM_Enchantment
            {
                Name        = enchantment.Name,
                Description = enchantment.Description,

                HealthAbsorbRatio  = enchantment.HealthAbsorbRatio,
                ManaAbsorbRatio    = enchantment.ManaAbsorbRatio,
                StaminaAbsorbRatio = enchantment.StaminaAbsorbRatio,

                GlobalStatusResistance = enchantment.GlobalStatusResistance,

                Indescructible   = enchantment.Indestructible,
                TrackDamageRatio = enchantment.TrackDamageRatio,
            };

            if (enchantment.Effects != null)
            {
                template.Effects = new List <DM_Effect>();
                foreach (var effect in enchantment.Effects)
                {
                    var effectTemplate = DM_Effect.ParseEffect(effect);

                    if (effectTemplate != null)
                    {
                        template.Effects.Add(effectTemplate);
                    }
                }
            }

            if (enchantment.AdditionalDamages != null)
            {
                template.AdditionalDamages = new List <AdditionalDamage>();
                foreach (var addDmg in enchantment.AdditionalDamages)
                {
                    template.AdditionalDamages.Add(new AdditionalDamage
                    {
                        BonusDamageType  = addDmg.BonusDamageType,
                        ConversionRatio  = addDmg.ConversionRatio,
                        SourceDamageType = addDmg.SourceDamageType
                    });
                }
            }

            if (enchantment.StatModifications != null)
            {
                template.StatModifications = new List <StatModification>();
                foreach (var statMod in enchantment.StatModifications)
                {
                    template.StatModifications.Add(new StatModification
                    {
                        Name  = statMod.Name,
                        Type  = statMod.Type,
                        Value = statMod.Value
                    });
                }
            }

            if (enchantment.DamageBonus != null)
            {
                template.DamageBonus = new List <Damages>();
                foreach (var dmgBonus in enchantment.DamageBonus.List)
                {
                    var dmg = Damages.ParseDamageType(dmgBonus);
                    template.DamageBonus.Add(dmg);
                }
            }

            if (enchantment.DamageModifier != null)
            {
                template.DamageModifier = new List <Damages>();
                foreach (var dmgBonus in enchantment.DamageModifier.List)
                {
                    var dmg = Damages.ParseDamageType(dmgBonus);
                    template.DamageModifier.Add(dmg);
                }
            }

            if (enchantment.ElementalResistances != null)
            {
                template.ElementalResistances = new List <Damages>();
                foreach (var dmgBonus in enchantment.ElementalResistances.List)
                {
                    var dmg = Damages.ParseDamageType(dmgBonus);
                    template.ElementalResistances.Add(dmg);
                }
            }

            return(template);
        }