Esempio n. 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();
                }
            }
Esempio n. 3
0
        public static SL_EffectTransform ParseTransform(Transform transform)
        {
            var holder = new SL_EffectTransform
            {
                TransformName = transform.name
            };

            if (transform.localPosition != Vector3.zero)
            {
                holder.Position = transform.localPosition;
            }
            if (transform.localEulerAngles != Vector3.zero)
            {
                holder.Rotation = transform.localEulerAngles;
            }
            if (transform.localScale != Vector3.one)
            {
                holder.Scale = transform.localScale;
            }

            var slEffects = new List <SL_Effect>();

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

                if (SL_Effect.ParseEffect(effect) is SL_Effect slEffect)
                {
                    slEffects.Add(slEffect);
                }
            }
            holder.Effects = slEffects.ToArray();

            var slConditions = new List <SL_EffectCondition>();

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

                if (SL_EffectCondition.ParseCondition(condition) is SL_EffectCondition slCondition)
                {
                    slConditions.Add(slCondition);
                }
            }
            holder.EffectConditions = slConditions.ToArray();

            var children = new List <SL_EffectTransform>();

            foreach (Transform child in transform)
            {
                if (child.name == "ExplosionFX" || child.name == "ProjectileFX")
                {
                    continue;
                }

                var transformHolder = ParseTransform(child);

                if (transformHolder.HasContent)
                {
                    children.Add(transformHolder);
                }
            }
            holder.ChildEffects = children.ToArray();

            return(holder);
        }
