Ejemplo n.º 1
0
            // Token: 0x06002624 RID: 9764 RVA: 0x000B0498 File Offset: 0x000AE698
            private void OnTeleporterCharged(TeleporterInteraction teleporterInteraction)
            {
                SceneCatalog.GetSceneDefForCurrentScene();
                StatSheet currentStats = base.networkUser.masterPlayerStatsComponent.currentStats;

                if (Run.instance && Run.instance.stageClearCount == 0)
                {
                    PlayerStatsComponent masterPlayerStatsComponent = base.networkUser.masterPlayerStatsComponent;
                    if (masterPlayerStatsComponent)
                    {
                        masterPlayerStatsComponent.currentStats.PushStatValue(StatDef.firstTeleporterCompleted, 1UL);
                    }
                }
            }
Ejemplo n.º 2
0
 public void OnGamePaused()
 {
     if (RoR2.Run.instance != null)
     {
         if (client.CurrentPresence != null)
         {
             SceneDef scene = SceneCatalog.GetSceneDefForCurrentScene();
             if (scene != null)
             {
                 client.SetPresence(BuildRichPresenceForStage(scene, RoR2.Run.instance, false));
             }
         }
     }
 }
Ejemplo n.º 3
0
        public void LoadData()
        {
            var newRun = Run.instance;

            TeamManager.instance.SetTeamLevel(TeamIndex.Player, 0);
            TeamManager.instance.GiveTeamExperience(TeamIndex.Player, (ulong)teamExp);
            TeamManager.instance.SetTeamLevel(TeamIndex.Monster, 1);

            newRun.seed = ulong.Parse(seed);
            newRun.selectedDifficulty = (DifficultyIndex)difficulty;
            newRun.fixedTime          = fixedTime;

            var stopwatch = newRun.GetFieldValue <Run.RunStopwatch>("runStopwatch");

            stopwatch.offsetFromFixedTime = 0f;
            stopwatch.isPaused            = false;

            newRun.SetFieldValue("runStopwatch", stopwatch);


            newRun.runRNG            = new Xoroshiro128Plus(ulong.Parse(seed));
            newRun.nextStageRng      = new Xoroshiro128Plus(newRun.runRNG.nextUlong);
            newRun.stageRngGenerator = new Xoroshiro128Plus(newRun.runRNG.nextUlong);

            int dummy;

            for (int i = 0; i < stageClearCount; i++)
            {
                dummy = (int)newRun.stageRngGenerator.nextUlong;
                dummy = newRun.nextStageRng.RangeInt(0, 1);
                dummy = newRun.nextStageRng.RangeInt(0, 1);
            }

            //Clearing drones to avoid them carrying over to the new loaded run
            foreach (var item in TeamComponent.GetTeamMembers(TeamIndex.Player))
            {
                var body = item.GetComponent <CharacterBody>();
                if (body)
                {
                    if (!body.isPlayerControlled)
                    {
                        item.GetComponent <HealthComponent>()?.Suicide();
                    }
                }
            }

            newRun.AdvanceStage(SceneCatalog.GetSceneDefFromSceneName(sceneName));
            newRun.stageClearCount = stageClearCount;
        }
Ejemplo n.º 4
0
 // Token: 0x06002792 RID: 10130 RVA: 0x000AAD90 File Offset: 0x000A8F90
 private void Check()
 {
     if (Run.instance && Run.instance.GetType() == typeof(Run))
     {
         SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
         if (sceneDefForCurrentScene == null)
         {
             return;
         }
         if (base.localUser.currentNetworkUser.masterPlayerStatsComponent.currentStats.GetStatValueULong(StatDef.totalDeaths) == 0UL && sceneDefForCurrentScene.stageOrder == 3)
         {
             base.Grant();
         }
     }
 }
Ejemplo n.º 5
0
        //When the game begins a new stage, update presence
        private void Run_BeginStage(On.RoR2.Run.orig_BeginStage orig, Run self)
        {
            //Grab the run start time (elapsed time does not take into account timer freeze from intermissions yet)
            //Also runs a little fast - find a better hook point!
            if (currentPrivacyLevel != PrivacyLevel.Disabled)
            {
                SceneDef scene = SceneCatalog.GetSceneDefForCurrentScene();

                if (scene != null)
                {
                    client.SetPresence(BuildRichPresenceForStage(scene, self, true));
                }
            }
            orig(self);
        }
Ejemplo n.º 6
0
        public void Hooks()
        {
            On.RoR2.Run.Start += (orig, self) => {
                Logger.LogMessage("Getting Stages to Remove");
                DefineStagesToRemove();

                orig(self);
            };

            On.RoR2.Stage.Start += (orig, self) => {
                CurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
                orig(self);
            };

            On.RoR2.Run.PickNextStageScene += PickValidScene;
        }
