using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DeathNoteMod.Cards;
using DeathNoteMod.Helpers;
using DeathNoteMod.MonoBehaviours;
using DeathNoteMod.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using Photon.Pun;
using RarityLib.Utils;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DeathNoteMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DeathNoteMod")]
[assembly: AssemblyTitle("DeathNoteMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 DeathNoteMod
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.hugo.rounds.deathnote", "Death Note", "1.1.0")]
[BepInProcess("Rounds.exe")]
public class DeathNotePlugin : BaseUnityPlugin
{
public const string ModId = "com.hugo.rounds.deathnote";
public const string ModName = "Death Note";
public const string Version = "1.1.0";
public const string ModInitials = "DN";
public static DeathNotePlugin Instance { get; private set; }
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
RarityUtils.AddRarity("OverclockTier", 0.01f, new Color(1f, 0.85f, 0.2f), new Color(0.55f, 0.45f, 0.05f));
RarityUtils.AddRarity("DamnationTier", 0.005f, new Color(0.55f, 0.02f, 0.08f), new Color(0.25f, 0f, 0.02f));
new Harmony("com.hugo.rounds.deathnote").PatchAll();
}
private void Start()
{
ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 20, (Action)delegate
{
CustomCard.BuildCard<DeathNoteCard>();
CustomCard.BuildCard<OverclockCard>((Action<CardInfo>)delegate(CardInfo ci)
{
OverclockCard.Card = ci;
});
CustomCard.BuildCard<DamnationCard>((Action<CardInfo>)delegate(CardInfo ci)
{
DamnationCard.Card = ci;
});
});
GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)ClearDeathNotes);
GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)ClearDeathNotes);
GameModeManager.AddHook("GameEnd", (Func<IGameModeHandler, IEnumerator>)ClearDeathNotes);
GameModeManager.AddHook("PlayerPickEnd", (Func<IGameModeHandler, IEnumerator>)ResetDamnationHand);
Unbound.RegisterCredits("Death Note", new string[1] { "Hugo" }, "Death Note + legendaries", "");
}
private static IEnumerator ClearDeathNotes(IGameModeHandler gm)
{
DeathNoteEffect[] array = Object.FindObjectsOfType<DeathNoteEffect>();
for (int i = 0; i < array.Length; i++)
{
array[i].ClearAllBanks();
}
yield break;
}
private static IEnumerator ResetDamnationHand(IGameModeHandler gm)
{
DamnationForcedHandPatch.ForceDamnationHand = false;
yield break;
}
}
}
namespace DeathNoteMod.Patches
{
[HarmonyPatch(typeof(CardChoice), "SpawnUniqueCard")]
internal static class DamnationForcedHandPatch
{
internal static bool ForceDamnationHand;
private static bool Prefix(CardChoice __instance, Vector3 position, Quaternion rotation, ref GameObject __result)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (!ForceDamnationHand || (Object)(object)DamnationCard.Card == (Object)null)
{
return true;
}
__result = Traverse.Create((object)__instance).Method("Spawn", new object[3]
{
((Component)DamnationCard.Card).gameObject,
position,
rotation
}).GetValue<GameObject>();
if ((Object)(object)__result != (Object)null)
{
__result.GetOrAddComponent<NonRefreshableCard>();
}
return false;
}
private static void Postfix(CardChoice __instance, GameObject __result)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__result == (Object)null || (Object)(object)DamnationCard.Card == (Object)null || !IsDamnation(__result))
{
return;
}
ForceDamnationHand = true;
__result.GetOrAddComponent<NonRefreshableCard>();
List<GameObject> value = Traverse.Create((object)__instance).Field("spawnedCards").GetValue<List<GameObject>>();
if (value == null)
{
return;
}
for (int i = 0; i < value.Count; i++)
{
GameObject val = value[i];
if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)__result) && !IsDamnation(val))
{
Vector3 position = val.transform.position;
Quaternion rotation = val.transform.rotation;
int theInt = val.GetComponent<PublicInt>()?.theInt ?? i;
if (PhotonNetwork.IsConnected)
{
PhotonNetwork.Destroy(val);
}
else
{
Object.Destroy((Object)(object)val);
}
GameObject value2 = Traverse.Create((object)__instance).Method("SpawnUniqueCard", new object[2] { position, rotation }).GetValue<GameObject>();
if (!((Object)(object)value2 == (Object)null))
{
value[i] = value2;
(value2.GetComponent<PublicInt>() ?? value2.AddComponent<PublicInt>()).theInt = theInt;
value2.GetOrAddComponent<NonRefreshableCard>();
}
}
}
}
private static bool IsDamnation(GameObject go)
{
CardInfo component = go.GetComponent<CardInfo>();
if ((Object)(object)component == (Object)null)
{
return false;
}
if (!(component.cardName == "Damnation"))
{
if ((Object)(object)DamnationCard.Card != (Object)null)
{
return (Object)(object)component.sourceCard == (Object)(object)DamnationCard.Card;
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(CardChoice), "StartPick")]
internal static class DamnationResetOnPickPatch
{
private static void Prefix()
{
DamnationForcedHandPatch.ForceDamnationHand = false;
}
}
[HarmonyPatch(typeof(HealthHandler), "DoDamage")]
public static class HealthHandlerDoDamagePatch
{
private static bool Prefix(HealthHandler __instance, Vector2 damage, Vector2 position, Color blinkColor, GameObject damagingWeapon, Player damagingPlayer, bool healthRemoval, bool lethal, bool ignoreBlock)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (DeathNoteEffect.IsReleasing)
{
return true;
}
if ((Object)(object)damagingPlayer == (Object)null)
{
return true;
}
DeathNoteEffect component = ((Component)damagingPlayer).GetComponent<DeathNoteEffect>();
if ((Object)(object)component == (Object)null)
{
return true;
}
Player component2 = ((Component)__instance).GetComponent<Player>();
if ((Object)(object)component2 == (Object)null)
{
return true;
}
return !component.TryBankDamage(component2, damage, position, blinkColor, damagingWeapon, healthRemoval, lethal, ignoreBlock);
}
}
}
namespace DeathNoteMod.MonoBehaviours
{
public class DeathNoteEffect : MonoBehaviour
{
private class DamageBank
{
public Player target;
public float totalDamage;
public Vector2 lastPosition;
public Color blinkColor;
public GameObject damagingWeapon;
public bool healthRemoval;
public bool lethal;
public bool ignoreBlock;
public Coroutine releaseRoutine;
}
public const float DelaySeconds = 15f;
private Player owner;
private readonly Dictionary<int, DamageBank> banks = new Dictionary<int, DamageBank>();
public static bool IsReleasing { get; private set; }
private void Awake()
{
owner = ((Component)this).GetComponent<Player>();
}
public bool TryBankDamage(Player target, Vector2 damage, Vector2 position, Color blinkColor, GameObject damagingWeapon, bool healthRemoval, bool lethal, bool ignoreBlock)
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)target == (Object)null || (Object)(object)owner == (Object)null)
{
return false;
}
if (target.playerID == owner.playerID)
{
return false;
}
int playerID = target.playerID;
if (!banks.TryGetValue(playerID, out var value))
{
value = new DamageBank
{
target = target,
totalDamage = 0f,
lastPosition = position,
blinkColor = blinkColor,
damagingWeapon = damagingWeapon,
healthRemoval = healthRemoval,
lethal = lethal,
ignoreBlock = ignoreBlock
};
banks[playerID] = value;
value.releaseRoutine = ((MonoBehaviour)this).StartCoroutine(ReleaseAfterDelay(playerID));
}
value.totalDamage += ((Vector2)(ref damage)).magnitude;
value.lastPosition = position;
value.blinkColor = blinkColor;
value.damagingWeapon = damagingWeapon;
value.healthRemoval = healthRemoval || value.healthRemoval;
value.lethal = lethal || value.lethal;
value.ignoreBlock = ignoreBlock || value.ignoreBlock;
banks[playerID] = value;
return true;
}
private IEnumerator ReleaseAfterDelay(int targetId)
{
yield return (object)new WaitForSecondsRealtime(15f);
if (!banks.TryGetValue(targetId, out var value))
{
yield break;
}
banks.Remove(targetId);
if ((Object)(object)value.target == (Object)null || value.totalDamage <= 0f)
{
yield break;
}
HealthHandler val = value.target.data?.healthHandler;
if ((Object)(object)val == (Object)null)
{
yield break;
}
Vector2 val2 = Vector2.up * value.totalDamage;
IsReleasing = true;
try
{
val.DoDamage(val2, value.lastPosition, value.blinkColor, value.damagingWeapon, owner, value.healthRemoval, value.lethal, value.ignoreBlock);
}
finally
{
IsReleasing = false;
}
}
public void ClearAllBanks()
{
foreach (DamageBank value in banks.Values)
{
if (value.releaseRoutine != null)
{
((MonoBehaviour)this).StopCoroutine(value.releaseRoutine);
}
}
banks.Clear();
}
private void OnDisable()
{
ClearAllBanks();
}
}
public class NonRefreshableCard : MonoBehaviour
{
}
}
namespace DeathNoteMod.Helpers
{
public static class CardEffectHelper
{
public static void DoubleAllCardEffectsExceptLives(Player player)
{
if (player?.data?.currentCards == null)
{
return;
}
CharacterStatModifiers stats = player.data.stats;
int respawns = stats.respawns;
int remainingRespawns = stats.remainingRespawns;
foreach (CardInfo item in new List<CardInfo>(player.data.currentCards))
{
if (!((Object)(object)item == (Object)null))
{
Cards.instance.AddCardToPlayer(player, item, true, "", 0f, 0f, false);
}
}
stats.respawns = respawns;
stats.remainingRespawns = remainingRespawns;
}
public static void DoubleExistingDebuffs(Player player)
{
if ((Object)(object)player?.data == (Object)null)
{
return;
}
CharacterStatModifiers stats = player.data.stats;
WorsenMultiplier(ref stats.health);
WorsenMultiplier(ref stats.movementSpeed);
WorsenMultiplier(ref stats.jump);
WorsenAboveBaseline(ref stats.gravity);
if (stats.slow > 0f)
{
stats.slow *= 2f;
}
if (stats.slowSlow > 0f)
{
stats.slowSlow *= 2f;
}
Holding component = ((Component)player).GetComponent<Holding>();
object obj;
if (component == null)
{
obj = null;
}
else
{
Holdable holdable = component.holdable;
obj = ((holdable != null) ? ((Component)holdable).GetComponent<Gun>() : null);
}
if (obj == null)
{
obj = ((Component)player).GetComponentInChildren<Gun>();
}
Gun val = (Gun)obj;
if (!((Object)(object)val == (Object)null))
{
WorsenMultiplier(ref val.damage);
WorsenMultiplier(ref val.projectileSpeed);
WorsenAboveBaseline(ref val.attackSpeed);
WorsenAboveBaseline(ref val.reloadTime);
WorsenAboveBaseline(ref val.spread);
WorsenAboveBaseline(ref val.gravity);
if (val.ammo < 0)
{
val.ammo *= 2;
}
}
}
private static void WorsenMultiplier(ref float value)
{
if (!(value >= 1f))
{
value = 1f - (1f - value) * 2f;
if (value < 0.05f)
{
value = 0.05f;
}
}
}
private static void WorsenAboveBaseline(ref float value)
{
if (!(value <= 1f))
{
value = 1f + (value - 1f) * 2f;
}
}
}
}
namespace DeathNoteMod.Cards
{
public class DamnationCard : CustomCard
{
public const string RarityName = "DamnationTier";
public const string CardTitle = "Damnation";
public static CardInfo Card { get; set; }
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
cardInfo.allowMultiple = false;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
CardEffectHelper.DoubleExistingDebuffs(player);
}
public override void Callback()
{
((Component)this).gameObject.GetOrAddComponent<NonRefreshableCard>();
}
protected override string GetTitle()
{
return "Damnation";
}
protected override string GetDescription()
{
return "Double all your debuffs. When this appears, it fills every card slot. Cannot be reshuffled.";
}
protected override GameObject GetCardArt()
{
return null;
}
protected override Rarity GetRarity()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return RarityUtils.GetRarity("DamnationTier");
}
protected override CardThemeColorType GetTheme()
{
return (CardThemeColorType)4;
}
protected override CardInfoStat[] GetStats()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
return (CardInfoStat[])(object)new CardInfoStat[2]
{
new CardInfoStat
{
positive = false,
stat = "Debuffs",
amount = "x2",
simepleAmount = (SimpleAmount)3
},
new CardInfoStat
{
positive = false,
stat = "Hand",
amount = "Forced",
simepleAmount = (SimpleAmount)0
}
};
}
public override string GetModName()
{
return "DN";
}
}
public class DeathNoteCard : CustomCard
{
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
cardInfo.allowMultiple = false;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
((Component)player).gameObject.GetOrAddComponent<DeathNoteEffect>();
}
public override void OnRemoveCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
DeathNoteEffect component = ((Component)player).GetComponent<DeathNoteEffect>();
if ((Object)(object)component != (Object)null)
{
component.ClearAllBanks();
Object.Destroy((Object)(object)component);
}
}
protected override string GetTitle()
{
return "Death Note";
}
protected override string GetDescription()
{
return "Your damage is stored. After 15 seconds, all pent-up damage hits at once.";
}
protected override GameObject GetCardArt()
{
return null;
}
protected override Rarity GetRarity()
{
return (Rarity)2;
}
protected override CardThemeColorType GetTheme()
{
return (CardThemeColorType)4;
}
protected override CardInfoStat[] GetStats()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
return (CardInfoStat[])(object)new CardInfoStat[1]
{
new CardInfoStat
{
positive = true,
stat = "Damage",
amount = "Delayed 15s",
simepleAmount = (SimpleAmount)0
}
};
}
public override string GetModName()
{
return "DN";
}
}
internal static class ComponentExtensions
{
public static T GetOrAddComponent<T>(this GameObject go) where T : Component
{
T component = go.GetComponent<T>();
if (!((Object)(object)component != (Object)null))
{
return go.AddComponent<T>();
}
return component;
}
}
public class OverclockCard : CustomCard
{
public const string RarityName = "OverclockTier";
public static CardInfo Card { get; set; }
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
cardInfo.allowMultiple = false;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
CardEffectHelper.DoubleAllCardEffectsExceptLives(player);
}
protected override string GetTitle()
{
return "Overclock";
}
protected override string GetDescription()
{
return "Double all your active card effects. Does not affect extra lives.";
}
protected override GameObject GetCardArt()
{
return null;
}
protected override Rarity GetRarity()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return RarityUtils.GetRarity("OverclockTier");
}
protected override CardThemeColorType GetTheme()
{
return (CardThemeColorType)1;
}
protected override CardInfoStat[] GetStats()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
return (CardInfoStat[])(object)new CardInfoStat[2]
{
new CardInfoStat
{
positive = true,
stat = "Card Effects",
amount = "x2",
simepleAmount = (SimpleAmount)3
},
new CardInfoStat
{
positive = true,
stat = "Extra Lives",
amount = "Unaffected",
simepleAmount = (SimpleAmount)0
}
};
}
public override string GetModName()
{
return "DN";
}
}
}