Esempio n. 4
0
        private void OnLateApply(object[] obj)
        {
            var preset = obj[0] as ImbueEffectPreset;

            SL_EffectTransform.ApplyTransformList(preset.transform, Effects, EffectBehaviour);
        }
        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();
        }
        protected internal void LateApplyStatusEffects(StatusEffect status)
        {
            if (!string.IsNullOrEmpty(this.ComplicationStatusIdentifier))
            {
                var complicStatus = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(this.ComplicationStatusIdentifier);
                if (complicStatus)
                {
                    status.ComplicationStatus = complicStatus;
                }
            }

            if (!string.IsNullOrEmpty(RequiredStatusIdentifier))
            {
                var required = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(this.RequiredStatusIdentifier);
                if (required)
                {
                    status.RequiredStatus = required;
                }
            }

            if (!string.IsNullOrEmpty(this.AmplifiedStatusIdentifier))
            {
                var amp = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(AmplifiedStatusIdentifier);
                if (amp)
                {
                    At.SetField(status, "m_amplifiedStatus", amp);
                }
                else
                {
                    SL.Log("StatusEffect.ApplyTemplate - could not find AmplifiedStatusIdentifier " + this.AmplifiedStatusIdentifier);
                }
            }

            // setup signature and finalize

            if (EffectBehaviour == EditBehaviours.Destroy)
            {
                UnityHelpers.DestroyChildren(status.transform);
            }

            Transform signature;

            if (status.transform.childCount < 1)
            {
                signature        = new GameObject($"SIGNATURE_{status.IdentifierName}").transform;
                signature.parent = status.transform;
                var comp = signature.gameObject.AddComponent <EffectSignature>();
                comp.SignatureUID = new UID($"{NewStatusID}_{status.IdentifierName}");
            }
            else
            {
                signature = status.transform.GetChild(0);
            }

            if (Effects != null)
            {
                if (signature)
                {
                    SL_EffectTransform.ApplyTransformList(signature, Effects, EffectBehaviour);
                }
                else
                {
                    SL.Log("Could not get effect signature!");
                }
            }

            // fix StatusData for the new effects
            CompileEffectsToData(status);

            var sigComp = signature.GetComponent <EffectSignature>();

            sigComp.enabled = true;

            var effects = signature.GetComponentsInChildren <Effect>();

            sigComp.Effects = effects.ToList();

            // Fix the effect signature for reference families
            if (status.FamilyMode == StatusEffect.FamilyModes.Reference)
            {
                signature.transform.parent = SL.CloneHolder;

                var family = status.EffectFamily;
                family.EffectSignature            = sigComp;
                status.StatusData.EffectSignature = sigComp;
            }

            // Need to reset description after changing effects.
            At.Invoke(status, "RefreshLoc");
        }
        internal void Internal_ApplyTemplate()
        {
            SL.Log($"Applying Enchantment Recipe, ID: {this.EnchantmentID}, Name: {this.Name}");

            var recipe = ScriptableObject.CreateInstance <EnchantmentRecipe>();

            recipe.RecipeID = this.EnchantmentID;
            recipe.ResultID = this.EnchantmentID;

            if (ResourcesPrefabManager.Instance.GetItemPrefab(this.IncenseItemID) is Item incense)
            {
                var list = new List <EnchantmentRecipe.PillarData>();
                foreach (var pillar in this.PillarDatas)
                {
                    list.Add(new EnchantmentRecipe.PillarData
                    {
                        Direction             = (UICardinalPoint_v2.CardinalPoint)pillar.Direction,
                        IsFar                 = pillar.IsFar,
                        CompatibleIngredients = new EnchantmentRecipe.IngredientData[]
                        {
                            new EnchantmentRecipe.IngredientData
                            {
                                Type = EnchantmentRecipe.IngredientData.IngredientType.Specific,
                                SpecificIngredient = incense
                            }
                        }
                    });
                }
                recipe.PillarDatas = list.ToArray();
            }

            recipe.CompatibleEquipments = new EnchantmentRecipe.EquipmentData
            {
                EquipmentTag = new TagSourceSelector(CustomTags.GetTag(this.CompatibleEquipment.RequiredTag)),
            };
            if (this.CompatibleEquipment.Equipments != null)
            {
                var equipList = new List <EnchantmentRecipe.IngredientData>();
                foreach (var ingData in this.CompatibleEquipment.Equipments)
                {
                    var data = new EnchantmentRecipe.IngredientData();
                    if (ingData.SelectorType == IngredientTypes.Tag)
                    {
                        data.Type          = EnchantmentRecipe.IngredientData.IngredientType.Generic;
                        data.IngredientTag = new TagSourceSelector(CustomTags.GetTag(ingData.SelectorValue));
                    }
                    else if (ingData.SelectorType == IngredientTypes.SpecificItem)
                    {
                        data.Type = EnchantmentRecipe.IngredientData.IngredientType.Specific;
                        data.SpecificIngredient = ResourcesPrefabManager.Instance.GetItemPrefab(ingData.SelectorValue);
                    }
                    equipList.Add(data);
                }
                recipe.CompatibleEquipments.CompatibleEquipments = equipList.ToArray();
            }
            else
            {
                recipe.CompatibleEquipments.CompatibleEquipments = new EnchantmentRecipe.IngredientData[0];
            }

            recipe.TimeOfDay          = this.TimeOfDay ?? new Vector2[0];
            recipe.Region             = this.Areas ?? new AreaManager.AreaEnum[0];
            recipe.Temperature        = this.Temperature ?? new TemperatureSteps[0];
            recipe.WindAltarActivated = this.WindAltarActivated;

            if (!string.IsNullOrEmpty(this.QuestEventUID))
            {
                recipe.QuestEvent = new QuestEventReference()
                {
                    m_eventUID = QuestEventUID, UID = QuestEventUID
                };
            }

            if (this.WeatherConditions != null)
            {
                var list = new List <EnchantmentRecipe.WeaterCondition>();
                foreach (var condition in this.WeatherConditions)
                {
                    list.Add(new EnchantmentRecipe.WeaterCondition
                    {
                        Invert  = condition.Invert,
                        Weather = (EnchantmentRecipe.WeaterType)condition.WeatherType
                    });
                }
                recipe.Weather = list.ToArray();
            }
            else
            {
                recipe.Weather = new EnchantmentRecipe.WeaterCondition[0];
            }

            recipe.TableIsInBuilding = this.IsEnchantingGuildRecipe;

            // ========== Create actual Enchantment effects prefab ==========

            var enchantmentObject = new GameObject(this.EnchantmentID + "_" + this.Name);

            GameObject.DontDestroyOnLoad(enchantmentObject);
            var enchantment = enchantmentObject.AddComponent <Enchantment>();

            At.SetField <EffectPreset>(enchantment, "m_StatusEffectID", this.EnchantmentID);

            SetLocalization(this, out enchantment.CustomDescLocKey);

            enchantment.EnchantTime = this.EnchantTime;

            if (this.Effects != null)
            {
                SL_EffectTransform.ApplyTransformList(enchantment.transform, this.Effects?.ToArray(), EditBehaviours.Override);
            }

            if (this.AddedDamages != null)
            {
                var list = new List <Enchantment.AdditionalDamage>();
                foreach (var dmg in this.AddedDamages)
                {
                    list.Add(new Enchantment.AdditionalDamage
                    {
                        BonusDamageType  = dmg.AddedDamageType,
                        ConversionRatio  = dmg.ConversionRatio,
                        SourceDamageType = dmg.SourceDamageType
                    });
                }
                enchantment.AdditionalDamages = list.ToArray();
            }
            if (this.StatModifications != null)
            {
                var list = new Enchantment.StatModificationList();
                foreach (var mod in this.StatModifications)
                {
                    list.Add(new Enchantment.StatModification
                    {
                        Name  = mod.Stat,
                        Type  = mod.Type,
                        Value = mod.Value
                    });
                }
                enchantment.StatModifications = list;
            }
            if (this.FlatDamageAdded != null)
            {
                enchantment.DamageBonus = SL_Damage.GetDamageList(this.FlatDamageAdded);
            }
            if (this.DamageModifierBonus != null)
            {
                enchantment.DamageModifier = SL_Damage.GetDamageList(this.DamageModifierBonus);
            }
            if (this.DamageResistanceBonus != null)
            {
                enchantment.ElementalResistances = SL_Damage.GetDamageList(this.DamageResistanceBonus);
            }

            enchantment.HealthAbsorbRatio  = this.HealthAbsorbRatio;
            enchantment.StaminaAbsorbRatio = this.StaminaAbsorbRatio;
            enchantment.ManaAbsorbRatio    = this.ManaAbsorbRatio;

            enchantment.Indestructible   = this.Indestructible;
            enchantment.TrackDamageRatio = this.TrackDamageRatio;

            enchantment.GlobalStatusResistance = this.GlobalStatusResistance;

            // =========== SET DICTIONARY REFS ============

            // Recipe dict
            if (References.ENCHANTMENT_RECIPES.ContainsKey(this.EnchantmentID))
            {
                References.ENCHANTMENT_RECIPES[this.EnchantmentID] = recipe;
            }
            else
            {
                References.ENCHANTMENT_RECIPES.Add(this.EnchantmentID, recipe);
            }

            // Enchantment dict
            if (References.ENCHANTMENT_PREFABS.ContainsKey(this.EnchantmentID))
            {
                References.ENCHANTMENT_PREFABS[this.EnchantmentID] = enchantment;
            }
            else
            {
                References.ENCHANTMENT_PREFABS.Add(this.EnchantmentID, enchantment);
            }
        }
        // ======== 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);
        }
