using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BNAPI;
using BepInEx;
using BepInEx.Logging;
using On.Voxels.TowerDefense.Upgrades;
using UnityEngine;
using Voxels.TowerDefense;
using Voxels.TowerDefense.Ballistics;
using Voxels.TowerDefense.Upgrades;
using Voxels.TowerDefense.upgrades;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PlentyTraits
{
public class AxeThrower : HeroUpgradeDefinition
{
public static readonly string AXETHROWER_ID = "Hero_Trait_AxeThrower";
public AxeThrower()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)"AXETHROWER CREATED");
base.upgradeType = ScriptableObject.CreateInstance<HeroUpgradeType>();
base.upgradeType.typeEnum = (HeroUpgradeTypeEnum)4;
base.upgradeType.canBeStartItem = true;
base.upgradeType.unknownNameTerm = "META_INVENTORY/UNKNOWN/TRAIT/NAME";
base.upgradeType.unknownDescriptionTerm = "META_INVENTORY/UNKNOWN/TRAIT/DESC";
base.upgradeType.startItemLockedTerm = "META_INVENTORY/START/TRAIT/LOCKED";
base.upgradeType.startItemUnlockedTerm = "META_INVENTORY/START/TRAIT/UNLOCKED";
base.affectsPortrait = false;
((Object)this).name = AXETHROWER_ID;
base.nameTerm = "NACU/TRAIT/AXE/NAME";
base.shortDescription = "NACU/TRAIT/AXE/DESCSHORT";
base.infoSprite = CustomSprites.Sprites["trait_axe"];
base.levels = (Level[])(object)new Level[1]
{
new Level
{
cost = 0,
description = "NACU/TRAIT/AXE/DESC"
}
};
}
public override void OnAppliedToSquad(EnglishSquad squad, int upgradeLevel)
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
((HeroUpgradeDefinition)this).OnAppliedToSquad(squad, upgradeLevel);
squad.heroAgent.GetOrAddComponent<LineOfSight>();
Object obj = LevelStateObjectReferences.dict["Viking_AxeThrower"];
AxeThrowing component = ((Component)((AgentComponent)((VikingReference)((obj is VikingReference) ? obj : null)).viking).agent).GetComponent<AxeThrowing>();
((Component)squad.heroAgent).gameObject.AddComponent<AxeThrowing>();
AxeThrowing component2 = ((Component)squad.heroAgent).GetComponent<AxeThrowing>();
component2.prepareSound = component.prepareSound;
component2.throwingAxePrefab = component.throwingAxePrefab;
component2.trajectoryUtility = component.trajectoryUtility;
component2.attackSettings = component.attackSettings;
switch (squad.hero.squadLevel)
{
case 0:
component2.ammo = 5;
component2.attackSettings.launchImpulse *= 0.9f;
break;
case 1:
component2.ammo = 8;
component2.attackSettings.damage *= 1.33f;
component2.attackSettings.knockback *= 1.33f;
component2.attackSettings.stun *= 1.5f;
break;
case 2:
component2.ammo = 11;
component2.attackSettings.damage *= 1.66f;
component2.attackSettings.launchImpulse *= 1.1f;
component2.attackSettings.knockback *= 1.66f;
component2.attackSettings.stun *= 2f;
break;
default:
component2.ammo = 14;
component2.attackSettings.damage *= 2f;
component2.attackSettings.launchImpulse *= 1.2f;
component2.attackSettings.knockback *= 2f;
component2.attackSettings.stun *= 2.5f;
break;
}
((AgentComponent)component2).Setup();
}
}
public class CheaperClass : HeroTraitCheaperUpgrades
{
public static readonly string CHEAPERCLASS_ID = "Hero_Trait_CheaperClass";
public CheaperClass()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)"CHEAPERCLASS CREATED");
((HeroUpgradeDefinition)this).upgradeType = ScriptableObject.CreateInstance<HeroUpgradeType>();
((HeroUpgradeDefinition)this).upgradeType.typeEnum = (HeroUpgradeTypeEnum)4;
((HeroUpgradeDefinition)this).upgradeType.canBeStartItem = true;
((HeroUpgradeDefinition)this).upgradeType.unknownNameTerm = "META_INVENTORY/UNKNOWN/TRAIT/NAME";
((HeroUpgradeDefinition)this).upgradeType.unknownDescriptionTerm = "META_INVENTORY/UNKNOWN/TRAIT/DESC";
((HeroUpgradeDefinition)this).upgradeType.startItemLockedTerm = "META_INVENTORY/START/TRAIT/LOCKED";
((HeroUpgradeDefinition)this).upgradeType.startItemUnlockedTerm = "META_INVENTORY/START/TRAIT/UNLOCKED";
((HeroUpgradeDefinition)this).affectsPortrait = false;
((Object)this).name = CHEAPERCLASS_ID;
((HeroUpgradeDefinition)this).nameTerm = "NACU/TRAIT/CCLASS/NAME";
((HeroUpgradeDefinition)this).shortDescription = "NACU/TRAIT/CCLASS/DESCSHORT";
((HeroUpgradeDefinition)this).infoSprite = CustomSprites.Sprites["trait_cheaperclass"];
((HeroUpgradeDefinition)this).levels = (Level[])(object)new Level[1]
{
new Level
{
cost = 0,
description = "NACU/TRAIT/CCLASS/DESC"
}
};
base.discount = 0.4f;
base.affectsType = (HeroUpgradeTypeEnum)1;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("nacu.plentytraits", "Plenty Traits", "1.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource logger;
public const string VERSION = "1.0";
public void OnEnable()
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
logger = ((BaseUnityPlugin)this).Logger;
string text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\";
CustomSprites.AddCustomSprite(text, "trait_axe");
CustomSprites.AddCustomSprite(text, "trait_thorns");
CustomSprites.AddCustomSprite(text, "trait_cheaperclass");
CustomSprites.AddCustomSprite(text, "trait_regenerative");
CustomTraits.RegisterTrait((HeroUpgradeDefinition)(object)ScriptableObject.CreateInstance<AxeThrower>(), AxeThrower.AXETHROWER_ID, true);
CustomTraits.RegisterTrait((HeroUpgradeDefinition)(object)ScriptableObject.CreateInstance<Thorns>(), Thorns.THORNS_ID, false);
CustomTraits.RegisterTrait((HeroUpgradeDefinition)(object)ScriptableObject.CreateInstance<Regenerative>(), Regenerative.REGENERATIVE_ID, false);
CustomTraits.RegisterTrait((HeroUpgradeDefinition)(object)ScriptableObject.CreateInstance<CheaperClass>(), CheaperClass.CHEAPERCLASS_ID, true);
CustomText.CustomTermsAdded += AddCustomTerms;
HouseTargetableAbility.GetNotificationTerm += new hook_GetNotificationTerm(HouseTargetableAbility_GetNotificationTerm);
logger.LogInfo((object)"Plenty Traits loaded");
}
private string HouseTargetableAbility_GetNotificationTerm(orig_GetNotificationTerm orig, HouseTargetableAbility self, out string pn, out string pv)
{
if (((ActiveAbility)self).isBanned)
{
pn = (pv = null);
return ((ActiveAbility)self).bannedTooltip;
}
return orig.Invoke(self, ref pn, ref pv);
}
private void AddCustomTerms()
{
CustomText.AddCustomTerm("NACU/TRAIT/AXE/NAME", "Axe Thrower");
CustomText.AddCustomTerm("NACU/TRAIT/AXE/DESCSHORT", "Commander throws axes");
CustomText.AddCustomTerm("NACU/TRAIT/AXE/DESC", "The commander throws axes.\nNumber and power of axes changes based on the squad level.");
CustomText.AddCustomTerm("NACU/TRAIT/THORNS/NAME", "Thorns");
CustomText.AddCustomTerm("NACU/TRAIT/THORNS/DESCSHORT", "Melee attackers get damaged back");
CustomText.AddCustomTerm("NACU/TRAIT/THORNS/DESC", "All melee attackers get damaged back for a small amount.");
CustomText.AddCustomTerm("NACU/TRAIT/CCLASS/NAME", "Quick Mastery");
CustomText.AddCustomTerm("NACU/TRAIT/CCLASS/DESCSHORT", "Cheaper class upgrades");
CustomText.AddCustomTerm("NACU/TRAIT/CCLASS/DESC", "This commander's class upgrades cost 40% less.");
CustomText.AddCustomTerm("NACU/TRAIT/REGENERATIVE/NAME", "Medical Training");
CustomText.AddCustomTerm("NACU/TRAIT/REGENERATIVE/DESCSHORT", "Units regenerate health");
CustomText.AddCustomTerm("NACU/TRAIT/REGENERATIVE/DESC", "All units passively regenerate lost health.\nSquad can't replenish at houses.");
CustomText.AddCustomTerm("NACU/HERO_TRAITS/REGENERATIVE/ABILITY_TOOLTIP", "Medical Training squads can't replenish.");
}
}
public class Regenerative : HeroUpgradeDefinition
{
public static readonly string REGENERATIVE_ID = "Hero_Trait_Regenerative";
public Regenerative()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)"REGENERATIVE CREATED");
base.upgradeType = ScriptableObject.CreateInstance<HeroUpgradeType>();
base.upgradeType.typeEnum = (HeroUpgradeTypeEnum)4;
base.upgradeType.canBeStartItem = true;
base.upgradeType.unknownNameTerm = "META_INVENTORY/UNKNOWN/TRAIT/NAME";
base.upgradeType.unknownDescriptionTerm = "META_INVENTORY/UNKNOWN/TRAIT/DESC";
base.upgradeType.startItemLockedTerm = "META_INVENTORY/START/TRAIT/LOCKED";
base.upgradeType.startItemUnlockedTerm = "META_INVENTORY/START/TRAIT/UNLOCKED";
base.affectsPortrait = false;
((Object)this).name = REGENERATIVE_ID;
base.nameTerm = "NACU/TRAIT/REGENERATIVE/NAME";
base.shortDescription = "NACU/TRAIT/REGENERATIVE/DESCSHORT";
base.infoSprite = CustomSprites.Sprites["trait_regenerative"];
base.levels = (Level[])(object)new Level[1]
{
new Level
{
cost = 0,
description = "NACU/TRAIT/REGENERATIVE/DESC"
}
};
}
public override void OnAppliedToSquad(EnglishSquad squad, int upgradeLevel)
{
((HeroUpgradeDefinition)this).OnAppliedToSquad(squad, upgradeLevel);
squad.heroAgent.GetOrAddComponent<SelfHealing>();
squad.minionPrefab.GetOrAddComponent<SelfHealing>();
ReplenishAbility upgrade = squad.upgradeManager.GetUpgrade<ReplenishAbility>();
if (Object.op_Implicit((Object)(object)upgrade))
{
((ActiveAbility)upgrade).BanAbility("NACU/HERO_TRAITS/REGENERATIVE/ABILITY_TOOLTIP", (string)null, (string)null);
}
}
}
public class SelfHealing : AgentComponent
{
public AgentState healing;
public float healingRate = 0.001f;
public override void Setup()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
healing = new AgentState("SelfHealing", ((AgentComponent)this).agent.aliveAndGrounded, true, false);
healing.OnUpdate += delegate
{
((AgentComponent)this).agent.health = Mathf.Min(((AgentComponent)this).agent.maxHealth, ((AgentComponent)this).agent.health + healingRate);
};
}
}
public class Thorns : HeroUpgradeDefinition, IAttackResponder
{
public static readonly string THORNS_ID = "Hero_Trait_Thorns";
public Thorns()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)"THORNS CREATED");
base.upgradeType = ScriptableObject.CreateInstance<HeroUpgradeType>();
base.upgradeType.typeEnum = (HeroUpgradeTypeEnum)4;
base.upgradeType.canBeStartItem = true;
base.upgradeType.unknownNameTerm = "META_INVENTORY/UNKNOWN/TRAIT/NAME";
base.upgradeType.unknownDescriptionTerm = "META_INVENTORY/UNKNOWN/TRAIT/DESC";
base.upgradeType.startItemLockedTerm = "META_INVENTORY/START/TRAIT/LOCKED";
base.upgradeType.startItemUnlockedTerm = "META_INVENTORY/START/TRAIT/UNLOCKED";
base.affectsPortrait = false;
((Object)this).name = THORNS_ID;
base.nameTerm = "NACU/TRAIT/THORNS/NAME";
base.shortDescription = "NACU/TRAIT/THORNS/DESCSHORT";
base.infoSprite = CustomSprites.Sprites["trait_thorns"];
base.levels = (Level[])(object)new Level[1]
{
new Level
{
cost = 0,
description = "NACU/TRAIT/THORNS/DESC"
}
};
}
public override void OnAppliedToSquad(EnglishSquad squad, int upgradeLevel)
{
((HeroUpgradeDefinition)this).OnAppliedToSquad(squad, upgradeLevel);
((Squad)squad).onAgentCreated += AddThing;
}
public void AddThing(Agent agent)
{
if (!agent.attackResponders.Contains((IAttackResponder)(object)this))
{
agent.attackResponders.Add((IAttackResponder)(object)this);
}
}
public void ModifyAttack(ref Attack attack)
{
//IL_002c: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
MonoBehaviour monoAttacker = attack.monoAttacker;
CloseCombatBrain val = (CloseCombatBrain)(object)((monoAttacker is CloseCombatBrain) ? monoAttacker : null);
if (val != null)
{
((AgentComponent)val).agent.DealDamage(new Attack(1.5f, 1f, 1f, -attack.direction, attack.pos, (MonoBehaviour)(object)val, (Squad)(object)((AgentComponent)val).enSquad, "Sfx/English/Sword", (ReusableEffect)(object)ScriptableObjectSingleton<PrefabManager>.instance.hitEffect));
}
}
}
}
namespace System.Runtime.Versioning
{
public class TargetFrameworkAttribute : Attribute
{
public string FrameworkName { get; set; }
public string FrameworkDisplayName { get; set; }
public TargetFrameworkAttribute(string frameworkName)
{
FrameworkName = frameworkName;
}
}
}