using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using MildMayhem.Art;
using MildMayhem.Cards;
using MildMayhem.Effects;
using RarityLib.Utils;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("StrongeGurke")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MildMayhem")]
[assembly: AssemblyTitle("MildMayhem")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MildMayhem
{
internal static class Fx
{
private sealed class Floater : MonoBehaviour
{
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)this).transform;
transform.position += Vector3.up * (1.2f * Time.deltaTime);
}
}
private static Font font;
public static void Pop(Vector3 worldPos, string text, Color color)
{
//IL_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
try
{
if ((Object)(object)font == (Object)null)
{
font = LoadFont();
}
if (!((Object)(object)font == (Object)null))
{
GameObject val = new GameObject("MildMayhem_Pop");
val.transform.position = worldPos;
TextMesh obj = val.AddComponent<TextMesh>();
obj.text = text;
obj.font = font;
obj.fontSize = 48;
obj.characterSize = 0.12f;
obj.anchor = (TextAnchor)4;
obj.color = color;
((Renderer)val.GetComponent<MeshRenderer>()).material = font.material;
((Renderer)val.GetComponent<MeshRenderer>()).sortingOrder = 500;
val.AddComponent<Floater>();
Object.Destroy((Object)val, 1.2f);
}
}
catch
{
}
}
private static Font LoadFont()
{
try
{
return Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
}
catch
{
}
try
{
return Resources.GetBuiltinResource<Font>("Arial.ttf");
}
catch
{
}
return null;
}
}
internal static class GameApi
{
private static readonly FieldInfo AmmoField = typeof(GunAmmo).GetField("currentAmmo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
public static bool IsOwner(CharacterData d)
{
if (!((Object)(object)d.view == (Object)null))
{
return d.view.IsMine;
}
return true;
}
public static int ViewId(CharacterData d)
{
if (!((Object)(object)d.view != (Object)null))
{
return 0;
}
return d.view.ViewID;
}
public static float HealthFraction(CharacterData d)
{
if (!(d.maxHealth <= 0f))
{
return d.health / d.maxHealth;
}
return 1f;
}
public static void AddImpulse(CharacterData d, Vector2 impulse)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Rigidbody2D component = ((Component)d).GetComponent<Rigidbody2D>();
if ((Object)(object)component != (Object)null)
{
component.AddForce(impulse, (ForceMode2D)1);
}
}
public static int GetAmmo(GunAmmo ammo)
{
if (!(AmmoField != null))
{
return 0;
}
return (int)AmmoField.GetValue(ammo);
}
public static void SetAmmo(GunAmmo ammo, int value)
{
if (AmmoField != null)
{
AmmoField.SetValue(ammo, value);
}
}
public static void ResetBlockCooldown(Block block)
{
block.ResetCD(false);
}
public static void ScaleBulletDamage(GameObject bullet, float mult)
{
if (!Mathf.Approximately(mult, 1f))
{
ProjectileHit component = bullet.GetComponent<ProjectileHit>();
if ((Object)(object)component != (Object)null)
{
component.damage *= mult;
}
}
}
public static void ScaleBulletSpeed(GameObject bullet, float mult)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
MoveTransform component = bullet.GetComponent<MoveTransform>();
if ((Object)(object)component != (Object)null)
{
component.velocity *= mult;
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.strongegurke.mildmayhem", "Mild Mayhem", "1.0.0")]
[BepInProcess("Rounds.exe")]
public sealed class Plugin : BaseUnityPlugin
{
public const string Guid = "com.strongegurke.mildmayhem";
public const string Version = "1.0.0";
internal static ManualLogSource Log;
internal static string AssetDir;
internal static bool AnimatedArt;
private void Awake()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
AssetDir = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets");
AnimatedArt = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "AnimatedCardArt", true, "Play the small idle animations on card art.").Value;
RarityUtils.AddRarity("Unfathomable", 0.002f, new Color(1f, 0.8f, 0.2f), new Color(0.35f, 0.1f, 0.5f));
}
private void Start()
{
CustomCard.BuildCard<PogoRecoilCard>();
CustomCard.BuildCard<SneezingFitCard>();
CustomCard.BuildCard<BananaPeelCard>();
CustomCard.BuildCard<CannonballPotatoCard>();
CustomCard.BuildCard<RunningStartCard>();
CustomCard.BuildCard<CoinFlipCard>();
CustomCard.BuildCard<PanicButtonCard>();
CustomCard.BuildCard<WobblyRoundsCard>();
CustomCard.BuildCard<MoonBootsCard>();
CustomCard.BuildCard<PunchCardCard>();
CustomCard.BuildCard<SlowBurnCard>();
CustomCard.BuildCard<CounterPunchCard>();
CustomCard.BuildCard<OnlyClaudeKnowsCard>();
GameModeManager.AddHook("RoundStart", (Func<IGameModeHandler, IEnumerator>)ResetRound);
GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)ResetGame);
Log.LogInfo((object)"Mild Mayhem 1.0.0 loaded: 13 cards registered.");
}
private static IEnumerator ResetRound(IGameModeHandler gm)
{
MayhemEffect.ResetAllForNewRound();
yield break;
}
private static IEnumerator ResetGame(IGameModeHandler gm)
{
MayhemEffect.DestroyAll();
yield break;
}
}
}
namespace MildMayhem.Effects
{
public sealed class PogoRecoilEffect : MayhemEffect
{
private const float Impulse = 5.5f;
private const float Cooldown = 0.35f;
private float next;
protected override void Begin()
{
Pipeline.AfterVolley += OnVolley;
}
protected override void End()
{
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.AfterVolley -= OnVolley;
}
}
private void OnVolley()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (!base.Dead && !Data.isGrounded && !(Time.time < next) && GameApi.IsOwner(Data))
{
next = Time.time + 0.35f;
Vector2 val = Vector2.op_Implicit(Data.aimDirection);
GameApi.AddImpulse(Data, -((Vector2)(ref val)).normalized * (5.5f * Mathf.Min(base.Scale, 2f)));
}
}
}
public sealed class SneezeEffect : MayhemEffect
{
private const float Interval = 7f;
private const float SpreadAdd = 0.15f;
private const float TotalDamage = 1.5f;
private float timer;
private bool armed;
private int extra;
private float dmgMult;
protected override void Begin()
{
Pipeline.AfterVolley += Disarm;
}
protected override void End()
{
Disarm();
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.AfterVolley -= Disarm;
}
}
protected override void OnRoundReset()
{
Disarm();
timer = 0f;
}
private void Update()
{
if (!armed && !base.Dead)
{
timer += Time.deltaTime;
if (timer >= 7f)
{
Arm();
}
}
}
private void Arm()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
armed = true;
extra = 2 + 2 * base.Stacks;
dmgMult = 1.5f / (float)(1 + extra);
Gun gun = Gun;
gun.numberOfProjectiles += extra;
Gun gun2 = Gun;
gun2.spread += 0.15f;
Gun gun3 = Gun;
gun3.damage *= dmgMult;
Fx.Pop(((Component)Owner).transform.position + Vector3.up * 1.6f, "*sniff*", Color.white);
}
private void Disarm()
{
if (armed)
{
armed = false;
timer = 0f;
Gun gun = Gun;
gun.numberOfProjectiles -= extra;
Gun gun2 = Gun;
gun2.spread -= 0.15f;
Gun gun3 = Gun;
gun3.damage /= dmgMult;
}
}
}
public sealed class BananaPeelEffect : MayhemEffect
{
private const float Duration = 2f;
private const float SpeedBonus = 0.45f;
private const float JumpPenalty = 0.15f;
private Action<BlockTriggerType> handler;
private bool active;
private float end;
private float dSpeed;
private float dJump;
protected override void Begin()
{
handler = delegate
{
Trigger();
};
Block block = Block;
block.BlockAction = (Action<BlockTriggerType>)Delegate.Combine(block.BlockAction, handler);
}
protected override void End()
{
Revert();
if ((Object)(object)Block != (Object)null)
{
Block block = Block;
block.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(block.BlockAction, handler);
}
}
protected override void OnRoundReset()
{
Revert();
}
private void Trigger()
{
if (!base.Dead)
{
end = Time.time + 2f;
if (!active)
{
active = true;
dSpeed = 0.45f * Mathf.Min(base.Scale, 2f);
dJump = 0.15f;
CharacterStatModifiers stats = Data.stats;
stats.movementSpeed += dSpeed;
CharacterStatModifiers stats2 = Data.stats;
stats2.jump -= dJump;
}
}
}
private void Revert()
{
if (active)
{
active = false;
CharacterStatModifiers stats = Data.stats;
stats.movementSpeed -= dSpeed;
CharacterStatModifiers stats2 = Data.stats;
stats2.jump += dJump;
}
}
private void Update()
{
if (active && Time.time >= end)
{
Revert();
}
}
}
public sealed class RunningStartEffect : MayhemEffect
{
private const float RefSpeed = 14f;
private const float MaxBonus = 0.4f;
private float lastX;
private float speed;
protected override void Begin()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
lastX = ((Component)Owner).transform.position.x;
Pipeline.Modify += Mod;
}
protected override void End()
{
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.Modify -= Mod;
}
}
protected override void OnRoundReset()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
speed = 0f;
lastX = ((Component)Owner).transform.position.x;
}
private void Update()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
float x = ((Component)Owner).transform.position.x;
float num = Mathf.Min(Mathf.Abs(x - lastX) / Mathf.Max(Time.deltaTime, 0.0001f), 21f);
speed = Mathf.Lerp(speed, num, 0.25f);
lastX = x;
}
private void Mod(ShotContext c)
{
c.DamageMult *= 1f + Mathf.Clamp01(speed / 14f) * 0.4f * Mathf.Min(base.Scale, 1.6f);
}
}
public sealed class CoinFlipEffect : MayhemEffect
{
private int magazine;
private int lastAmmo;
private bool heads;
protected override void Begin()
{
lastAmmo = GameApi.GetAmmo(Ammo);
Pipeline.Modify += Mod;
Flip();
}
protected override void End()
{
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.Modify -= Mod;
}
}
protected override void OnRoundReset()
{
lastAmmo = GameApi.GetAmmo(Ammo);
Flip();
}
private void Update()
{
int ammo = GameApi.GetAmmo(Ammo);
bool flag = Time.frameCount - Pipeline.LastRefundFrame <= 1;
if (ammo > lastAmmo && ammo >= Ammo.maxAmmo && !flag)
{
Flip();
}
lastAmmo = ammo;
}
private void Flip()
{
//IL_0059: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
Random random = new Random(GameApi.ViewId(Data) * 7919 + ++magazine * 104729);
heads = random.NextDouble() < 0.5;
if (!base.Dead)
{
Fx.Pop(((Component)Owner).transform.position + Vector3.up * 1.6f, heads ? "HEADS!" : "tails", (Color)(heads ? new Color(1f, 0.85f, 0.2f) : Color.gray));
}
}
private void Mod(ShotContext c)
{
c.DamageMult *= (heads ? (1f + 0.4f * Mathf.Min(base.Scale, 1.6f)) : 0.8f);
}
}
public sealed class PanicButtonEffect : MayhemEffect
{
private const float Threshold = 0.3f;
private const float Duration = 2f;
private const float SpeedBonus = 0.35f;
private int used;
private bool boosted;
private float end;
protected override void OnRoundReset()
{
used = 0;
Unboost();
}
protected override void End()
{
Unboost();
}
private void Update()
{
//IL_00c3: 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_00d2: 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)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
if (boosted && Time.time >= end)
{
Unboost();
}
if (!base.Dead && used < base.Stacks && !(Data.health <= 0f) && !(GameApi.HealthFraction(Data) >= 0.3f))
{
used++;
if (GameApi.IsOwner(Data))
{
GameApi.ResetBlockCooldown(Block);
}
if (!boosted)
{
boosted = true;
end = Time.time + 2f;
CharacterStatModifiers stats = Data.stats;
stats.movementSpeed += 0.35f;
}
Fx.Pop(((Component)Owner).transform.position + Vector3.up * 1.6f, "PANIC!", Color.red);
}
}
private void Unboost()
{
if (boosted)
{
boosted = false;
CharacterStatModifiers stats = Data.stats;
stats.movementSpeed -= 0.35f;
}
}
}
public sealed class WobblyEffect : MayhemEffect
{
private int shots;
protected override void Begin()
{
Pipeline.Modify += Mod;
}
protected override void End()
{
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.Modify -= Mod;
}
}
private void Mod(ShotContext c)
{
c.Bullet.AddComponent<BulletWobble>().Init(Mathf.Min(12f + 3f * (float)base.Stacks, 20f), (shots++ % 2 == 0) ? 1f : (-1f));
}
}
public sealed class BulletWobble : MonoBehaviour
{
private MoveTransform mt;
private float amp;
private float sign;
private float t;
private const float Freq = 9f;
public void Init(float amplitudeDegrees, float s)
{
amp = amplitudeDegrees;
sign = s;
mt = ((Component)this).GetComponent<MoveTransform>();
}
private void Update()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)mt == (Object)null))
{
t += Time.deltaTime;
float num = sign * amp * 9f * Mathf.Cos(9f * t) * Time.deltaTime;
mt.velocity = Quaternion.Euler(0f, 0f, num) * mt.velocity;
}
}
}
public sealed class PunchCardEffect : MayhemEffect
{
private int count;
protected override void Begin()
{
Pipeline.AfterVolley += OnVolley;
}
protected override void End()
{
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.AfterVolley -= OnVolley;
}
}
protected override void OnRoundReset()
{
count = 0;
}
private void OnVolley()
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if (++count >= Mathf.Max(3, 6 - base.Stacks))
{
count = 0;
Pipeline.LastRefundFrame = Time.frameCount;
GameApi.SetAmmo(Ammo, Mathf.Min(Ammo.maxAmmo, GameApi.GetAmmo(Ammo) + 1));
Fx.Pop(((Component)Owner).transform.position + Vector3.up * 1.6f, "FREE!", Color.green);
}
}
}
public sealed class SlowBurnEffect : MayhemEffect
{
private const float FullAfter = 4f;
private const float MaxBonus = 0.6f;
private float idle;
protected override void Begin()
{
Pipeline.Modify += Mod;
Pipeline.AfterVolley += Reset;
}
protected override void End()
{
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.Modify -= Mod;
Pipeline.AfterVolley -= Reset;
}
}
protected override void OnRoundReset()
{
idle = 0f;
}
private void Update()
{
if (!base.Dead)
{
idle += Time.deltaTime;
}
}
private void Reset()
{
idle = 0f;
}
private void Mod(ShotContext c)
{
c.DamageMult *= 1f + Mathf.Clamp01(idle / 4f) * 0.6f * Mathf.Min(base.Scale, 1.5f);
}
}
public sealed class CounterPunchEffect : MayhemEffect
{
private const float Window = 3f;
private const float DamageBonus = 0.8f;
private const float SpeedBonus = 0.3f;
private Action<BlockTriggerType> handler;
private float until;
protected override void Begin()
{
handler = delegate
{
until = Time.time + 3f;
};
Block block = Block;
block.BlockAction = (Action<BlockTriggerType>)Delegate.Combine(block.BlockAction, handler);
Pipeline.Modify += Mod;
Pipeline.AfterVolley += Consume;
}
protected override void End()
{
if ((Object)(object)Block != (Object)null)
{
Block block = Block;
block.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(block.BlockAction, handler);
}
if ((Object)(object)Pipeline != (Object)null)
{
Pipeline.Modify -= Mod;
Pipeline.AfterVolley -= Consume;
}
}
protected override void OnRoundReset()
{
until = 0f;
}
private void Mod(ShotContext c)
{
if (Time.time < until)
{
c.DamageMult *= 1f + 0.8f * Mathf.Min(base.Scale, 1.5f);
c.SpeedMult *= 1.3f;
}
}
private void Consume()
{
until = 0f;
}
}
public sealed class ChaosEffect : MayhemEffect
{
private const float Interval = 5f;
private const float Duration = 3f;
private float timer;
private float until;
private int tick;
private Action revert;
protected override void OnRoundReset()
{
Revert();
timer = 0f;
}
protected override void End()
{
Revert();
}
private void Update()
{
if (!base.Dead)
{
if (revert != null && Time.time >= until)
{
Revert();
}
timer += Time.deltaTime;
if (timer >= 5f && revert == null)
{
timer = 0f;
Trigger();
}
}
}
private void Revert()
{
Action action = revert;
revert = null;
action?.Invoke();
}
private void Trigger()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
Random random = new Random(GameApi.ViewId(Data) * 31337 + ++tick * 7727);
until = Time.time + 3f;
Vector3 worldPos = ((Component)Owner).transform.position + Vector3.up * 1.6f;
switch (random.Next(4))
{
case 0:
{
float d2 = -0.55f;
CharacterStatModifiers stats2 = Data.stats;
stats2.gravity += d2;
revert = delegate
{
CharacterStatModifiers stats3 = Data.stats;
stats3.gravity -= d2;
};
Fx.Pop(worldPos, "???", Color.magenta);
break;
}
case 1:
{
float d = 0.8f;
CharacterStatModifiers stats = Data.stats;
stats.movementSpeed += d;
revert = delegate
{
CharacterStatModifiers stats3 = Data.stats;
stats3.movementSpeed -= d;
};
Fx.Pop(worldPos, "ZOOM", Color.cyan);
break;
}
case 2:
{
Gun gun2 = Gun;
gun2.numberOfProjectiles += 3;
Gun gun3 = Gun;
gun3.spread += 0.1f;
revert = delegate
{
Gun gun4 = Gun;
gun4.numberOfProjectiles -= 3;
Gun gun5 = Gun;
gun5.spread -= 0.1f;
};
Fx.Pop(worldPos, "BULLET WEATHER", Color.yellow);
break;
}
default:
{
Gun gun = Gun;
gun.attackSpeed *= 0.5f;
revert = delegate
{
Gun gun4 = Gun;
gun4.attackSpeed *= 2f;
};
Fx.Pop(worldPos, "TURBO", Color.red);
break;
}
}
}
}
public abstract class MayhemEffect : MonoBehaviour
{
private static readonly List<MayhemEffect> All = new List<MayhemEffect>();
protected Player Owner;
protected CharacterData Data;
protected Gun Gun;
protected GunAmmo Ammo;
protected Block Block;
protected ShotPipeline Pipeline;
public int Stacks { get; private set; } = 1;
protected float Scale
{
get
{
float num = 0f;
float num2 = 1f;
for (int i = 0; i < Stacks; i++)
{
num += num2;
num2 *= 0.65f;
}
return num;
}
}
protected bool Dead
{
get
{
if (!((Object)(object)Data == (Object)null))
{
return Data.dead;
}
return true;
}
}
public static T Apply<T>(Player p, Gun gun, GunAmmo ammo, CharacterData data, Block block) where T : MayhemEffect
{
T component = ((Component)p).gameObject.GetComponent<T>();
if ((Object)(object)component != (Object)null)
{
int stacks = component.Stacks;
component.Stacks = stacks + 1;
component.StacksChanged();
return component;
}
component = ((Component)p).gameObject.AddComponent<T>();
component.Owner = p;
component.Data = data;
component.Gun = gun;
component.Ammo = ammo;
component.Block = block;
component.Pipeline = ShotPipeline.For(gun);
All.Add(component);
component.Begin();
return component;
}
public static void ResetAllForNewRound()
{
MayhemEffect[] array = All.ToArray();
foreach (MayhemEffect mayhemEffect in array)
{
if ((Object)(object)mayhemEffect != (Object)null)
{
mayhemEffect.OnRoundReset();
}
}
}
public static void DestroyAll()
{
MayhemEffect[] array = All.ToArray();
foreach (MayhemEffect mayhemEffect in array)
{
if ((Object)(object)mayhemEffect != (Object)null)
{
Object.Destroy((Object)(object)mayhemEffect);
}
}
All.Clear();
}
protected virtual void Begin()
{
}
protected virtual void StacksChanged()
{
}
protected virtual void OnRoundReset()
{
}
protected virtual void End()
{
}
private void OnDestroy()
{
End();
All.Remove(this);
}
}
public sealed class ShotContext
{
public GameObject Bullet;
public float DamageMult = 1f;
public float SpeedMult = 1f;
public bool FirstInVolley;
}
public sealed class ShotPipeline : MonoBehaviour
{
public const float MaxDamageMult = 2.2f;
public const float MaxSpeedMult = 1.5f;
public int LastRefundFrame = -10;
private Gun gun;
private int lastFrame = -1;
private bool open;
public event Action<ShotContext> Modify;
public event Action AfterVolley;
public static ShotPipeline For(Gun gun)
{
ShotPipeline component = ((Component)gun).GetComponent<ShotPipeline>();
if ((Object)(object)component != (Object)null)
{
return component;
}
component = ((Component)gun).gameObject.AddComponent<ShotPipeline>();
component.gun = gun;
gun.ShootPojectileAction = (Action<GameObject>)Delegate.Combine(gun.ShootPojectileAction, new Action<GameObject>(component.OnShoot));
return component;
}
private void OnShoot(GameObject bullet)
{
ShotContext shotContext = new ShotContext
{
Bullet = bullet,
FirstInVolley = (Time.frameCount != lastFrame)
};
lastFrame = Time.frameCount;
open = true;
this.Modify?.Invoke(shotContext);
GameApi.ScaleBulletDamage(bullet, Mathf.Clamp(shotContext.DamageMult, 0.1f, 2.2f));
if (!Mathf.Approximately(shotContext.SpeedMult, 1f))
{
GameApi.ScaleBulletSpeed(bullet, Mathf.Clamp(shotContext.SpeedMult, 0.5f, 1.5f));
}
}
private void LateUpdate()
{
if (open)
{
open = false;
this.AfterVolley?.Invoke();
}
}
private void OnDestroy()
{
if ((Object)(object)gun != (Object)null)
{
Gun obj = gun;
obj.ShootPojectileAction = (Action<GameObject>)Delegate.Remove(obj.ShootPojectileAction, new Action<GameObject>(OnShoot));
}
}
}
}
namespace MildMayhem.Cards
{
public sealed class PogoRecoilCard : MayhemCard
{
protected override string Id => "pogo_recoil";
protected override string Title => "Pogo Recoil";
protected override string Desc => "Shooting in mid-air kicks you the other way.";
protected override CardThemeColorType Theme => (CardThemeColorType)7;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Jump height", "+10%"),
MayhemCard.Stat(positive: true, "Air recoil", "Shoot to hop")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
statModifiers.jump = 1.1f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<PogoRecoilEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class SneezingFitCard : MayhemCard
{
protected override string Id => "sneezing_fit";
protected override string Title => "Sneezing Fit";
protected override string Desc => "Every 7 seconds your next shot is an unplanned shotgun.";
protected override Rarity RarityValue => (Rarity)1;
protected override CardThemeColorType Theme => (CardThemeColorType)5;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Bullets", "+4 every 7s"),
MayhemCard.Stat(positive: false, "Spread", "Messy")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<SneezeEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class BananaPeelCard : MayhemCard
{
protected override string Id => "banana_peel";
protected override string Title => "Banana Peel";
protected override string Desc => "Blocking makes you dangerously slippery.";
protected override CardThemeColorType Theme => (CardThemeColorType)1;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[3]
{
MayhemCard.Stat(positive: true, "Speed after block", "+45% for 2s"),
MayhemCard.Stat(positive: false, "Jump after block", "-15%"),
MayhemCard.Stat(positive: false, "Block cooldown", "+0.2s")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
block.cdAdd = 0.2f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<BananaPeelEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class CannonballPotatoCard : MayhemCard
{
protected override string Id => "cannonball_potato";
protected override string Title => "Cannonball Potato";
protected override string Desc => "Heavy, slow, and extremely offended.";
protected override CardThemeColorType Theme => (CardThemeColorType)6;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[3]
{
MayhemCard.Stat(positive: true, "Damage", "+40%"),
MayhemCard.Stat(positive: false, "Bullet speed", "-25%"),
MayhemCard.Stat(positive: false, "Reload time", "+0.3s")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
gun.damage = 1.4f;
gun.projectileSpeed = 0.75f;
gun.reloadTimeAdd = 0.3f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
}
}
public sealed class RunningStartCard : MayhemCard
{
protected override string Id => "running_start";
protected override string Title => "Running Start";
protected override string Desc => "The faster you run, the harder you hit.";
protected override Rarity RarityValue => (Rarity)1;
protected override CardThemeColorType Theme => (CardThemeColorType)0;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Damage at full sprint", "+40%"),
MayhemCard.Stat(positive: false, "Damage standing still", "+0%")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<RunningStartEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class CoinFlipCard : MayhemCard
{
protected override string Id => "coin_flip";
protected override string Title => "Coin Flip";
protected override string Desc => "Every magazine is a gamble. Heads wins, tails sulks.";
protected override Rarity RarityValue => (Rarity)1;
protected override CardThemeColorType Theme => (CardThemeColorType)3;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Heads", "+40% damage"),
MayhemCard.Stat(positive: false, "Tails", "-20% damage")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<CoinFlipEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class PanicButtonCard : MayhemCard
{
protected override string Id => "panic_button";
protected override string Title => "Panic Button";
protected override string Desc => "Below 30% health, once per round: block refreshed and you run for your life.";
protected override Rarity RarityValue => (Rarity)1;
protected override CardThemeColorType Theme => (CardThemeColorType)8;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Emergency", "Block reset + 35% speed"),
MayhemCard.Stat(positive: false, "Health", "-10%")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
statModifiers.health = 0.9f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<PanicButtonEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class WobblyRoundsCard : MayhemCard
{
protected override string Id => "wobbly_rounds";
protected override string Title => "Wobbly Rounds";
protected override string Desc => "Bullets that cannot walk in a straight line.";
protected override Rarity RarityValue => (Rarity)1;
protected override CardThemeColorType Theme => (CardThemeColorType)1;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[3]
{
MayhemCard.Stat(positive: true, "Damage", "+20%"),
MayhemCard.Stat(positive: true, "Bullet speed", "+10%"),
MayhemCard.Stat(positive: false, "Flight path", "Wobbly")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
gun.damage = 1.2f;
gun.projectileSpeed = 1.1f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<WobblyEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class MoonBootsCard : MayhemCard
{
protected override string Id => "moon_boots";
protected override string Title => "Moon Boots";
protected override string Desc => "Floaty, bouncy, and a little bit fragile.";
protected override CardThemeColorType Theme => (CardThemeColorType)4;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[3]
{
MayhemCard.Stat(positive: true, "Gravity", "-25%"),
MayhemCard.Stat(positive: true, "Jump height", "+15%"),
MayhemCard.Stat(positive: false, "Health", "-15%")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
statModifiers.gravity = 0.75f;
statModifiers.jump = 1.15f;
statModifiers.health = 0.85f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
}
}
public sealed class PunchCardCard : MayhemCard
{
protected override string Id => "punch_card";
protected override string Title => "Punch Card";
protected override string Desc => "Every 5th shot is on the house.";
protected override CardThemeColorType Theme => (CardThemeColorType)1;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[1] { MayhemCard.Stat(positive: true, "Free shot", "Every 5th") };
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<PunchCardEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class SlowBurnCard : MayhemCard
{
protected override string Id => "slow_burn";
protected override string Title => "Slow Burn";
protected override string Desc => "Patience is a weapon. Hold your fire to charge the next shot.";
protected override Rarity RarityValue => (Rarity)1;
protected override CardThemeColorType Theme => (CardThemeColorType)2;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Damage after 4s idle", "+60%"),
MayhemCard.Stat(positive: false, "Fire rate", "-15%")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
gun.attackSpeed = 1.15f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<SlowBurnEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class CounterPunchCard : MayhemCard
{
protected override string Id => "counter_punch";
protected override string Title => "Counter Punch";
protected override string Desc => "A well-timed block loads your next shot with spite.";
protected override Rarity RarityValue => (Rarity)2;
protected override CardThemeColorType Theme => (CardThemeColorType)2;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[2]
{
MayhemCard.Stat(positive: true, "Shot after block", "+80% dmg, +30% speed"),
MayhemCard.Stat(positive: false, "Block cooldown", "+0.15s")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
block.cdAdd = 0.15f;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<CounterPunchEffect>(player, gun, gunAmmo, data, block);
}
}
public sealed class OnlyClaudeKnowsCard : MayhemCard
{
public const string RarityName = "Unfathomable";
protected override string Id => "only_claude_knows";
protected override string Title => "Only Claude knows what's happening";
protected override string Desc => "Nobody knows what this does. Possibly everything. Good luck.";
protected override Rarity RarityValue => RarityUtils.GetRarity("Unfathomable");
protected override CardThemeColorType Theme => (CardThemeColorType)8;
protected override CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[10]
{
MayhemCard.Stat(positive: true, "Damage", "+100%"),
MayhemCard.Stat(positive: true, "Health", "+150%"),
MayhemCard.Stat(positive: true, "Fire rate", "x2"),
MayhemCard.Stat(positive: true, "Reload", "-60%"),
MayhemCard.Stat(positive: true, "Bullets", "+2"),
MayhemCard.Stat(positive: true, "Bounces", "+3"),
MayhemCard.Stat(positive: true, "Extra jumps", "+2"),
MayhemCard.Stat(positive: true, "Life steal", "+30%"),
MayhemCard.Stat(positive: true, "Extra life", "+1"),
MayhemCard.Stat(positive: false, "Reality", "Unreliable")
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
cardInfo.allowMultiple = false;
gun.damage = 2f;
gun.attackSpeed = 0.5f;
gun.reloadTime = 0.4f;
gun.projectileSpeed = 1.5f;
gun.knockback = 1.5f;
gun.numberOfProjectiles = 2;
gun.reflects = 3;
gun.ammo = 6;
statModifiers.health = 2.5f;
statModifiers.movementSpeed = 1.4f;
statModifiers.jump = 1.3f;
statModifiers.numberOfJumps = 2;
statModifiers.lifeSteal = 0.3f;
statModifiers.respawns = 1;
block.cdMultiplier = 0.4f;
block.additionalBlocks = 2;
}
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
MayhemEffect.Apply<ChaosEffect>(player, gun, gunAmmo, data, block);
}
}
public abstract class MayhemCard : CustomCard
{
protected abstract string Id { get; }
protected abstract string Title { get; }
protected abstract string Desc { get; }
protected virtual Rarity RarityValue => (Rarity)0;
protected virtual CardThemeColorType Theme => (CardThemeColorType)3;
protected virtual CardInfoStat[] StatList => (CardInfoStat[])(object)new CardInfoStat[0];
protected override string GetTitle()
{
return Title;
}
protected override string GetDescription()
{
return Desc;
}
protected override GameObject GetCardArt()
{
return CardArt.Get(Id);
}
protected override Rarity GetRarity()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return RarityValue;
}
protected override CardInfoStat[] GetStats()
{
return StatList;
}
protected override CardThemeColorType GetTheme()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return Theme;
}
public override string GetModName()
{
return "MILD";
}
protected static CardInfoStat Stat(bool positive, string name, string amount)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
return new CardInfoStat
{
positive = positive,
stat = name,
amount = amount,
simepleAmount = (SimpleAmount)0
};
}
}
}
namespace MildMayhem.Art
{
internal static class CardArt
{
private static readonly Dictionary<string, GameObject> Cache = new Dictionary<string, GameObject>();
public static GameObject Get(string id)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
if (Cache.TryGetValue(id, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
List<Sprite> list = new List<Sprite>();
for (int i = 0; i < 16; i++)
{
string path = Path.Combine(Plugin.AssetDir, "Cards", id + "_" + i + ".png");
if (!File.Exists(path))
{
break;
}
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
{
filterMode = (FilterMode)1
};
if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
{
break;
}
list.Add(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f));
}
if (list.Count == 0)
{
Plugin.Log.LogWarning((object)("No art frames found for " + id));
return null;
}
GameObject val2 = new GameObject("MildMayhem_Art_" + id);
val2.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)val2);
RectTransform obj = val2.AddComponent<RectTransform>();
obj.anchorMin = Vector2.zero;
obj.anchorMax = Vector2.one;
Vector2 offsetMin = (obj.offsetMax = Vector2.zero);
obj.offsetMin = offsetMin;
Image val3 = val2.AddComponent<Image>();
val3.sprite = list[0];
val3.preserveAspect = true;
((Graphic)val3).raycastTarget = false;
if (Plugin.AnimatedArt && list.Count > 1)
{
val2.AddComponent<FrameAnimator>().Setup(val3, list.ToArray(), 4f);
}
Cache[id] = val2;
return val2;
}
}
internal sealed class FrameAnimator : MonoBehaviour
{
private Image image;
private Sprite[] frames;
private float fps;
public void Setup(Image img, Sprite[] f, float framesPerSecond)
{
image = img;
frames = f;
fps = framesPerSecond;
}
private void Update()
{
if (!((Object)(object)image == (Object)null) && frames != null && frames.Length != 0)
{
image.sprite = frames[(int)(Time.unscaledTime * fps) % frames.Length];
}
}
}
}