using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("DirectorRework")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+95d8952ad0de9e32828db0fba03bd118883d64d7")]
[assembly: AssemblyProduct("DirectorRework")]
[assembly: AssemblyTitle("DirectorRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DirectorRework
{
[BepInPlugin("com.Nuxlar.DirectorRework", "DirectorRework", "1.1.0")]
public class DirectorRework : BaseUnityPlugin
{
private ConfigEntry<bool> teleporterBoss;
public void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
CombatDirector.AttemptSpawnOnTarget += new hook_AttemptSpawnOnTarget(ResetMonsterCard);
Chat.SendBroadcastChat_ChatMessageBase += new hook_SendBroadcastChat_ChatMessageBase(ChangeMessage);
BossGroup.UpdateBossMemories += new hook_UpdateBossMemories(UpdateTitle);
teleporterBoss = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Apply to Teleporter Boss", true, "If enabled, multiple boss types may appear.");
}
private bool ResetMonsterCard(orig_AttemptSpawnOnTarget orig, CombatDirector self, Transform target, PlacementMode mode)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
ref DirectorCard currentMonsterCard = ref self.currentMonsterCard;
if (currentMonsterCard != null && self.resetMonsterCardIfFailed)
{
int spawnCountInCurrentWave = self.spawnCountInCurrentWave;
int cost = currentMonsterCard.cost;
do
{
if ((Object)(object)self == (Object)(object)TeleporterInteraction.instance?.bossDirector)
{
if (!teleporterBoss.Value)
{
break;
}
self.SetNextSpawnAsBoss();
flag = spawnCountInCurrentWave == 0 || (float)currentMonsterCard.cost <= self.monsterCredit;
}
else
{
float nextNormalizedFloat = self.rng.nextNormalizedFloat;
currentMonsterCard = self.finalMonsterCardsSelection.Evaluate(nextNormalizedFloat);
self.PrepareNewMonsterWave(currentMonsterCard);
}
}
while (currentMonsterCard.cost > cost && (double)currentMonsterCard.cost * 0.85 > (double)self.monsterCredit);
self.spawnCountInCurrentWave = spawnCountInCurrentWave;
}
return flag | orig.Invoke(self, target, mode);
}
private void ChangeMessage(orig_SendBroadcastChat_ChatMessageBase orig, ChatMessageBase message)
{
SubjectFormatChatMessage val = (SubjectFormatChatMessage)(object)((message is SubjectFormatChatMessage) ? message : null);
if (val != null)
{
bool? flag = val.paramTokens?.Any();
if (flag.HasValue && flag.GetValueOrDefault() && ((SubjectChatMessage)val).baseToken == "SHRINE_COMBAT_USE_MESSAGE")
{
val.paramTokens[0] = Language.GetString("LOGBOOK_CATEGORY_MONSTER").ToLower();
}
}
orig.Invoke(message);
}
private void UpdateTitle(orig_UpdateBossMemories orig, BossGroup self)
{
orig.Invoke(self);
if (!teleporterBoss.Value)
{
return;
}
Dictionary<(string, string), float> dictionary = new Dictionary<(string, string), float>();
float num = 0f;
for (int i = 0; i < self.bossMemoryCount; i++)
{
CharacterBody cachedBody = self.bossMemories[i].cachedBody;
if (!Object.op_Implicit((Object)(object)cachedBody))
{
continue;
}
HealthComponent healthComponent = cachedBody.healthComponent;
if (!(((healthComponent != null) ? new bool?(healthComponent.alive) : null) ?? true))
{
continue;
}
string bestBodyName = Util.GetBestBodyName(((Component)cachedBody).gameObject);
string text = cachedBody.GetSubtitle();
(string, string) key = (bestBodyName, text);
if (!dictionary.ContainsKey(key))
{
dictionary[key] = 0f;
}
dictionary[key] += healthComponent.combinedHealth + healthComponent.missingCombinedHealth * 4f;
if (dictionary[key] > num)
{
num = dictionary[key];
if (string.IsNullOrEmpty(text))
{
text = Language.GetString("NULL_SUBTITLE");
}
self.bestObservedName = bestBodyName;
self.bestObservedSubtitle = "<sprite name=\"CloudLeft\" tint=1> " + text + " <sprite name=\"CloudRight\" tint=1>";
}
}
}
}
}