Esempio n. 9
0
        public override void ApplyToComponent <T>(T component)
        {
            base.ApplyToComponent(component);

            var comp = component as ShootProjectile;

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

            if (this.ProjectileShots != null)
            {
                var list = new List <ProjectileShot>();
                foreach (var shot in this.ProjectileShots)
                {
                    list.Add(new ProjectileShot()
                    {
                        RandomLocalDirectionAdd = shot.RandomLocalDirectionAdd,
                        LocalDirectionOffset    = shot.LocalDirectionOffset,
                        LockDirection           = shot.LockDirection,
                        MustShoot = shot.MustShoot,
                        NoBaseDir = shot.NoBaseDir
                    });
                }
                comp.ProjectileShots = list.ToArray();
            }

            if (GetProjectilePrefab(this.BaseProjectile) is GameObject projectile)
            {
                var copy = GameObject.Instantiate(projectile);
                GameObject.DontDestroyOnLoad(copy);
                copy.SetActive(false);

                var newProjectile = copy.GetComponent <Projectile>();
                comp.BaseProjectile = newProjectile;

                newProjectile.DefenseLength             = this.DefenseLength;
                newProjectile.DefenseRange              = this.DefenseRange;
                newProjectile.DisableOnHit              = this.DisableOnHit;
                newProjectile.EffectsOnlyIfHitCharacter = this.EffectsOnlyIfHitCharacter;
                newProjectile.EndMode            = this.EndMode;
                newProjectile.LateShootTime      = this.LateShootTime;
                newProjectile.Lifespan           = this.Lifespan;
                newProjectile.LightIntensityFade = this.LightIntensityFade;
                newProjectile.PointOffset        = this.PointOffset;
                newProjectile.TrailEnabled       = this.TrailEnabled;
                newProjectile.TrailTime          = this.TrailTime;
                newProjectile.Unblockable        = this.Unblockable;

                newProjectile.ImpactSoundMaterial = this.ImpactSoundMaterial;
                if (newProjectile.GetComponentInChildren <ImpactSoundPlayer>() is ImpactSoundPlayer player)
                {
                    player.SoundMaterial = this.ImpactSoundMaterial;
                }

                SL_EffectTransform.ApplyTransformList(newProjectile.transform, ProjectileEffects, EffectBehaviour);
            }
        }
