public void TestToStream() { using (var stringWriter = new StringWriter()) { SceneConvert.ToXmlStream(stringWriter, new SceneDef { Name = "hand_left", BgType = BackgroundType.External, Entities = new List <Entity> { new Entity { Tag = "WOUND_GLASS", Position = new Vector2(1.4f, 1.4f), Rotation = 1.4f } } }); string result = stringWriter.ToString(); ZLog.Info(result); SceneDef sceneDef = SceneConvert.FromXmlText(result); Assert.AreEqual(BackgroundType.External, sceneDef.BgType); } }
// Token: 0x0600290C RID: 10508 RVA: 0x000AD544 File Offset: 0x000AB744 private void OnMostRecentSceneDefChanged(SceneDef sceneDef) { if (sceneDef == this.requiredSceneDef && Run.instance.GetRunStopwatch() <= LoaderSpeedRunAchievement.requirement) { base.Grant(); } }
// Token: 0x06002528 RID: 9512 RVA: 0x000AEAA0 File Offset: 0x000ACCA0 public static void Stage(PageBuilder builder) { SceneDef sceneDef = (SceneDef)builder.entry.extraData; builder.AddStagePanel(sceneDef); builder.AddNotesPanel(Language.IsTokenInvalid(sceneDef.loreToken) ? Language.GetString("EARLY_ACCESS_LORE") : Language.GetString(sceneDef.loreToken)); }
private void SceneCatalog_onMostRecentSceneDefChanged(SceneDef sceneDef) { stageRequirementMet = stageInfo.Keys.Contains(sceneDef.baseSceneName); if (stageRequirementMet) { yThreshold = stageInfo[sceneDef.baseSceneName]; } }
// Token: 0x06002925 RID: 10533 RVA: 0x000AD871 File Offset: 0x000ABA71 private void OnMostRecentSceneDefChanged(SceneDef sceneDef) { this.sceneOk = (sceneDef.baseSceneName == HuntressMaintainFullHealthOnFrozenWallAchievement.requiredScene); if (this.sceneOk) { this.failed = false; } }
public static bool TryGetStage(string stageName, out SceneDef stage) { stage = SceneCatalog.GetSceneDefFromSceneName(stageName); if (!stage) { Debug.LogWarning("Warning! Stage name: \"" + stageName + "\" does not exist, TeamPVP mod might be outdated!"); return(false); } return(true); }
// Token: 0x0600267C RID: 9852 RVA: 0x000B2040 File Offset: 0x000B0240 private void Check() { if (Run.instance && Run.instance.GetType() == typeof(Run)) { SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene(); if (sceneDefForCurrentScene && sceneDefForCurrentScene.stageOrder < Run.instance.stageClearCount) { base.Grant(); } } }
public static void TryAddStage(string stageName, List <SceneDef> stages) { SceneDef stage = SceneCatalog.GetSceneDefFromSceneName(stageName); if (!stage) { Debug.LogWarning("Warning! Stage name: \"" + stageName + "\" does not exist, TeamPVP mod might be outdated!"); return; } stages.Add(stage); }
/// <summary> /// Registers a SceneDef to the SceneCatalog /// </summary> /// <param name="sceneDef">The SceneDef to register.</param> public static void RegisterSceneDef(SceneDef sceneDef) { //Check if the SurvivorDef has already been registered. if (SceneDefDefinitions.Contains(sceneDef)) { LogCore.LogE(sceneDef + " has already been registered, please do not register the same SceneDef twice."); return; } //If not, add it to our SurvivorDefinitions SceneDefDefinitions.Add(sceneDef); }
// Token: 0x06002797 RID: 10135 RVA: 0x000AAE40 File Offset: 0x000A9040 private void Check() { if (Run.instance && Run.instance.GetType() == typeof(Run) && base.localUser != null && base.localUser.currentNetworkUser != null) { SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene(); StatSheet currentStats = base.localUser.currentNetworkUser.masterPlayerStatsComponent.currentStats; if (sceneDefForCurrentScene.stageOrder >= 3 && currentStats.GetStatValueULong(StatDef.totalHealthHealed) <= 0f && base.localUser.cachedBody && base.localUser.cachedBody.healthComponent && base.localUser.cachedBody.healthComponent.alive) { base.Grant(); } } }
private void Run_AdvanceStage(On.RoR2.Run.orig_AdvanceStage orig, Run self, SceneDef nextScene) { if (!SceneExitController.isRunning) { // advancing stage through cheats! if (nextScene.baseSceneName == "bazaar") { bazaar.ResetBazaarPlayers(); } } orig(self, nextScene); }
private static void HookAwake(Action <SceneDef> orig, SceneDef self) { if (self is SceneDefReference sdr) { var def = Resources.Load <SceneDef>($"SceneDefs/{sdr.name}"); foreach (var field in sceneDefFields) { field.SetValue(self, field.GetValue(def)); } } orig(self); }
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)); } } } }
/// <summary> /// Adds a SceneDef to your Mod's ContentPack /// <para>If you want he scene to be weaved with vanilla stages, use RainOfStages</para> /// </summary> /// <param name="sceneDef">The SceneDef to Add.</param> /// <returns>true if valid and added, false if one of the requirements is not met</returns> public static bool AddSceneDef(SceneDef sceneDef) { //Add stuff here, i dont know what qualifies as a "valid" sceneDef, then again, people should just use ROS for handling sceneDefs, r2api just lets you add them this way for the sake of completion var asm = Assembly.GetCallingAssembly(); if (CatalogBlockers.GetAvailability <SceneDef>()) { R2API.Logger.LogInfo($"Assembly {asm.GetName().Name} is trying to add a SceneDef, R2API does not support weaving of Scenes, Use RainOfStages instead for weaving SceneDefs."); R2APIContentManager.HandleContentAddition(asm, sceneDef); return(true); } RejectContent(sceneDef, asm, "SceneDef", "but the SceneCatalog has already initialized!"); return(false); }
//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); }
// 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(); } } }
public static SceneDef ExportSceneFrom(IEnumerable <ISceneExportable> gos) { var sceneDef = new SceneDef(); int index = 0; foreach (var exp in gos) { exp.Index = index++; } foreach (var exp in gos) { var exportedDef = exp.Export(); sceneDef.Entities.Add(exportedDef); } return(sceneDef); }
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; }
private static void ReplaceMusic(SceneDef scene, ref string Songtype, Dictionary <string, List <string> > musicList) { Debug.Log("checking music"); //checks if there are custom songs for the scene if (musicList.ContainsKey(scene.sceneName)) { Debug.Log("editing music"); //adds the default one to the list if not in it //if (!musicList[scene.sceneName].Contains(Songtype)) //{ // musicList[scene.sceneName].Add(Songtype); //} //takes a random one from the list and put it in int randomInt = RoR2Application.rng.RangeInt(0, musicList.Count - 1); Songtype = musicList[scene.sceneName][randomInt]; } }
/* * 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(); } }
// Token: 0x06002527 RID: 9511 RVA: 0x000AE9E4 File Offset: 0x000ACBE4 public void AddStagePanel(SceneDef sceneDef) { string statDisplayValue = this.userProfile.statSheet.GetStatDisplayValue(PerStageStatDef.totalTimesVisited.FindStatDef(sceneDef.sceneName)); string statDisplayValue2 = this.userProfile.statSheet.GetStatDisplayValue(PerStageStatDef.totalTimesCleared.FindStatDef(sceneDef.sceneName)); string stringFormatted = Language.GetStringFormatted("STAGE_PREFIX_TOTALTIMESVISITED", new object[] { statDisplayValue }); string stringFormatted2 = Language.GetStringFormatted("STAGE_PREFIX_TOTALTIMESCLEARED", new object[] { statDisplayValue2 }); PageBuilder.sharedStringBuilder.Clear(); PageBuilder.sharedStringBuilder.Append(stringFormatted); PageBuilder.sharedStringBuilder.Append("\n"); PageBuilder.sharedStringBuilder.Append(stringFormatted2); this.AddSimpleTextPanel(PageBuilder.sharedStringBuilder.ToString()); }
public static void LoadDestinations() { Destinations.Clear(); FinalDestination = null; Tools.TryAddStage("artifactworld", Destinations); Tools.TryAddStage("blackbeach", Destinations); Tools.TryAddStage("dampcavesimple", Destinations); Tools.TryAddStage("foggyswamp", Destinations); Tools.TryAddStage("frozenwall", Destinations); Tools.TryAddStage("goldshores", Destinations); Tools.TryAddStage("golemplains", Destinations); Tools.TryAddStage("goolake", Destinations); Tools.TryAddStage("shipgraveyard", Destinations); Tools.TryAddStage("wispgraveyard", Destinations); Tools.TryAddStage("rootjungle", Destinations); if (Tools.TryGetStage("skymeadow", out SceneDef finalStage)) { FinalDestination = finalStage; } }
public RichPresence BuildRichPresenceForStage(SceneDef scene, Run run, bool includeRunTime) { RichPresence presence = new RichPresence() { Assets = new DiscordRPC.Assets() { LargeImageKey = scene.sceneName, LargeImageText = RoR2.Language.GetString(scene.subtitleToken) //add player character here! }, State = "Classic Run", Details = string.Format("Stage {0} - {1}", (run.stageClearCount + 1), RoR2.Language.GetString(scene.nameToken)) }; if (scene.sceneType == SceneType.Stage && includeRunTime) { presence.Timestamps = new Timestamps() { StartUnixMilliseconds = (ulong)DateTimeOffset.Now.ToUnixTimeSeconds() - ((ulong)run.GetRunStopwatch()) }; } return(presence); }
private static StageInfo GetStage(ClassicStageInfo stage) { StageInfo stageInfo = new StageInfo { stage = Stage.Custom, customStageName = "", }; SceneInfo info = stage.GetComponent <SceneInfo>(); if (!info) { return(stageInfo); } SceneDef scene = info.sceneDef; if (!scene) { return(stageInfo); } switch (scene.sceneName) { case "golemplains": stageInfo.stage = Stage.TitanicPlains; break; case "blackbeach": stageInfo.stage = Stage.DistantRoost; break; case "goolake": stageInfo.stage = Stage.AbandonedAqueduct; break; case "foggyswamp": stageInfo.stage = Stage.WetlandAspect; break; case "frozenwall": stageInfo.stage = Stage.RallypointDelta; break; case "wispgraveyard": stageInfo.stage = Stage.ScorchedAcres; break; case "dampcavesimple": stageInfo.stage = Stage.AbyssalDepths; break; case "shipgraveyard": stageInfo.stage = Stage.SirensCall; break; case "goldshores": stageInfo.stage = Stage.GildedCoast; break; default: stageInfo.stage = Stage.Custom; stageInfo.customStageName = scene.sceneName; break; } return(stageInfo); }
private static void RunAdvanceStage(On.RoR2.Run.orig_AdvanceStage orig, Run self, SceneDef nextScene) { try { RandomizeRunArtifacts(); } catch (Exception e) { InstanceLogger.LogWarning("Failed to randomize artifacts"); InstanceLogger.LogError(e); } orig(self, nextScene); }
private static void Stage_BeginAdvanceStage(On.RoR2.Stage.orig_BeginAdvanceStage orig, Stage self, SceneDef destinationStage) { foreach (var player in players) { for (var i = 0; i < player.GetBuffCount(maxHPDownStage); i++) { player.RemoveBuff(maxHPDownStage); } } orig(self, destinationStage); }
public void setNext(string tittle, string subtittle, string next) { this.nextscene = new SceneDef(tittle, subtittle, next); }
private void Stage_BeginAdvanceStage(On.RoR2.Stage.orig_BeginAdvanceStage orig, Stage self, SceneDef destinationStage) { orig(self, destinationStage); UnblockTimedRespawn(); RespawnType = RespawnType.Default; usersTimedRespawn.ResetAllRespawnTimers(); }
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); }
public static void ToXmlStream(TextWriter writer, SceneDef sceneDef) { XML_SERIALIZER.Serialize(writer, sceneDef); }