Beispiel #1
0
 public static void RefreshAll()
 {
     foreach (var hudInstance in HUD.readOnlyInstanceList)
     {
         MysticsItemsRhythmHUDUnderCrosshair.RefreshForHUDInstance(hudInstance);
         MysticsItemsRhythmHUDOverSkills.RefreshForHUDInstance(hudInstance);
     }
 }
Beispiel #2
0
            public static new void RefreshForHUDInstance(HUD hudInstance)
            {
                CharacterMaster             targetMaster    = hudInstance.targetMaster;
                CharacterBody               targetBody      = targetMaster ? targetMaster.GetBody() : null;
                MysticsItemsRhythmBehaviour rhythmBehaviour = targetBody ? targetBody.GetComponent <MysticsItemsRhythmBehaviour>() : null;

                bool shouldDisplay = rhythmUIUnderCrosshair.Value && rhythmBehaviour;

                MysticsItemsRhythmHUDUnderCrosshair targetIndicatorInstance = instancesList.Where(x => x is MysticsItemsRhythmHUDUnderCrosshair).Select(x => x as MysticsItemsRhythmHUDUnderCrosshair).FirstOrDefault(x => x.hud == hudInstance);

                if (targetIndicatorInstance != shouldDisplay)
                {
                    if (!targetIndicatorInstance)
                    {
                        if (hudInstance.mainUIPanel)
                        {
                            var transform = (RectTransform)hudInstance.mainUIPanel.transform.Find("SpringCanvas");
                            if (transform)
                            {
                                targetIndicatorInstance     = Instantiate(rhythmHUDUnderCrosshair, transform).GetComponent <MysticsItemsRhythmHUDUnderCrosshair>();
                                targetIndicatorInstance.hud = hudInstance;
                            }
                        }
                    }
                    else
                    {
                        Destroy(targetIndicatorInstance.gameObject);
                    }
                }

                if (shouldDisplay)
                {
                    targetIndicatorInstance.rhythmBehaviour = rhythmBehaviour;
                    targetIndicatorInstance.UpdateText();
                }
            }
Beispiel #3
0
 public static void RefreshForHUDInstance(HUD hudInstance)
 {
     MysticsItemsRhythmHUDUnderCrosshair.RefreshForHUDInstance(hudInstance);
     MysticsItemsRhythmHUDOverSkills.RefreshForHUDInstance(hudInstance);
 }
