Example #1
0
        private void OnLateApply(object[] obj)
        {
            var preset = obj[0] as ImbueEffectPreset;

            SL_EffectTransform.ApplyTransformList(preset.transform, Effects, EffectBehaviour);
        }
        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");
        }
Example #3
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);
            }
        }
        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);
            }
        }
        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;
                    }
                }
            }
        }