示例#1
0
        public static SL_ImbueEffect ParseImbueEffect(ImbueEffectPreset imbue)
        {
            var template = new SL_ImbueEffect
            {
                TargetStatusID = imbue.PresetID,
                Name           = imbue.Name,
                Description    = imbue.Description
            };

            //CustomStatusEffects.GetImbueLocalization(imbue, out template.Name, out template.Description);

            var list = new List <SL_EffectTransform>();

            foreach (Transform child in imbue.transform)
            {
                var effectsChild = SL_EffectTransform.ParseTransform(child);

                if (effectsChild.HasContent)
                {
                    list.Add(effectsChild);
                }
            }
            template.Effects = list.ToArray();

            return(template);
        }
        public override void SerializeEffect <T>(T effect)
        {
            base.SerializeEffect(effect);

            var comp = effect as ShootBlast;

            if (comp.BaseBlast is Blast blast && GetBlastPrefabEnum(blast) != BlastPrefabs.NONE)
            {
                BaseBlast             = GetBlastPrefabEnum(blast);
                AffectHitTargetCenter = blast.AffectHitTargetCenter;
                DontPlayHitSound      = blast.DontPlayHitSound;
                FXIsWorld             = blast.FXIsWorld;
                HitOnShoot            = blast.HitOnShoot;
                IgnoreShooter         = blast.IgnoreShooter;
                ImpactSoundMaterial   = blast.ImpactSoundMaterial;
                Interruptible         = blast.Interruptible;
                MaxHitTargetCount     = blast.MaxHitTargetCount;
                Radius           = blast.Radius;
                RefreshTime      = blast.RefreshTime;
                DontPlayHitSound = blast.DontPlayHitSound;
                PlayFXOnRefresh  = blast.PlayFXOnRefresh;
                DelayFirstShoot  = blast.DelayFirstShoot;

                BlastLifespan                  = comp.BlastLifespan;
                IgnoreStop                     = comp.IgnoreStop;
                InstantiatedAmount             = comp.InstanstiatedAmount;
                NoTargetForwardMultiplier      = comp.NoTargetForwardMultiplier;
                ParentToShootTransform         = comp.ParentToShootTransform;
                UseTargetCharacterPositionType = comp.UseTargetCharacterPositionType;

                if (blast.transform.childCount > 0)
                {
                    var list = new List <SL_EffectTransform>();
                    foreach (Transform child in blast.transform)
                    {
                        var effectsChild = SL_EffectTransform.ParseTransform(child);

                        if (effectsChild.HasContent)
                        {
                            list.Add(effectsChild);
                        }
                    }
                    BlastEffects = list.ToArray();
                }
            }
        public virtual void SerializeStatus(StatusEffect status)
        {
            var preset = status.GetComponent <EffectPreset>();

            this.NewStatusID            = preset?.PresetID ?? -1;
            this.TargetStatusIdentifier = status.IdentifierName;
            this.StatusIdentifier       = status.IdentifierName;
            this.IgnoreBuildupIfApplied = status.IgnoreBuildUpIfApplied;
            this.BuildupRecoverySpeed   = status.BuildUpRecoverSpeed;
            this.DisplayedInHUD         = status.DisplayInHud;
            this.IsHidden    = status.IsHidden;
            this.Lifespan    = status.StatusData.LifeSpan;
            this.RefreshRate = status.RefreshRate;
            this.AmplifiedStatusIdentifier    = status.AmplifiedStatus?.IdentifierName ?? "";
            this.PlayFXOnActivation           = status.PlayFXOnActivation;
            this.ComplicationStatusIdentifier = status.ComplicationStatus?.IdentifierName;
            this.FXOffset                 = status.FxOffset;
            this.IgnoreBarrier            = status.IgnoreBarrier;
            this.IsMalusEffect            = status.IsMalusEffect;
            this.NormalizeDamageDisplay   = status.NormalizeDamageDisplay;
            this.PlaySpecialFXOnStop      = status.PlaySpecialFXOnStop;
            this.RemoveRequiredStatus     = status.RemoveRequiredStatus;
            this.RequiredStatusIdentifier = status.RequiredStatus?.IdentifierName;
            this.SpecialSFX               = status.SpecialSFX;
            this.VFXInstantiationType     = status.FxInstantiation;

            this.ActionOnHit = status.ActionOnHit;

            this.Priority = (int)At.GetField(status, "m_priority");

            this.DelayedDestroyTime = status.DelayedDestroyTime;
            this.Purgeable          = status.Purgeable;

            CustomStatusEffects.GetStatusLocalization(status, out Name, out Description);

            var tags = At.GetField(status, "m_tagSource") as TagListSelectorComponent;

            if (tags)
            {
                Tags = tags.Tags.Select(it => it.TagName).ToArray();
            }

            var vfx = status.FXPrefab?.GetComponent <VFXSystem>();

            if (vfx)
            {
                VFXPrefab = SL_PlayVFX.GetVFXSystemEnum(vfx);
            }

            // PARSE EFFECT FAMILY
            FamilyMode = status.FamilyMode;
            if (status.EffectFamily != null)
            {
                if (FamilyMode == StatusEffect.FamilyModes.Bind)
                {
                    BindFamily = SL_StatusEffectFamily.ParseEffectFamily(status.EffectFamily);
                }
                else
                {
                    ReferenceFamilyUID = status.EffectFamily.UID;
                }
            }

            // For existing StatusEffects, the StatusData contains the real values, so we need to SetValue to each Effect.
            var statusData = status.StatusData.EffectsData;
            var components = status.GetComponentsInChildren <Effect>();

            for (int i = 0; i < components.Length; i++)
            {
                var comp = components[i];
                if (comp && comp.Signature.Length > 0)
                {
                    comp.SetValue(statusData[i].Data);
                }
            }

            var       effects = new List <SL_EffectTransform>();
            Transform signature;

            if (status.transform.childCount > 0)
            {
                signature = status.transform.GetChild(0);
                if (signature.transform.childCount > 0)
                {
                    foreach (Transform child in signature.transform)
                    {
                        var effectsChild = SL_EffectTransform.ParseTransform(child);

                        if (effectsChild.HasContent)
                        {
                            effects.Add(effectsChild);
                        }
                    }
                }
            }

            Effects = effects.ToArray();
        }
        // ======== Serializing Enchantment into a Template =========

        public static SL_EnchantmentRecipe SerializeEnchantment(EnchantmentRecipe recipe)
        {
            var enchantment = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(recipe.ResultID);

            var template = new SL_EnchantmentRecipe
            {
                Name          = enchantment.Name,
                Description   = enchantment.Description,
                EnchantmentID = recipe.RecipeID,

                IncenseItemID      = recipe.PillarDatas?[0]?.CompatibleIngredients?[0].SpecificIngredient?.ItemID ?? -1,
                TimeOfDay          = recipe.TimeOfDay,
                Areas              = recipe.Region,
                Temperature        = recipe.Temperature,
                WindAltarActivated = recipe.WindAltarActivated,

                IsEnchantingGuildRecipe = recipe.TableIsInBuilding,

                EnchantTime        = enchantment.EnchantTime,
                HealthAbsorbRatio  = enchantment.HealthAbsorbRatio,
                StaminaAbsorbRatio = enchantment.StaminaAbsorbRatio,
                ManaAbsorbRatio    = enchantment.ManaAbsorbRatio,
                Indestructible     = enchantment.Indestructible,
                TrackDamageRatio   = enchantment.TrackDamageRatio
            };

            if (recipe.PillarDatas != null)
            {
                var pillarList = new List <PillarData>();
                foreach (var pillarData in recipe.PillarDatas)
                {
                    var data = new PillarData
                    {
                        Direction = (Directions)pillarData.Direction,
                        IsFar     = pillarData.IsFar,
                    };
                    pillarList.Add(data);
                }
                template.PillarDatas = pillarList.ToArray();
            }

            var compatibleEquipment = new EquipmentData
            {
                RequiredTag = recipe.CompatibleEquipments.EquipmentTag.Tag.TagName
            };

            if (recipe.CompatibleEquipments.CompatibleEquipments != null)
            {
                var equipList = new List <IngredientData>();
                foreach (var equipData in recipe.CompatibleEquipments.CompatibleEquipments)
                {
                    var data = new IngredientData
                    {
                        SelectorType = (IngredientTypes)equipData.Type
                    };
                    if (data.SelectorType == IngredientTypes.SpecificItem)
                    {
                        data.SelectorValue = equipData.SpecificIngredient?.ItemID.ToString();
                    }
                    else
                    {
                        data.SelectorValue = equipData.IngredientTag.Tag.TagName;
                    }
                    equipList.Add(data);
                }
                compatibleEquipment.Equipments = equipList.ToArray();
            }
            template.CompatibleEquipment = compatibleEquipment;

            // Parse the actual Enchantment effects

            if (enchantment.transform.childCount > 0)
            {
                var effects = new List <SL_EffectTransform>();
                foreach (Transform child in enchantment.transform)
                {
                    var effectsChild = SL_EffectTransform.ParseTransform(child);

                    if (effectsChild.HasContent)
                    {
                        effects.Add(effectsChild);
                    }
                }
                template.Effects = effects.ToArray();
            }

            if (enchantment.AdditionalDamages != null)
            {
                var list = new List <AdditionalDamage>();
                foreach (var addedDmg in enchantment.AdditionalDamages)
                {
                    list.Add(new AdditionalDamage
                    {
                        AddedDamageType  = addedDmg.BonusDamageType,
                        ConversionRatio  = addedDmg.ConversionRatio,
                        SourceDamageType = addedDmg.SourceDamageType
                    });
                }
                template.AddedDamages = list.ToArray();
            }
            if (enchantment.StatModifications != null)
            {
                var list = new List <StatModification>();
                foreach (var statMod in enchantment.StatModifications)
                {
                    list.Add(new StatModification
                    {
                        Stat  = statMod.Name,
                        Type  = statMod.Type,
                        Value = statMod.Value
                    });
                }
                template.StatModifications = list.ToArray();
            }

            if (enchantment.DamageBonus != null)
            {
                template.FlatDamageAdded = SL_Damage.ParseDamageList(enchantment.DamageBonus).ToArray();
            }
            if (enchantment.DamageModifier != null)
            {
                template.DamageModifierBonus = SL_Damage.ParseDamageList(enchantment.DamageModifier).ToArray();
            }
            if (enchantment.ElementalResistances != null)
            {
                template.DamageResistanceBonus = SL_Damage.ParseDamageList(enchantment.ElementalResistances).ToArray();
            }

            template.GlobalStatusResistance = enchantment.GlobalStatusResistance;

            return(template);
        }
示例#5
0
        public override void SerializeEffect <T>(T effect)
        {
            base.SerializeEffect(effect);

            var comp = effect as ShootProjectile;

            AddDirection             = comp.AddDirection;
            AddRotationForce         = comp.AddRotationForce;
            AutoTarget               = comp.AutoTarget;
            AutoTargetMaxAngle       = comp.AutoTargetMaxAngle;
            AutoTargetRange          = comp.AutoTargetRange;
            IgnoreShooterCollision   = comp.IgnoreShooterCollision;
            ProjectileForce          = comp.ProjectileForce;
            TargetCountPerProjectile = comp.TargetCountPerProjectile;
            TargetingMode            = comp.TargetingMode;
            TargetRange              = comp.TargetRange;
            YMagnitudeAffect         = comp.YMagnitudeAffect;
            YMagnitudeForce          = comp.YMagnitudeForce;
            InstantiatedAmount       = comp.IntanstiatedAmount;
            CameraAddYDirection      = comp.CameraAddYDirection;

            var prefabEnum = GetProjectilePrefabEnum(comp.BaseProjectile);

            if (prefabEnum != ProjectilePrefabs.NONE)
            {
                var proj = comp.BaseProjectile;

                BaseProjectile            = prefabEnum;
                DefenseLength             = proj.DefenseLength;
                DefenseRange              = proj.DefenseRange;
                DisableOnHit              = proj.DisableOnHit;
                EffectsOnlyIfHitCharacter = proj.EffectsOnlyIfHitCharacter;
                EndMode             = proj.EndMode;
                ImpactSoundMaterial = proj.ImpactSoundMaterial;
                LateShootTime       = proj.LateShootTime;
                Lifespan            = proj.Lifespan;
                LightIntensityFade  = proj.LightIntensityFade;
                PointOffset         = proj.PointOffset;
                TrailEnabled        = proj.TrailEnabled;
                TrailTime           = proj.TrailTime;
                Unblockable         = proj.Unblockable;

                var list = new List <SL_EffectTransform>();
                foreach (Transform child in proj.transform)
                {
                    var effectsChild = SL_EffectTransform.ParseTransform(child);

                    if (effectsChild.HasContent)
                    {
                        list.Add(effectsChild);
                    }
                }
                ProjectileEffects = list.ToArray();
            }
            else if (comp.BaseProjectile)
            {
                SL.Log("Couldn't parse blast prefab to enum: " + comp.BaseProjectile.name);
            }

            var shots = new List <SL_ProjectileShot>();

            foreach (var shot in comp.ProjectileShots)
            {
                shots.Add(new SL_ProjectileShot()
                {
                    RandomLocalDirectionAdd = shot.RandomLocalDirectionAdd,
                    LocalDirectionOffset    = shot.LocalDirectionOffset,
                    LockDirection           = shot.LockDirection,
                    MustShoot = shot.MustShoot,
                    NoBaseDir = shot.NoBaseDir
                });
            }
            ProjectileShots = shots.ToArray();
        }