using System;
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 HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChildTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f1328d46819ad369cfa6686d0cef675bbdfd44f9")]
[assembly: AssemblyProduct("ChildTweaks")]
[assembly: AssemblyTitle("ChildTweaks")]
[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 ChildTweaks
{
public class ChildBlink : BaseState
{
public static GameObject tpEffect = Main.teleportVFX;
public float destealthDuration = 1f;
public float tpDuration = 1f;
public float fireFrolicDuration = 0.3f;
public Material destealtMat = Main.destealthMat;
public string beginSoundString = "Play_child_attack2_teleport";
public string endSoundString = "Play_child_attack2_reappear";
private Transform modelTransform;
private CharacterModel characterModel;
private HurtBoxGroup hurtboxGroup;
private bool frolicFireFired;
private bool tpFired;
public override void OnEnter()
{
((BaseState)this).OnEnter();
((EntityState)this).PlayAnimation("Gesture, Override", "FrolicEnter", "FrolicEnter.playbackRate", 1f, 0f);
fireFrolicDuration += tpDuration;
Util.PlaySound(beginSoundString, ((EntityState)this).gameObject);
FireTPEffect();
modelTransform = ((EntityState)this).GetModelTransform();
if (Object.op_Implicit((Object)(object)modelTransform))
{
characterModel = ((Component)modelTransform).GetComponent<CharacterModel>();
hurtboxGroup = ((Component)modelTransform).GetComponent<HurtBoxGroup>();
}
if (Object.op_Implicit((Object)(object)characterModel))
{
CharacterModel obj = characterModel;
int invisibilityCount = obj.invisibilityCount + 1;
obj.invisibilityCount = invisibilityCount;
}
if (Object.op_Implicit((Object)(object)hurtboxGroup))
{
HurtBoxGroup obj2 = hurtboxGroup;
int invisibilityCount = obj2.hurtBoxesDeactivatorCounter + 1;
obj2.hurtBoxesDeactivatorCounter = invisibilityCount;
}
}
private void FireTPEffect()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
//IL_0038: Expected O, but got Unknown
Vector3 position = ((Component)((BaseState)this).FindModelChild("Chest")).transform.position;
EffectManager.SpawnEffect(tpEffect, new EffectData
{
origin = position,
scale = 1f
}, true);
}
public override void FixedUpdate()
{
((EntityState)this).FixedUpdate();
if ((double)((EntityState)this).fixedAge > (double)tpDuration && !tpFired)
{
tpFired = true;
TeleportAway();
}
if (!((double)((EntityState)this).fixedAge <= (double)fireFrolicDuration) && !frolicFireFired)
{
Util.PlaySound(endSoundString, ((EntityState)this).gameObject);
FireTPEffect();
frolicFireFired = true;
((EntityState)this).outer.SetNextStateToMain();
}
}
public override void OnExit()
{
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
if (!((EntityState)this).outer.destroying)
{
modelTransform = ((EntityState)this).GetModelTransform();
if (Object.op_Implicit((Object)(object)modelTransform))
{
TemporaryOverlayInstance obj = TemporaryOverlayManager.AddOverlay(((Component)modelTransform).gameObject);
obj.duration = destealthDuration;
obj.destroyComponentOnEnd = true;
obj.originalMaterial = destealtMat;
obj.inspectorCharacterModel = ((Component)modelTransform).gameObject.GetComponent<CharacterModel>();
obj.alphaCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
obj.animateShaderAlpha = true;
}
}
if (Object.op_Implicit((Object)(object)characterModel))
{
CharacterModel obj2 = characterModel;
int invisibilityCount = obj2.invisibilityCount - 1;
obj2.invisibilityCount = invisibilityCount;
}
if (Object.op_Implicit((Object)(object)hurtboxGroup))
{
HurtBoxGroup obj3 = hurtboxGroup;
int invisibilityCount = obj3.hurtBoxesDeactivatorCounter - 1;
obj3.hurtBoxesDeactivatorCounter = invisibilityCount;
}
if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
{
((EntityState)this).characterMotor.disableAirControlUntilCollision = false;
}
((EntityState)this).characterBody.transform.LookAt(((Component)((EntityState)this).characterBody.master).GetComponent<BaseAI>().currentEnemy.characterBody.transform.position);
((EntityState)this).OnExit();
}
public void TeleportAway()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_005f: 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_0077: 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_00b5: 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_00c0: 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)
((Component)((EntityState)this).GetComponent<ModelLocator>().modelTransform).GetComponent<CharacterModel>();
NodeGraph nodeGraph = SceneInfo.instance.GetNodeGraph((GraphType)0);
Vector3 corePosition = ((EntityState)this).characterBody.corePosition;
List<NodeIndex> list = nodeGraph.FindNodesInRange(corePosition, 10f, 25f, (HullMask)1);
Vector3 val = default(Vector3);
bool flag = false;
int num = 35;
while (!flag)
{
NodeIndex val2 = list.ElementAt(Random.Range(1, list.Count));
nodeGraph.GetNodePosition(val2, ref val);
double num2 = Vector3.Distance(((EntityState)this).characterBody.coreTransform.position, val);
num--;
if (num2 > 35.0 || num < 0)
{
flag = true;
}
}
if (num < 0)
{
Debug.LogWarning((object)"Child.ChildBlink state entered a loop where it ran more than 35 times without getting out - check what it's doing");
}
TeleportHelper.TeleportBody(((EntityState)this).characterBody, val + Vector3.up * 1.5f, false);
}
}
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
{
int num = callerPath.LastIndexOf("ChildTweaks");
if (num >= 0)
{
callerPath = callerPath.Substring(num + "ChildTweaks".Length + 1);
}
return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
}
internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Error_NoCallerPrefix(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Fatal_NoCallerPrefix(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Info_NoCallerPrefix(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Message_NoCallerPrefix(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Warning_NoCallerPrefix(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("Nuxlar.ChildTweaks", "Nuxlar", "1.2.1")]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "Nuxlar.ChildTweaks";
public const string PluginAuthor = "Nuxlar";
public const string PluginName = "ChildTweaks";
public const string PluginVersion = "1.2.1";
public LoopSoundDef lsdSparkProjectile = ScriptableObject.CreateInstance<LoopSoundDef>();
public static GameObject teleportVFX;
public static Material destealthMat;
private SkillDef skillDef = ScriptableObject.CreateInstance<SkillDef>();
public static GameObject meleeEffectPrefab;
internal static Main Instance { get; private set; }
public static string PluginDirectory { get; private set; }
public void Awake()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Log.Init(((BaseUnityPlugin)this).Logger);
lsdSparkProjectile.startSoundName = "Play_spark_projectile_loop";
lsdSparkProjectile.stopSoundName = "Stop_spark_projectile_loop";
LoadAssets();
TweakProjectile();
TweakProjectileGhost();
TweakSpawnCard();
TweakSkillDrivers();
TweakBody();
TweakEntityState();
bool flag = default(bool);
ContentAddition.AddEntityState<ChildBlink>(ref flag);
}
private void CreateSkill(GameObject body)
{
//IL_0030: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
skillDef.skillName = "ChildBlink";
skillDef.skillNameToken = "ChildBlink";
skillDef.activationState = new SerializableEntityStateType(typeof(ChildBlink));
skillDef.activationStateMachineName = "Body";
skillDef.interruptPriority = (InterruptPriority)1;
skillDef.baseMaxStock = 1;
skillDef.baseRechargeInterval = 8f;
skillDef.rechargeStock = 1;
skillDef.requiredStock = 1;
skillDef.stockToConsume = 1;
skillDef.dontAllowPastMaxStocks = true;
skillDef.beginSkillCooldownOnSkillEnd = true;
skillDef.canceledFromSprinting = false;
skillDef.forceSprintDuringState = false;
skillDef.fullRestockOnAssign = true;
skillDef.resetCooldownTimerOnUse = true;
skillDef.isCombatSkill = false;
skillDef.mustKeyPress = false;
skillDef.cancelSprintingOnActivation = true;
SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
val.variants = (Variant[])(object)new Variant[1]
{
new Variant
{
skillDef = skillDef
}
};
GenericSkill val2 = body.AddComponent<GenericSkill>();
val2._skillFamily = val;
body.GetComponent<SkillLocator>().secondary = val2;
ContentAddition.AddSkillFamily(val);
ContentAddition.AddSkillDef(skillDef);
}
private void TweakProjectile()
{
//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)
AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Child.ChildTrackingSparkBall_prefab), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
GameObject result = x.Result;
result.GetComponent<ProjectileController>().flightSoundLoop = lsdSparkProjectile;
ProjectileSimple component = result.GetComponent<ProjectileSimple>();
component.enableVelocityOverLifetime = false;
component.desiredForwardSpeed = 18f;
};
}
private void TweakProjectileGhost()
{
//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)
AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Child.ChildTrackingSparkBallGhost_prefab), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
Transform child = x.Result.transform.GetChild(0);
foreach (ObjectScaleCurve item in ((Component)child).GetComponents<ObjectScaleCurve>().ToList())
{
Object.Destroy((Object)(object)item);
}
Object.Destroy((Object)(object)((Component)child).GetComponent<ObjectTransformCurve>());
child.localScale = new Vector3(1.5f, 1.5f, 1.5f);
};
}
private void TweakSpawnCard()
{
//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)
AsyncOperationHandle<SpawnCard> val = AssetAsyncReferenceManager<SpawnCard>.LoadAsset(new AssetReferenceT<SpawnCard>(RoR2_DLC2_Child.cscChild_asset), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<SpawnCard> x)
{
x.Result.directorCreditCost = 25;
};
}
private void TweakBody()
{
//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)
AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Child.ChildBody_prefab), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
//IL_0035: 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_005f: Unknown result type (might be due to invalid IL or missing references)
GameObject result = x.Result;
result.transform.GetChild(0).GetChild(0).GetChild(1)
.GetChild(2)
.position = new Vector3(0f, 2f, 0f);
Object.Destroy((Object)(object)result.GetComponent<ChildMonsterController>());
result.GetComponent<SetStateOnHurt>().hurtState = new SerializableEntityStateType(typeof(HurtState));
CreateSkill(result);
};
}
private void TweakSkillDrivers()
{
//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)
AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Child.ChildMaster_prefab), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
AISkillDriver[] components = x.Result.GetComponents<AISkillDriver>();
foreach (AISkillDriver val2 in components)
{
if (val2.customName == "Frolic")
{
val2.requiredSkill = null;
}
if (val2.customName == "RunAway")
{
val2.maxDistance = 25f;
}
if (val2.customName == "FireSparkBall")
{
val2.maxDistance = 40f;
val2.minDistance = 20f;
}
if (val2.customName == "PathFromAfar")
{
val2.movementType = (MovementType)1;
val2.minDistance = 30f;
val2.shouldSprint = true;
}
}
};
}
private void TweakEntityState()
{
//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)
AsyncOperationHandle<EntityStateConfiguration> val = AssetAsyncReferenceManager<EntityStateConfiguration>.LoadAsset(new AssetReferenceT<EntityStateConfiguration>(RoR2_DLC2_Child.EntityStates_ChildMonster_FireTrackingSparkBall_asset), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<EntityStateConfiguration> x)
{
EntityStateConfiguration result = x.Result;
for (int i = 0; i < result.serializedFieldsCollection.serializedFields.Length; i++)
{
if (result.serializedFieldsCollection.serializedFields[i].fieldName == "bombDamageCoefficient")
{
result.serializedFieldsCollection.serializedFields[i].fieldValue.stringValue = "3";
}
}
};
}
private void LoadAssets()
{
//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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Child.FrolicTeleportVFX_prefab), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
teleportVFX = x.Result;
};
AsyncOperationHandle<Material> val2 = AssetAsyncReferenceManager<Material>.LoadAsset(new AssetReferenceT<Material>(RoR2_Base_Parent.matParentDissolve_mat), (AsyncReferenceHandleUnloadType)2);
val2.Completed += delegate(AsyncOperationHandle<Material> x)
{
destealthMat = x.Result;
};
val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Child.MuzzleflashFrolic_prefab), (AsyncReferenceHandleUnloadType)2);
val.Completed += delegate(AsyncOperationHandle<GameObject> x)
{
meleeEffectPrefab = x.Result;
};
}
}
}