Beispiel #4
0
        public override void OnLoad()
        {
            base.OnLoad();
            itemDef.name = "MysticsItems_Rhythm";
            SetItemTierWhenAvailable(ItemTier.Tier2);
            itemDef.tags = new ItemTag[]
            {
                ItemTag.Damage,
                ItemTag.CannotCopy,
                ItemTag.AIBlacklist
            };

            itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Metronome/Model.prefab"));
            itemDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Metronome/Icon.png");
            itemDisplayPrefab         = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false));
            onSetupIDRS += () =>
            {
                AddDisplayRule("CommandoBody", "GunMeshR", new Vector3(-0.14977F, -0.00011F, 0.19943F), new Vector3(357.2297F, 89.56014F, 94.90321F), new Vector3(0.06413F, 0.06413F, 0.06413F));
                AddDisplayRule("HuntressBody", "Muzzle", new Vector3(0.5712F, -0.07049F, -0.35215F), new Vector3(6.74464F, 202.348F, 181.4547F), new Vector3(0.06599F, 0.06599F, 0.06599F));
                AddDisplayRule("Bandit2Body", "MainWeapon", new Vector3(-0.04183F, 0.35156F, -0.0992F), new Vector3(88.13229F, 267.2944F, 94.61585F), new Vector3(0.08705F, 0.08705F, 0.08705F));
                AddDisplayRule("ToolbotBody", "Head", new Vector3(-0.91116F, 1.81749F, -1.53393F), new Vector3(307.0614F, 172.1482F, 186.2799F), new Vector3(1.12349F, 1.12349F, 1.12349F));
                AddDisplayRule("EngiBody", "Chest", new Vector3(0.15956F, 0.09173F, 0.2025F), new Vector3(25.66347F, 26.21173F, 15.26607F), new Vector3(0.10282F, 0.10282F, 0.10282F));
                //AddDisplayRule("EngiTurretBody", "Head", new Vector3(0.035F, 0.89075F, -1.47928F), new Vector3(0F, 90F, 303.695F), new Vector3(0.07847F, 0.07847F, 0.07847F));
                //AddDisplayRule("EngiWalkerTurretBody", "Head", new Vector3(0.03562F, 1.40676F, -1.39837F), new Vector3(0F, 90F, 303.1705F), new Vector3(0.08093F, 0.09844F, 0.07912F));
                AddDisplayRule("MageBody", "LowerArmR", new Vector3(0.00535F, 0.17996F, 0.16359F), new Vector3(78.29745F, 168.3501F, 168.913F), new Vector3(0.11636F, 0.11636F, 0.11636F));
                AddDisplayRule("MercBody", "Head", new Vector3(0.04902F, 0.12013F, -0.1775F), new Vector3(71.07915F, 177.6901F, 358.0208F), new Vector3(0.06645F, 0.06645F, 0.06645F));
                AddDisplayRule("TreebotBody", "Chest", new Vector3(0.24295F, -0.27633F, 0.51083F), new Vector3(23.09669F, 28.90149F, 30.20801F), new Vector3(0.21041F, 0.21041F, 0.20824F));
                AddDisplayRule("LoaderBody", "MechBase", new Vector3(0.11134F, 0.33975F, 0.46839F), new Vector3(0F, 0F, 0F), new Vector3(0.09109F, 0.09109F, 0.09109F));
                AddDisplayRule("CrocoBody", "LowerArmL", new Vector3(-0.95799F, 3.65747F, -1.35262F), new Vector3(72.10529F, 137.362F, 285.0087F), new Vector3(1F, 1F, 1F));
                AddDisplayRule("CaptainBody", "MuzzleGun", new Vector3(0.00434F, 0.07836F, 0.00366F), new Vector3(355.4746F, 178.9148F, 3.6623F), new Vector3(0.08307F, 0.08307F, 0.08307F));
                AddDisplayRule("BrotherBody", "LowerArmL", BrotherInfection.green, new Vector3(0.06027F, 0.23329F, 0.00112F), new Vector3(39.08279F, 113.2626F, 275.5628F), new Vector3(0.04861F, 0.04367F, 0.10724F));
                //AddDisplayRule("ScavBody", "Stomach", new Vector3(-0.92389F, 11.6509F, -5.90638F), new Vector3(20.93637F, 118.4181F, 332.9505F), new Vector3(0.24839F, 0.25523F, 0.24839F));
                if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper)
                {
                    AddDisplayRule("SniperClassicBody", "Chest", new Vector3(0.00594F, 0.11541F, -0.28484F), new Vector3(17.80415F, 179.5633F, 359.9077F), new Vector3(0.09333F, 0.09333F, 0.09333F));
                }
                AddDisplayRule("RailgunnerBody", "GunScope", new Vector3(0F, 0.31801F, 0.29244F), new Vector3(0F, 180F, 0F), new Vector3(0.09512F, 0.09512F, 0.09512F));
                AddDisplayRule("VoidSurvivorBody", "Chest", new Vector3(-0.09581F, 0.08226F, 0.18489F), new Vector3(351.5411F, 0.02671F, 5.65843F), new Vector3(0.0887F, 0.0887F, 0.05188F));
            };

            CharacterBody.onBodyStartGlobal          += CharacterBody_onBodyStartGlobal;
            On.RoR2.CharacterBody.OnInventoryChanged += CharacterBody_OnInventoryChanged;
            HUD.onHudTargetChangedGlobal             += HUD_onHudTargetChangedGlobal;

            var animationCurveHolderObj = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Metronome/AnimationCurveHolder.prefab").GetComponent <ParticleSystem>();
            var animationCurveHolder    = animationCurveHolderObj.main;

            rhythmHUDUnderCrosshair = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Metronome/RhythmHUDUnderCrosshair.prefab");
            rhythmHUDUnderCrosshair.AddComponent <HudElement>();
            MysticsItemsRhythmHUDUnderCrosshair indicatorComponent = rhythmHUDUnderCrosshair.AddComponent <MysticsItemsRhythmHUDUnderCrosshair>();

            indicatorComponent.canvasGroup                   = rhythmHUDUnderCrosshair.GetComponent <CanvasGroup>();
            indicatorComponent.noteTemplate                  = rhythmHUDUnderCrosshair.transform.Find("Bar/NoteLeft").gameObject;
            indicatorComponent.comboText                     = rhythmHUDUnderCrosshair.transform.Find("ComboText").GetComponent <TextMeshProUGUI>();
            indicatorComponent.barTransform                  = rhythmHUDUnderCrosshair.transform.Find("Bar");
            indicatorComponent.comboHitAnimation             = animationCurveHolder.startLifetime.curve;
            indicatorComponent.comboHitAnimationMultiplier   = 2f;
            indicatorComponent.comboBreakAnimation           = animationCurveHolder.startSpeed.curve;
            indicatorComponent.comboBreakAnimationMultiplier = 2f;
            indicatorComponent.noteFadeInAnimation           = AnimationCurve.EaseInOut(0f, 0f, 0.3f, 1f);

            RectTransform rectTransform = indicatorComponent.noteTemplate.GetComponent <RectTransform>();
            var           size          = Mathf.Abs(rectTransform.localPosition.x) / readTime * beatWindowEarly * 2f;

            rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size);
            rectTransform = indicatorComponent.barTransform.Find("Judgement") as RectTransform;
            rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size + 4f);

            rhythmHUDOverSkills = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Metronome/RhythmHUDOverSkills.prefab");
            rhythmHUDOverSkills.AddComponent <HudElement>();
            MysticsItemsRhythmHUDOverSkills indicatorComponent2 = rhythmHUDOverSkills.AddComponent <MysticsItemsRhythmHUDOverSkills>();

            indicatorComponent2.canvasGroup             = rhythmHUDOverSkills.GetComponent <CanvasGroup>();
            indicatorComponent2.overSkillSingleTemplate = rhythmHUDOverSkills.transform.Find("OverSkillSingleTemplate").gameObject;
            indicatorComponent2.noteTemplate            = rhythmHUDOverSkills.transform.Find("OverSkillSingleTemplate/Offset/NoteTemplate").gameObject;
            indicatorComponent2.comboText                     = rhythmHUDOverSkills.transform.Find("ComboText").GetComponent <TextMeshProUGUI>();
            indicatorComponent2.comboHitAnimation             = animationCurveHolder.startLifetime.curve;
            indicatorComponent2.comboHitAnimationMultiplier   = 2f;
            indicatorComponent2.comboBreakAnimation           = animationCurveHolder.startSpeed.curve;
            indicatorComponent2.comboBreakAnimationMultiplier = 5f;
            indicatorComponent2.noteFadeInAnimation           = AnimationCurve.EaseInOut(0f, 0f, 0.3f, 1f);

            rectTransform = indicatorComponent2.noteTemplate.GetComponent <RectTransform>();
            size          = Mathf.Abs((rectTransform.parent.Find("Bar") as RectTransform).rect.height) / readTime * beatWindowEarly;
            rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size);
            rectTransform = rectTransform.parent.Find("Judgement") as RectTransform;
            rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size + 4f);
        }