using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SuperSayianSuperMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SuperSayianSuperMod")]
[assembly: AssemblyTitle("SuperSayianSuperMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ObamaSuperStack;
[BepInPlugin("jaxon.jacksonbeta.supersayiansupermod", "Super Sayian Super Mod", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "jaxon.jacksonbeta.supersayiansupermod";
public const string PluginName = "Super Sayian Super Mod";
public const string PluginVersion = "1.0.0";
internal static Plugin Instance;
internal static readonly bool EnableEarlierObamaChanges;
internal const int SuperSlot = 2;
internal static AudioClip PowerUpScream;
internal static AudioClip SpiritBombSound;
private Harmony _harmony;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Instance = this;
_harmony = new Harmony("jaxon.jacksonbeta.supersayiansupermod");
Patch(typeof(Options), "FU", typeof(SuperSaiyanDirectInputPatch), "Prefix");
Patch(typeof(Options), "OnEnable", typeof(SuperSaiyanActivationPatch), "Prefix");
Patch(typeof(rselectDisplay), "Start", typeof(SuperSaiyanMenuPatch), "Postfix");
Patch(typeof(PlayerInfo), "FixedUpdate", typeof(SuperSaiyanCostPatch), "Postfix");
Patch(typeof(setSprite), "Update", typeof(SuperSaiyanVisibleSpritePatch), "Postfix");
Patch(typeof(HitBoxInterpreter), "StrongHit", typeof(TripleObamukenHitPatch), "Prefix", "Postfix");
((MonoBehaviour)this).StartCoroutine(LoadAudio());
((BaseUnityPlugin)this).Logger.LogInfo((object)"Super Sayian Super Mod 1.0.0 loaded");
}
private void Patch(Type targetType, string targetMethod, Type patchType, params string[] patchMethods)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(targetType, targetMethod, (Type[])null, (Type[])null);
if (methodInfo == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)("[DIAG] Missing target " + targetType.Name + "." + targetMethod));
return;
}
for (int i = 0; i < patchMethods.Length; i++)
{
MethodInfo methodInfo2 = AccessTools.Method(patchType, patchMethods[i], (Type[])null, (Type[])null);
if (methodInfo2 == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)("[DIAG] Missing patch method " + patchType.Name + "." + patchMethods[i]));
continue;
}
HarmonyMethod val = new HarmonyMethod(methodInfo2);
if (patchMethods[i] == "Prefix")
{
_harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
}
private void Update()
{
}
private IEnumerator LoadAudio()
{
string path = Path.Combine(Paths.PluginPath, "Super Sayian Super Mod", "Assets");
string fallbackDirectory = Path.Combine(Paths.CachePath, "ObamaOverdrive");
string path2 = ResolveAudioFile(Path.Combine(path, "power-up-scream.mp3"), fallbackDirectory, "power-up-scream.mp3", "ObamaOverdrive.Assets.power-up-scream.mp3");
string energy = ResolveAudioFile(Path.Combine(path, "spirit-bomb.mp3"), fallbackDirectory, "spirit-bomb.mp3", "ObamaOverdrive.Assets.spirit-bomb.mp3");
yield return LoadClip(path2, delegate(AudioClip clip)
{
PowerUpScream = clip;
});
yield return LoadClip(energy, delegate(AudioClip clip)
{
SpiritBombSound = clip;
});
}
internal static IEnumerator FinalizeDamage(PlayerInfo attacker, PlayerInfo target, int healthBefore, int chargeBefore)
{
yield return (object)new WaitForEndOfFrame();
if ((Object)(object)target != (Object)null)
{
target.health = healthBefore - 4;
}
if ((Object)(object)attacker != (Object)null)
{
attacker.superCharge = Mathf.Min(4, chargeBefore + 4);
}
Diagnostic("HitFinalize damage=4 health=" + (((Object)(object)target != (Object)null) ? target.health.ToString() : "null"));
}
private string ResolveAudioFile(string installedPath, string fallbackDirectory, string fileName, string resourceName)
{
if (File.Exists(installedPath))
{
return installedPath;
}
Directory.CreateDirectory(fallbackDirectory);
string text = Path.Combine(fallbackDirectory, fileName);
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
if (stream == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Missing embedded audio resource: " + resourceName));
return installedPath;
}
using FileStream destination = File.Create(text);
stream.CopyTo(destination);
return text;
}
private IEnumerator LoadClip(string path, Action<AudioClip> assign)
{
if (!File.Exists(path))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Missing audio file: " + path));
yield break;
}
UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, (AudioType)13);
try
{
yield return request.SendWebRequest();
if ((int)request.result != 1)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not load audio: " + request.error));
yield break;
}
assign(DownloadHandlerAudioClip.GetContent(request));
}
finally
{
((IDisposable)request)?.Dispose();
}
}
private void OnDestroy()
{
if (_harmony != null)
{
_harmony.UnpatchSelf();
}
Instance = null;
}
internal static void Diagnostic(string message)
{
if ((Object)(object)Instance != (Object)null)
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[DIAG] " + message));
}
}
}
public sealed class SuperSaiyanState : MonoBehaviour
{
public bool Transformed;
public bool FrameDataBoosted;
public bool RendererDiagnosticWritten;
public int ActivationCount;
public bool SuperLocked;
public int LastActivationFrame = -1;
public int LastTintStage;
public float LastTintTime = -999f;
public int PendingHealth;
public PlayerInfo PendingTarget;
public bool PendingHit;
public int PendingSuperCharge;
public int LastAppliedDamageFrame = -1;
public PlayerInfo LastAppliedDamageTarget;
}
internal static class SuperSaiyanSystem
{
internal static bool HandleSuperStart(Options options)
{
if ((Object)(object)options == (Object)null || ((Object)((Component)options).gameObject).name != "SuperStart")
{
return true;
}
PlayerInfo val = ObamaChecks.FindOwner((Component)(object)options);
if (!ObamaChecks.IsObama(val) || val.superID != 2)
{
return true;
}
if (val.superCharge < 4)
{
return true;
}
((Component)options).gameObject.SetActive(false);
Activate(val);
return false;
}
internal static void Activate(PlayerInfo obama)
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if (!ObamaChecks.IsObama(obama) || obama.superID != 2 || obama.superCharge < 4)
{
return;
}
SuperSaiyanState superSaiyanState = ((Component)obama).GetComponent<SuperSaiyanState>();
if ((Object)(object)superSaiyanState == (Object)null)
{
superSaiyanState = ((Component)obama).gameObject.AddComponent<SuperSaiyanState>();
}
if (!superSaiyanState.Transformed && superSaiyanState.LastActivationFrame != Time.frameCount)
{
superSaiyanState.LastActivationFrame = Time.frameCount;
if ((Object)(object)((Component)superSaiyanState).GetComponent<SuperSaiyanVisualEnforcer>() == (Object)null)
{
((Component)superSaiyanState).gameObject.AddComponent<SuperSaiyanVisualEnforcer>();
}
string[] obj = new string[10]
{
"Activate owner=",
((Object)obama).name,
" scene=",
null,
null,
null,
null,
null,
null,
null
};
Scene scene = ((Component)obama).gameObject.scene;
obj[3] = ((Scene)(ref scene)).name;
obj[4] = " player=";
obj[5] = obama.player.ToString();
obj[6] = " superID=";
obj[7] = obama.superID.ToString();
obj[8] = " transformed=";
obj[9] = superSaiyanState.Transformed.ToString();
Plugin.Diagnostic(string.Concat(obj));
superSaiyanState.ActivationCount = 1;
Plugin.Diagnostic("SuperSayian activation tint=yellow damage=2");
obama.superCharge = 0;
obama.superCost = 4;
if (superSaiyanState.ActivationCount == 1)
{
Transform(obama, superSaiyanState);
ReturnToNeutral(obama);
}
}
}
internal static void Maintain(PlayerInfo obama)
{
//IL_003e: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
if (!ObamaChecks.IsObama(obama) || obama.superID != 2)
{
return;
}
obama.superCost = 4;
SuperSaiyanState component = ((Component)obama).GetComponent<SuperSaiyanState>();
if ((Object)(object)component != (Object)null && component.Transformed)
{
TintRenderer(((Component)obama).GetComponent<SpriteRenderer>(), StackTint(1));
if (!component.RendererDiagnosticWritten)
{
component.RendererDiagnosticWritten = true;
SpriteRenderer component2 = ((Component)obama).GetComponent<SpriteRenderer>();
Plugin.Diagnostic("Maintain rootRenderer=" + ((Object)(object)component2 != (Object)null) + " rootColor=" + (((Object)(object)component2 != (Object)null) ? ((object)component2.color/*cast due to .constrained prefix*/).ToString() : "null") + " currentAnim=" + (((Object)(object)obama.currentAnim != (Object)null) ? ((Object)obama.currentAnim).name : "null"));
}
}
}
private static void Transform(PlayerInfo obama, SuperSaiyanState state)
{
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
state.Transformed = true;
if (!state.FrameDataBoosted)
{
obama.runSpeed *= 1.4f;
obama.dashSpeed *= 1.4f;
obama.dashAccel *= 1.35f;
obama.dashDecel *= 1.25f;
obama.traction *= 1.25f;
obama.airSpeed *= 1.35f;
obama.airMax *= 1.35f;
obama.airAccel *= 1.3f;
obama.jumpForce *= 1.15f;
obama.doubleJumpForce *= 1.15f;
Options[] componentsInChildren = ((Component)obama).GetComponentsInChildren<Options>(true);
foreach (Options val in componentsInChildren)
{
val.actionableFrame = Mathf.Max(0, Mathf.FloorToInt((float)val.actionableFrame * 0.6f));
if (val.frames == null)
{
continue;
}
for (int j = 0; j < val.frames.Length; j++)
{
if (val.frames[j] != null)
{
val.frames[j].frames = Mathf.Max(1, Mathf.CeilToInt((float)val.frames[j].frames * 0.65f));
}
}
}
state.FrameDataBoosted = true;
}
TintCombatSprites(obama, new Color(1f, 0.82f, 0.12f, 1f));
if ((Object)(object)Plugin.PowerUpScream != (Object)null)
{
AudioSource.PlayClipAtPoint(Plugin.PowerUpScream, ((Component)obama).transform.position, 1f);
}
}
private static Color StackTint(int count)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
return new Color(1f, 0.82f, 0.12f, 1f);
}
private static void PlayScream(PlayerInfo obama)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Plugin.PowerUpScream != (Object)null)
{
AudioSource.PlayClipAtPoint(Plugin.PowerUpScream, ((Component)obama).transform.position, 1f);
}
}
private static void ApplyStackedBuffs(PlayerInfo obama, SuperSaiyanState state)
{
obama.runSpeed *= 1.4f;
obama.dashSpeed *= 1.4f;
obama.dashAccel *= 1.35f;
obama.dashDecel *= 1.25f;
obama.traction *= 1.25f;
obama.airSpeed *= 1.35f;
obama.airMax *= 1.35f;
obama.airAccel *= 1.3f;
obama.jumpForce *= 1.15f;
obama.doubleJumpForce *= 1.15f;
Options[] componentsInChildren = ((Component)obama).GetComponentsInChildren<Options>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].actionableFrame = Mathf.Max(0, Mathf.FloorToInt((float)componentsInChildren[i].actionableFrame * 0.6f));
if (componentsInChildren[i].frames == null)
{
continue;
}
for (int j = 0; j < componentsInChildren[i].frames.Length; j++)
{
if (componentsInChildren[i].frames[j] != null)
{
componentsInChildren[i].frames[j].frames = Mathf.Max(1, Mathf.CeilToInt((float)componentsInChildren[i].frames[j].frames * 0.65f));
}
}
}
}
private static void TintCombatSprites(PlayerInfo obama, Color tint)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0038: 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)
TintRenderer(((Component)obama).GetComponent<SpriteRenderer>(), tint);
TintAnimationObject(obama.defaultAnim, tint);
TintAnimationObject(obama.currentAnim, tint);
Options[] componentsInChildren = ((Component)obama).GetComponentsInChildren<Options>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
TintFrames(componentsInChildren[i].frames, tint);
}
JustAnimate[] componentsInChildren2 = ((Component)obama).GetComponentsInChildren<JustAnimate>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
TintFrames(componentsInChildren2[j].frames, tint);
}
}
private static void TintFrames(anim[] frames, Color tint)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (frames == null)
{
return;
}
for (int i = 0; i < frames.Length; i++)
{
if (frames[i] != null)
{
TintAnimationObject(frames[i].spriteObject, tint);
}
}
}
private static void TintAnimationObject(GameObject animation, Color tint)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)animation == (Object)null))
{
SpriteRenderer[] componentsInChildren = animation.GetComponentsInChildren<SpriteRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
TintRenderer(componentsInChildren[i], tint);
}
}
}
private static void TintRenderer(SpriteRenderer renderer, Color tint)
{
//IL_000a: 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_0016: 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_0027: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)renderer != (Object)null)
{
renderer.color = new Color(tint.r, tint.g, tint.b, renderer.color.a);
}
}
internal static void TintNetworkPainter(PlayerInfo obama, Color tint)
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Sprite God");
if ((Object)(object)val == (Object)null)
{
return;
}
spriteGod component = val.GetComponent<spriteGod>();
if ((Object)(object)component == (Object)null || component.rendererList == null || component.painterList == null)
{
return;
}
SpriteRenderer component2 = ((Component)obama).GetComponent<SpriteRenderer>();
int num = Mathf.Min(component.rendererList.Length, component.painterList.Length);
bool flag = false;
for (int i = 0; i < num; i++)
{
if ((Object)(object)component.rendererList[i] == (Object)(object)component2 && (Object)(object)component.painterList[i] != (Object)null)
{
flag = true;
TintRenderer(component.painterList[i], tint);
}
}
SuperSaiyanState component3 = ((Component)obama).GetComponent<SuperSaiyanState>();
if ((Object)(object)component3 != (Object)null && !component3.RendererDiagnosticWritten)
{
Plugin.Diagnostic("SpriteGod source=" + ((Object)(object)component2 != (Object)null) + " matchedPainter=" + flag + " rendererSlots=" + num);
}
}
private static void ReturnToNeutral(PlayerInfo obama)
{
//IL_0021: 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_003a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)obama.currentAnim != (Object)null)
{
obama.currentAnim.SetActive(false);
}
Transform transform = ((Component)obama).transform;
transform.position += new Vector3(0f, 0.001f, 0f);
obama.defaultAnim.SetActive(true);
obama.currentAnim = obama.defaultAnim;
obama.hit = 0;
}
private static void ActivateBlueExBidenBlast(PlayerInfo obama)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
GameObject val = null;
Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
foreach (Transform val2 in array)
{
if (!((Object)(object)val2 == (Object)null) && !(((Object)val2).name != "Super (Parent) (1)") && !((Object)(object)val2.Find("Super Start EX") == (Object)null))
{
val = ((Component)val2).gameObject;
break;
}
}
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"Obama Overdrive: complete Biden EX super hierarchy was not loaded; second Super Saiyan activation cancelled.");
obama.superCharge = 4;
ReturnToNeutral(obama);
return;
}
Scene scene = val.scene;
Plugin.Diagnostic("EX hierarchy found scene=" + ((Scene)(ref scene)).name + " source=" + ((Object)val).name);
if ((Object)(object)obama.currentAnim != (Object)null)
{
obama.currentAnim.SetActive(false);
}
GameObject val3 = Object.Instantiate<GameObject>(val, ((Component)obama).transform);
((Object)val3).name = "Blue EX Biden Blast Sequence";
StripNativeAudio(val3);
Options[] componentsInChildren = val3.GetComponentsInChildren<Options>(true);
for (int j = 0; j < componentsInChildren.Length; j++)
{
componentsInChildren[j].infoScript = obama;
}
JustAnimate[] componentsInChildren2 = val3.GetComponentsInChildren<JustAnimate>(true);
for (int k = 0; k < componentsInChildren2.Length; k++)
{
componentsInChildren2[k].info = obama;
}
justAnimateUI[] componentsInChildren3 = val3.GetComponentsInChildren<justAnimateUI>(true);
for (int l = 0; l < componentsInChildren3.Length; l++)
{
componentsInChildren3[l].infoscriptForFacing = obama;
}
Transform val4 = val3.transform.Find("Super Start EX");
if ((Object)(object)val4 == (Object)null)
{
Debug.LogError((object)"Obama Overdrive: cloned Biden EX hierarchy had no Super Start EX object.");
Object.Destroy((Object)(object)val3);
obama.superCharge = 4;
ReturnToNeutral(obama);
return;
}
SpriteRenderer[] componentsInChildren4 = val3.GetComponentsInChildren<SpriteRenderer>(true);
for (int m = 0; m < componentsInChildren4.Length; m++)
{
componentsInChildren4[m].color = new Color(0.1f, 0.55f, 1f, componentsInChildren4[m].color.a);
}
val3.SetActive(true);
GameObject gameObject = ((Component)val4).gameObject;
ExBlastFallbackController exBlastFallbackController = val3.AddComponent<ExBlastFallbackController>();
exBlastFallbackController.Owner = obama;
GameObject val5 = FindGlobalExBlastTemplate();
exBlastFallbackController.ExBlast = (((Object)(object)val5 != (Object)null) ? Object.Instantiate<GameObject>(val5, val3.transform) : null);
if ((Object)(object)exBlastFallbackController.ExBlast != (Object)null)
{
((Object)exBlastFallbackController.ExBlast).name = "Blue EX BLAST";
}
exBlastFallbackController.FinalFrame = FindDescendant(val3.transform, "frame (85)");
Plugin.Diagnostic("EX clone created start=" + ((Object)(object)val4 != (Object)null) + " exBlast=" + ((Object)(object)exBlastFallbackController.ExBlast != (Object)null) + " finalFrame85=" + ((Object)(object)exBlastFallbackController.FinalFrame != (Object)null));
gameObject.SetActive(true);
obama.currentAnim = gameObject;
}
private static GameObject FindGlobalExBlastTemplate()
{
Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && ((Object)array[i]).name == "EX BLAST" && (Object)(object)((Component)array[i]).GetComponent<exbidenblast>() != (Object)null)
{
return ((Component)array[i]).gameObject;
}
}
return null;
}
private static GameObject FindDescendant(Transform root, string objectName)
{
Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (((Object)componentsInChildren[i]).name == objectName)
{
return ((Component)componentsInChildren[i]).gameObject;
}
}
return null;
}
private static void StripNativeAudio(GameObject blast)
{
AudioSource[] componentsInChildren = blast.GetComponentsInChildren<AudioSource>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].Stop();
componentsInChildren[i].mute = true;
componentsInChildren[i].playOnAwake = false;
}
Options[] componentsInChildren2 = blast.GetComponentsInChildren<Options>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
ClearFrameSounds(componentsInChildren2[j].frames);
}
JustAnimate[] componentsInChildren3 = blast.GetComponentsInChildren<JustAnimate>(true);
for (int k = 0; k < componentsInChildren3.Length; k++)
{
ClearFrameSounds(componentsInChildren3[k].frames);
}
justAnimateUI[] componentsInChildren4 = blast.GetComponentsInChildren<justAnimateUI>(true);
for (int l = 0; l < componentsInChildren4.Length; l++)
{
ClearFrameSounds(componentsInChildren4[l].frames);
}
}
private static void ClearFrameSounds(anim[] frames)
{
if (frames == null)
{
return;
}
for (int i = 0; i < frames.Length; i++)
{
if (frames[i] != null)
{
frames[i].sfx = (animSound[])(object)new animSound[0];
}
}
}
}
public sealed class ExBlastFallbackController : MonoBehaviour
{
public PlayerInfo Owner;
public GameObject ExBlast;
public GameObject FinalFrame;
private bool _launched;
private bool _energyPlayed;
private void FixedUpdate()
{
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
if (_launched || (Object)(object)Owner == (Object)null || (Object)(object)ExBlast == (Object)null)
{
return;
}
if (ExBlast.activeInHierarchy)
{
_launched = true;
Owner.currentAnim = ExBlast;
PlayEnergySound();
Plugin.Diagnostic("EX BLAST became active through native cloned enabler");
}
else if (!((Object)(object)FinalFrame == (Object)null) && FinalFrame.activeInHierarchy)
{
_launched = true;
Plugin.Diagnostic("Final frame (85) active; forcing EX BLAST fallback");
if ((Object)(object)Owner.currentAnim != (Object)null && (Object)(object)Owner.currentAnim != (Object)(object)ExBlast)
{
Owner.currentAnim.SetActive(false);
}
ExBlast.transform.SetParent(((Component)Owner).transform, false);
exbidenblast component = ExBlast.GetComponent<exbidenblast>();
if ((Object)(object)component != (Object)null)
{
component.counter = 0;
}
SpriteRenderer[] componentsInChildren = ExBlast.GetComponentsInChildren<SpriteRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].color = new Color(0.1f, 0.55f, 1f, componentsInChildren[i].color.a);
}
ExBlast.SetActive(true);
Owner.currentAnim = ExBlast;
PlayEnergySound();
Plugin.Diagnostic("Fallback EX BLAST SetActive complete active=" + ExBlast.activeInHierarchy);
}
}
private void PlayEnergySound()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (!_energyPlayed && !((Object)(object)Plugin.SpiritBombSound == (Object)null))
{
_energyPlayed = true;
AudioSource.PlayClipAtPoint(Plugin.SpiritBombSound, ((Component)Owner).transform.position, 1f);
}
}
}
public sealed class SuperSaiyanVisualEnforcer : MonoBehaviour
{
private PlayerInfo _owner;
private SpriteRenderer _root;
private void Awake()
{
_owner = ((Component)this).GetComponent<PlayerInfo>();
_root = ((Component)this).GetComponent<SpriteRenderer>();
Plugin.Diagnostic("YellowTint rootCache=" + (((Object)(object)_root != (Object)null) ? ((Object)_root).name : "null"));
}
private void LateUpdate()
{
//IL_005f: 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)
if (ObamaChecks.IsObama(_owner) && _owner.superID == 2)
{
SuperSaiyanState component = ((Component)this).GetComponent<SuperSaiyanState>();
if (!((Object)(object)component == (Object)null) && component.Transformed && !((Object)(object)_root == (Object)null))
{
_root.color = new Color(1f, 0.82f, 0.12f, _root.color.a);
}
}
}
}
[HarmonyPatch(typeof(Options), "FU")]
[HarmonyPriority(800)]
internal static class SuperSaiyanDirectInputPatch
{
private static void Prefix(Options __instance)
{
PlayerInfo val = ObamaChecks.FindOwner((Component)(object)__instance);
if (ObamaChecks.IsObama(val) && val.superID == 2 && !((Object)(object)val.receiver == (Object)null))
{
SuperSaiyanState component = ((Component)val).GetComponent<SuperSaiyanState>();
if ((Object)(object)component != (Object)null && component.SuperLocked)
{
val.receiver.holdingSuper = 3;
}
else if (val.receiver.holdingSuper == 2 && val.superCharge >= 4 && val.hit >= 0 && (!((Object)(object)val.enemyScript != (Object)null) || !val.enemyScript.blockSuper))
{
val.receiver.holdingSuper = 3;
SuperSaiyanSystem.Activate(val);
}
}
}
}
[HarmonyPatch(typeof(Options), "OnEnable")]
[HarmonyPriority(800)]
internal static class SuperSaiyanActivationPatch
{
private static bool Prefix(Options __instance)
{
return SuperSaiyanSystem.HandleSuperStart(__instance);
}
}
[HarmonyPatch(typeof(PlayerInfo), "FixedUpdate")]
internal static class SuperSaiyanMaintenancePatch
{
private static void Postfix(PlayerInfo __instance)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if (!ObamaChecks.IsObama(__instance) || __instance.superID != 2)
{
return;
}
SuperSaiyanState component = ((Component)__instance).GetComponent<SuperSaiyanState>();
if (!((Object)(object)component == (Object)null) && component.Transformed)
{
SpriteRenderer component2 = ((Component)__instance).GetComponent<SpriteRenderer>();
if ((Object)(object)component2 != (Object)null)
{
component2.color = new Color(1f, 0.82f, 0.12f, component2.color.a);
}
if (!component.RendererDiagnosticWritten)
{
component.RendererDiagnosticWritten = true;
Plugin.Diagnostic("YellowTint root=" + ((Object)(object)component2 != (Object)null) + " color=" + (((Object)(object)component2 != (Object)null) ? ((object)component2.color/*cast due to .constrained prefix*/).ToString() : "null"));
}
}
}
}
internal static class SuperSaiyanCostPatch
{
private static void Postfix(PlayerInfo __instance)
{
if (ObamaChecks.IsObama(__instance) && __instance.superID == 2)
{
__instance.superCost = 4;
}
}
}
[HarmonyPatch(typeof(healthBarPortrait), "Update")]
[HarmonyPriority(0)]
internal static class SuperSaiyanPortraitColorPatch
{
private static void Postfix(healthBarPortrait __instance)
{
//IL_0070: 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 ((Object)(object)__instance == (Object)null || (Object)(object)__instance.godSprite == (Object)null)
{
return;
}
PlayerInfo component = ((Component)__instance.godSprite).GetComponent<PlayerInfo>();
if (!ObamaChecks.IsObama(component) || component.superID != 2)
{
return;
}
SuperSaiyanState component2 = ((Component)component).GetComponent<SuperSaiyanState>();
if (!((Object)(object)component2 == (Object)null) && component2.Transformed)
{
SpriteRenderer component3 = ((Component)__instance).GetComponent<SpriteRenderer>();
if ((Object)(object)component3 != (Object)null)
{
component3.color = new Color(1f, 1f, 1f, component3.color.a);
}
}
}
}
[HarmonyPatch(typeof(setSprite), "Update")]
[HarmonyPriority(0)]
internal static class SuperSaiyanVisibleSpritePatch
{
private static void Postfix(setSprite __instance)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.sr == (Object)null)
{
return;
}
PlayerInfo val = ObamaChecks.FindOwner((Component)(object)__instance);
if (!ObamaChecks.IsObama(val) || val.superID != 2)
{
return;
}
SuperSaiyanState component = ((Component)val).GetComponent<SuperSaiyanState>();
if (!((Object)(object)component == (Object)null) && component.Transformed)
{
__instance.sr.color = new Color(1f, 0.82f, 0.12f, __instance.sr.color.a);
if (!component.RendererDiagnosticWritten)
{
component.RendererDiagnosticWritten = true;
Plugin.Diagnostic("YellowTint visibleHook renderer=" + ((Object)__instance.sr).name + " color=" + ((object)__instance.sr.color/*cast due to .constrained prefix*/).ToString());
}
}
}
}
[HarmonyPatch(typeof(BidenExDecider), "OnEnable")]
[HarmonyPriority(800)]
internal static class SuperSaiyanExFinisherPatch
{
private static bool Prefix(BidenExDecider __instance)
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
PlayerInfo val = ObamaChecks.FindOwner((Component)(object)__instance);
if (!ObamaChecks.IsObama(val) || val.superID != 2)
{
return true;
}
SuperSaiyanState component = ((Component)val).GetComponent<SuperSaiyanState>();
if ((Object)(object)component == (Object)null || !component.Transformed)
{
return true;
}
Plugin.Diagnostic("BidenExDecider reached for player=" + val.player + " ex=" + ((Object)(object)__instance.ex != (Object)null) + " normal=" + ((Object)(object)__instance.normal != (Object)null));
if ((Object)(object)__instance.normal != (Object)null)
{
__instance.normal.SetActive(false);
}
if ((Object)(object)__instance.ex != (Object)null)
{
SpriteRenderer[] componentsInChildren = __instance.ex.GetComponentsInChildren<SpriteRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].color = new Color(0.1f, 0.55f, 1f, componentsInChildren[i].color.a);
}
__instance.ex.SetActive(true);
val.currentAnim = __instance.ex;
}
((Component)__instance).gameObject.SetActive(false);
return false;
}
}
[HarmonyPatch(typeof(exbidenblast), "OnEnable")]
[HarmonyPriority(800)]
internal static class SuperSaiyanExBlastDiagnosticPatch
{
private static void Prefix(exbidenblast __instance)
{
PlayerInfo val = ObamaChecks.FindOwner((Component)(object)__instance);
Plugin.Diagnostic("exbidenblast.OnEnable object=" + ((Object)__instance).name + " parentOwner=" + (((Object)(object)val != (Object)null) ? (val.characterID + "/player" + val.player) : "null"));
}
}
[HarmonyPatch(typeof(rselectDisplay), "Start")]
internal static class SuperSaiyanMenuPatch
{
private static void Postfix(rselectDisplay __instance)
{
SuperSaiyanMenu.Ensure(__instance);
}
}
internal static class SuperSaiyanMenu
{
internal static void EnsureAll()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
rselectDisplay[] array = Resources.FindObjectsOfTypeAll<rselectDisplay>();
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null)
{
Scene scene = ((Component)array[i]).gameObject.scene;
if (((Scene)(ref scene)).IsValid())
{
Ensure(array[i]);
}
}
}
}
internal static void Ensure(rselectDisplay display)
{
//IL_00fb: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)display == (Object)null || (Object)(object)display.target == (Object)null || display.superNames == null || display.superNames.Length == 0 || display.superNames[0] != "Obamahameha")
{
return;
}
VerticalMenu component = ((Component)display).GetComponent<VerticalMenu>();
if ((Object)(object)component == (Object)null || component.menuOptions == null || component.menuOptions.Length == 0)
{
return;
}
if (display.superNames.Length < 2)
{
int num = ((display.superCosts != null && display.superCosts.Length != 0) ? display.superCosts[0] : 6);
display.superNames = new string[2] { "Obamahameha", "Super Sayian" };
display.superCosts = new int[2] { num, 4 };
}
if (component.menuOptions.Length < 2)
{
GameObject val = component.menuOptions[0];
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
((Object)val2).name = "Super Sayian";
val2.transform.localPosition = val.transform.localPosition + new Vector3(0f, -60f, 0f);
menuSetSuper component2 = val2.GetComponent<menuSetSuper>();
if ((Object)(object)component2 != (Object)null)
{
component2.superInt = 2;
component2.superName = "Super Sayian";
component2.player = component.player;
}
component.menuOptions = (GameObject[])(object)new GameObject[2] { val, val2 };
string[] obj = new string[5] { "Obama Overdrive: injected Super Saiyan into ", null, null, null, null };
Scene scene = ((Component)display).gameObject.scene;
obj[1] = ((Scene)(ref scene)).name;
obj[2] = " player ";
obj[3] = component.player.ToString();
obj[4] = " selector.";
Debug.Log((object)string.Concat(obj));
}
int num2 = 1;
if (display.superNames.Length > num2)
{
display.superNames[num2] = "Super Sayian";
}
if (display.superCosts != null && display.superCosts.Length > num2)
{
display.superCosts[num2] = 4;
}
if (component.menuOptions.Length > num2)
{
((Object)component.menuOptions[num2]).name = "Super Sayian";
menuSetSuper component3 = component.menuOptions[num2].GetComponent<menuSetSuper>();
if ((Object)(object)component3 != (Object)null)
{
component3.superInt = 2;
component3.superName = "Super Sayian";
component3.player = component.player;
}
}
if (display.target.boxSprites != null && display.target.boxSprites.Length == 1)
{
display.target.boxSprites = (Sprite[])(object)new Sprite[2]
{
display.target.boxSprites[0],
display.target.boxSprites[0]
};
}
if (display.target.numberSprites != null && display.target.numberSprites.Length == 1)
{
display.target.numberSprites = (Sprite[])(object)new Sprite[2]
{
display.target.numberSprites[0],
display.target.numberSprites[0]
};
}
}
}
public sealed class ObamukenMarker : MonoBehaviour
{
public PlayerInfo Owner;
public bool BonusHitsApplied;
}
internal static class ObamukenShotgun
{
private static readonly float[] SpreadAngles = new float[5] { -20f, -10f, 0f, 10f, 20f };
internal static bool HandleSpawner(BasicProjectileSpawner spawner)
{
PlayerInfo val = (((Object)(object)spawner.info != (Object)null) ? spawner.info : ObamaChecks.FindOwner((Component)(object)spawner));
if (!ObamaChecks.IsObama(val) || (Object)(object)val.receiver == (Object)null || !IsObamukenAnimation(val.currentAnim))
{
return true;
}
bool stationary = val.receiver.holdingAttack > 0 && val.receiver.holdingSpecial > 0;
for (int i = 0; i < SpreadAngles.Length; i++)
{
Spawn(spawner, val, SpreadAngles[i], stationary);
}
return false;
}
private static bool IsObamukenAnimation(GameObject animation)
{
if ((Object)(object)animation == (Object)null)
{
return false;
}
if (!(((Object)animation).name == "Fireball Ground"))
{
return ((Object)animation).name == "Fireball Air";
}
return true;
}
private static void Spawn(BasicProjectileSpawner spawner, PlayerInfo obama, float angleDegrees, bool stationary)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_014c: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: 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_019d: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)spawner.prefab == (Object)null)
{
return;
}
Vector3 position = spawner.prefab.transform.position;
Vector3 val = (spawner.useSpawnerPositionInsteadOfPlayer ? new Vector3(((Component)spawner).transform.position.x + position.x * (float)obama.facing, ((Component)spawner).transform.position.y + position.y, 0f) : new Vector3(((Component)obama).transform.position.x + position.x * (float)obama.facing, ((Component)obama).transform.position.y + position.y, 0f));
float num = angleDegrees * (MathF.PI / 180f);
if (stationary)
{
val += new Vector3(Mathf.Cos(num) * 1.25f * (float)obama.facing, Mathf.Sin(num) * 1.25f, 0f);
}
Vector3 val2 = (Vector3)((obama.facing != 1 || spawner.prefabRotation.z == 0f) ? spawner.prefabRotation : new Vector3(spawner.prefabRotation.x, spawner.prefabRotation.y, 0f - spawner.prefabRotation.z));
val2.z += angleDegrees * (float)obama.facing;
GameObject val3 = Object.Instantiate<GameObject>(spawner.prefab, val, Quaternion.Euler(val2));
val3.AddComponent<ObamukenMarker>().Owner = obama;
val3.transform.localScale = new Vector3((float)obama.facing * val3.transform.localScale.x, val3.transform.localScale.y, 1f);
hitBoxAssigner component = val3.GetComponent<hitBoxAssigner>();
if ((Object)(object)component != (Object)null)
{
component.info = obama;
}
JustAnimate component2 = val3.GetComponent<JustAnimate>();
if ((Object)(object)component2 != (Object)null)
{
component2.info = obama;
}
projectileTraj component3 = val3.GetComponent<projectileTraj>();
if (!((Object)(object)component3 == (Object)null))
{
Vector3 val4 = ((spawner.specialTraj != Vector3.zero) ? spawner.specialTraj : ((component3.constantTraj != Vector3.zero) ? component3.constantTraj : component3.traj));
component3.constantTraj = Vector3.zero;
component3.accel = Vector3.zero;
component3.scale = Vector3.zero;
component3.dontAdjustForFacing = true;
if (stationary)
{
component3.traj = Vector3.zero;
return;
}
val4.x = Mathf.Abs(val4.x) * (float)obama.facing;
component3.traj = new Vector3(val4.x * Mathf.Cos(num) - val4.y * Mathf.Sin(num), val4.x * Mathf.Sin(num) + val4.y * Mathf.Cos(num), 0f);
}
}
}
[HarmonyPatch(typeof(BasicProjectileSpawner), "OnEnable")]
internal static class ObamukenSpawnerPatch
{
private static bool Prefix(BasicProjectileSpawner __instance)
{
if (!Plugin.EnableEarlierObamaChanges)
{
return true;
}
return ObamukenShotgun.HandleSpawner(__instance);
}
}
[HarmonyPatch(typeof(HitBoxInterpreter), "StrongHit")]
[HarmonyPriority(0)]
internal static class TripleObamukenHitPatch
{
private static void Prefix(HitBoxInterpreter __instance)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.info == (Object)null || (Object)(object)__instance.info.enemyScript == (Object)null)
{
return;
}
PlayerInfo info = __instance.info;
if (ObamaChecks.IsObama(info))
{
SuperSaiyanState component = ((Component)info).GetComponent<SuperSaiyanState>();
if (!((Object)(object)component == (Object)null) && component.ActivationCount >= 1 && (component.LastAppliedDamageFrame != Time.frameCount || !((Object)(object)component.LastAppliedDamageTarget == (Object)(object)__instance.info.enemyScript)))
{
component.PendingHealth = __instance.info.enemyScript.health;
component.PendingTarget = __instance.info.enemyScript;
component.PendingSuperCharge = info.superCharge;
component.PendingHit = true;
}
}
}
private static void Postfix(HitBoxInterpreter __instance)
{
ObamukenMarker component = ((Component)((Component)__instance).transform.root).GetComponent<ObamukenMarker>();
if ((Object)(object)__instance.info == (Object)null || (Object)(object)__instance.info.enemyScript == (Object)null)
{
return;
}
PlayerInfo info = __instance.info;
if (ObamaChecks.IsObama(info))
{
SuperSaiyanState component2 = ((Component)info).GetComponent<SuperSaiyanState>();
if ((Object)(object)component2 != (Object)null && component2.PendingHit && (Object)(object)component2.PendingTarget == (Object)(object)__instance.info.enemyScript)
{
int num = 4;
__instance.info.enemyScript.health = component2.PendingHealth - num;
info.superCharge = Mathf.Min(4, component2.PendingSuperCharge + num);
component2.LastAppliedDamageFrame = Time.frameCount;
component2.LastAppliedDamageTarget = __instance.info.enemyScript;
Plugin.Diagnostic("Hit stage=" + component2.ActivationCount + " damage=" + num + " superCharge=" + info.superCharge);
component2.PendingHit = false;
if ((Object)(object)Plugin.Instance != (Object)null)
{
((MonoBehaviour)Plugin.Instance).StartCoroutine(Plugin.FinalizeDamage(info, __instance.info.enemyScript, component2.PendingHealth, component2.PendingSuperCharge));
}
}
}
if (Plugin.EnableEarlierObamaChanges && !((Object)(object)component == (Object)null) && !component.BonusHitsApplied && ObamaChecks.IsObama(component.Owner) && __instance.info.hit == 1 && __instance.info.enemyScript.hit == -1)
{
component.BonusHitsApplied = true;
PlayerInfo enemyScript = __instance.info.enemyScript;
enemyScript.health -= 2;
PlayerInfo owner = component.Owner;
owner.score += 2;
PlayerInfo owner2 = component.Owner;
owner2.superCharge += 2;
}
}
}
internal static class ObamaChecks
{
internal static bool IsObama(PlayerInfo info)
{
if ((Object)(object)info != (Object)null)
{
return info.characterID == "Obama TA";
}
return false;
}
internal static PlayerInfo FindOwner(Component component)
{
Transform val = component.transform;
while ((Object)(object)val != (Object)null)
{
PlayerInfo component2 = ((Component)val).GetComponent<PlayerInfo>();
if ((Object)(object)component2 != (Object)null)
{
return component2;
}
val = val.parent;
}
return null;
}
internal static bool IsObamuken(Options options)
{
if ((Object)(object)options == (Object)null)
{
return false;
}
string name = ((Object)((Component)options).gameObject).name;
if (!(name == "Fireball Ground"))
{
return name == "Fireball Air";
}
return true;
}
}
[HarmonyPatch(typeof(obamawifforhit), "OnEnable")]
internal static class AlwaysHitSuperPatch
{
private static void Prefix(obamawifforhit __instance)
{
if (Plugin.EnableEarlierObamaChanges)
{
PlayerInfo val = ObamaChecks.FindOwner((Component)(object)__instance);
if (ObamaChecks.IsObama(val) && !((Object)(object)val.enemyScript == (Object)null))
{
val.enemyScript.hit = -2;
val.enemyScript.superTimer = 0;
}
}
}
}
[HarmonyPatch(typeof(ObamaChargeUI), "FixedUpdate")]
internal static class NoUniqueCooldownPatch
{
private static void Postfix(ObamaChargeUI __instance)
{
if (Plugin.EnableEarlierObamaChanges && !__instance.notObama && ObamaChecks.IsObama(__instance.info))
{
__instance.totalChargeTime = 0;
__instance.startFrame = 0;
__instance.charge = 0;
__instance.chargeReady = true;
Refill(__instance.groundOption);
Refill(__instance.airOption);
}
}
private static void Refill(GameObject optionObject)
{
if (!((Object)(object)optionObject == (Object)null))
{
Options component = optionObject.GetComponent<Options>();
if (!((Object)(object)component == (Object)null))
{
component.chargesSet = true;
component.maxCharges = 1000;
component.charges = 1000;
}
}
}
}
[HarmonyPatch(typeof(Options), "OnEnable")]
internal static class InstantObamukenPatch
{
private static void Postfix(Options __instance)
{
if (!Plugin.EnableEarlierObamaChanges || !ObamaChecks.IsObama(ObamaChecks.FindOwner((Component)(object)__instance)) || !ObamaChecks.IsObamuken(__instance))
{
return;
}
__instance.lockOut = false;
__instance.actionableFrame = 0;
__instance.chargesSet = true;
__instance.maxCharges = 1000;
__instance.charges = 1000;
if (__instance.frames != null && __instance.frames.Length > 3)
{
if ((Object)(object)__instance.frames[__instance.currentAnim].spriteObject != (Object)null)
{
__instance.frames[__instance.currentAnim].spriteObject.SetActive(false);
}
__instance.currentFrame = 24;
__instance.currentAnim = 3;
__instance.currentAnimFrame = 0;
if ((Object)(object)__instance.frames[3].spriteObject != (Object)null)
{
__instance.frames[3].spriteObject.SetActive(true);
}
}
}
}