コード例 #1
0
        internal ImbueEffectPreset Internal_ApplyTemplate()
        {
            if (this.NewStatusID == -1)
            {
                this.NewStatusID = this.TargetStatusID;
            }

            var preset = CustomStatusEffects.CreateCustomImbue(this);

            SLPackManager.AddLateApplyListener(OnLateApply, preset);

            CustomStatusEffects.SetImbueLocalization(preset, Name, Description);

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

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

                    preset.ImbueStatusIcon = sprite;
                }
            }

            return(preset);
        }
コード例 #2
0
        public override void ApplyToItem(Item item)
        {
            base.ApplyToItem(item);

            var comp = item as LevelAttackSkill;

            if (this.WatchedStatusIdentifier != null)
            {
                var status = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(this.WatchedStatusIdentifier);
                if (status)
                {
                    comp.WatchedStatus = status;
                }
                else
                {
                    SL.LogWarning("SL_LevelAttackSkill: could not find a status by the name of '" + this.WatchedStatusIdentifier + "'");
                }
            }

            var stages = At.GetField(comp, "m_skillStages") as LevelAttackSkill.SkillStage[];

            int newMax = this.Stages?.Length ?? stages.Length;

            if (this.Stages != null)
            {
                if (stages.Length != newMax)
                {
                    Array.Resize(ref stages, newMax);
                }

                for (int i = 0; i < stages.Length; i++)
                {
                    var stage = stages[i];
                    stage.StageDefaultName = Stages[i].Name;
                    stage.StageLocKey      = null;
                    stage.StageAnim        = Stages[i].Animation;
                    if (!stage.StageIcon)
                    {
                        stage.StageIcon = comp.ItemIcon;
                    }
                }
            }

            // check for custom level icons
            if (!string.IsNullOrEmpty(SLPackName) && !string.IsNullOrEmpty(SubfolderName) && SL.GetSLPack(SLPackName) is SLPack pack)
            {
                var dir = $@"{pack.GetPathForCategory<ItemCategory>()}\{SubfolderName}\Textures";

                for (int i = 0; i < newMax; i++)
                {
                    //var path = dir + $@"\icon{i + 2}.png";

                    if (pack.FileExists(dir, $@"icon{i + 2}.png"))
                    {
                        var tex    = pack.LoadTexture2D(dir, $@"icon{i + 2}.png");
                        var sprite = CustomTextures.CreateSprite(tex, CustomTextures.SpriteBorderTypes.NONE);

                        stages[i].StageIcon = sprite;
                    }
                }
            }

            At.SetField(comp, "m_skillStages", stages);
        }
コード例 #3
0
        private SkillSchool CreateSchool(bool applyRowsInstantly = false)
        {
            var template = (Resources.Load("_characters/CharacterProgression") as GameObject).transform.Find("Test");

            // instantiate a copy of the dev template
            m_object = UnityEngine.Object.Instantiate(template).gameObject;

            var school = m_object.GetComponent <SkillSchool>();

            // set the name to the gameobject and the skill tree name/uid
            m_object.name = this.Name;
            At.SetField(school, "m_defaultName", this.Name);
            At.SetField(school, "m_nameLocKey", "");

            if (string.IsNullOrEmpty(this.UID))
            {
                this.UID = this.Name;
            }
            At.SetField(school, "m_uid", new UID(this.UID));

            // TODO set currency and icon

            // fix the breakthrough int
            At.SetField(school, "m_breakthroughSkillIndex", -1);

            // set the sprite
            if (this.Sigil)
            {
                school.SchoolSigil = this.Sigil;
            }
            else if (!string.IsNullOrEmpty(this.SigilIconName) && !string.IsNullOrEmpty(this.SLPackName))
            {
                var pack = SL.GetSLPack(this.SLPackName);
                if (pack != null)
                {
                    if (pack.Texture2D.TryGetValue(this.SigilIconName, out Texture2D sigilTex))
                    {
                        var sprite = CustomTextures.CreateSprite(sigilTex);
                        school.SchoolSigil = sprite;
                    }
                    else
                    {
                        SL.LogWarning("Applying an SL_SkillTree, could not find any loaded Texture by the name of '" + this.SigilIconName + "'");
                    }
                }
                else
                {
                    SL.LogWarning("Applying an SL_SkillSchool, could not find any loaded SLPack with the name '" + this.SLPackName + "'");
                }
            }

            // add it to the game's skill tree holder.
            var list = (At.GetField(SkillTreeHolder.Instance, "m_skillTrees") as SkillSchool[]).ToList();

            list.Add(school);
            At.SetField(SkillTreeHolder.Instance, "m_skillTrees", list.ToArray());

            if (applyRowsInstantly)
            {
                ApplyRows();
            }

            return(school);
        }