Ejemplo n.º 7
0
        /*
         * private static void FindImpaleDotIndex()
         * {
         *      if (!ZetArtifactsPlugin.PluginLoaded("com.themysticsword.elitevariety")) return;
         *
         *      if (impaleDotIndex == DotController.DotIndex.None && !attemptedFindImpaleDotIndex)
         *      {
         *              BaseUnityPlugin Plugin = BepInEx.Bootstrap.Chainloader.PluginInfos["com.themysticsword.elitevariety"].Instance;
         *              Assembly PluginAssembly = Assembly.GetAssembly(Plugin.GetType());
         *
         *              if (PluginAssembly != null)
         *              {
         *                      BindingFlags Flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
         *
         *                      Type type = Type.GetType("EliteVariety.Buffs.ImpPlaneImpaled, " + PluginAssembly.FullName, false);
         *                      if (type != null)
         *                      {
         *                              FieldInfo indexField = type.GetField("dotIndex", Flags);
         *                              if (indexField != null)
         *                              {
         *                                      impaleDotIndex = (DotController.DotIndex)indexField.GetValue(type);
         *
         *                                      Debug.LogWarning("ZetArtifact [ZetLoopifact] - Impale DotIndex : " + impaleDotIndex);
         *                              }
         *                              else
         *                              {
         *                                      Debug.LogWarning("ZetArtifact [ZetLoopifact] - Could Not Find Field : ImpPlaneImpaled.dotIndex");
         *                              }
         *                      }
         *                      else
         *                      {
         *                              Debug.LogWarning("ZetArtifact [ZetLoopifact] - Could Not Find Type : EliteVariety.Buffs.ImpPlaneImpaled");
         *                      }
         *              }
         *              else
         *              {
         *                      Debug.LogWarning("ZetArtifact [ZetLoopifact] - Could Not Find EliteVariety Assembly");
         *              }
         *      }
         *
         *      attemptedFindImpaleDotIndex = true;
         * }
         */
        private static void RebuildEliteTypeArray()
        {
            if (earlyEliteDef != null)
            {
                SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
                string   sceneName = sceneDefForCurrentScene ? sceneDefForCurrentScene.baseSceneName : "";

                List <EliteDef> eliteDefs = new List <EliteDef>
                {
                    ZetArtifactsContent.Elites.HauntedEarly,
                    ZetArtifactsContent.Elites.PoisonEarly
                };

                if (sceneName != "moon2" && ZetArtifactsPlugin.PluginLoaded("com.arimah.PerfectedLoop"))
                {
                    eliteDefs.Add(ZetArtifactsContent.Elites.LunarEarly);
                }

                /*
                 * EquipmentIndex equipIndex;
                 * EliteDef eliteDef;
                 *
                 * if (ZetArtifactsPlugin.PluginLoaded("com.themysticsword.elitevariety"))
                 * {
                 *      if (impaleElite == null)
                 *      {
                 *              equipIndex = EquipmentCatalog.FindEquipmentIndex("EliteVariety_AffixImpPlane");
                 *              if (equipIndex != EquipmentIndex.None)
                 *              {
                 *                      eliteDef = GetEquipmentEliteDef(EquipmentCatalog.GetEquipmentDef(equipIndex));
                 *                      if (eliteDef != null) impaleElite = eliteDef;
                 *              }
                 *      }
                 *
                 *      if (impaleElite != null) eliteDefs.Add(impaleElite);
                 * }
                 */
                if (Enabled)
                {
                    Debug.LogWarning("ZetArtifact [ZetLoopifact] - Rebuild EarlyEliteTypeArray : " + eliteDefs.Count);
                }
                earlyEliteDef.eliteTypes = eliteDefs.ToArray();
            }
        }
Ejemplo n.º 8
0
        private bool Check(HashSet <SceneDef> setToCheck, string groupIdentifier, out SceneDef[] choices, SceneDef currentScene)
        {
            choices = Array.Empty <SceneDef>();

            if (currentScene.destinations.Contains(SceneCatalog.GetSceneDefFromSceneName(groupIdentifier)))
            {
                if (setToCheck.Any())
                {
                    choices = setToCheck.ToArray();

                    return(true);
                }
            }

            else
            {
                choices = Array.Empty <SceneDef>();
                return(false);
            }

            return(false);
        }
Ejemplo n.º 9
0
        public static void CCLoadScene(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                return;
            }

            string sceneName = args[0];

            try
            {
                var sceneDef = SceneCatalog.GetSceneDefFromSceneName(sceneName);
                if (!SceneCatalog.allSceneDefs.Contains(sceneDef))
                {
                    throw new Exception();
                }
                Run.instance.AdvanceStage(sceneDef);
            }
            catch
            {
                Debug.LogError($"Invalid scene name '{sceneName}'");
            }
        }
Ejemplo n.º 10
0
        public static bool IsLogVanilla(LogMessage log)
        {
            bool isVanilla = false;

            if (SceneCatalog.availability.available != false && SceneCatalog.GetSceneDefForCurrentScene() && SceneCatalog.GetSceneDefForCurrentScene().baseSceneName == "lobby")
            {
                isVanilla = true;
            }
            if (log.message == "Skin skinCrocoDefault (RoR2.SkinDef) has an empty renderer field in its rendererInfos.")
            {
                isVanilla = true;
            }
            return(isVanilla);
        }
