Esempio n. 1
0
        public static void SetupSummon()
        {
            var summon = ResourcesPrefabManager.Instance.GetItemPrefab(8890103) as Skill;

            // destroy the existing skills, but keep the rest (VFX / Sound).
            GameObject.DestroyImmediate(summon.transform.Find("Lightning").gameObject);
            GameObject.DestroyImmediate(summon.transform.Find("SummonSoul").gameObject);

            var effects = new GameObject("Effects");

            effects.transform.parent = summon.transform;
            effects.AddComponent <SummonSkeleton>();

            // setup custom blade visuals
            try
            {
                var blade        = ResourcesPrefabManager.Instance.GetItemPrefab(2598500) as Weapon;
                var bladeVisuals = CustomItemVisuals.GetOrAddVisualLink(blade).ItemVisuals;
                if (bladeVisuals.transform.Find("Weapon3DVisual").GetComponent <MeshRenderer>() is MeshRenderer mesh)
                {
                    mesh.material.color = new Color(-0.5f, 1.5f, -0.5f);
                }
            }
            catch { }

            //// make sure the config is applied from the save
            //SummonManager.Skeleton.Health = NecromancerMod.settings.Summon_MaxHealth;
            //SummonManager.Skeleton.HealthRegen = NecromancerMod.settings.Summon_HealthLoss;
            //SummonManager.Ghost.Health = NecromancerMod.settings.StrongSummon_MaxHealth;
            //SummonManager.Ghost.HealthRegen = NecromancerMod.settings.StrongSummon_HealthLoss;
        }
        //public static float LifeSpan = 40f;

        #region Plague Aura Skill Setup

        // this also sets up the PlagueTendrils effect.

        public static void SetupPlagueAura()
        {
            // 8890107
            var plagueSkill = ResourcesPrefabManager.Instance.GetItemPrefab(8890107) as Skill;

            // destroy wind altar condition
            Destroy(plagueSkill.transform.Find("AdditionalActivationConditions").gameObject);

            // setup skill
            plagueSkill.CastSheathRequired = -1;
            plagueSkill.RequiredItems      = new Skill.ItemRequired[0];

            // get the Summon component, change to custom activation fx
            var effects        = plagueSkill.transform.Find("Effects").gameObject;
            var origSummon     = effects.GetComponent <Summon>();
            var plagueAuraComp = effects.AddComponent <PlagueAura>();

            At.InheritBaseValues(plagueAuraComp, origSummon);
            Destroy(origSummon);

            // ======== set summoned prefab to our custom activated item (loaded with sideloader) ========
            var plagueStone = ResourcesPrefabManager.Instance.GetItemPrefab(8999050);

            plagueAuraComp.SummonedPrefab = plagueStone.transform;

            var ephemeral = plagueStone.GetComponent <Ephemeral>();

            ephemeral.LifeSpan = NecromancyBase.settings.PlagueAura_SigilLifespan;

            //// setup custom visuals
            //var origVisuals = plagueStone.GetComponent<Item>().VisualPrefab;
            //origVisuals.gameObject.SetActive(false);
            //var newVisuals = Instantiate(origVisuals.gameObject);
            //DontDestroyOnLoad(newVisuals);
            //origVisuals.gameObject.SetActive(true);
            var newVisuals = CustomItemVisuals.GetOrAddVisualLink(plagueStone).ItemVisuals;

            var magiccircle = newVisuals.transform.Find("mdl_fx_magicCircle");

            // destroy rotating bolt fx
            Destroy(magiccircle.transform.Find("FX_Bolt").gameObject);

            // setup the clouds
            if (newVisuals.transform.Find("mdl_itm_firestone") is Transform t)
            {
                t.parent = magiccircle;
                Destroy(t.Find("FX_Bolt").gameObject);

                var ps = t.Find("smoke_desu").GetComponent <ParticleSystem>();
                var m  = ps.main;
                m.startColor = Color.green;

                t.Find("smoke_desu").position += Vector3.down * 3.2f;
            }

            // setup the Plague Tendrils effect (from inside that class)
            PlagueTendrils.SetupPlagueTendrils(effects);
        }
        public static bool Prefix(Item __instance, ref Sprite __result)
        {
            if (CustomItemVisuals.GetItemVisualLink(__instance) is CustomItemVisuals.ItemVisualsLink link &&
                link.ItemIcon)
            {
                __result = link.ItemIcon;
                return(false);
            }

            return(true);
        }
        public static bool Prefix(Item __instance, bool _special, ref Transform __result)
        {
            try
            {
                if (CustomItemVisuals.GetItemVisualLink(__instance) is CustomItemVisuals.ItemVisualsLink link)
                {
                    if (!_special)
                    {
                        if (link.ItemVisuals)
                        {
                            __result = link.ItemVisuals;
                            return(false);
                        }
                    }
                    else
                    {
                        if (__instance.UseSpecialVisualFemale)
                        {
                            if (link.ItemSpecialFemaleVisuals)
                            {
                                __result = link.ItemSpecialFemaleVisuals;
                                return(false);
                            }
                        }
                        else if (link.ItemSpecialVisuals)
                        {
                            __result = link.ItemSpecialVisuals;
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                SL.LogInnerException(e);
                return(true);
            }
        }
Esempio n. 5
0
        public static void OnPacksLoaded()
        {
            // setup custom mana projectile
            var manaArrow = ResourcesPrefabManager.Instance.GetItemPrefab(ManaArrowID) as Ammunition;

            // set empty equipped visuals (hide quiver)
            var vLink = CustomItemVisuals.GetOrAddVisualLink(manaArrow);

            vLink.ItemSpecialVisuals = new GameObject("ManaQuiverDummy").transform;
            GameObject.DontDestroyOnLoad(vLink.ItemSpecialVisuals.gameObject);

            // custom arrow ProjectileItem component (determines the ammunition behaviour as projectile)
            var origProjFX = manaArrow.ProjectileFXPrefab.gameObject;

            origProjFX.SetActive(false);
            manaArrow.ProjectileFXPrefab = GameObject.Instantiate(origProjFX).transform;
            origProjFX.SetActive(true);

            GameObject.DontDestroyOnLoad(manaArrow.ProjectileFXPrefab.gameObject);

            var projItem = manaArrow.ProjectileFXPrefab.GetComponent <ProjectileItem>();

            projItem.CollisionBehavior   = ProjectileItem.CollisionBehaviorTypes.Destroyed;
            projItem.EphemeralProjectile = true;

            projItem.m_itemID = ManaArrowID;
            projItem.m_item   = ResourcesPrefabManager.Instance.GetItemPrefab(ManaArrowID);

            var raycast = projItem.GetComponent <RaycastProjectile>();

            raycast.ProjectileVisualsToDisable = projItem.gameObject;

            raycast.ImpactSoundMaterial = EquipmentSoundMaterials.Goo;

            // yield the OnPacksLoaded call (and wait a second just in case) so we can be sure other mods have loaded.
            ManaBowPlugin.Instance.StartCoroutine(LateFix());
        }
        public static void SetupManaArrow()
        {
            Debug.Log("Setting up mana arrow");

            // setup custom mana projectile
            var manaArrow = ResourcesPrefabManager.Instance.GetItemPrefab(ManaArrowID) as Ammunition;

            // set empty equipped visuals (hide quiver)
            var vLink = CustomItemVisuals.GetOrAddVisualLink(manaArrow);

            vLink.ItemSpecialVisuals = new GameObject("ManaQuiverDummy").transform;
            GameObject.DontDestroyOnLoad(vLink.ItemSpecialVisuals.gameObject);

            // custom arrow ProjectileItem component (determines the ammunition behaviour as projectile)
            var origProjFX = manaArrow.ProjectileFXPrefab.gameObject;

            origProjFX.SetActive(false);
            manaArrow.ProjectileFXPrefab = GameObject.Instantiate(origProjFX).transform;
            origProjFX.SetActive(true);

            GameObject.DontDestroyOnLoad(manaArrow.ProjectileFXPrefab.gameObject);

            var projItem = manaArrow.ProjectileFXPrefab.GetComponent <ProjectileItem>();

            projItem.CollisionBehavior   = ProjectileItem.CollisionBehaviorTypes.Destroyed;
            projItem.EphemeralProjectile = true;

            At.SetField(projItem, "m_itemID", ManaArrowID);
            At.SetField(projItem, "m_item", ResourcesPrefabManager.Instance.GetItemPrefab(ManaArrowID));

            var raycast = projItem.GetComponent <RaycastProjectile>();

            raycast.ProjectileVisualsToDisable = projItem.gameObject;

            raycast.ImpactSoundMaterial = EquipmentSoundMaterials.Goo;
        }
Esempio n. 7
0
        private static Item NewHellstone(int baseItemID, int newItemId, String name, String desc)
        {
            int totalWeight = CurrencyEffects.ALL[newItemId].Sum(x => x.GetWeight());

            desc += "\n";

            CurrencyEffects.ALL[newItemId].ForEach(x =>
            {
                float chance = (float)x.GetWeight() / (float)totalWeight * 100;

                desc += "\n" + chance + "% to: " + x.Get().GetDescription() + "\n";
            });

            desc += "\n Use when your desired gear is in your pouch (and no other gear there).";

            if (HELLSTONE_OF_ARCANA_ID != newItemId) // this hellstone is used on non magical items, unlike others
            {
                desc += "\n Only works on Magical items.";
            }
            else
            {
                desc += "\n Only works on Non Magical items.";
            }

            var template = new SL_Item()
            {
                Name          = name,
                Description   = desc,
                Target_ItemID = baseItemID,
                New_ItemID    = newItemId,
                Tags          = new string[]

                {
                    TagSourceManager.Valuable.TagName
                },
                IsUsable = true
            };

            var item = CustomItems.CreateCustomItem(template);

            var effects = item.transform.Find("Effects");

            if (effects == null)
            {
                // If the item doesn't have "Effects", just add it.
                effects = new GameObject("Effects").transform;
                effects.transform.parent = item.transform;
                // If you didn't use CreateCustomItem, you'd need to call DontDestroyOnLoad(gaberries.gameObject);
            }
            CurrencyEffectComponent eff = effects.gameObject.AddComponent <CurrencyEffectComponent>();

            UnityEngine.Object.DontDestroyOnLoad(eff);

            var png    = CustomTextures.LoadTexture(@"BepInEx\plugins\Grindward\Icons\" + newItemId + ".png", false, false);
            var sprite = CustomTextures.CreateSprite(png, CustomTextures.SpriteBorderTypes.ItemIcon);

            CustomItemVisuals.SetSpriteLink(item, sprite);

            At.SetValue(sprite, typeof(Item), item, "m_itemIcon");

            return(item);
        }
        // usually called from LoadScene. Also by the Sync functions when you join a host.
        public IEnumerator SetupBonfireLocal(Vector3 position, string uid)
        {
            Debug.Log("Setting up bonfire at: " + position.ToString() + ", uid: " + uid);

            var bonfire = new GameObject("Bonfire_" + uid);

            bonfire.transform.position = position;

            var activatedCampfire = CustomItemVisuals.GetOrigItemVisuals(ResourcesPrefabManager.Instance.GetItemPrefab(5000101).GetComponent <Deployable>().DeployedStateItemPrefab, VisualPrefabType.VisualPrefab);
            var fireVisuals       = Instantiate(activatedCampfire.gameObject);

            fireVisuals.transform.parent   = bonfire.transform;
            fireVisuals.transform.position = bonfire.transform.position;

            var swordVisuals = Instantiate(CustomItemVisuals.GetOrigItemVisuals(ResourcesPrefabManager.Instance.GetItemPrefab(2000151), VisualPrefabType.VisualPrefab).gameObject);

            swordVisuals.transform.parent   = bonfire.transform;
            swordVisuals.transform.position = bonfire.transform.position + Vector3.up;
            swordVisuals.transform.rotation = Quaternion.Euler(0, 0, 90);

            var sigilVisuals = Instantiate(CustomItemVisuals.GetOrigItemVisuals(ResourcesPrefabManager.Instance.GetItemPrefab(8000010), VisualPrefabType.VisualPrefab).gameObject);

            sigilVisuals.transform.parent   = bonfire.transform;
            sigilVisuals.transform.position = bonfire.transform.position;

            // interaction gameobject base
            GameObject actionHolder = new GameObject("Interaction_Holder");

            actionHolder.transform.parent   = bonfire.transform;
            actionHolder.transform.position = bonfire.transform.position;

            // setup components
            InteractionTriggerBase triggerBase  = actionHolder.AddComponent <InteractionTriggerBase>();
            InteractionActivator   activator    = actionHolder.AddComponent <InteractionActivator>();
            InteractionBase        interactBase = actionHolder.AddComponent <InteractionBase>();

            // setup the trigger base
            triggerBase.SetHolderUID(uid);
            triggerBase.GenerateColliderIfNone = true;
            triggerBase.IsLargeTrigger         = true;
            triggerBase.DetectionPriority      = -9999;
            triggerBase.SetActivator(activator);

            // setup the interaction activator
            activator.SetUID(uid);
            At.SetValue("Rest at <color=#fc4e03>Bonfire</color>", typeof(InteractionActivator), activator, "m_overrideBasicText");
            At.SetValue(interactBase, typeof(InteractionActivator), activator, "m_sceneBasicInteraction");

            // setup the event interaction base
            interactBase.OnActivationEvent = BonfireEvent;

            // =========== finalize =========== //
            bonfire.gameObject.SetActive(true);

            yield return(new WaitForSeconds(0.1f));

            //activator.Reregister();
            foreach (ParticleSystem ps in fireVisuals.GetComponentsInChildren <ParticleSystem>())
            {
                ps.Play();
                var m = ps.main;
                m.prewarm     = true;
                m.playOnAwake = true;
            }
            foreach (Light light in fireVisuals.GetComponentsInChildren <Light>())
            {
                light.gameObject.SetActive(true);
            }
            foreach (SoundPlayer sound in fireVisuals.GetComponentsInChildren <SoundPlayer>())
            {
                sound.Play(false);
            }
        }