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 RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Navigation;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArtifactOfGreed")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArtifactOfGreed")]
[assembly: AssemblyTitle("ArtifactOfGreed")]
[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 TaxGreed
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.gogogadgetjustice.taxevasion", "Tax Evasion", "1.2.0")]
public class TaxGreedPlugin : BaseUnityPlugin
{
public class TaxmanMarker : MonoBehaviour
{
}
public class MoneyEffectController : MonoBehaviour
{
private CharacterBody body;
private float effectTimer = 0f;
private float coinSpawnTimer = 0f;
private const float EFFECT_INTERVAL = 1f;
private const float COIN_INTERVAL = 0.3f;
private void Start()
{
body = ((Component)this).GetComponent<CharacterBody>();
Chat.AddMessage("<color=#FFD700>MoneyEffectController started on " + ((Object)body).name + "</color>");
}
private void FixedUpdate()
{
if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
{
effectTimer += Time.fixedDeltaTime;
coinSpawnTimer += Time.fixedDeltaTime;
if (effectTimer >= 1f)
{
effectTimer = 0f;
SpawnDollarSignEffect();
}
if (coinSpawnTimer >= 0.3f)
{
coinSpawnTimer = 0f;
SpawnCoinBurst();
}
}
}
private void SpawnDollarSignEffect()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0088: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)body))
{
return;
}
Vector3 corePosition = body.corePosition;
int num = Random.Range(2, 4);
for (int i = 0; i < num; i++)
{
Vector3 val = Random.insideUnitSphere * 2.5f;
val.y = Mathf.Abs(val.y) + 1f;
Vector3 val2 = corePosition + val;
if (Object.op_Implicit((Object)(object)DamageNumberManager.instance))
{
DamageNumberManager.instance.SpawnDamageNumber((float)Random.Range(10, 999), val2, false, (TeamIndex)2, (DamageColorIndex)11);
}
}
}
private void SpawnCoinBurst()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//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_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
if (Object.op_Implicit((Object)(object)body))
{
Vector3 corePosition = body.corePosition;
Vector3 val = Random.insideUnitSphere * 1.8f;
val.y = Mathf.Abs(val.y);
Vector3 val2 = corePosition + val;
GameObject val3 = Resources.Load<GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact");
if (Object.op_Implicit((Object)(object)val3))
{
EffectManager.SimpleImpactEffect(val3, val2, Vector3.up, true);
}
if (Object.op_Implicit((Object)(object)val3) && Random.value > 0.5f)
{
EffectData val4 = new EffectData
{
origin = val2,
scale = 1f,
color = Color32.op_Implicit(new Color(1f, 0.84f, 0f, 1f))
};
EffectManager.SpawnEffect(val3, val4, true);
}
}
}
}
public const string ModGuid = "com.gogogadgetjustice.taxevasion";
public const string ModName = "Tax Evasion";
public const string ModVer = "1.2.0";
public static ConfigEntry<bool> ModEnabled;
public static ConfigEntry<int> MinGoldThreshold;
public static ConfigEntry<float> StartDelay;
public static ConfigEntry<float> SpawnInterval;
public static ConfigEntry<float> TaxPercentage;
public static ConfigEntry<uint> LunarCoinLossPerHit;
private float runStopwatch = 0f;
private float spawnTimer = 0f;
private bool isInvasionActive = false;
private uint goldTaxGoal = 0u;
private uint totalGoldCollected = 0u;
private List<SurvivorDef> remainingSurvivors = new List<SurvivorDef>();
private List<CharacterMaster> activeTaxmen = new List<CharacterMaster>();
private void Awake()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
SetupConfig();
HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
CharacterBody.Start += new hook_Start(CharacterBody_Start);
Run.onRunStartGlobal += delegate
{
ResetInvasion();
};
}
private void SetupConfig()
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Expected O, but got Unknown
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Is the mod active?");
StartDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Logic", "Start Delay", 100f, "Seconds to wait before the taxman starts checking gold levels.");
MinGoldThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Logic", "Min Gold Threshold", 100, "Minimum gold a player must have to trigger the invasion.");
SpawnInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Logic", "Spawn Interval", 10f, "Seconds to wait before adding the next survivor class to the field.");
TaxPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("Logic", "Tax Percentage", 8.2f, "Percentage of the player's gold the taxmen aim to collect (0.1 = 10%).");
LunarCoinLossPerHit = ((BaseUnityPlugin)this).Config.Bind<uint>("Combat", "Lunar Coin Loss", 1u, "Lunar Coins lost per hit.");
ModSettingsManager.SetModIcon((Sprite)null);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ModEnabled));
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(StartDelay, new StepSliderConfig
{
min = 0f,
max = 1800f,
increment = 30f
}));
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MinGoldThreshold, new IntSliderConfig
{
min = 10,
max = 10000
}));
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(SpawnInterval, new StepSliderConfig
{
min = 5f,
max = 120f,
increment = 5f
}));
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(TaxPercentage, new StepSliderConfig
{
min = 0.01f,
max = 1f,
increment = 0.01f
}));
}
private void ResetInvasion()
{
isInvasionActive = false;
runStopwatch = 0f;
spawnTimer = 0f;
totalGoldCollected = 0u;
activeTaxmen.Clear();
remainingSurvivors.Clear();
}
private void Update()
{
if (!NetworkServer.active || !ModEnabled.Value || !Object.op_Implicit((Object)(object)Run.instance) || Run.instance.isRunStopwatchPaused)
{
return;
}
runStopwatch += Time.deltaTime;
if (!isInvasionActive)
{
if (runStopwatch >= StartDelay.Value)
{
CheckForHighWealth();
}
return;
}
spawnTimer += Time.deltaTime;
if (spawnTimer >= SpawnInterval.Value)
{
spawnTimer = 0f;
SpawnNextTaxman();
}
if (totalGoldCollected >= goldTaxGoal)
{
EndInvasion("Tax goal reached. The Collectors retreat.");
}
}
private void CheckForHighWealth()
{
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
if (instance.master.money >= MinGoldThreshold.Value)
{
StartInvasion(instance.master);
break;
}
}
}
private void StartInvasion(CharacterMaster target)
{
//IL_0046: 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_006b: Expected O, but got Unknown
isInvasionActive = true;
totalGoldCollected = 0u;
goldTaxGoal = (uint)((float)target.money * TaxPercentage.Value);
remainingSurvivors = SurvivorCatalog.allSurvivorDefs.ToList();
ShuffleList(remainingSurvivors);
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = $"<color=#e5da64>Taxation Notification: Target collection goal: ${goldTaxGoal}.</color>"
});
SpawnNextTaxman();
}
private void SpawnNextTaxman()
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
if (remainingSurvivors.Count == 0)
{
return;
}
SurvivorDef val = remainingSurvivors[0];
remainingSurvivors.RemoveAt(0);
string text = ((Object)val.bodyPrefab).name.Replace("Body", "MonsterMaster");
GameObject val2 = MasterCatalog.FindMasterPrefab(text);
if (!Object.op_Implicit((Object)(object)val2))
{
val2 = MasterCatalog.FindMasterPrefab("CommandoMonsterMaster");
}
CharacterMaster master = PlayerCharacterMasterController.instances[Random.Range(0, PlayerCharacterMasterController.instances.Count)].master;
Vector3 val3 = (Object.op_Implicit((Object)(object)master.GetBody()) ? master.GetBody().footPosition : Vector3.zero);
NodeGraph groundNodes = SceneInfo.instance.groundNodes;
List<NodeIndex> list = groundNodes.FindNodesInRange(val3, 20f, 100f, (HullMask)0);
if (list.Count > 0)
{
groundNodes.GetNodePosition(list[Random.Range(0, list.Count)], ref val3);
}
CharacterMaster val4 = new MasterSummon
{
masterPrefab = val2,
position = val3,
rotation = Quaternion.identity,
teamIndexOverride = (TeamIndex)2,
ignoreTeamMemberLimit = true
}.Perform();
if (Object.op_Implicit((Object)(object)val4))
{
((Component)val4).gameObject.AddComponent<TaxmanMarker>();
if (Object.op_Implicit((Object)(object)master.inventory))
{
val4.inventory.CopyItemsFrom(master.inventory);
}
val4.inventory.GiveItemPermanent(Items.InvadingDoppelganger, 1);
activeTaxmen.Add(val4);
SpawnGoldEffect(val3);
}
}
private void CharacterBody_Start(orig_Start orig, CharacterBody self)
{
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)self.master) && Object.op_Implicit((Object)(object)((Component)self.master).GetComponent<TaxmanMarker>()))
{
Chat.AddMessage("<color=#FFD700>Tax Collector body spawned! Adding effects to " + ((Object)self).name + "...</color>");
if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<MoneyEffectController>()))
{
MoneyEffectController moneyEffectController = ((Component)self).gameObject.AddComponent<MoneyEffectController>();
Chat.AddMessage("<color=#FFD700>MoneyEffectController component added!</color>");
}
}
}
private void SpawnGoldEffect(Vector3 position)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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)
//IL_0049: 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_0069: Expected O, but got Unknown
GameObject val = Resources.Load<GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact");
if (!Object.op_Implicit((Object)(object)val))
{
val = Resources.Load<GameObject>("Prefabs/Effects/LightningStrikeImpact");
}
if (Object.op_Implicit((Object)(object)val))
{
EffectData val2 = new EffectData
{
origin = position,
scale = 2f,
color = Color32.op_Implicit(new Color(1f, 0.84f, 0f))
};
EffectManager.SpawnEffect(val, val2, true);
}
Util.PlaySound("Play_item_proc_goldOnHurt", ((Component)RoR2Application.instance).gameObject);
}
private void EndInvasion(string message)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#e5da64>" + message + "</color>"
});
foreach (CharacterMaster activeTaxman in activeTaxmen)
{
if (Object.op_Implicit((Object)(object)activeTaxman) && Object.op_Implicit((Object)(object)activeTaxman.GetBodyObject()))
{
SpawnGoldEffect(activeTaxman.GetBodyObject().transform.position);
Object.Destroy((Object)(object)activeTaxman.GetBodyObject());
Object.Destroy((Object)(object)((Component)activeTaxman).gameObject);
}
}
activeTaxmen.Clear();
isInvasionActive = false;
}
private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active && Object.op_Implicit((Object)(object)damageInfo.attacker))
{
CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.master) && Object.op_Implicit((Object)(object)((Component)component.master).GetComponent<TaxmanMarker>()) && Object.op_Implicit((Object)(object)self.body) && self.body.isPlayerControlled)
{
CharacterMaster playerMaster = self.body.master;
uint money = playerMaster.money;
uint num = (uint)Mathf.Min((float)money, 1f + (float)money * 0.002f);
CharacterMaster obj = playerMaster;
obj.money -= num;
totalGoldCollected += num;
NetworkUser val = ((IEnumerable<NetworkUser>)NetworkUser.readOnlyInstancesList).FirstOrDefault((Func<NetworkUser, bool>)((NetworkUser u) => (Object)(object)u.master == (Object)(object)playerMaster));
if (Object.op_Implicit((Object)(object)val))
{
val.DeductLunarCoins(LunarCoinLossPerHit.Value);
}
SpawnDollarSign(damageInfo.position, num);
PlayMoneySound(((Component)self.body).gameObject);
damageInfo.damage = 0f;
damageInfo.rejected = true;
if (playerMaster.money == 0)
{
EndInvasion("Target is destitute. Collection suspended.");
}
}
}
orig.Invoke(self, damageInfo);
}
private void SpawnDollarSign(Vector3 position, uint goldLost)
{
//IL_0017: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_008b: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Resources.Load<GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact");
if (Object.op_Implicit((Object)(object)val))
{
EffectData val2 = new EffectData
{
origin = position + Vector3.up * 2f,
scale = 1.5f,
color = Color32.op_Implicit(new Color(1f, 0.84f, 0f))
};
EffectManager.SpawnEffect(val, val2, true);
}
if (goldLost != 0 && Object.op_Implicit((Object)(object)DamageNumberManager.instance))
{
DamageNumberManager.instance.SpawnDamageNumber((float)goldLost, position + Vector3.up * 2f, false, (TeamIndex)0, (DamageColorIndex)11);
}
}
private void PlayMoneySound(GameObject target)
{
string[] array = new string[4] { "Play_item_proc_goldOnHurt", "Play_UI_tripleShopCard", "Play_item_proc_crit_cooldown", "Play_UI_podOrbiter" };
Util.PlaySound(array[0], target);
}
private void ShuffleList<T>(List<T> list)
{
int num = list.Count;
while (num > 1)
{
num--;
int index = Random.Range(0, num + 1);
T value = list[index];
list[index] = list[num];
list[num] = value;
}
}
}
}