// Token: 0x06000018 RID: 24 RVA: 0x000025D0 File Offset: 0x000007D0
        public static StatusEffect MakeStatusEffectPrefab(string effectName, string familyName, string description, float lifespan, float refreshRate, StatusEffectFamily.StackBehaviors stackBehavior, string targetStatusName, bool isMalusEffect, string tagID = null, UID?uid = null, string modGUID = null)
        {
            Dictionary <string, StatusEffect> dictionary = At.GetValue(typeof(ResourcesPrefabManager), null, "STATUSEFFECT_PREFABS") as Dictionary <string, StatusEffect>;
            StatusEffectFamily statusEffectFamily        = TinyEffectManager.MakeStatusEffectFamiliy(familyName, stackBehavior, -1, StatusEffectFamily.LengthTypes.Short, null, null);
            GameObject         gameObject   = TinyEffectManager.InstantiateClone(dictionary[targetStatusName].gameObject, effectName, false, true);
            StatusEffect       statusEffect = dictionary[effectName] = (gameObject.GetComponent <StatusEffect>() ?? gameObject.AddComponent <StatusEffect>());

            At.SetValue <string>(effectName, typeof(StatusEffect), statusEffect, "m_identifierName");
            At.SetValue <StatusEffectFamily>(statusEffectFamily, typeof(StatusEffect), statusEffect, "m_bindFamily");
            At.SetValue <string>(effectName, typeof(StatusEffect), statusEffect, "m_nameLocKey");
            At.SetValue <string>(description, typeof(StatusEffect), statusEffect, "m_descriptionLocKey");
            statusEffect.RefreshRate   = refreshRate;
            statusEffect.IsMalusEffect = isMalusEffect;
            At.SetValue <StatusEffect.EffectSignatureModes>(StatusEffect.EffectSignatureModes.Reference, typeof(StatusEffect), statusEffect, "m_effectSignatureMode");
            At.SetValue <StatusEffect.FamilyModes>(StatusEffect.FamilyModes.Bind, typeof(StatusEffect), statusEffect, "m_familyMode");
            TagSourceSelector value = (tagID != null) ? new TagSourceSelector(TagSourceManager.Instance.GetTag(tagID)) : new TagSourceSelector();

            At.SetValue <TagSourceSelector>(value, typeof(StatusEffect), statusEffect, "m_effectType");
            StatusData statusData = statusEffect.StatusData = new StatusData(statusEffect.StatusData);

            statusData.LifeSpan = lifespan;
            List <StatusData> list = At.GetValue(typeof(StatusEffect), statusEffect, "m_statusStack") as List <StatusData>;

            list[0] = statusData;
            UnityEngine.Object.Destroy(gameObject.GetComponentInChildren <EffectSignature>().gameObject);
            EffectSignature effectSignature = statusEffectFamily.EffectSignature = (statusData.EffectSignature = TinyEffectManager.MakeFreshObject("Signature", true, true, null).AddComponent <EffectSignature>());

            effectSignature.name         = "Signature";
            effectSignature.SignatureUID = (uid ?? ((modGUID != null) ? TinyUIDManager.MakeUID(effectName, modGUID, "Status Effect") : UID.Generate()));
            StatusEffectFamilySelector statusEffectFamilySelector = new StatusEffectFamilySelector();

            statusEffectFamilySelector.Set(statusEffectFamily);
            At.SetValue <StatusEffectFamilySelector>(statusEffectFamilySelector, typeof(StatusEffect), statusEffect, "m_stackingFamily");
            return(statusEffect);
        }
Example #2
0
 public bool HasFamily(StatusEffectFamily family)
 {
     foreach (StatusEffect effect in Effects)
         if (effect.family == family)
             return true;
     return false;
 }