Ejemplo n.º 11
0
        //Upgraded copy of Run.Start
        internal void LoadData()
        {
            if (ModSupport.IsSSLoaded)
            {
                ShareSuiteMapTransion();
            }
            if (trialArtifact != -1)
            {
                ArtifactTrialMissionController.trialArtifact = ArtifactCatalog.GetArtifactDef((ArtifactIndex)trialArtifact);
            }

            var instance = Run.instance;

            instance.SetRuleBook(ruleBook.Load());

            if (NetworkServer.active)
            {
                instance.seed = seed;
                instance.selectedDifficulty = (DifficultyIndex)difficulty;
                instance.fixedTime          = fixedTime;
                instance.shopPortalCount    = shopPortalCount;

                instance.runStopwatch = new Run.RunStopwatch
                {
                    offsetFromFixedTime = offsetFromFixedTime,
                    isPaused            = isPaused
                };

                runRng.LoadData(instance);
                instance.GenerateStageRNG();
            }

            instance.allowNewParticipants = true;
            UnityEngine.Object.DontDestroyOnLoad(instance.gameObject);

            var onlyInstancesList = NetworkUser.readOnlyInstancesList;

            for (int index = 0; index < onlyInstancesList.Count; ++index)
            {
                instance.OnUserAdded(onlyInstancesList[index]);
            }
            instance.allowNewParticipants = false;

            instance.stageClearCount = stageClearCount;
            if (NetworkServer.active)
            {
                instance.nextStageScene = SceneCatalog.GetSceneDefFromSceneName(nextSceneName);
                NetworkManager.singleton.ServerChangeScene(sceneName);
            }

            itemMask.LoadDataOut(out instance.availableItems);
            equipmentMask.LoadDataOut(out instance.availableEquipment);

            instance.BuildUnlockAvailability();
            instance.BuildDropTable();

            foreach (var flag in eventFlags)
            {
                instance.SetEventFlag(flag);
            }

            if (onRunStartGlobalDelegate.GetValue(null) is MulticastDelegate onRunStartGlobal && onRunStartGlobal != null)
            {
                foreach (var handler in onRunStartGlobal.GetInvocationList())
                {
                    handler.Method.Invoke(handler.Target, new object[] { instance });
                }
            }
        }
Ejemplo n.º 12
0
        public void DefineStagesToRemove()
        {
            if (!EnableRoost)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("blackbeach"));
            }

            if (!EnablePlains)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("golemplains"));
            }

            if (!EnableAqueduct)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("goolake"));
            }

            if (!EnableWetland)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("foggyswamp"));
            }

            if (!EnableRallypoint)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("frozenwall"));
            }

            if (!EnableAcres)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("wispgraveyard"));
            }

            if (!EnableDepths)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("dampcavesimple"));
            }

            if (!EnableSiren)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("shipgraveyard"));
            }

            if (!EnableGrove)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("rootjungle"));
            }

            if (!EnableMeadow)
            {
                StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName("skymeadow"));
            }

            string[] customremoval = CustomStages.Split(',');

            if (customremoval[0].Equals(""))
            {
                customremoval = Array.Empty <string>();
            }

            if (customremoval.Any())
            {
                foreach (var scene in customremoval)
                {
                    StagesToRemove.Add(SceneCatalog.GetSceneDefFromSceneName(scene));
                }
            }

            GenerateStageLists();
        }
Ejemplo n.º 13
0
        private void SummonLunarChimera(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            int             inventoryCount = GetCount(self);
            CharacterMaster master         = self.master;

            if (NetworkServer.active && inventoryCount > 0 && master && !IsMinion(master)) //Check if we're a minion or not. If we are, we don't summon a chimera.
            {
                LunarChimeraComponent lcComponent = LunarChimeraComponent.GetOrCreateComponent(master);
                if (!lcComponent.LastChimeraSpawned || !lcComponent.LastChimeraSpawned.master || !lcComponent.LastChimeraSpawned.master.hasBody)
                {
                    lcComponent.LastChimeraSpawned = null;
                    lcComponent.ResummonCooldown  -= Time.fixedDeltaTime;
                    if (lcComponent.ResummonCooldown <= 0f && SceneCatalog.mostRecentSceneDef != SceneCatalog.GetSceneDefFromSceneName("bazaar"))
                    {
                        DirectorPlacementRule placeRule = new DirectorPlacementRule
                        {
                            placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                            minDistance   = 10f,
                            maxDistance   = 40f,
                            spawnOnTarget = self.transform
                        };
                        DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(lunarChimeraSpawnCard, placeRule, RoR2Application.rng)
                        {
                            teamIndexOverride = TeamIndex.Player
                                                //summonerBodyObject = self.gameObject
                        };
                        GameObject gameObject = DirectorCore.instance.TrySpawnObject(directorSpawnRequest);
                        if (gameObject)
                        {
                            CharacterMaster cMaster = gameObject.GetComponent <CharacterMaster>();
                            if (cMaster)
                            {
                                //RoR2.Chat.AddMessage($"Character Master Found: {component}");
                                cMaster.teamIndex = TeamIndex.Neutral;
                                cMaster.inventory.GiveItem(ItemIndex.BoostDamage, lunarChimeraBaseDamageBoost + (lunarChimeraAdditionalDamageBoost * inventoryCount - 1));
                                cMaster.inventory.GiveItem(ItemIndex.BoostHp, lunarChimeraBaseHPBoost * inventoryCount);
                                cMaster.inventory.GiveItem(ItemIndex.BoostAttackSpeed, lunarChimeraBaseAttackSpeedBoost);
                                cMaster.inventory.GiveItem(ItemIndex.Hoof, lunarChimeraBaseMovementSpeedBoost * inventoryCount);
                                cMaster.minionOwnership.SetOwner(master);

                                CharacterBody cBody = cMaster.GetBody();
                                if (cBody)
                                {
                                    //RoR2.Chat.AddMessage($"CharacterBody Found: {component4}");
                                    cBody.teamComponent.teamIndex = TeamIndex.Neutral;
                                    cBody.gameObject.AddComponent <LunarChimeraRetargetComponent>();
                                    lcComponent.LastChimeraSpawned = cBody;
                                    DeathRewards deathRewards = cBody.GetComponent <DeathRewards>();
                                    if (deathRewards)
                                    {
                                        //RoR2.Chat.AddMessage($"DeathRewards Found: {component5}");
                                        deathRewards.goldReward = 0;
                                        deathRewards.expReward  = 0;
                                    }
                                    NetworkIdentity bodyNet = cBody.GetComponent <NetworkIdentity>();
                                    if (bodyNet)
                                    {
                                        new AssignOwner(lcComponent.netId, bodyNet.netId).Send(NetworkDestination.Clients);
                                    }
                                }
                            }
                            lcComponent.ResummonCooldown = lunarChimeraResummonCooldownDuration;
                        }
                    }
                }
            }
            orig(self);
        }
