using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Engi.EngiWeapon;
using EntityStates.Railgunner.Weapon;
using Microsoft.CodeAnalysis;
using On.RoR2.CharacterAI;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPaths;
using UnityEngine;
using UnityEngine.AddressableAssets;
[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RailgunnerTurret")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fb15dd3fbd463a8288797890aa10e39092691980")]
[assembly: AssemblyProduct("RailgunnerTurret")]
[assembly: AssemblyTitle("RailgunnerTurret")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RailgunnerTurret
{
public class Assets
{
public static GameObject railgunnerTurretPrefab;
public static GameObject railgunnerTurretMasterPrefab;
public static GameObject wristDisplay = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Engi.EngiTurretWristDisplay_prefab).WaitForCompletion();
public static GameObject blueprints = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Engi.EngiWalkerTurretBlueprints_prefab).WaitForCompletion();
public static GameObject hitEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC1_Railgunner.ImpactRailgun_prefab).WaitForCompletion();
public static GameObject muzzleFlashPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Common_VFX.Muzzleflash1_prefab).WaitForCompletion();
public static GameObject tracerEffectPrefab;
public static void Init()
{
CreateRailgunnerTurretPrefab();
CreateRailgunnerTurretSkill();
CreateTracerEffectPrefab();
}
public static void CreateTracerEffectPrefab()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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: Expected O, but got Unknown
tracerEffectPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC1_Railgunner.TracerRailgunSuper_prefab).WaitForCompletion(), "RailgunnerTurretTracerEffectPrefab", false);
((Component)tracerEffectPrefab.transform.Find("StartTransform/PP")).gameObject.SetActive(false);
ContentPacks.effectDefs.Add(new EffectDef(tracerEffectPrefab));
}
public static void CreateRailgunnerTurretPrefab()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Invalid comparison between Unknown and I4
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Invalid comparison between Unknown and I4
railgunnerTurretPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Engi.EngiWalkerTurretBody_prefab).WaitForCompletion(), "RailgunnerTurretBody");
ContentPacks.bodyPrefabs.Add(railgunnerTurretPrefab);
railgunnerTurretMasterPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Engi.EngiWalkerTurretMaster_prefab).WaitForCompletion(), "RailgunnerTurretMaster");
ContentPacks.masterPrefabs.Add(railgunnerTurretMasterPrefab);
CharacterMaster component = railgunnerTurretMasterPrefab.GetComponent<CharacterMaster>();
component.bodyPrefab = railgunnerTurretPrefab;
CharacterBody component2 = railgunnerTurretPrefab.GetComponent<CharacterBody>();
((Object)component2).name = "RailgunnerTurretBody";
SkillLocator component3 = ((Component)component2).GetComponent<SkillLocator>();
component2.baseMoveSpeed *= 0.6f;
SkillDef val = Object.Instantiate<SkillDef>(Addressables.LoadAssetAsync<SkillDef>((object)RoR2_DLC1_Railgunner.RailgunnerBodyFireSnipeSuper_asset).WaitForCompletion());
ContentPacks.skillDefs.Add(val);
val.activationState = new SerializableEntityStateType(typeof(FireSnipeSuperTurret));
ContentPacks.entityStateTypes.Add(typeof(FireSnipeSuperTurret));
val.baseRechargeInterval = 21f;
val.baseMaxStock = 1;
SkillFamily skillFamily = component3.primary.skillFamily;
Variant[] array = new Variant[1];
Variant val2 = new Variant
{
skillDef = val,
unlockableDef = null
};
((Variant)(ref val2)).viewableNode = new Node(val.skillNameToken, false, (Node)null);
array[0] = val2;
skillFamily.variants = (Variant[])(object)array;
AISkillDriver[] components = ((Component)component).GetComponents<AISkillDriver>();
AISkillDriver[] array2 = components;
foreach (AISkillDriver val3 in array2)
{
if ((int)val3.skillSlot == 0)
{
val3.maxDistance = 9999f;
val3.activationRequiresTargetLoS = true;
val3.activationRequiresAimConfirmation = true;
val3.activationRequiresAimTargetLoS = true;
}
if ((int)val3.moveTargetType == 2 && val3.minDistance == 110f)
{
val3.minDistance = 30f;
}
}
AddRailgunnerSoundbank(railgunnerTurretPrefab);
}
private static void AddRailgunnerSoundbank(GameObject gameObject)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
AkBank component = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC1_Railgunner.RailgunnerBody_prefab).WaitForCompletion().GetComponent<AkBank>();
if ((Object)(object)component != (Object)null)
{
AkBank val = gameObject.AddComponent<AkBank>();
((AkTriggerHandler)val).triggerList = ((AkTriggerHandler)component).triggerList;
val.data.WwiseObjectReference = component.data.WwiseObjectReference;
val.unloadTriggerList = component.unloadTriggerList;
}
}
private static void CreateRailgunnerTurretSkill()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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)
SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)RoR2_Base_Engi.EngiBodyPlaceWalkerTurret_asset).WaitForCompletion();
SkillDef val2 = Object.Instantiate<SkillDef>(val);
val2.skillName = "RailgunnerTurret";
val2.skillNameToken = "ENGI_RAILGUNNER_TURRET_NAME";
val2.skillDescriptionToken = "ENGI_RAILGUNNER_TURRET_DESC";
LanguageAPI.Add("ENGI_RAILGUNNER_TURRET_NAME", "TRM99 \"Noisy Cricket\"");
LanguageAPI.Add("ENGI_RAILGUNNER_TURRET_DESC", "Place a <style=cIsUtility>mobile</style> turret that <style=cIsUtility>inherits all your items.</style> Fires a high powered laser for <style=cIsDamage>3000% damage</style> with a cooldown of <style=cIsDamage>21 seconds</style>. Targets the <style=cIsUtility>highest health</style> enemy it can see. Can place up to 2.");
val2.activationState = new SerializableEntityStateType(typeof(PlaceRailgunnerTurret));
ContentPacks.entityStateTypes.Add(typeof(PlaceRailgunnerTurret));
SkillFamily val3 = Addressables.LoadAssetAsync<SkillFamily>((object)RoR2_Base_Engi.EngiBodySpecialFamily_asset).WaitForCompletion();
Variant val4 = default(Variant);
val4.skillDef = val2;
Variant element = val4;
val3.variants = val3.variants.Append(element).ToArray();
ContentAddition.AddSkillDef(val2);
}
}
public class PlaceRailgunnerTurret : PlaceWalkerTurret
{
public override void OnEnter()
{
((PlaceTurret)this).wristDisplayPrefab = Assets.wristDisplay;
((PlaceTurret)this).blueprintPrefab = Assets.blueprints;
((PlaceTurret)this).placeSoundString = "";
((PlaceTurret)this).turretMasterPrefab = Assets.railgunnerTurretMasterPrefab;
((PlaceTurret)this).OnEnter();
}
}
public class FireSnipeSuperTurret : FireSnipeSuper
{
public override void OnEnter()
{
((GenericBulletBaseState)this).hitEffectPrefab = Assets.hitEffectPrefab;
((GenericBulletBaseState)this).force = 4000f;
((BaseFireSnipe)this).headshotSoundString = "Play_railgunner_m2_headshot";
((GenericBulletBaseState)this).fireSoundString = "Play_railgunner_R_fire";
((GenericBulletBaseState)this).damageCoefficient = 30f;
((BaseFireSnipe)this).critDamageMultiplier = 1.5f;
((GenericBulletBaseState)this).bulletRadius = 1f;
((GenericBulletBaseState)this).bulletCount = 1;
((GenericBulletBaseState)this).baseDuration = 1f;
((BaseFireSnipe)this).animationStateName = "FireSuper";
((BaseFireSnipe)this).animationPlaybackRateParam = "Super.playbackRate";
((BaseFireSnipe)this).animationLayerName = "Gesture, Override";
((GenericBulletBaseState)this).recoilAmplitudeX = 1f;
((GenericBulletBaseState)this).recoilAmplitudeY = 6f;
((GenericBulletBaseState)this).procCoefficient = 1.5f;
((BaseFireSnipe)this).piercingDamageCoefficientPerTarget = 1f;
((GenericBulletBaseState)this).muzzleName = "Muzzle";
((GenericBulletBaseState)this).muzzleFlashPrefab = Assets.muzzleFlashPrefab;
((GenericBulletBaseState)this).minSpread = 0f;
((GenericBulletBaseState)this).maxSpread = 0f;
((GenericBulletBaseState)this).maxDistance = 9999f;
((BaseFireSnipe)this).isPiercing = true;
((GenericBulletBaseState)this).useSmartCollision = true;
((BaseFireSnipe)this).useSecondaryStocks = false;
((BaseFireSnipe)this).trajectoryAimAssistMultiplier = 0f;
((GenericBulletBaseState)this).tracerEffectPrefab = Assets.tracerEffectPrefab;
((GenericBulletBaseState)this).spreadYawScale = 0f;
((GenericBulletBaseState)this).spreadPitchScale = 0f;
((GenericBulletBaseState)this).spreadBloomValue = 0f;
((BaseFireSnipe)this).selfKnockbackForce = 10000f;
((BaseFireSnipe)this).OnEnter();
}
public override void ModifyBullet(BulletAttack bulletAttack)
{
((FireSnipeSuper)this).ModifyBullet(bulletAttack);
bulletAttack.sniper = false;
EntityStateMachine component = ((Component)((EntityState)this).characterBody).GetComponent<EntityStateMachine>();
EntityState state = component.state;
GenericCharacterMain val = (GenericCharacterMain)(object)((state is GenericCharacterMain) ? state : null);
if (val != null)
{
val.jumpInputReceived = true;
val.ProcessJump(true);
}
}
}
internal class ContentPacks : IContentPackProvider
{
[CompilerGenerated]
private sealed class <FinalizeAsync>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public FinalizeAsyncArgs args;
public ContentPacks <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FinalizeAsync>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
args.ReportProgress(1f);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <GenerateContentPackAsync>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public GetContentPackAsyncArgs args;
public ContentPacks <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GenerateContentPackAsync>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
ContentPack.Copy(<>4__this.contentPack, args.output);
args.ReportProgress(1f);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <LoadStaticContentAsync>d__10 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public LoadStaticContentAsyncArgs args;
public ContentPacks <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadStaticContentAsync>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
<>4__this.contentPack.identifier = <>4__this.identifier;
<>4__this.contentPack.bodyPrefabs.Add(bodyPrefabs.ToArray());
<>4__this.contentPack.masterPrefabs.Add(masterPrefabs.ToArray());
<>4__this.contentPack.entityStateTypes.Add(entityStateTypes.ToArray());
<>4__this.contentPack.skillDefs.Add(skillDefs.ToArray());
<>4__this.contentPack.effectDefs.Add(effectDefs.ToArray());
args.ReportProgress(1f);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal ContentPack contentPack = new ContentPack();
public static List<GameObject> bodyPrefabs = new List<GameObject>();
public static List<GameObject> masterPrefabs = new List<GameObject>();
public static List<EffectDef> effectDefs = new List<EffectDef>();
public static List<SkillDef> skillDefs = new List<SkillDef>();
public static List<Type> entityStateTypes = new List<Type>();
public string identifier => "bouncyshield.RailgunnerTurret";
public void Init()
{
//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);
}
[IteratorStateMachine(typeof(<LoadStaticContentAsync>d__10))]
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadStaticContentAsync>d__10(0)
{
<>4__this = this,
args = args
};
}
[IteratorStateMachine(typeof(<GenerateContentPackAsync>d__11))]
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GenerateContentPackAsync>d__11(0)
{
<>4__this = this,
args = args
};
}
[IteratorStateMachine(typeof(<FinalizeAsync>d__12))]
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FinalizeAsync>d__12(0)
{
<>4__this = this,
args = args
};
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("bouncyshield.RailgunnerTurret", "RailgunnerTurret", "1.0.0")]
public class RailgunnerTurret : BaseUnityPlugin
{
public const string PluginGUID = "bouncyshield.RailgunnerTurret";
public const string PluginAuthor = "bouncyshield";
public const string PluginName = "RailgunnerTurret";
public const string PluginVersion = "1.0.0";
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Hooks();
Assets.Init();
new ContentPacks().Init();
}
private void Hooks()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
BaseAI.UpdateTargets += new hook_UpdateTargets(TurretUpdateTargets);
}
private void TurretUpdateTargets(orig_UpdateTargets orig, BaseAI self)
{
//IL_005e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_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_008c: 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_009e: 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_00a7: Expected O, but got Unknown
orig.Invoke(self);
CharacterBody body = self.body;
if (!((Object)self).name.Contains("RailgunnerTurret"))
{
return;
}
InputBankTest inputBank = body.inputBank;
TeamComponent teamComponent = body.teamComponent;
if ((Object)(object)body == (Object)null || (Object)(object)inputBank == (Object)null || (Object)(object)teamComponent == (Object)null)
{
return;
}
BullseyeSearch val = new BullseyeSearch
{
searchOrigin = body.corePosition,
searchDirection = inputBank.aimDirection,
teamMaskFilter = TeamMask.GetEnemyTeams(teamComponent.teamIndex),
maxDistanceFilter = 9999f,
filterByLoS = true,
sortMode = (SortMode)0
};
val.RefreshCandidates();
HurtBox val2 = null;
float num = float.NegativeInfinity;
foreach (HurtBox result in val.GetResults())
{
float combinedHealth = result.healthComponent.combinedHealth;
if (combinedHealth > num)
{
num = combinedHealth;
val2 = result;
}
}
if (Object.op_Implicit((Object)(object)val2))
{
self.currentEnemy.bestHurtBox = val2;
}
}
}
}