Example #3
0
 static public Disease GetDiseaseOfFamily(this Character character, StatusEffectFamily statusEffectFamily)
 {
     foreach (var statusEffect in character.StatusEffectMngr.Statuses)
     {
         if (statusEffect.TryAs(out Disease disease) && statusEffect.EffectFamily.UID == statusEffectFamily.UID)
         {
             return(disease);
         }
     }
     return(null);
 }
 public bool HasFamily(StatusEffectFamily family)
 {
     foreach (StatusEffect effect in Effects)
     {
         if (effect.family == family)
         {
             return(true);
         }
     }
     return(false);
 }
 internal static SL_StatusEffectFamily ParseEffectFamily(StatusEffectFamily family)
 {
     return(new SL_StatusEffectFamily
     {
         UID = family.UID,
         Name = family.Name,
         LengthType = family.LengthType,
         MaxStackCount = family.MaxStackCount,
         StackBehaviour = family.StackBehavior
     });
 }
Example #6
0
 public StatusEffectState(uint uid, int affected, bool doesExpire, DateTime expiresAt, StatusEffectFamily family,
                          bool isDebuff, bool isUnique, string typeName)
 {
     Uid        = uid;
     Affected   = affected;
     DoesExpire = doesExpire;
     ExpiresAt  = expiresAt;
     Family     = family;
     IsDebuff   = isDebuff;
     IsUnique   = isUnique;
     TypeName   = typeName;
 }
Example #7
0
 public StatusEffectState(uint uid, int affected, bool doesExpire, DateTime expiresAt, StatusEffectFamily family,
     bool isDebuff, bool isUnique, string typeName)
 {
     Uid = uid;
     Affected = affected;
     DoesExpire = doesExpire;
     ExpiresAt = expiresAt;
     Family = family;
     IsDebuff = isDebuff;
     IsUnique = isUnique;
     TypeName = typeName;
 }
        // Token: 0x06000019 RID: 25 RVA: 0x00002810 File Offset: 0x00000A10
        public static StatusEffectFamily MakeStatusEffectFamiliy(string familyName, StatusEffectFamily.StackBehaviors stackBehavior, int maxStackCount, StatusEffectFamily.LengthTypes lengthType, UID?uid = null, string modGUID = null)
        {
            StatusEffectFamily statusEffectFamily = new StatusEffectFamily();

            uid = new UID?(uid ?? ((modGUID != null) ? TinyUIDManager.MakeUID(familyName, modGUID, "Status Effect Family") : UID.Generate()));
            At.SetValue <UID>(uid.Value, typeof(StatusEffectFamily), statusEffectFamily, "m_uid");
            statusEffectFamily.Name          = familyName;
            statusEffectFamily.StackBehavior = stackBehavior;
            statusEffectFamily.MaxStackCount = maxStackCount;
            statusEffectFamily.LengthType    = lengthType;
            return(statusEffectFamily);
        }
        // Normal template apply method
        internal void Internal_ApplyTemplate()
        {
            if (!StatusEffectFamilyLibrary.Instance)
            {
                return;
            }

            var library = StatusEffectFamilyLibrary.Instance;

            StatusEffectFamily family;

            if (library.StatusEffectFamilies.Where(it => (string)it.UID == this.UID).Any())
            {
                family = library.StatusEffectFamilies.First(it => (string)it.UID == this.UID);
            }
            else
            {
                family = new StatusEffectFamily();
                library.StatusEffectFamilies.Add(family);
            }

            if (family == null)
            {
                SL.LogWarning("Applying SL_StatusEffectFamily template, null error");
                return;
            }

            if (this.UID != null)
            {
                At.SetField(family, "m_uid", new UID(this.UID));
            }

            if (this.Name != null)
            {
                family.Name = this.Name;
            }

            if (this.StackBehaviour != null)
            {
                family.StackBehavior = (StatusEffectFamily.StackBehaviors) this.StackBehaviour;
            }

            if (this.MaxStackCount != null)
            {
                family.MaxStackCount = (int)this.MaxStackCount;
            }

            if (this.LengthType != null)
            {
                family.LengthType = (StatusEffectFamily.LengthTypes) this.LengthType;
            }
        }