Ejemplo n.º 14
0
 private bool CheckIfCurrentStageQualifyForSharing()
 {
     return(!PluginGlobals.IgnoredStages.Contains(SceneCatalog.GetSceneDefForCurrentScene().baseSceneName));
 }
Ejemplo n.º 15
0
 // Token: 0x06002909 RID: 10505 RVA: 0x000AD513 File Offset: 0x000AB713
 public override void OnInstall()
 {
     base.OnInstall();
     this.requiredSceneDef = SceneCatalog.GetSceneDefFromSceneName("mysteryspace");
 }
Ejemplo n.º 16
0
        //Upgraded copy of Run.Start
        public void LoadData()
        {
            if (trialArtifact != -1)
            {
                ArtifactTrialMissionController.trialArtifact = ArtifactCatalog.GetArtifactDef((ArtifactIndex)trialArtifact);
            }

            var instance = Run.instance;

            instance.seed = ulong.Parse(seed);
            instance.selectedDifficulty = (DifficultyIndex)difficulty;
            instance.fixedTime          = fixedTime;
            instance.shopPortalCount    = shopPortalCount;

            var stopwatch = instance.GetFieldValue <Run.RunStopwatch>("runStopwatch");

            stopwatch.offsetFromFixedTime = offsetFromFixedTime;
            stopwatch.isPaused            = isPaused;

            instance.SetFieldValue("runStopwatch", stopwatch);

            if (NetworkServer.active)
            {
                runRng.LoadData(instance);
                instance.InvokeMethod("GenerateStageRNG");
                typeof(Run).GetMethod("PopulateValidStages", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null);
            }

            instance.SetFieldValue("allowNewParticipants", true);
            UnityEngine.Object.DontDestroyOnLoad(instance.gameObject);

            var onlyInstancesList = NetworkUser.readOnlyInstancesList;

            for (int index = 0; index < onlyInstancesList.Count; ++index)
            {
                instance.OnUserAdded(onlyInstancesList[index]);
            }
            instance.SetFieldValue("allowNewParticipants", false);

            if (NetworkServer.active)
            {
                instance.nextStageScene = SceneCatalog.GetSceneDefFromSceneName(nextSceneName);
                NetworkManager.singleton.ServerChangeScene(sceneName);
                ProperSave.Instance.StartCoroutine(WaitForSceneChange());
            }

            itemMask.LoadData(out instance.availableItems);
            equipmentMask.LoadData(out instance.availableEquipment);

            instance.InvokeMethod("BuildUnlockAvailability");
            instance.BuildDropTable();

            foreach (var flag in eventFlags)
            {
                instance.SetEventFlag(flag);
            }

            if (typeof(Run).GetField("onRunStartGlobal", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null) is MulticastDelegate onRunStartGlobal && onRunStartGlobal != null)
            {
                foreach (var handler in onRunStartGlobal.GetInvocationList())
                {
                    handler.Method.Invoke(handler.Target, new object[] { instance });
                }
            }
        }
 public bool CheckIfCurrentStageIsIgnoredForTimedRespawn()
 {
     return(PluginConfig.IgnoredMapsForTimedRespawn.Value.Contains(SceneCatalog.GetSceneDefForCurrentScene().baseSceneName));
 }
