diff --git a/Configuration.cs b/Configuration.cs index da97702..d3de8b3 100644 --- a/Configuration.cs +++ b/Configuration.cs @@ -70,7 +70,7 @@ public Configuration(BaseUnityPlugin plugin, UnityAction reloadChannelPoints) { // Twitch TwitchChannel = plugin.Config.Bind("Twitch", "Channel", "", "Your Twitch channel name. The channel to monitor Twitch chat."); - TwitchClientID = TwitchUsername = plugin.Config.Bind("Twitch", "ClientID", "q6batx0epp608isickayubi39itsckt", "Client ID used to get ImplicitOAuth value"); + TwitchClientID = plugin.Config.Bind("Twitch", "ClientID", "q6batx0epp608isickayubi39itsckt", "Client ID used to get ImplicitOAuth value"); TwitchUsername = plugin.Config.Bind("Twitch", "Username", "", "Your Twitch username. The username to use when calling Twitch APIs. If you aren't using a secondary account, this should be the same as 'Channel'."); TwitchOAuth = plugin.Config.Bind("Twitch", "ImplicitOAuth", "", "Implicit OAuth code (this is not your password - it's a generated password!). See the README/Mod Description in the thunderstore to see how to get it."); TwitchDebugLogs = plugin.Config.Bind("Twitch", "DebugLogs", false, "Enable debug logging for Twitch - will spam to the console!"); diff --git a/Events/EventDirector.cs b/Events/EventDirector.cs index f241dfd..1d86d43 100644 --- a/Events/EventDirector.cs +++ b/Events/EventDirector.cs @@ -19,7 +19,6 @@ class EventDirector : MonoBehaviour { private BlockingCollection> eventQueue; private bool previousState; - private int forceChargingCount; /// /// Event that fires when the event director changes states between processing events, to pausing processing events. @@ -31,7 +30,6 @@ public void Awake() { eventQueue = new BlockingCollection>(); previousState = false; - forceChargingCount = 0; //Stage.onServerStageBegin += Stage_onServerStageBegin; //Stage.onServerStageComplete += Stage_onServerStageComplete; @@ -43,11 +41,6 @@ public void OnDestroy() //Stage.onServerStageBegin -= Stage_onServerStageBegin; //Stage.onServerStageComplete -= Stage_onServerStageComplete; //TeleporterInteraction.onTeleporterFinishGlobal -= TeleporterInteraction_onTeleporterFinishGlobal; - - if (Interlocked.Exchange(ref forceChargingCount, 0) > 0) - { - On.RoR2.TeleporterInteraction.UpdateMonstersClear -= TeleporterInteraction_UpdateMonstersClear; - } } public void Update() @@ -96,51 +89,6 @@ public void ClearEvents() while(eventQueue.TryTake(out _)) {} } - private void SetTeleporterCrystals(bool enabled) - { - if (TeleporterInteraction.instance) - { - ChildLocator component = TeleporterInteraction.instance.GetComponent().modelTransform.GetComponent(); - if (component) - { - if (enabled) - { - // Only enable, never disable - component.FindChild("TimeCrystalProps").gameObject.SetActive(true); - } - - Transform transform = component.FindChild("TimeCrystalBeaconBlocker"); - EffectManager.SpawnEffect(LegacyResourcesAPI.Load("Prefabs/Effects/TimeCrystalDeath"), new EffectData - { - origin = transform.transform.position - }, true); - transform.gameObject.SetActive(enabled); - } - } - } - - /// - /// Force the current stages teleporter to not fully charge until the returned handle is disposed. - ///
- /// Important: You must ensure the returned IDisposable is invoked to not risk locking the player into a stage, - /// because the teleporter is set to never fully charge. - ///
- /// A handle to the state. Call the IDisposable.Dispose() when you are done. - public IDisposable CreateOpenTeleporterObjectiveHandle() - { - int newValue = Interlocked.Increment(ref forceChargingCount); - - Log.Error($"EventDirector::ForceChargingState::Count = {newValue}"); - if (newValue == 1) - { - Log.Error("EventDirector::ForceChargingState::Enabled = true"); - On.RoR2.TeleporterInteraction.UpdateMonstersClear += TeleporterInteraction_UpdateMonstersClear; - SetTeleporterCrystals(true); - } - - return new ForceChargingHandle(this); - } - private IEnumerator Wrap(IEnumerator coroutine) { while (true) @@ -159,15 +107,6 @@ private IEnumerator Wrap(IEnumerator coroutine) } } - private void TeleporterInteraction_UpdateMonstersClear(On.RoR2.TeleporterInteraction.orig_UpdateMonstersClear orig, TeleporterInteraction self) - { - // We don't call the original to keep monstersCleared from flapping between True and False - // orig(self); - - FieldInfo monstersCleared = typeof(TeleporterInteraction).GetField("monstersCleared", BindingFlags.NonPublic | BindingFlags.Instance); - monstersCleared.SetValue(self, false); - } - private bool ShouldProcessEvents() { if (!enabled) @@ -219,43 +158,5 @@ private bool ShouldProcessEvents() return true; } - - private class ForceChargingHandle : IDisposable - { - private readonly EventDirector eventDirector; - private int disposed; - - public ForceChargingHandle(EventDirector eventDirector) - { - this.eventDirector = eventDirector; - this.disposed = 0; - } - - public void Dispose() - { - int previouslyDisposed = Interlocked.Exchange(ref disposed, 1); - if (previouslyDisposed == 1) - { - return; - } - - int newValue = Interlocked.Decrement(ref eventDirector.forceChargingCount); - if (newValue < 0) - { - Log.Error("Something didn't correctly ref count ForceChargingState!"); - Log.Exception(new Exception()); - Interlocked.Exchange(ref eventDirector.forceChargingCount, 0); - newValue = 0; - } - - Log.Error($"EventDirector::ForceChargingState::Count = {newValue}"); - if (newValue == 0) - { - Log.Error("EventDirector::ForceChargingState::Enabled = false"); - On.RoR2.TeleporterInteraction.UpdateMonstersClear -= eventDirector.TeleporterInteraction_UpdateMonstersClear; - eventDirector.SetTeleporterCrystals(false); - } - } - } } } diff --git a/Events/MonsterSpawner.cs b/Events/MonsterSpawner.cs index 32a8fc4..deec621 100644 --- a/Events/MonsterSpawner.cs +++ b/Events/MonsterSpawner.cs @@ -39,16 +39,10 @@ private CombatSquad SpawnMonstersInternal( { CombatSquad group = gameObject.AddComponent(); - IDisposable chargingHandle = null; - if (director) - { - chargingHandle = director.CreateOpenTeleporterObjectiveHandle(); - } group.onMemberLost += (master) => { if (group.memberCount == 0) { - chargingHandle?.Dispose(); Destroy(group); } }; @@ -131,7 +125,6 @@ private CombatSquad SpawnMonstersInternal( if (!spawnedAny) { Log.Error("Couldn't spawn any monster!"); - chargingHandle?.Dispose(); Destroy(group); return null; } diff --git a/README.md b/README.md index efb9268..efff525 100644 --- a/README.md +++ b/README.md @@ -115,10 +115,10 @@ To disable an event, simply set the weight to 0. Giving a higher weight increase |`BountyWeight`|number|1|✔️|Weight for the doppleganger bit event. Your Doppleganger has come to try to stop you!| |`ShrineOfOrderWeight`|number|1|✔️|Weight for the Shrine of Order bit event. What's this? You see a Shrine that looks rare, and seems to emit a purple hue. You can't help yourself, but you offer a Lunar coin to it...| |`ShrineOfTheMountainWeight`|number|1|✔️|Weight for the Shrine of the Mountain bit event. You have angered the Twitch Chat gods. Prepare for your final battle at the teleporter.| -|`TitanWeight`|number|1|✔️|Weight for the Aurelionite bit event. Aurelionite comes from the void to try to stop you! **(Until this monster is killed, the teleporter will not fully charge)**| -|`LunarWispWeight`|number|1|✔️|Weight for the Lunar Chimera (Wisp) bit event. Lunar Chimera's come from the void to try to stop you! **(Until these monsters are killed, the teleporter will not fully charge)**| -|`MithrixWeight`|number|1|✔️|Weight for the Mithrix bit event. Twitch Chat decides to enter your stage to stop you a little earlier in the run... **(Until this monster is killed, the teleporter will not fully charge)**| -|`ElderLemurianWeight`|number|1|✔️|Weight for the Elder Lemurian bit event. Elder Lumerian's come from the void to try to stop you! **(Until these monsters are killed, the teleporter will not fully charge)**| +|`TitanWeight`|number|1|✔️|Weight for the Aurelionite bit event. Aurelionite comes from the void to try to stop you!| +|`LunarWispWeight`|number|1|✔️|Weight for the Lunar Chimera (Wisp) bit event. Lunar Chimera's come from the void to try to stop you!| +|`MithrixWeight`|number|1|✔️|Weight for the Mithrix bit event. Twitch Chat decides to enter your stage to stop you a little earlier in the run...| +|`ElderLemurianWeight`|number|1|✔️|Weight for the Elder Lemurian bit event. Elder Lumerian's come from the void to try to stop you!| ## UI diff --git a/VsTwitch.cs b/VsTwitch.cs index 0d44e97..0a9f5e3 100644 --- a/VsTwitch.cs +++ b/VsTwitch.cs @@ -523,6 +523,11 @@ private void GameNetworkManager_onStartHostGlobal() try { Log.Info("Connecting to Twitch..."); + if (string.IsNullOrWhiteSpace(configuration.TwitchUsername.Value)) + { + configuration.TwitchUsername.Value = configuration.TwitchChannel.Value; + } + twitchManager.Connect( configuration.TwitchChannel.Value, configuration.TwitchOAuth.Value,