using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Agents;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using StateMachines;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("GAU8Avenger")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GAU8Avenger")]
[assembly: AssemblyTitle("GAU8Avenger")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace GAU8Avenger
{
public class GAU8 : MonoBehaviour
{
private const float AfterburnDuration = 0f;
private static float _afterburnTimer = 0f;
private static bool _didVertForThisUpdate = false;
private static bool _didHorForThisUpdate = false;
private static bool _horMvmt = false;
private static bool _horIsForward = false;
private static float _horPortion = 0f;
private static float _vertPortion = 0f;
private static float _ang2Vert = 0f;
private static readonly Vector3 Up = new Vector3(0f, 1f, 0f);
private static Vector3 _forward = Vector3.zero;
private static Vector3 _flatForward = Vector3.zero;
public static bool PreventWarpToGoodNode = false;
private static float _preventWarpActiveDuration = 0f;
private static float _horForwardMult = 0.5f;
private static float _horStillMag = 4f;
private static float _horBackMag = 20f;
private static float _vertUpMaxMag = 8f;
private static float _vertDownMaxMag = 12f;
private static float _vertUnitImpulse = 1.2f;
private static float _preventWarpDuration = 0.2f;
private static bool EffectEnabled { get; set; } = false;
public static uint ArchetypeID { get; private set; } = 71001u;
public static uint GearID { get; private set; } = 71101u;
private static bool EnsureUniqueIDs()
{
int num = 0;
while (GameDataBlockBase<ArchetypeDataBlock>.HasBlock(ArchetypeID) && num < 2000)
{
num++;
ArchetypeID++;
}
if (GameDataBlockBase<ArchetypeDataBlock>.HasBlock(ArchetypeID))
{
return false;
}
int num2 = 0;
while (!GameDataBlockBase<PlayerOfflineGearDataBlock>.HasBlock(GearID) && num2 < 2000)
{
num2++;
GearID++;
}
if (GameDataBlockBase<PlayerOfflineGearDataBlock>.HasBlock(GearID))
{
return false;
}
return true;
}
public static void AddGear()
{
//IL_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_006d: 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_0073: 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_008a: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Expected O, but got Unknown
//IL_01e0: Expected O, but got Unknown
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Expected O, but got Unknown
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Expected O, but got Unknown
//IL_0234: Expected O, but got Unknown
if (!EnsureUniqueIDs())
{
Logger.Error("Could not find unique IDs for GAU-8 Avenger archetype or gear!");
return;
}
List<WeaponAnimSequenceItem> val = new List<WeaponAnimSequenceItem>();
val.Add(new WeaponAnimSequenceItem
{
TriggerTime = 0f,
Type = (eWeaponAnimSequenceItemType)0,
StringData = "Front_Bullpup_1_equip_weaponmovement"
});
val.Add(new WeaponAnimSequenceItem
{
TriggerTime = 2f,
Type = (eWeaponAnimSequenceItemType)7
});
ArchetypeDataBlock val2 = new ArchetypeDataBlock();
((GameDataBlockBase<ArchetypeDataBlock>)val2).name = "GAU8_Avenger";
val2.PublicName = new LocalizedText
{
Id = 0u,
UntranslatedText = "A-10 Warthog"
};
val2.Description = new LocalizedText
{
Id = 0u,
UntranslatedText = "#SecretVault\nThe A-10 Warthog's GAU-8 Avenger single-barrel (?) rotary cannon is brought into the complex, courtesy of @randomuserhi"
};
val2.RecoilDataID = 31u;
val2.Damage = 1.1f;
val2.ShotDelay = 0.006f;
val2.DefaultClipSize = 280;
val2.CostOfBullet = 0.3f;
val2.DamageFalloff = new Vector2(25f, 65f);
val2.PiercingBullets = true;
val2.PiercingDamageCountLimit = 3;
val2.HipFireSpread = 1.4f;
val2.AimTransitionTime = 0.22f;
val2.DefaultReloadTime = 1.8f;
val2.SpecialChargetupTime = 0.2f;
val2.SpecialCooldownTime = 0.1f;
val2.FireMode = (eWeaponFireMode)2;
val2.DamageBoosterEffect = (AgentModifier)67;
val2.StaggerDamageMulti = 1f;
val2.PrecisionDamageMulti = 1f;
val2.ShellCasingSize = 1f;
val2.AimSpread = 0.1f;
val2.EquipTransitionTime = 0.5f;
val2.ShellCasingSpeedRange = new Vector2(3f, 5f);
val2.EquipSequence = val;
val2.AimSequence = new List<WeaponAnimSequenceItem>();
val2.BurstDelay = 0f;
val2.BurstShotCount = 0;
val2.ShotgunBulletCount = 0;
val2.ShotgunConeSize = 0;
val2.ShotgunBulletSpread = 0;
val2.SpecialSemiBurstCountTimeout = 0f;
((GameDataBlockBase<ArchetypeDataBlock>)val2).persistentID = ArchetypeID;
ArchetypeDataBlock val3 = val2;
GameDataBlockBase<ArchetypeDataBlock>.AddBlock(val3, -1);
GameDataBlockBase<GearCategoryDataBlock>.GetBlock(17u).BurstArchetype = ((GameDataBlockBase<ArchetypeDataBlock>)(object)val3).persistentID;
PlayerOfflineGearDataBlock val4 = new PlayerOfflineGearDataBlock
{
Type = (eOfflineGearType)1
};
((GameDataBlockBase<PlayerOfflineGearDataBlock>)val4).name = "GAU8_Avenger";
val4.GearJSON = "{\"Ver\":1,\"Name\":\"GAU-8 Avenger\",\"Packet\":{\"Comps\":{\"Length\":14,\"a\":{\"c\":1,\"v\":1},\"b\":{\"c\":2,\"v\":17},\"c\":{\"c\":3,\"v\":108},\"d\":{\"c\":4,\"v\":22},\"e\":{\"c\":5,\"v\":38},\"f\":{\"c\":6,\"v\":2},\"g\":{\"c\":7,\"v\":2},\"h\":{\"c\":12,\"v\":41},\"i\":{\"c\":16,\"v\":8},\"j\":{\"c\":19,\"v\":17},\"k\":{\"c\":21,\"v\":4},\"l\":{\"c\":23,\"v\":17},\"m\":{\"c\":25,\"v\":5}},\"publicName\":{\"data\":\"GAU-8 Avenger\"}}}";
((GameDataBlockBase<PlayerOfflineGearDataBlock>)val4).internalEnabled = true;
((GameDataBlockBase<PlayerOfflineGearDataBlock>)val4).persistentID = GearID;
GameDataBlockBase<PlayerOfflineGearDataBlock>.AddBlock(val4, -1);
}
private void FixedUpdate()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//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_005c: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
if (EffectEnabled)
{
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if (!((Agent)localPlayerAgent).IsLocallyOwned)
{
Logger.Error("Cannot apply effect to non-local player agent!");
return;
}
Vector3 inputMoveVector = localPlayerAgent.Locomotion.GetInputMoveVector(true);
FPSCamera fPSCamera = localPlayerAgent.FPSCamera;
_forward = fPSCamera.Forward;
_flatForward = ((LookCameraController)fPSCamera).FlatForward;
_horMvmt = ((Vector3)(ref inputMoveVector)).magnitude > 0.1f;
_horIsForward = Vector3.Dot(_flatForward, ((Vector3)(ref inputMoveVector)).normalized) >= -0.001f;
_vertPortion = Vector3.Dot(_forward, Up);
_horPortion = Mathf.Sqrt(1f - _vertPortion * _vertPortion);
_ang2Vert = Mathf.Acos(_vertPortion);
_didHorForThisUpdate = false;
_didVertForThisUpdate = false;
}
}
public static void ApplyEffectHor()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_0035: 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_0052: Unknown result type (might be due to invalid IL or missing references)
if (!EffectEnabled || _didHorForThisUpdate)
{
return;
}
_didHorForThisUpdate = true;
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
Vector3 horizontalVelocity = localPlayerAgent.Locomotion.HorizontalVelocity;
if (_horMvmt)
{
if (_horIsForward)
{
horizontalVelocity *= 1f - _horPortion * (1f - _horForwardMult);
}
else
{
float num = Vector3.Dot(_flatForward, horizontalVelocity);
Vector3 val = horizontalVelocity - _flatForward * num;
float magnitude = ((Vector3)(ref val)).magnitude;
float num2 = _horBackMag * _horPortion;
float num3 = Mathf.Sqrt(num2 * num2 - magnitude * magnitude);
horizontalVelocity = val - num3 * _flatForward;
}
}
else
{
horizontalVelocity = (0f - _horPortion * _horStillMag) * _flatForward;
}
localPlayerAgent.Locomotion.HorizontalVelocity = horizontalVelocity;
}
public static void ApplyEffectVert()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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)
//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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if (!EffectEnabled || _didVertForThisUpdate)
{
return;
}
_didVertForThisUpdate = true;
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
Vector3 val = localPlayerAgent.Locomotion.VerticalVelocity;
if (_vertPortion < -0.2f)
{
val -= _vertUnitImpulse * _vertPortion * Up;
if (((Vector3)(ref val)).magnitude > _vertUpMaxMag)
{
val = ((Vector3)(ref val)).normalized * _vertUpMaxMag;
}
}
else if (_vertPortion > 0.2f)
{
val -= _vertUnitImpulse * _vertPortion * Up;
if (((Vector3)(ref val)).magnitude > _vertDownMaxMag)
{
val = ((Vector3)(ref val)).normalized * _vertDownMaxMag;
}
}
localPlayerAgent.Locomotion.VerticalVelocity = val;
}
public static void UpdateEffectState(bool enabled)
{
if (enabled)
{
_afterburnTimer = 0f;
}
EffectEnabled = enabled;
if (enabled)
{
PreventWarpToGoodNode = true;
_preventWarpActiveDuration = 0f;
}
}
private void Update()
{
_preventWarpActiveDuration += Time.deltaTime;
if (PreventWarpToGoodNode && _preventWarpActiveDuration > _preventWarpDuration)
{
PreventWarpToGoodNode = false;
}
if (EffectEnabled)
{
_afterburnTimer += Time.deltaTime;
if (_afterburnTimer > 0f)
{
EffectEnabled = false;
_afterburnTimer = 0f;
}
}
}
}
internal static class Logger
{
private static ManualLogSource _mLogSource;
public static bool Ready => _mLogSource != null;
public static void Setup()
{
_mLogSource = Logger.CreateLogSource("io.takina.gtfo.GAU8Avenger");
}
public static void SetupFromInit(ManualLogSource logSource)
{
_mLogSource = logSource;
}
private static string Format(object data)
{
return data.ToString();
}
public static void Debug(object msg)
{
_mLogSource.LogDebug((object)Format(msg));
}
public static void Info(object msg)
{
_mLogSource.LogInfo((object)Format(msg));
}
public static void Warn(object msg)
{
_mLogSource.LogWarning((object)Format(msg));
}
public static void Error(object msg)
{
_mLogSource.LogError((object)Format(msg));
}
public static void Fatal(object msg)
{
_mLogSource.LogFatal((object)Format(msg));
}
}
[HarmonyPatch]
public class Patch
{
[HarmonyPatch(typeof(BulletWeapon), "Fire")]
[HarmonyPostfix]
public static void BulletWeapon_Fire_Postfix(BulletWeapon __instance)
{
GAU8.UpdateEffectState(((GameDataBlockBase<ArchetypeDataBlock>)(object)((ItemEquippable)__instance).FPItemHolder.WieldedItem.ArchetypeData).persistentID == GAU8.ArchetypeID);
}
[HarmonyPatch(typeof(PLOC_Base), "UpdateHorizontalVelocityOnGround")]
[HarmonyPostfix]
public static void PLOC_Base_UpdateHorizontalVelocityOnGround_Postfix(PLOC_Base __instance)
{
GAU8.ApplyEffectHor();
}
[HarmonyPatch(typeof(PLOC_Base), "UpdateHorizontalVelocityInAir")]
[HarmonyPostfix]
public static void PLOC_Base_UpdateHorizontalVelocityInAir_Postfix(PLOC_Base __instance)
{
GAU8.ApplyEffectHor();
}
[HarmonyPatch(typeof(PLOC_Base), "UpdateVerticalVelocityOnGround")]
[HarmonyPostfix]
public static void PLOC_Base_UpdateVerticalVelocityOnGround_Postfix(PLOC_Base __instance)
{
GAU8.ApplyEffectVert();
}
[HarmonyPatch(typeof(PLOC_Base), "UpdateVerticalVelocityInAir")]
[HarmonyPostfix]
public static void PLOC_Base_UpdateVerticalVelocityInAir_Postfix(PLOC_Base __instance)
{
GAU8.ApplyEffectVert();
}
[HarmonyPatch(typeof(PLOC_Fall), "Update")]
[HarmonyPostfix]
public static void PLOC_Fall_Update(PLOC_Fall __instance)
{
if (GAU8.PreventWarpToGoodNode)
{
__instance.m_enterTime = Clock.Time;
}
}
[HarmonyPatch(typeof(PLOC_Jump), "Update")]
[HarmonyPostfix]
public static void PLOC_Jump_Update(PLOC_Jump __instance)
{
if (GAU8.PreventWarpToGoodNode)
{
((MachineState<PLOC_Base>)(object)__instance).StateChangeTime = Clock.Time;
}
}
}
[BepInPlugin("io.takina.gtfo.GAU8Avenger", "GAU8Avenger", "1.1.1")]
public class Plugin : BasePlugin
{
public const string NAME = "GAU8Avenger";
public const string GUID = "io.takina.gtfo.GAU8Avenger";
public const string VERSION = "1.1.1";
public override void Load()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
Logger.Setup();
Logger.Info("GAU8Avenger [io.takina.gtfo.GAU8Avenger @ 1.1.1]");
Logger.Info("Patching...");
Harmony val = new Harmony("io.takina.gtfo.GAU8Avenger");
EventAPI.OnAssetsLoaded += GAU8.AddGear;
((BasePlugin)this).AddComponent<GAU8>();
val.PatchAll(typeof(Patch));
Logger.Info("Finished Patching");
}
}
}