using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EntityStates.DeepVoidPortalBattery;
using EntityStates.MeridianEvent;
using EntityStates.Missions.Arena.NullWard;
using EntityStates.Missions.BrotherEncounter;
using EntityStates.Missions.Moon;
using EntityStates.ShrineHalcyonite;
using On.EntityStates.DeepVoidPortalBattery;
using On.EntityStates.MeridianEvent;
using On.EntityStates.Missions.Arena.NullWard;
using On.EntityStates.Missions.BrotherEncounter;
using On.EntityStates.Missions.Moon;
using On.EntityStates.ShrineHalcyonite;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using WarBannerBuff.Components;
using WarBannerBuff.ItemChanges;
using WarBannerBuff.Modules;
[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 = "")]
[assembly: AssemblyCompany("WarBannerBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WarBannerBuff")]
[assembly: AssemblyTitle("WarBannerBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WarBannerBuff
{
[BepInPlugin("com.kking117.WarBannerBuff", "WarBannerBuff", "5.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MainPlugin : BaseUnityPlugin
{
public const string MODUID = "com.kking117.WarBannerBuff";
public const string MODNAME = "WarBannerBuff";
public const string MODTOKEN = "KKING117_WARBANNERBUFF_";
public const string MODVERSION = "5.3.1";
internal static ManualLogSource ModLogger;
public static PluginInfo pluginInfo;
internal static bool Starstorm_Loaded;
public static float RecoveryTick;
public static float HealBase;
public static float HealLevel;
public static float HealMin;
public static float RechargeBase;
public static float RechargeLevel;
public static float RechargeMin;
public static float RegenBonus;
public static float DamageBonus;
public static float CritBonus;
public static float ArmorBonus;
public static float AttackBonus;
public static float MoveBonus;
public static float VoidBanner;
public static float PillarBanner;
public static float DeepVoidBanner;
public static float BossBanner;
public static float FocusBanner;
public static float MeridianBanner;
public static float HalcyonBanner;
public static bool Merge_Enable;
public static float Merge_MinOverlap;
public static float Merge_FuseMult;
public static bool SS2_ShareWithGreaterBanner;
public void Awake()
{
ModLogger = ((BaseUnityPlugin)this).Logger;
pluginInfo = ((BaseUnityPlugin)this).Info;
ReadConfig();
new WarBanner();
new ContentPacks().Initialize();
((ResourceAvailability)(ref GameModeCatalog.availability)).CallWhenAvailable((Action)PostLoad);
}
private void PostLoad()
{
LoadCompat();
}
private void LoadCompat()
{
//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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Invalid comparison between Unknown and I4
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (!SS2_ShareWithGreaterBanner)
{
return;
}
Starstorm_Loaded = Chainloader.PluginInfos.ContainsKey("com.TeamMoonstorm");
if (Starstorm_Loaded)
{
BuffIndex val = BuffCatalog.FindBuffIndex("BuffGreaterBanner");
if ((int)val > -1)
{
WarBanner.GreaterBannerBuff = BuffCatalog.GetBuffDef(val);
}
if ((Object)(object)WarBanner.GreaterBannerBuff != (Object)(object)Buffs.Warbanner)
{
ModLogger.LogInfo((object)"Found SS2 Greater Banner Buff");
}
else
{
ModLogger.LogInfo((object)"Couldn't find SS2 Greater Banner Buff");
}
}
}
public void ReadConfig()
{
RecoveryTick = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Tick Interval", 0f, "Delay in seconds between each heal/recharge tick. (0 or less disables this feature)").Value;
HealBase = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Heal Max Health", 0.0025f, "Heal this % amount of health based on their total health. (0.01 = 1%)").Value;
HealLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Heal Level Health", 0.25f, "Heal this flat amount of health per level.").Value;
HealMin = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Minimum Heal", 1f, "The minimum amount of healing to gain.").Value;
RechargeBase = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Recharge Max Shield", 0f, "Recharge this % amount of shield based on their total shield. (0.01 = 1%)").Value;
RechargeLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Recharge Level Shield", 0f, "Recharge this flat amount of shield per level.").Value;
RechargeMin = ((BaseUnityPlugin)this).Config.Bind<float>("Healing and Recharge", "Minimum Recharge", 0f, "The minimum amount of recharge to gain.").Value;
AttackBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "Attack Speed Bonus", 0.3f, "Attack Speed bonus from Warbanners.").Value;
MoveBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "Move Speed Bonus", 0.3f, "Movement Speed bonus from Warbanners.").Value;
DamageBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "Damage Bonus", 0.2f, "Damage bonus from Warbanners.").Value;
CritBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "Crit Bonus", 0f, "Crit bonus from Warbanners.").Value;
ArmorBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "Armor Bonus", 0f, "Armor bonus from Warbanners.").Value;
RegenBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "Regen Bonus", 3f, "Regen bonus from Warbanners. (Scales with level)").Value;
BossBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Mithrix Phase Banners", 1f, "Players equipped with Warbanners will place one down at the start of Mithrix's phases. (Except the item steal phase.) (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
PillarBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Moon Pillar Banners", 0.75f, "Players equipped with Warbanners will place one down at the start of a Moon Pillar event. (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
DeepVoidBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Deep Void Signal Banners", 0.75f, "Players equipped with Warbanners will place one down at the start of a Deep Void Signal event. (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
VoidBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Void Cell Banners", 0.5f, "Players equipped with Warbanners will place one down at the start of a Void Cell event. (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
FocusBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Focus Banners", 1f, "Players equipped with Warbanners will place one down when activating the Focus in Simulacrum. (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
MeridianBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Prime Meridian Banners", 1f, "Players equipped with Warbanners will place one down at the start of False Son's phases. (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
HalcyonBanner = ((BaseUnityPlugin)this).Config.Bind<float>("Placement Events", "Halcyon Shrine Banners", 0f, "Players equipped with Warbanners will place one down when activating the Halcyon Shrine. (X = Banner radius multiplier for banners placed from this.) (0.0 or less disables this.)").Value;
Merge_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("Banner Merging", "Enable", true, "Allow banner merging? (May cause stutters when banners are placed.)").Value;
Merge_MinOverlap = ((BaseUnityPlugin)this).Config.Bind<float>("Banner Merging", "Minimum Overlap", 0.25f, "Minimum amount of overlap that banners need to merge. Values closer to 0 makes the requirement less strict. (Accepts 0-1)").Value;
Merge_FuseMult = ((BaseUnityPlugin)this).Config.Bind<float>("Banner Merging", "Merge Multiplier", 0.5f, "How much radius to take from the smaller banners when merging.").Value;
SS2_ShareWithGreaterBanner = ((BaseUnityPlugin)this).Config.Bind<bool>("Starstorm 2", "Count Greater Warbanner", false, "Makes the buff granted by the Greater Warbanner also count as the Warbanner buff.").Value;
}
}
}
namespace WarBannerBuff.Modules
{
public static class Buffs
{
internal static List<BuffDef> buffDefs = new List<BuffDef>();
internal static BuffDef AddNewBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff, bool isCooldown)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
((Object)val).name = buffName;
val.buffColor = buffColor;
val.canStack = canStack;
val.isDebuff = isDebuff;
val.eliteDef = null;
val.iconSprite = buffIcon;
val.isCooldown = isCooldown;
((Object)val).name = ((Object)val).name;
buffDefs.Add(val);
return val;
}
}
internal class ContentPacks : IContentPackProvider
{
internal ContentPack contentPack = new ContentPack();
public string identifier => "com.kking117.WarBannerBuff";
public void Initialize()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
}
private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)this);
}
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
contentPack.identifier = identifier;
contentPack.buffDefs.Add(Buffs.buffDefs.ToArray());
args.ReportProgress(1f);
yield break;
}
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
ContentPack.Copy(contentPack, args.output);
args.ReportProgress(1f);
yield break;
}
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
args.ReportProgress(1f);
yield break;
}
}
}
namespace WarBannerBuff.ItemChanges
{
public class WarBanner
{
public static float OverlapDistanceMult;
public static BuffDef ModdedBuff = Buffs.Warbanner;
public static GameObject BannerWard = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/WardOnLevel/WarbannerWard.prefab").WaitForCompletion();
public static GameObject BuffVFX = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/WardOnLevel/WarbannerBuffEffect.prefab").WaitForCompletion();
private static string BannerWard_RefName = "(Clone)";
private static float NextRecover = 1f;
public static BuffDef GreaterBannerBuff;
public WarBanner()
{
ClampConfig();
CreateBuff();
UpdateText();
Hooks();
}
private void ClampConfig()
{
MainPlugin.Merge_FuseMult = Math.Max(0f, MainPlugin.Merge_MinOverlap);
MainPlugin.Merge_FuseMult = Math.Min(1f, MainPlugin.Merge_MinOverlap);
OverlapDistanceMult = 1f - MainPlugin.Merge_FuseMult;
MainPlugin.Merge_FuseMult = Math.Min(1f, MainPlugin.Merge_MinOverlap);
MainPlugin.DamageBonus = Math.Max(0f, MainPlugin.DamageBonus);
MainPlugin.AttackBonus = Math.Max(0f, MainPlugin.AttackBonus);
MainPlugin.CritBonus = Math.Max(0f, MainPlugin.CritBonus);
MainPlugin.ArmorBonus = Math.Max(0f, MainPlugin.ArmorBonus);
MainPlugin.RegenBonus = Math.Max(0f, MainPlugin.RegenBonus);
MainPlugin.MoveBonus = Math.Max(0f, MainPlugin.MoveBonus);
}
private void CreateBuff()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
ModdedBuff = Buffs.AddNewBuff("WarBanner(Modded)", Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/WardOnLevel/bdWarbanner.asset").WaitForCompletion().iconSprite, Color.yellow, canStack: false, isDebuff: false, isCooldown: false);
BannerWard.GetComponent<BuffWard>().buffDef = ModdedBuff;
CharacterBody.UpdateAllTemporaryVisualEffects += new hook_UpdateAllTemporaryVisualEffects(CharacterBody_UpdateAllTemporaryVisualEffects);
BannerWard_RefName = ((Object)BannerWard).name + BannerWard_RefName;
GreaterBannerBuff = ModdedBuff;
}
private void Hooks()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Expected O, but got Unknown
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Expected O, but got Unknown
if (MainPlugin.RecoveryTick > 0f)
{
Run.Start += new hook_Start(Run_Start);
Run.FixedUpdate += new hook_FixedUpdate(Run_FixedUpdate);
HealthComponent.ServerFixedUpdate += new hook_ServerFixedUpdate(HealthComponent_FixedUpdate);
}
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsHook);
if (MainPlugin.BossBanner > 0f)
{
Phase1.OnEnter += new hook_OnEnter(Phase1_OnEnter);
Phase2.OnEnter += new hook_OnEnter(Phase2_OnEnter);
Phase3.OnEnter += new hook_OnEnter(Phase3_OnEnter);
}
if (MainPlugin.PillarBanner > 0f)
{
MoonBatteryActive.OnEnter += new hook_OnEnter(MoonBatteryActive_OnEnter);
}
if (MainPlugin.VoidBanner > 0f)
{
Active.OnEnter += new hook_OnEnter(NullWardActive_OnEnter);
}
if (MainPlugin.DeepVoidBanner > 0f)
{
BaseDeepVoidPortalBatteryState.OnEnter += new hook_OnEnter(DeepVoidPortal_OnEnter);
}
if (MainPlugin.FocusBanner > 0f)
{
InfiniteTowerRun.OnSafeWardActivated += new hook_OnSafeWardActivated(InfiniteTowerRun_OnSafeWardActivated);
}
if (MainPlugin.HalcyonBanner > 0f)
{
ShrineHalcyoniteActivatedState.OnEnter += new hook_OnEnter(Halcyon_OnEnter);
}
if (MainPlugin.MeridianBanner > 0f)
{
Phase1.OnEnter += new hook_OnEnter(Meridian_Phase1);
Phase2.OnEnter += new hook_OnEnter(Meridian_Phase2);
Phase3.OnEnter += new hook_OnEnter(Meridian_Phase3);
}
if (MainPlugin.Merge_Enable)
{
BuffWard.Start += new hook_Start(BuffWard_Start);
}
}
private static void UpdateText()
{
string text = "Drop a Warbanner on level up or starting the Teleporter event. Grants allies";
string text2 = "On <style=cIsUtility>level up</style> or starting the <style=cIsUtility>Teleporter event</style>, drop a banner that strengthens all allies within <style=cIsUtility>16m</style> <style=cStack>(+8m per stack)</style>.\n\nThe banner grants:";
List<string> list = new List<string>();
List<string> list2 = new List<string>();
if (MainPlugin.DamageBonus > 0f)
{
list.Add(" damage");
list2.Add($" <style=cIsDamage>+{MainPlugin.DamageBonus * 100f}% damage</style>");
}
if (MainPlugin.AttackBonus > 0f)
{
list.Add(" attack speed");
list2.Add($" <style=cIsDamage>+{MainPlugin.AttackBonus * 100f}% attack speed</style>");
}
if (MainPlugin.CritBonus > 0f)
{
list.Add(" crit chance");
list2.Add($" <style=cIsDamage>+{MainPlugin.CritBonus}% crit chance</style>");
}
if (MainPlugin.ArmorBonus > 0f)
{
list.Add(" armor");
list2.Add($" <style=cIsHealing>+{MainPlugin.ArmorBonus} armor</style>");
}
if (MainPlugin.RegenBonus > 0f)
{
list.Add(" regen");
list2.Add($" <style=cIsHealing>+{MainPlugin.RegenBonus} base health regen</style>");
}
if (MainPlugin.MoveBonus > 0f)
{
list.Add(" movement speed");
list2.Add($" <style=cIsUtility>+{MainPlugin.MoveBonus * 100f}% movement speed</style>");
}
for (int i = 0; i < list.Count; i++)
{
if (i == list.Count - 1)
{
text += " and";
text2 += " and";
}
else if (i > 0)
{
text += ",";
text2 += ",";
}
text += list[i];
text2 += list2[i];
}
text += ".";
text2 += ".";
LanguageAPI.Add("ITEM_WARDONLEVEL_PICKUP", text);
LanguageAPI.Add("ITEM_WARDONLEVEL_DESC", text2);
}
private void RecalculateStatsHook(CharacterBody sender, StatHookEventArgs args)
{
if (HasBannerBuff(sender))
{
args.damageMultAdd += MainPlugin.DamageBonus;
args.attackSpeedMultAdd += MainPlugin.AttackBonus;
args.moveSpeedMultAdd += MainPlugin.MoveBonus;
args.critAdd += MainPlugin.CritBonus;
args.armorAdd += MainPlugin.ArmorBonus;
if (MainPlugin.RegenBonus > 0f)
{
args.baseRegenAdd += MainPlugin.RegenBonus;
args.levelRegenAdd += MainPlugin.RegenBonus / 5f;
}
}
}
private void Run_Start(orig_Start orig, Run self)
{
orig.Invoke(self);
NextRecover = 1f;
}
private void Run_FixedUpdate(orig_FixedUpdate orig, Run self)
{
orig.Invoke(self);
if (MainPlugin.RecoveryTick > 0f)
{
if (NextRecover <= 0f)
{
NextRecover += MainPlugin.RecoveryTick;
}
NextRecover -= Time.fixedDeltaTime;
}
}
private void HealthComponent_FixedUpdate(orig_ServerFixedUpdate orig, HealthComponent self, float deltaTime)
{
//IL_0059: 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)
orig.Invoke(self, deltaTime);
if (Object.op_Implicit((Object)(object)self.body) && HasBannerBuff(self.body) && NextRecover <= 0f)
{
float num = CalculateHeal(self);
if (num > 0f)
{
self.Heal(num, default(ProcChainMask), true);
}
num = CalculateRecharge(self);
if (num > 0f)
{
self.RechargeShield(num);
}
}
}
private static float CalculateHeal(HealthComponent self)
{
float num = 0f;
if (Object.op_Implicit((Object)(object)self.body))
{
num = self.fullHealth * MainPlugin.HealBase;
float num2 = self.body.level - 1f;
num += MainPlugin.HealLevel * num2;
if (num < MainPlugin.HealMin)
{
num = MainPlugin.HealMin;
}
}
return num;
}
private static float CalculateRecharge(HealthComponent self)
{
float num = 0f;
if (Object.op_Implicit((Object)(object)self.body))
{
num = self.fullShield * MainPlugin.RechargeBase;
float num2 = self.body.level - 1f;
num += MainPlugin.RechargeLevel * num2;
if (num < MainPlugin.RechargeMin)
{
num = MainPlugin.RechargeMin;
}
}
return num;
}
private static void Halcyon_OnEnter(orig_OnEnter orig, ShrineHalcyoniteActivatedState self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.HalcyonBanner);
}
private static void Meridian_Phase1(orig_OnEnter orig, Phase1 self)
{
orig.Invoke(self);
if (NetworkServer.active)
{
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.MeridianBanner);
}
}
private static void Meridian_Phase2(orig_OnEnter orig, Phase2 self)
{
orig.Invoke(self);
if (NetworkServer.active)
{
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.MeridianBanner);
}
}
private static void Meridian_Phase3(orig_OnEnter orig, Phase3 self)
{
orig.Invoke(self);
if (NetworkServer.active)
{
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.MeridianBanner);
}
}
private static void Phase1_OnEnter(orig_OnEnter orig, Phase1 self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.BossBanner);
}
private static void Phase2_OnEnter(orig_OnEnter orig, Phase2 self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.BossBanner);
}
private static void Phase3_OnEnter(orig_OnEnter orig, Phase3 self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.BossBanner);
}
private static void MoonBatteryActive_OnEnter(orig_OnEnter orig, MoonBatteryActive self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.PillarBanner);
}
private static void NullWardActive_OnEnter(orig_OnEnter orig, Active self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.VoidBanner);
}
private static void DeepVoidPortal_OnEnter(orig_OnEnter orig, BaseDeepVoidPortalBatteryState self)
{
orig.Invoke(self);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.DeepVoidBanner);
}
private static void InfiniteTowerRun_OnSafeWardActivated(orig_OnSafeWardActivated orig, InfiniteTowerRun self, InfiniteTowerSafeWardController safeWard)
{
orig.Invoke(self, safeWard);
SpawnTeamWarBanners((TeamIndex)1, MainPlugin.FocusBanner);
}
private static void BuffWard_Start(orig_Start orig, BuffWard self)
{
orig.Invoke(self);
TryMergeWithWard(self);
}
private static void SpawnTeamWarBanners(TeamIndex team, float sizemult)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active || !(sizemult > 0f))
{
return;
}
ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(team);
for (int i = 0; i < teamMembers.Count; i++)
{
CharacterBody body = teamMembers[i].body;
if (!Object.op_Implicit((Object)(object)body))
{
continue;
}
HealthComponent healthComponent = body.healthComponent;
if (Object.op_Implicit((Object)(object)healthComponent) && healthComponent.alive && Object.op_Implicit((Object)(object)body.inventory))
{
int itemCount = body.inventory.GetItemCount(Items.WardOnLevel);
if (itemCount > 0)
{
GameObject val = Object.Instantiate<GameObject>(BannerWard, ((Component)teamMembers[i]).transform.position, Quaternion.identity);
val.GetComponent<TeamFilter>().teamIndex = team;
val.GetComponent<BuffWard>().Networkradius = (8f + 8f * (float)itemCount) * sizemult;
NetworkServer.Spawn(val);
}
}
}
}
private static void TryMergeWithWard(BuffWard thisbuffWard)
{
//IL_003f: 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_00ba: 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)
if (!NetworkServer.active || !(((Object)((Component)thisbuffWard).gameObject).name == BannerWard_RefName) || thisbuffWard.expires)
{
return;
}
TeamIndex teamIndex = thisbuffWard.teamFilter.teamIndex;
List<BuffWard> list = new List<BuffWard>();
BuffWard val = thisbuffWard;
BuffWard[] array = Object.FindObjectsOfType<BuffWard>();
foreach (BuffWard val2 in array)
{
if ((Object)(object)val2 != (Object)(object)thisbuffWard && !val2.expires && ((Object)val2).name == ((Object)thisbuffWard).name && val2.invertTeamFilter == thisbuffWard.invertTeamFilter && val2.teamFilter.teamIndex == teamIndex && IsWardInRange(val2, thisbuffWard))
{
list.Add(val2);
if (val2.radius > val.radius)
{
val = val2;
}
}
}
if (list.Count <= 0)
{
return;
}
float radius = val.radius;
float num = 0f;
if ((Object)(object)thisbuffWard != (Object)(object)val)
{
num += thisbuffWard.radius;
}
foreach (BuffWard item in list)
{
if ((Object)(object)item != (Object)(object)val)
{
num += item.radius;
}
item.expires = true;
Object.Destroy((Object)(object)((Component)item).gameObject);
}
thisbuffWard.radius = radius + num * MainPlugin.Merge_FuseMult;
TryMergeWithWard(thisbuffWard);
}
private static bool IsWardInRange(BuffWard target, BuffWard searcher)
{
//IL_0026: 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)
float num = searcher.radius * OverlapDistanceMult;
float num2 = target.radius * OverlapDistanceMult;
float num3 = Vector3.Distance(((Component)target).gameObject.transform.position, ((Component)searcher).gameObject.transform.position);
if (num3 - num2 <= num)
{
return true;
}
if (num3 - num <= num2)
{
return true;
}
return false;
}
private static void CharacterBody_UpdateAllTemporaryVisualEffects(orig_UpdateAllTemporaryVisualEffects orig, CharacterBody self)
{
//IL_010f: 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_009f: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (self.HasBuff(ModdedBuff) && !self.HasBuff(Buffs.Warbanner))
{
WarBannerBuffVFX warBannerBuffVFX = ((Component)self).GetComponent<WarBannerBuffVFX>();
if ((Object)(object)warBannerBuffVFX == (Object)null)
{
warBannerBuffVFX = ((Component)self).gameObject.AddComponent<WarBannerBuffVFX>();
}
if ((Object)(object)warBannerBuffVFX.effect == (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(BuffVFX, self.corePosition, Quaternion.identity);
warBannerBuffVFX.effect = val.GetComponent<TemporaryVisualEffect>();
warBannerBuffVFX.effect.parentTransform = self.coreTransform;
warBannerBuffVFX.effect.visualState = (VisualState)0;
warBannerBuffVFX.effect.healthComponent = self.healthComponent;
warBannerBuffVFX.effect.radius = self.radius;
LocalCameraEffect component = val.GetComponent<LocalCameraEffect>();
if (Object.op_Implicit((Object)(object)component))
{
component.targetCharacter = ((Component)self).gameObject;
}
}
}
else
{
WarBannerBuffVFX component2 = ((Component)self).GetComponent<WarBannerBuffVFX>();
if ((Object)(object)component2 != (Object)null)
{
component2.effect.visualState = (VisualState)1;
}
}
}
private bool HasBannerBuff(CharacterBody body)
{
if (body.HasBuff(ModdedBuff) || body.HasBuff(GreaterBannerBuff))
{
return true;
}
return false;
}
}
}
namespace WarBannerBuff.Components
{
public class WarBannerBuffVFX : MonoBehaviour
{
public TemporaryVisualEffect effect;
}
}