Esempio n. 1
0
        public override void SerializeEffect <T>(T effect, DM_Effect holder)
        {
            base.SerializeEffect(effect, holder);

            var template = holder as DM_ShootBlast;
            var comp     = effect as ShootBlast;

            if (comp.BaseBlast is Blast blast)
            {
                template.BaseBlast             = blast.name;
                template.AffectHitTargetCenter = blast.AffectHitTargetCenter;
                template.HitOnShoot            = blast.HitOnShoot;
                template.IgnoreShooter         = blast.IgnoreShooter;
                template.Interruptible         = blast.Interruptible;
                template.MaxHitTargetCount     = blast.MaxHitTargetCount;
                template.Radius      = blast.Radius;
                template.RefreshTime = blast.RefreshTime;

                template.BlastLifespan      = comp.BlastLifespan;
                template.InstantiatedAmount = comp.InstanstiatedAmount;

                foreach (Transform child in blast.transform)
                {
                    var effectsChild = DM_EffectTransform.ParseTransform(child);

                    if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0 || effectsChild.EffectConditions.Count > 0)
                    {
                        template.BlastEffects.Add(effectsChild);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void SerializeEffect <T>(T effect, DM_Effect holder)
        {
            base.SerializeEffect(effect, holder);

            var template = holder as DM_ShootProjectile;
            var comp     = effect as ShootProjectile;

            if (comp.BaseProjectile is Projectile projectile)
            {
                template.BaseProjectile = projectile.name;

                template.AutoTarget               = comp.AutoTarget;
                template.AutoTargetMaxAngle       = comp.AutoTargetMaxAngle;
                template.AutoTargetRange          = comp.AutoTargetRange;
                template.IgnoreShooterCollision   = comp.IgnoreShooterCollision;
                template.TargetCountPerProjectile = comp.TargetCountPerProjectile;
                template.TargetingMode            = comp.TargetingMode;
                template.TargetRange              = comp.TargetRange;
                template.InstantiatedAmount       = comp.IntanstiatedAmount;

                template.DisableOnHit = projectile.DisableOnHit;
                template.EffectsOnlyIfHitCharacter = projectile.EffectsOnlyIfHitCharacter;
                template.EndMode       = projectile.EndMode;
                template.LateShootTime = projectile.LateShootTime;
                template.Lifespan      = projectile.Lifespan;
                template.Unblockable   = projectile.Unblockable;

                if (comp.ProjectileShots != null)
                {
                    template.ProjectileShots = comp.ProjectileShots.Length;
                }

                foreach (Transform child in projectile.transform)
                {
                    var effectsChild = DM_EffectTransform.ParseTransform(child);

                    if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0 || effectsChild.EffectConditions.Count > 0)
                    {
                        template.ProjectileEffects.Add(effectsChild);
                    }
                }
            }
        }
        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;
        }
Esempio n. 4
0
        public static DM_ImbueEffect ParseImbueEffect(ImbueEffectPreset imbue)
        {
            var template = new DM_ImbueEffect
            {
                StatusID    = imbue.PresetID,
                Name        = imbue.Name,
                Description = imbue.Description
            };

            template.Effects = new List <DM_EffectTransform>();
            foreach (Transform child in imbue.transform)
            {
                var effectsChild = DM_EffectTransform.ParseTransform(child);

                if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0) // || effectsChild.EffectConditions.Count > 0)
                {
                    template.Effects.Add(effectsChild);
                }
            }

            return(template);
        }
Esempio n. 5
0
        public virtual void SerializeItem(Item item, DM_Item holder)
        {
            holder.gameObjectName = item.gameObject.name;

            holder.ItemID                 = item.ItemID;
            holder.Name                   = item.Name;
            holder.Description            = item.Description;
            holder.LegacyItemID           = item.LegacyItemID;
            holder.CastLocomotionEnabled  = item.CastLocomotionEnabled;
            holder.CastModifier           = item.CastModifier;
            holder.CastSheatheRequired    = item.CastSheathRequired;
            holder.GroupItemInDisplay     = item.GroupItemInDisplay;
            holder.HasPhysicsWhenWorld    = item.HasPhysicsWhenWorld;
            holder.IsPickable             = item.IsPickable;
            holder.IsUsable               = item.IsUsable;
            holder.QtyRemovedOnUse        = item.QtyRemovedOnUse;
            holder.MobileCastMovementMult = item.MobileCastMovementMult;
            holder.RepairedInRest         = item.RepairedInRest;
            holder.BehaviorOnNoDurability = item.BehaviorOnNoDurability;

            holder.OverrideSellModifier = (float)At.GetField(item, "m_overrideSellModifier");

            if (item.GetComponent <Perishable>() is Perishable perish)
            {
                float perishRate     = perish.DepletionRate * 0.03333333f;
                float perishModifier = 1 / perishRate;

                var      remainingTicks = item.MaxDurability * perishModifier; // each tick is 2 in-game minutes (~5 seconds irl)
                var      minutes        = remainingTicks * 2;
                TimeSpan t = TimeSpan.FromMinutes(minutes);

                holder.PerishTime = $"{t.Days} Days, {t.Hours} Hours, {t.Minutes} Minutes, {t.Seconds} Seconds";
            }

            holder.CastType = (Character.SpellCastType)At.GetField(item, "m_activateEffectAnimType");

            if (item.GetComponent <ItemStats>() is ItemStats stats)
            {
                holder.StatsHolder = DM_ItemStats.ParseItemStats(stats);
            }

            if (item.Tags != null)
            {
                foreach (Tag tag in item.Tags)
                {
                    holder.Tags.Add(tag.TagName);

                    ListManager.AddTagSource(tag, Serializer.SafeName(item.Name));
                }
            }

            foreach (Transform child in item.transform)
            {
                var effectsChild = DM_EffectTransform.ParseTransform(child);

                if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0 || effectsChild.EffectConditions.Count > 0)
                {
                    holder.EffectTransforms.Add(effectsChild);
                }
            }
        }
        public virtual void SerializeStatusEffect(StatusEffect status, EffectPreset preset)
        {
            PresetID               = preset?.PresetID ?? -1;
            Identifier             = status.IdentifierName?.Trim();
            IgnoreBuildupIfApplied = status.IgnoreBuildUpIfApplied;
            BuildupRecoverySpeed   = status.BuildUpRecoverSpeed;
            DisplayedInHUD         = status.DisplayInHud;
            IsHidden               = status.IsHidden;
            Lifespan               = status.StatusData.LifeSpan;
            RefreshRate            = status.RefreshRate;
            LengthType             = status.LengthType.ToString();

            ComplicationStatusIdentifier = status.ComplicationStatus?.IdentifierName;
            RequiredStatusIdentifier     = status.RequiredStatus?.IdentifierName;
            RemoveRequiredStatus         = status.RemoveRequiredStatus;
            NormalizeDamageDisplay       = status.NormalizeDamageDisplay;
            IgnoreBarrier = status.IgnoreBarrier;

            GetStatusLocalization(status, out Name, out Description);

            Tags = new List <string>();
            status.InitTags();
            var tags = (TagSource)At.GetField(status, "m_tagSource");

            foreach (var tag in tags.Tags)
            {
                Tags.Add(tag.TagName);

                ListManager.AddTagSource(tag, Name);
            }

            // 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);
                }
            }

            Effects = new List <DM_EffectTransform>();

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

                        if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0 || effectsChild.EffectConditions.Count > 0)
                        {
                            Effects.Add(effectsChild);
                        }
                    }
                }
            }
        }