Ejemplo n.º 18
0
        //Upgraded copy of Run.Start
        public void LoadData()
        {
            if (trialArtifact != -1)
            {
                ArtifactTrialMissionController.trialArtifact = ArtifactCatalog.GetArtifactDef((ArtifactIndex)trialArtifact);
            }

            var instance = Run.instance;

            onRuleBookUpdateMethod.Invoke(instance, new object[] { instance.GetFieldValue <NetworkRuleBook>("networkRuleBookComponent") });

            if (NetworkServer.active)
            {
                instance.seed = seed;
                instance.selectedDifficulty = (DifficultyIndex)difficulty;
                instance.fixedTime          = fixedTime;
                instance.shopPortalCount    = shopPortalCount;

                var stopwatch = instance.GetFieldValue <Run.RunStopwatch>("runStopwatch");
                stopwatch.offsetFromFixedTime = offsetFromFixedTime;
                stopwatch.isPaused            = isPaused;

                instance.SetFieldValue("runStopwatch", stopwatch);

                runRng.LoadData(instance);
                generateStageRNGMethod.Invoke(instance, null);
            }

            instance.SetFieldValue("allowNewParticipants", true);
            UnityEngine.Object.DontDestroyOnLoad(instance.gameObject);

            var onlyInstancesList = NetworkUser.readOnlyInstancesList;

            for (int index = 0; index < onlyInstancesList.Count; ++index)
            {
                instance.OnUserAdded(onlyInstancesList[index]);
            }
            instance.SetFieldValue("allowNewParticipants", false);

            if (NetworkServer.active)
            {
                instance.nextStageScene = SceneCatalog.GetSceneDefFromSceneName(nextSceneName);
                NetworkManager.singleton.ServerChangeScene(sceneName);
            }
            instance.stageClearCount = stageClearCount;

            itemMask.LoadData(out instance.availableItems);
            equipmentMask.LoadData(out instance.availableEquipment);

            buildUnlockAvailabilityMethod.Invoke(instance, null);
            instance.BuildDropTable();

            foreach (var flag in eventFlags)
            {
                instance.SetEventFlag(flag);
            }

            if (onRunStartGlobalDelegate.GetValue(null) is MulticastDelegate onRunStartGlobal && onRunStartGlobal != null)
            {
                foreach (var handler in onRunStartGlobal.GetInvocationList())
                {
                    handler.Method.Invoke(handler.Target, new object[] { instance });
                }
            }
        }
