using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Alexandria.ItemAPI;
using BepInEx;
using Dungeonator;
using UnityEngine;
[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: AssemblyVersion("0.0.0.0")]
namespace JacketPassiveEnhancement;
[BepInPlugin("jacket.passive.aesthetic", "Jacket Aesthetic of Vice", "2.0.6")]
public class JacketPassiveEnhancement : BaseUnityPlugin
{
private bool foundJacket;
private PlayerController jacketPlayer;
private bool itemAdded;
private int currentStacks;
private float stackTimer;
private float lastHealth = 1f;
private int lastEnemyCount;
private const float DAMAGE_PER_STACK = 0.01f;
private const float SPEED_PER_STACK = 0.005f;
private const float RELOAD_PER_STACK = 0.01f;
private const int MAX_STACKS = 25;
private const float STACK_DURATION = 5f;
private float originalDamage = 1f;
private float originalSpeed = 1f;
private float originalReload = 1f;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ Aesthetic of Vice - Mod Carregado!");
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
private void GMStart(GameManager manager)
{
RegisterPassiveItem();
}
private void RegisterPassiveItem()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
try
{
string text = "Aesthetic of Vice";
GameObject val = new GameObject(text);
AestheticOfViceItem aestheticOfViceItem = val.AddComponent<AestheticOfViceItem>();
ItemBuilder.AddSpriteToObject(text, "JacketPassiveEnhancement/Sprites/icon", val, (Assembly)null);
string text2 = "Violence is the Answer";
string text3 = "A red jacket covered in blood, worn by one of Miami's most relentless killers.\n\nThey say whoever wears it feels an uncontrollable fury and a connection to chaos.\n\nEffect: Aesthetic of Vice\nKill enemies quickly to build stacks (max 25)!\n\nEach stack grants:\n• +1% Damage\n• +0.5% Speed\n• +1% Reload Speed\n\nGetting hit removes ALL stacks!\n\nHotline Miami style!";
ItemBuilder.SetupItem((PickupObject)(object)aestheticOfViceItem, text2, text3, "aestheticvice");
((PickupObject)aestheticOfViceItem).quality = (ItemQuality)4;
((PickupObject)aestheticOfViceItem).CanBeDropped = false;
Databases.Items.Add((PickupObject)(object)aestheticOfViceItem, false, "ANY");
((BaseUnityPlugin)this).Logger.LogInfo((object)$"✅ Item '{text}' registrado com ID: {((PickupObject)aestheticOfViceItem).PickupObjectId}");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Erro ao registrar item: " + ex.Message + "\n" + ex.StackTrace));
}
}
private void Update()
{
if (!foundJacket)
{
FindJacket();
}
else if ((Object)(object)jacketPlayer != (Object)null)
{
UpdateStackTimer();
CheckForDamage();
UpdateBonuses();
CheckForEnemyKills();
}
}
private void FindJacket()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
try
{
PlayerController val = (PlayerController)Object.FindObjectOfType(typeof(PlayerController));
if ((Object)(object)val != (Object)null && IsJacket(val))
{
ActivatePassive(val);
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Erro: " + ex.Message));
}
}
private bool IsJacket(PlayerController player)
{
if (((Object)player).name.ToLower().Contains("jacket"))
{
return true;
}
if ((Object)(object)((GameActor)player).CurrentGun != (Object)null)
{
string text = ((Object)((GameActor)player).CurrentGun).name.ToLower();
if (text.Contains("bat") || text.Contains("taco"))
{
return true;
}
}
return false;
}
private void ActivatePassive(PlayerController player)
{
jacketPlayer = player;
foundJacket = true;
originalDamage = jacketPlayer.stats.GetStatValue((StatType)5);
originalSpeed = jacketPlayer.stats.GetStatValue((StatType)0);
originalReload = jacketPlayer.stats.GetStatValue((StatType)10);
lastHealth = ((BraveBehaviour)jacketPlayer).healthHaver.GetCurrentHealth();
lastEnemyCount = GetEnemyCount();
AddItemToInventory();
((BaseUnityPlugin)this).Logger.LogInfo((object)"\ud83c\udfad Aesthetic of Vice ATIVADA!");
}
private void AddItemToInventory()
{
if (itemAdded)
{
return;
}
try
{
PickupObject byName = PickupObjectDatabase.GetByName("Aesthetic of Vice");
PassiveItem val = (PassiveItem)(object)((byName is PassiveItem) ? byName : null);
if ((Object)(object)val != (Object)null)
{
((PickupObject)val).Pickup(jacketPlayer);
itemAdded = true;
((BaseUnityPlugin)this).Logger.LogInfo((object)"\ud83d\udce6 Item adicionado ao inventário!");
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Erro ao adicionar item: " + ex.Message));
}
}
private int GetEnemyCount()
{
if ((Object)(object)jacketPlayer == (Object)null || jacketPlayer.CurrentRoom == null)
{
return 0;
}
return jacketPlayer.CurrentRoom.GetActiveEnemies((ActiveEnemyType)0)?.Count ?? 0;
}
private void CheckForEnemyKills()
{
int enemyCount = GetEnemyCount();
if (enemyCount < lastEnemyCount)
{
int num = lastEnemyCount - enemyCount;
for (int i = 0; i < num; i++)
{
AddStack();
}
}
lastEnemyCount = enemyCount;
}
private void CheckForDamage()
{
if (!((Object)(object)jacketPlayer == (Object)null) && !((Object)(object)((BraveBehaviour)jacketPlayer).healthHaver == (Object)null))
{
float currentHealth = ((BraveBehaviour)jacketPlayer).healthHaver.GetCurrentHealth();
if (currentHealth < lastHealth && currentStacks > 0)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)$"\ud83d\udca5 RESET! Perdeu todos os {currentStacks} stacks!");
currentStacks = 0;
stackTimer = 0f;
}
lastHealth = currentHealth;
}
}
private void AddStack()
{
if (currentStacks < 25)
{
currentStacks++;
stackTimer = 5f;
((BaseUnityPlugin)this).Logger.LogInfo((object)$"\ud83d\udd25 Stack +{currentStacks}/{25}!");
}
else
{
stackTimer = 5f;
}
}
private void UpdateStackTimer()
{
if (currentStacks > 0 && stackTimer > 0f)
{
stackTimer -= Time.deltaTime;
if (stackTimer <= 0f)
{
currentStacks = 0;
((BaseUnityPlugin)this).Logger.LogInfo((object)"⏰ Todos os stacks expiraram!");
}
}
}
private void UpdateBonuses()
{
if (!((Object)(object)jacketPlayer == (Object)null))
{
float num = 1f + (float)currentStacks * 0.01f;
float num2 = 1f + (float)currentStacks * 0.005f;
float num3 = 1f + (float)currentStacks * 0.01f;
jacketPlayer.stats.SetBaseStatValue((StatType)5, originalDamage * num, jacketPlayer);
jacketPlayer.stats.SetBaseStatValue((StatType)0, originalSpeed * num2, jacketPlayer);
jacketPlayer.stats.SetBaseStatValue((StatType)10, originalReload * num3, jacketPlayer);
jacketPlayer.stats.RecalculateStats(jacketPlayer, false, false);
}
}
}
public class AestheticOfViceItem : PassiveItem
{
public override void Pickup(PlayerController player)
{
((PassiveItem)this).Pickup(player);
}
public override DebrisObject Drop(PlayerController player)
{
return ((PassiveItem)this).Drop(player);
}
}