コード例 #4
0
        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
                    });
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Apply the SL_ItemVisual prefab to the Item.
        /// </summary>
        /// <param name="item">The Item to set to.</param>
        public void ApplyToItem(Item item)
        {
            if (CustomItemVisuals.GetOrigItemVisuals(item, Type) is Transform origPrefab)
            {
                bool setPrefab = false;

                // Check for AssetBundle Prefabs first
                if (!string.IsNullOrEmpty(Prefab_SLPack) && SL.GetSLPack(Prefab_SLPack) is SLPack pack)
                {
                    if (pack.AssetBundles.ContainsKey(Prefab_AssetBundle))
                    {
                        var newVisuals = pack.AssetBundles[Prefab_AssetBundle].LoadAsset <GameObject>(Prefab_Name);

                        origPrefab = SetCustomVisualPrefab(item, this.Type, newVisuals.transform, origPrefab).transform;

                        SL.Log("Loaded custom visual prefab: " + newVisuals.name);
                        setPrefab = true;
                    }
                }
                // Not using AssetBundle, check for ResourcesPrefabPath.
                else if (!string.IsNullOrEmpty(ResourcesPrefabPath))
                {
                    // Only set this if the user has defined a different value than what exists on the item.
                    bool set = false;
                    switch (Type)
                    {
                    case VisualPrefabType.VisualPrefab:
                        set = item.VisualPrefabPath == ResourcesPrefabPath; break;

                    case VisualPrefabType.SpecialVisualPrefabDefault:
                        set = item.SpecialVisualPrefabDefaultPath == ResourcesPrefabPath; break;

                    case VisualPrefabType.SpecialVisualPrefabFemale:
                        set = item.SpecialVisualPrefabFemalePath == ResourcesPrefabPath; break;
                    }

                    if (!set)
                    {
                        // Get the original visual prefab to clone from
                        var orig = ResourcesPrefabManager.Instance.GetItemVisualPrefab(ResourcesPrefabPath);

                        if (!orig)
                        {
                            SL.Log("SL_ItemVisual: Could not find an Item Visual at the Resources path: " + ResourcesPrefabPath);
                        }
                        else
                        {
                            CustomItemVisuals.CloneAndSetVisuals(item, orig.gameObject, Type);

                            switch (Type)
                            {
                            case VisualPrefabType.VisualPrefab:
                                At.SetField(item, "m_visualPrefabPath", ResourcesPrefabPath); break;

                            case VisualPrefabType.SpecialVisualPrefabDefault:
                                At.SetField(item, "m_specialVisualPrefabDefaultPath", ResourcesPrefabPath); break;

                            case VisualPrefabType.SpecialVisualPrefabFemale:
                                At.SetField(item, "m_specialVisualPrefabFemalePath", ResourcesPrefabPath); break;
                            }

                            setPrefab = true;
                        }
                    }
                }

                // If we didn't change the Visual Prefab in any way, clone the original to avoid conflicts.
                if (!setPrefab)
                {
                    origPrefab = CustomItemVisuals.CloneVisualPrefab(item, Type).transform;
                }

                // Get the actual visuals (for weapons and a lot of items, this is not the base prefab).
                Transform actualVisuals = origPrefab.transform;
                if (this.Type == VisualPrefabType.VisualPrefab)
                {
                    if (origPrefab.childCount > 0)
                    {
                        foreach (Transform child in origPrefab)
                        {
                            if (child.gameObject.activeSelf && child.GetComponent <BoxCollider>() && child.GetComponent <MeshRenderer>())
                            {
                                actualVisuals = child;
                                break;
                            }
                        }
                    }
                }

                if (actualVisuals)
                {
                    var visualComp = origPrefab.GetComponent <ItemVisual>();

                    ApplyItemVisualSettings(visualComp, actualVisuals);
                }
            }
        }
コード例 #6
0
        private void OnLateApply(object[] obj)
        {
            var comp = obj[0] as LevelStatusEffect;

            int origMax = (int)At.GetField(comp, "m_maxLevel");
            int newMax  = MaxLevel ?? origMax;

            At.SetField(comp, "m_maxLevel", newMax);

            Sprite[] origIcons = new Sprite[origMax - 1];

            // prepare the level data array and get current icons
            if (comp.StatusLevelData == null)
            {
                comp.StatusLevelData = new LevelStatusEffect.LevelData[newMax - 1];
            }
            else if (comp.StatusLevelData.Length > 0)
            {
                comp.StatusLevelData = comp.StatusLevelData.OrderBy(it => it.LevelIndex).ToArray();

                for (int i = 0; i < origMax - 1; i++)
                {
                    origIcons[i] = comp.StatusLevelData[i].Icon;
                }
            }

            if (origMax != newMax)
            {
                Array.Resize(ref comp.StatusLevelData, newMax - 1);
            }

            // set the level datas
            for (int i = 0; i < newMax - 1; i++)
            {
                if (comp.StatusLevelData[i] == null)
                {
                    comp.StatusLevelData[i] = new LevelStatusEffect.LevelData();
                }

                var level = comp.StatusLevelData[i];
                level.LevelIndex = i;
                level.StatusData = new StatusData(comp.StatusData)
                {
                    EffectsData = GenerateEffectsData(comp.StatusEffectSignature.Effects, i + 2)
                };
            }

            // check for custom level icons
            if (!string.IsNullOrEmpty(SerializedSLPackName) &&
                !string.IsNullOrEmpty(SerializedSubfolderName) &&
                SL.GetSLPack(SerializedSLPackName) is SLPack pack)
            {
                var dir = $@"{pack.GetPathForCategory<StatusCategory>()}\{SerializedSubfolderName}";
                for (int i = 0; i < newMax - 1; i++)
                {
                    if (pack.FileExists(dir, $@"icon{i + 2}.png"))
                    {
                        var tex    = pack.LoadTexture2D(dir, $@"icon{i + 2}.png");
                        var sprite = CustomTextures.CreateSprite(tex, CustomTextures.SpriteBorderTypes.NONE);

                        //list.Add(sprite);
                        comp.StatusLevelData[i].Icon = sprite;
                    }
                }
            }

            // ensure all levels at least have some icon
            for (int i = 0; i < newMax - 1; i++)
            {
                if (!comp.StatusLevelData[i].Icon)
                {
                    comp.StatusLevelData[i].Icon = comp.StatusIcon;
                }
            }
        }