Example #10
0
 private void AddEffect(string typeName, uint uid, bool doesExpire, DateTime expiresAt,
                        StatusEffectFamily _family)
     //Don't manually use this clientside. The server adds and removes what is needed.
 {
     Type t = Type.GetType("CGO." + typeName);
     if (t == null || !t.IsSubclassOf(typeof (StatusEffect))) return;
     var newEffect = (StatusEffect) Activator.CreateInstance(t, new object[] {uid, Owner});
     newEffect.doesExpire = doesExpire;
     newEffect.expiresAt = expiresAt;
     newEffect.family = _family;
     Effects.Add(newEffect);
     newEffect.OnAdd();
     if (Changed != null) Changed(this);
 }
        // used by SL_StatusEffect Bind Families
        public StatusEffectFamily CreateAsBindFamily()
        {
            var ret = new StatusEffectFamily
            {
                Name          = this.Name,
                LengthType    = (StatusEffectFamily.LengthTypes) this.LengthType,
                MaxStackCount = (int)this.MaxStackCount,
                StackBehavior = (StatusEffectFamily.StackBehaviors) this.StackBehaviour
            };

            At.SetField(ret, "m_uid", new UID(this.UID));

            return(ret);
        }
        private void AddEffect(string typeName, uint uid, bool doesExpire, DateTime expiresAt,
                               StatusEffectFamily _family)
        //Don't manually use this clientside. The server adds and removes what is needed.
        {
            Type t = Type.GetType("CGO." + typeName);

            if (t == null || !t.IsSubclassOf(typeof(StatusEffect)))
            {
                return;
            }
            var newEffect = (StatusEffect)Activator.CreateInstance(t, new object[] { uid, Owner });

            newEffect.doesExpire = doesExpire;
            newEffect.expiresAt  = expiresAt;
            newEffect.family     = _family;
            Effects.Add(newEffect);
            newEffect.OnAdd();
            if (Changed != null)
            {
                Changed(this);
            }
        }
        internal virtual void Internal_ApplyTemplate(StatusEffect status)
        {
            SL.Log("Applying Status Effect template: " + Name ?? status.name);

            SLPackManager.AddLateApplyListener(OnLateApply, status);

            CustomStatusEffects.SetStatusLocalization(status, Name, Description);

            if (status.StatusData == null)
            {
                status.StatusData = new StatusData();
            }

            if (Lifespan != null)
            {
                status.StatusData.LifeSpan = (float)Lifespan;
            }

            if (RefreshRate != null)
            {
                status.RefreshRate = (float)RefreshRate;
            }

            if (this.Priority != null)
            {
                At.SetField(status, "m_priority", (int)this.Priority);
            }

            if (this.Purgeable != null)
            {
                At.SetField(status, "m_purgeable", (bool)this.Purgeable);
            }

            if (this.DelayedDestroyTime != null)
            {
                status.DelayedDestroyTime = (int)this.DelayedDestroyTime;
            }

            if (BuildupRecoverySpeed != null)
            {
                status.BuildUpRecoverSpeed = (float)BuildupRecoverySpeed;
            }

            if (IgnoreBuildupIfApplied != null)
            {
                status.IgnoreBuildUpIfApplied = (bool)IgnoreBuildupIfApplied;
            }

            if (DisplayedInHUD != null)
            {
                status.DisplayInHud = (bool)DisplayedInHUD;
            }

            if (IsHidden != null)
            {
                status.IsHidden = (bool)IsHidden;
            }

            if (IsMalusEffect != null)
            {
                status.IsMalusEffect = (bool)this.IsMalusEffect;
            }

            if (this.ActionOnHit != null)
            {
                At.SetField(status, "m_actionOnHit", (StatusEffect.ActionsOnHit) this.ActionOnHit);
            }

            if (this.RemoveRequiredStatus != null)
            {
                status.RemoveRequiredStatus = (bool)this.RemoveRequiredStatus;
            }

            if (this.NormalizeDamageDisplay != null)
            {
                status.NormalizeDamageDisplay = (bool)this.NormalizeDamageDisplay;
            }

            if (this.IgnoreBarrier != null)
            {
                status.IgnoreBarrier = (bool)this.IgnoreBarrier;
            }

            if (this.StatusIdentifier != this.TargetStatusIdentifier)
            {
                At.SetField(status, "m_effectType", new TagSourceSelector(Tag.None));
            }

            if (Tags != null)
            {
                var tagSource = CustomTags.SetTagSource(status.gameObject, Tags, true);
                At.SetField(status, "m_tagSource", tagSource);
            }
            else if (!status.GetComponent <TagSource>())
            {
                var tagSource = status.gameObject.AddComponent <TagSource>();
                At.SetField(status, "m_tagSource", tagSource);
            }

            if (this.PlayFXOnActivation != null)
            {
                status.PlayFXOnActivation = (bool)this.PlayFXOnActivation;
            }

            if (this.VFXInstantiationType != null)
            {
                status.FxInstantiation = (StatusEffect.FXInstantiationTypes) this.VFXInstantiationType;
            }

            if (this.VFXPrefab != null)
            {
                if (this.VFXPrefab == SL_PlayVFX.VFXPrefabs.NONE)
                {
                    status.FXPrefab = null;
                }
                else
                {
                    var clone = GameObject.Instantiate(SL_PlayVFX.GetVfxSystem((SL_PlayVFX.VFXPrefabs) this.VFXPrefab));
                    GameObject.DontDestroyOnLoad(clone);
                    status.FXPrefab = clone.transform;
                }
            }

            if (this.FXOffset != null)
            {
                status.FxOffset = (Vector3)this.FXOffset;
            }

            if (this.PlaySpecialFXOnStop != null)
            {
                status.PlaySpecialFXOnStop = (bool)this.PlaySpecialFXOnStop;
            }

            // setup family
            if (this.FamilyMode == null && this.StatusIdentifier != this.TargetStatusIdentifier)
            {
                // Creating a new status, but no unique bind family was declared. Create one.
                var family = new StatusEffectFamily
                {
                    Name          = this.StatusIdentifier + "_FAMILY",
                    LengthType    = StatusEffectFamily.LengthTypes.Short,
                    MaxStackCount = 1,
                    StackBehavior = StatusEffectFamily.StackBehaviors.IndependantUnique
                };

                At.SetField(status, "m_bindFamily", family);
                At.SetField(status, "m_familyMode", StatusEffect.FamilyModes.Bind);
            }

            if (this.FamilyMode == StatusEffect.FamilyModes.Bind)
            {
                At.SetField(status, "m_familyMode", StatusEffect.FamilyModes.Bind);

                if (this.BindFamily != null)
                {
                    At.SetField(status, "m_bindFamily", this.BindFamily.CreateAsBindFamily());
                }
            }
            else if (this.FamilyMode == StatusEffect.FamilyModes.Reference)
            {
                At.SetField(status, "m_familyMode", StatusEffect.FamilyModes.Reference);

                if (this.ReferenceFamilyUID != null)
                {
                    At.SetField(status, "m_stackingFamily", new StatusEffectFamilySelector()
                    {
                        SelectorValue = this.ReferenceFamilyUID
                    });
                }
            }

            // check for custom icon
            if (!string.IsNullOrEmpty(SerializedSLPackName) &&
                !string.IsNullOrEmpty(SerializedSubfolderName) &&
                SL.GetSLPack(SerializedSLPackName) is SLPack pack)
            {
                var dir = $@"{pack.GetPathForCategory<StatusCategory>()}\{SerializedSubfolderName}";

                if (pack.FileExists(dir, "icon.png"))
                {
                    var tex    = pack.LoadTexture2D(dir, "icon.png");
                    var sprite = CustomTextures.CreateSprite(tex, CustomTextures.SpriteBorderTypes.NONE);

                    status.OverrideIcon = sprite;
                    At.SetField(status, "m_defaultStatusIcon", new StatusTypeIcon(Tag.None)
                    {
                        Icon = sprite
                    });
                }
            }
        }