Ejemplo n.º 19
0
        public override void OnLoad()
        {
            equipmentDef.name = "MysticsItems_ArchaicMask";
            ConfigManager.Balance.CreateEquipmentCooldownOption(equipmentDef, "Equipment: Legendary Mask", 140f);
            equipmentDef.canDrop = true;
            ConfigManager.Balance.CreateEquipmentEnigmaCompatibleOption(equipmentDef, "Equipment: Legendary Mask", true);
            ConfigManager.Balance.CreateEquipmentCanBeRandomlyTriggeredOption(equipmentDef, "Equipment: Legendary Mask", true);
            equipmentDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Equipment/Archaic Mask/Model.prefab"));
            equipmentDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Equipment/Archaic Mask/Icon.png");
            MysticsItemsContent.Resources.unlockableDefs.Add(GetUnlockableDef());

            SetScalableChildEffect(equipmentDef.pickupModelPrefab, "Mask/Effects/Point Light");
            SetScalableChildEffect(equipmentDef.pickupModelPrefab, "Mask/Effects/Fire");
            Material matArchaicMaskFire = equipmentDef.pickupModelPrefab.transform.Find("Mask/Effects/Fire").gameObject.GetComponent <Renderer>().sharedMaterial;

            HopooShaderToMaterial.CloudRemap.Apply(
                matArchaicMaskFire,
                Main.AssetBundle.LoadAsset <Texture>("Assets/Equipment/Archaic Mask/texRampArchaicMaskFire.png")
                );
            HopooShaderToMaterial.CloudRemap.Boost(matArchaicMaskFire, 0.5f);
            itemDisplayPrefab = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(equipmentDef.pickupModelPrefab, equipmentDef.pickupModelPrefab.name + "Display", false));
            MysticsRisky2Utils.Utils.CopyChildren(equipmentDef.pickupModelPrefab, unlockInteractablePrefab);

            onSetupIDRS += () =>
            {
                AddDisplayRule("CommandoBody", "Head", new Vector3(-0.001F, 0.253F, 0.124F), new Vector3(0.055F, 269.933F, 20.48F), new Vector3(0.147F, 0.147F, 0.147F));
                AddDisplayRule("HuntressBody", "Head", new Vector3(-0.001F, 0.221F, 0.039F), new Vector3(0.073F, 269.903F, 25.101F), new Vector3(0.119F, 0.119F, 0.121F));
                AddDisplayRule("Bandit2Body", "Head", new Vector3(0F, 0.047F, 0.102F), new Vector3(0F, 270F, 0F), new Vector3(0.097F, 0.097F, 0.097F));
                AddDisplayRule("ToolbotBody", "Head", new Vector3(0.321F, 3.4F, -0.667F), new Vector3(0F, 90F, 56.608F), new Vector3(0.933F, 0.933F, 0.933F));
                AddDisplayRule("EngiBody", "HeadCenter", new Vector3(0F, 0F, 0.117F), new Vector3(0F, 270F, 0F), new Vector3(0.12F, 0.12F, 0.12F));
                AddDisplayRule("MageBody", "Head", new Vector3(0F, 0.05F, 0.104F), new Vector3(0F, 270F, 0F), new Vector3(0.07F, 0.07F, 0.07F));
                AddDisplayRule("MercBody", "Head", new Vector3(0F, 0.135F, 0.117F), new Vector3(0F, 270F, 11.977F), new Vector3(0.123F, 0.123F, 0.123F));
                AddDisplayRule("TreebotBody", "FlowerBase", new Vector3(0.2F, 0.873F, 0.344F), new Vector3(0F, 295.888F, 344.74F), new Vector3(0.283F, 0.283F, 0.283F));
                AddDisplayRule("LoaderBody", "Head", new Vector3(0F, 0.097F, 0.116F), new Vector3(0F, 270F, 4.685F), new Vector3(0.117F, 0.117F, 0.117F));
                AddDisplayRule("CrocoBody", "Head", new Vector3(0.012F, 4.425F, 1.271F), new Vector3(355.778F, 271.534F, 2.51F), new Vector3(0.973F, 0.973F, 0.973F));
                AddDisplayRule("CaptainBody", "Head", new Vector3(0F, 0.064F, 0.12F), new Vector3(0F, 270F, 0F), new Vector3(0.104F, 0.107F, 0.118F));
                AddDisplayRule("ScavBody", "MuzzleEnergyCannon", new Vector3(-0.26641F, -0.48169F, 0.74377F), new Vector3(9.57747F, 91.16208F, 178.8642F), new Vector3(2.78505F, 2.78505F, 2.78505F));
                AddDisplayRule("EquipmentDroneBody", "HeadCenter", new Vector3(0F, -0.507F, -0.381F), new Vector3(0F, 270F, 270F), new Vector3(0.965F, 0.965F, 0.965F));
                if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper)
                {
                    AddDisplayRule("SniperClassicBody", "Head", new Vector3(-0.0039F, 0.15803F, -0.07916F), new Vector3(356.8718F, 270F, 87.82172F), new Vector3(0.14049F, 0.14049F, 0.14049F));
                }
                AddDisplayRule("RailgunnerBody", "Head", new Vector3(0F, 0.04792F, 0.09549F), new Vector3(0F, 270F, 352.3218F), new Vector3(0.10505F, 0.10505F, 0.10505F));
                AddDisplayRule("VoidSurvivorBody", "Head", new Vector3(-0.06693F, -1.12064F, -0.77318F), new Vector3(90F, 0F, 0F), new Vector3(0.5795F, 0.5795F, 0.5795F));
            };

            crosshairPrefab = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load <GameObject>("Prefabs/WoodSpriteIndicator"), "MysticsItems_ArchaicMaskIndicator", false);
            Object.Destroy(crosshairPrefab.GetComponentInChildren <Rewired.ComponentControls.Effects.RotateAroundAxis>());
            crosshairPrefab.GetComponentInChildren <SpriteRenderer>().sprite             = Main.AssetBundle.LoadAsset <Sprite>("Assets/Equipment/Archaic Mask/Crosshair.png");
            crosshairPrefab.GetComponentInChildren <SpriteRenderer>().color              = new Color(190f / 255f, 65f / 255f, 255f / 255f);
            crosshairPrefab.GetComponentInChildren <SpriteRenderer>().transform.rotation = Quaternion.identity;
            crosshairPrefab.GetComponentInChildren <TMPro.TextMeshPro>().color           = new Color(190f / 255f, 65f / 255f, 255f / 255f);
            while (crosshairPrefab.GetComponentInChildren <ObjectScaleCurve>().overallCurve.length > 0)
            {
                crosshairPrefab.GetComponentInChildren <ObjectScaleCurve>().overallCurve.RemoveKey(0);
            }
            crosshairPrefab.GetComponentInChildren <ObjectScaleCurve>().overallCurve.AddKey(0f, 2f);
            crosshairPrefab.GetComponentInChildren <ObjectScaleCurve>().overallCurve.AddKey(0.5f, 1f);
            crosshairPrefab.GetComponentInChildren <ObjectScaleCurve>().overallCurve.AddKey(1f, 1f);

            MysticsItemsArchaicMaskUnlockInteraction unlockInteraction = unlockInteractablePrefab.AddComponent <MysticsItemsArchaicMaskUnlockInteraction>();

            unlockInteraction.effects = unlockInteractablePrefab.transform.Find("Mask/Effects").gameObject;

            ParticleSystem particleSystem = unlockInteraction.effects.GetComponentInChildren <ParticleSystem>();

            ParticleSystem.MainModule particleSystemMain = particleSystem.main;
            particleSystemMain.startLifetime = 3.5f;

            unlockInteractablePrefab.AddComponent <GenericDisplayNameProvider>().displayToken = "EQUIPMENT_" + equipmentDef.name.ToUpper(System.Globalization.CultureInfo.InvariantCulture) + "_NAME";

            Highlight highlight = unlockInteractablePrefab.AddComponent <Highlight>();

            highlight.targetRenderer = unlockInteractablePrefab.GetComponentInChildren <Renderer>();
            highlight.highlightColor = Highlight.HighlightColor.interactive;

            GameObject entityLocatorHolder = unlockInteractablePrefab.transform.Find("EntityLocatorHolder").gameObject;

            entityLocatorHolder.layer = LayerIndex.pickups.intVal;
            SphereCollider sphereCollider = entityLocatorHolder.AddComponent <SphereCollider>();

            sphereCollider.radius    = 1.5f;
            sphereCollider.isTrigger = true;
            entityLocatorHolder.AddComponent <EntityLocator>().entity = unlockInteractablePrefab;

            MysticsRisky2Utils.Utils.CopyChildren(Main.AssetBundle.LoadAsset <GameObject>("Assets/Equipment/Archaic Mask/ForcedPickup.prefab"), forcedPickupPrefab);
            GenericPickupController genericPickupController = forcedPickupPrefab.AddComponent <GenericPickupController>();

            forcedPickupPrefab.AddComponent <Highlight>();
            PickupDisplay pickupDisplay = forcedPickupPrefab.transform.Find("PickupDisplay").gameObject.AddComponent <PickupDisplay>();

            pickupDisplay.spinSpeed    = 0f;
            pickupDisplay.verticalWave = new Wave {
                amplitude = 0f
            };
            pickupDisplay.coloredParticleSystems  = new ParticleSystem[] { };
            genericPickupController.pickupDisplay = pickupDisplay;
            forcedPickupPrefab.transform.Find("PickupTrigger").gameObject.layer = LayerIndex.pickups.intVal;
            forcedPickupPrefab.transform.Find("PickupTrigger").gameObject.AddComponent <EntityLocator>().entity = forcedPickupPrefab;
            forcedPickupPrefab.AddComponent <MysticsItemsArchaicMaskForcedPickup>();

            On.RoR2.SceneDirector.PopulateScene += (orig, self) =>
            {
                orig(self);
                if (SceneCatalog.GetSceneDefForCurrentScene().baseSceneName == "wispgraveyard")
                {
                    Vector3 position = Vector3.zero;
                    Vector3 rotation = Vector3.zero;
                    int     variant  = Random.Range(0, 2);
                    switch (variant)
                    {
                    case 0:
                        position = new Vector3(78.64633f, 42.3367f, 35.37148f);
                        rotation = new Vector3(4.26f, 150f, 20f);
                        break;

                    case 1:
                        position = new Vector3(-350.1f, 7.494953f, -72.9473f);
                        rotation = new Vector3(0f, 270f, 30f);
                        break;
                    }
                    GameObject obj = Object.Instantiate(unlockInteractablePrefab, position, Quaternion.Euler(rotation));
                    NetworkServer.Spawn(obj);
                }
            };

            UseTargetFinder(TargetFinderType.Enemies, crosshairPrefab);
        }