Esempio n. 10
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();
        }
        public override void ApplyToComponent <T>(T component)
        {
            base.ApplyToComponent(component);

            var comp = component as ShootBlast;

            if (GetBlastPrefab(this.BaseBlast) is GameObject baseBlast)
            {
                var copy = GameObject.Instantiate(baseBlast);
                GameObject.DontDestroyOnLoad(copy);
                copy.SetActive(false);

                var newBlast = copy.GetComponent <Blast>();
                comp.BaseBlast = newBlast;

                comp.BlastLifespan        = this.BlastLifespan;
                comp.IgnoreStop           = this.IgnoreStop;
                comp.InstanstiatedAmount  = this.InstantiatedAmount;
                comp.LocalCastPositionAdd = this.LocalPositionAdd;
                comp.NoAim = this.NoAim;
                comp.NoTargetForwardMultiplier      = this.NoTargetForwardMultiplier;
                comp.ParentToShootTransform         = this.ParentToShootTransform;
                comp.UseTargetCharacterPositionType = this.UseTargetCharacterPositionType;

                newBlast.AffectHitTargetCenter = this.AffectHitTargetCenter;
                newBlast.DontPlayHitSound      = this.DontPlayHitSound;
                newBlast.FXIsWorld             = this.FXIsWorld;
                newBlast.HitOnShoot            = this.HitOnShoot;
                newBlast.IgnoreShooter         = this.IgnoreShooter;
                newBlast.Interruptible         = this.Interruptible;
                newBlast.MaxHitTargetCount     = this.MaxHitTargetCount;
                newBlast.Radius           = this.Radius;
                newBlast.RefreshTime      = this.RefreshTime;
                newBlast.DontPlayHitSound = this.DontPlayHitSound;
                newBlast.PlayFXOnRefresh  = this.PlayFXOnRefresh;
                newBlast.DelayFirstShoot  = this.DelayFirstShoot;

                newBlast.ImpactSoundMaterial = this.ImpactSoundMaterial;
                if (newBlast.GetComponentInChildren <ImpactSoundPlayer>() is ImpactSoundPlayer player)
                {
                    player.SoundMaterial = this.ImpactSoundMaterial;
                }

                SL_EffectTransform.ApplyTransformList(newBlast.transform, BlastEffects, EffectBehaviour);

                if (newBlast is BlastDelayedHits delayedBlast)
                {
                    var conditionChilds = new List <Transform>();
                    foreach (Transform child in delayedBlast.transform)
                    {
                        if (child.GetComponent <EffectCondition>())
                        {
                            conditionChilds.Add(child);
                        }
                    }

                    var list = new List <BlastDelayedHits.SplitCondition>();
                    foreach (var child in conditionChilds)
                    {
                        var split = new BlastDelayedHits.SplitCondition
                        {
                            ConditionHolder = child
                        };
                        split.Init();
                        list.Add(split);
                    }
                    delayedBlast.EffectsPerCondition = list.ToArray();

                    if (delayedBlast.transform.Find("RevealedSoul") is Transform soulTransform)
                    {
                        var soulFX = new BlastDelayedHits.SplitCondition
                        {
                            ConditionHolder = soulTransform,
                        };
                        soulFX.Init();
                        delayedBlast.RevealSoulEffects = soulFX;
                    }
                }
            }
        }