Ejemplo n.º 20
0
        private void Stage_onStageStartGlobal(Stage stage)
        {
            if (!NetworkServer.active)
            {
                return;
            }

            if (IsOnVIPSelectionStage)
            {
                spawnedBarrels = new List <GameObject>(characterAllies.Count);
                foreach (var masterController in PlayerCharacterMasterController.instances)
                {
                    SetGodMode(masterController.master, true);
                    masterController.master.money = 0;
                }

                foreach (var masterController in PlayerCharacterMasterController.instances)
                {
                    if (masterController.master.GetBody())
                    {
                        SpawnVIPSelections(masterController.master);
                        StartCoroutine(SendChat(6f,
                                                new Chat.SimpleChatMessage()
                        {
                            baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " +
                                        $"<color=#{ColorUtility.ToHtmlStringRGB(Color.gray)}>Select an ally you would like to " +
                                        $"protect for the run. Select the portal slot to choose no ally (disabling the mod).</color>"
                        }));
                        break;
                    }
                }
            }
            else if (run.stageClearCount == 0)
            {
                foreach (var masterController in PlayerCharacterMasterController.instances)
                {
                    SetGodMode(masterController.master, false);
                    masterController.master.GiveMoney(run.ruleBook.startingMoney);
                }
                foreach (var master in allies)
                {
                    SetGodMode(master, false);
                }
                spawnedBarrels.Clear();

                Debug.Log("Unhooking from RoR2.Run.OnServerBossAdded");
                On.RoR2.Run.OnServerBossAdded -= Run_OnServerBossAdded;
            }

            StartCoroutine(TeleportAlliesToFirstAvailablePlayerRoutine(null, 3));

            if (SceneCatalog.GetSceneDefForCurrentScene().baseSceneName == "moon" && allies.Count != 0)
            {
                // Stage with Mithrix, so we need to set up extra stuff for the AI
                StartCoroutine(SendChat(3f,
                                        new Chat.SimpleChatMessage()
                {
                    baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " +
                                $"The AI is broken on this stage... your ally will try to teleport to you when you reach the final area."
                }));
                On.EntityStates.Missions.BrotherEncounter.Phase1.OnEnter += Phase1_OnEnter;
            }
        }
Ejemplo n.º 21
0
        private IEnumerator WaitForSceneChange()
        {
            yield return(new WaitUntil(() => SceneCatalog.GetSceneDefForCurrentScene().baseSceneName == sceneName));

            Run.instance.stageClearCount = stageClearCount;
        }
Ejemplo n.º 22
0
        public override void OnLoad()
        {
            base.OnLoad();
            itemDef.name = "MysticsItems_Spotter";
            SetItemTierWhenAvailable(ItemTier.Tier2);
            itemDef.tags = new ItemTag[]
            {
                ItemTag.Damage
            };
            MysticsItemsContent.Resources.unlockableDefs.Add(GetUnlockableDef());
            itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Spotter/Model.prefab"));
            itemDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Spotter/Icon.png");
            Material mat = itemDef.pickupModelPrefab.transform.Find("mdlSpotterBroken").gameObject.GetComponent <MeshRenderer>().sharedMaterial;

            HopooShaderToMaterial.Standard.Apply(mat);
            HopooShaderToMaterial.Standard.Gloss(mat, 0.2f, 1f);
            HopooShaderToMaterial.Standard.Emission(mat, 1f);
            itemDisplayPrefab = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false));
            MysticsRisky2Utils.Utils.CopyChildren(itemDef.pickupModelPrefab, unlockInteractablePrefab);

            ModelPanelParameters modelPanelParameters = itemDef.pickupModelPrefab.GetComponent <ModelPanelParameters>();

            modelPanelParameters.minDistance = 6f;
            modelPanelParameters.maxDistance = 12f;

            itemDisplayPrefab.transform.localScale    = Vector3.one * 0.2f;
            itemDisplayPrefab.transform.localRotation = Quaternion.Euler(new Vector3(0f, -90f, 0f));
            Rigidbody rigidbody = enemyFollowerPrefab.AddComponent <Rigidbody>();

            rigidbody.useGravity = false;
            enemyFollowerPrefab.AddComponent <GenericOwnership>();
            MysticsItemsSpotterController component = enemyFollowerPrefab.AddComponent <MysticsItemsSpotterController>();

            component.follower = PrefabAPI.InstantiateClone(itemDisplayPrefab, "SpotterFollower", false);
            component.follower.transform.SetParent(enemyFollowerPrefab.transform);
            SimpleLeash leash = component.leash = enemyFollowerPrefab.AddComponent <SimpleLeash>();

            leash.minLeashRadius = 0f;
            leash.maxLeashRadius = Mathf.Infinity;
            leash.smoothTime     = 0.2f;
            SimpleRotateToDirection rotateToDirection = component.rotateToDirection = enemyFollowerPrefab.AddComponent <SimpleRotateToDirection>();

            rotateToDirection.maxRotationSpeed = 720f;
            rotateToDirection.smoothTime       = 0.1f;

            unlockInteractablePrefab.transform.localScale *= 0.4f;
            unlockInteractablePrefab.AddComponent <MysticsItemsSpotterUnlockInteraction>();

            GameObject sparks = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load <GameObject>("Prefabs/NetworkedObjects/RadarTower").transform.Find("mdlRadar").Find("Sparks").gameObject, "Sparks", false);

            sparks.transform.localPosition = new Vector3(0f, 1f, 0f);
            ParticleSystem.MainModule particleSystem = sparks.GetComponentInChildren <ParticleSystem>().main;
            particleSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
            sparks.transform.SetParent(unlockInteractablePrefab.transform);

            Highlight highlight = unlockInteractablePrefab.AddComponent <Highlight>();

            highlight.targetRenderer = unlockInteractablePrefab.GetComponentInChildren <Renderer>();
            highlight.highlightColor = Highlight.HighlightColor.interactive;

            PurchaseInteraction purchaseInteraction = unlockInteractablePrefab.AddComponent <PurchaseInteraction>();

            purchaseInteraction.displayNameToken = "MYSTICSITEMS_BROKENSPOTTER_NAME";
            purchaseInteraction.contextToken     = "MYSTICSITEMS_BROKENSPOTTER_CONTEXT";
            purchaseInteraction.costType         = CostTypeIndex.VolatileBattery;
            purchaseInteraction.available        = true;
            purchaseInteraction.cost             = 1;
            purchaseInteraction.automaticallyScaleCostWithDifficulty = false;
            purchaseInteraction.requiredUnlockable = "";
            purchaseInteraction.setUnavailableOnTeleporterActivated = false;

            GameObject entityLocatorHolder = unlockInteractablePrefab.transform.Find("EntityLocatorHolder").gameObject;

            entityLocatorHolder.layer = LayerIndex.pickups.intVal;
            SphereCollider sphereCollider = entityLocatorHolder.AddComponent <SphereCollider>();

            sphereCollider.radius    = 12f;
            sphereCollider.isTrigger = true;
            entityLocatorHolder.AddComponent <EntityLocator>().entity = unlockInteractablePrefab;

            On.RoR2.SceneDirector.PopulateScene += (orig, self) =>
            {
                orig(self);
                if (SceneCatalog.GetSceneDefForCurrentScene().baseSceneName == "rootjungle")
                {
                    GameObject obj = Object.Instantiate(unlockInteractablePrefab, new Vector3(-139.576f, -0.824233f - 1f, 35.42688f), Quaternion.Euler(new Vector3(-29f, 25f, 348f)));
                    NetworkServer.Spawn(obj);
                }
            };

            On.RoR2.CharacterBody.Awake += (orig, self) =>
            {
                orig(self);
                self.onInventoryChanged += delegate()
                {
                    if (NetworkServer.active)
                    {
                        self.AddItemBehavior <MysticsItemsSpotterBehaviour>(self.inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_Spotter));
                    }
                };
            };

            repairSoundEventDef           = ScriptableObject.CreateInstance <NetworkSoundEventDef>();
            repairSoundEventDef.eventName = "Play_drone_repair";
            MysticsItemsContent.Resources.networkSoundEventDefs.Add(repairSoundEventDef);

            highlightPrefab = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Spotter/SpotterTargetHighlight.prefab");
            MysticsItemsSpotterHighlight highlightComponent = highlightPrefab.AddComponent <MysticsItemsSpotterHighlight>();

            highlightComponent.insideViewObject  = highlightPrefab.transform.Find("Pivot").gameObject;
            highlightComponent.outsideViewObject = highlightPrefab.transform.Find("PivotOutsideView").gameObject;
            highlightComponent.textTargetName    = highlightPrefab.transform.Find("Pivot/Rectangle/Enemy Name").gameObject.GetComponent <TextMeshProUGUI>();
            highlightComponent.textTargetName.gameObject.AddComponent <MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsTextMeshUseLanguageDefaultFont>();
            highlightComponent.textTargetHP = highlightPrefab.transform.Find("Pivot/Rectangle/Health").gameObject.GetComponent <TextMeshProUGUI>();
            highlightComponent.textTargetHP.gameObject.AddComponent <MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsTextMeshUseLanguageDefaultFont>();

            RoR2Application.onLateUpdate += MysticsItemsSpotterHighlight.UpdateAll;
        }