using System;
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.Projectile;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPaths;
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("2.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+34599ad4f7db60e7d6266aefd136ba5d455956e9")]
[assembly: AssemblyProduct("ChildTweaks")]
[assembly: AssemblyTitle("ChildTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 blinkPrefab = Main.teleportVFX;
public float duration = 0.2f;
public float speedCoefficient = 5f;
public float destealthDuration = 0.5f;
public Material destealtMat = Main.destealthMat;
public string beginSoundString = "Play_child_attack2_teleport";
public string endSoundString = "Play_child_attack2_reappear";
private Transform modelTransform;
private float stopwatch;
private Vector3 blinkVector = Vector3.zero;
private CharacterModel characterModel;
private HurtBoxGroup hurtboxGroup;
public override void OnEnter()
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
((BaseState)this).OnEnter();
((EntityState)this).PlayAnimation("Gesture, Override", "FrolicEnter", "FrolicEnter.playbackRate", 0.5f, 0f);
Util.PlaySound(beginSoundString, ((EntityState)this).gameObject);
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;
}
blinkVector = GetBlinkVector();
CreateBlinkEffect(Util.GetCorePosition(((EntityState)this).gameObject));
}
protected virtual Vector3 GetBlinkVector()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return ((EntityState)this).inputBank.aimDirection;
}
private void CreateBlinkEffect(Vector3 origin)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
EffectManager.SpawnEffect(blinkPrefab, new EffectData
{
rotation = Util.QuaternionSafeLookRotation(blinkVector),
origin = origin
}, false);
}
public override void FixedUpdate()
{
//IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0073: Unknown result type (might be due to invalid IL or missing references)
((EntityState)this).FixedUpdate();
stopwatch += ((EntityState)this).GetDeltaTime();
if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && Object.op_Implicit((Object)(object)((EntityState)this).characterDirection))
{
((EntityState)this).characterMotor.velocity = Vector3.zero;
CharacterMotor characterMotor = ((EntityState)this).characterMotor;
characterMotor.rootMotion += blinkVector * (base.moveSpeedStat * speedCoefficient * ((EntityState)this).GetDeltaTime());
}
if (!((double)stopwatch < (double)duration) && ((EntityState)this).isAuthority)
{
((EntityState)this).outer.SetNextStateToMain();
}
}
public override void OnExit()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (!((EntityState)this).outer.destroying)
{
Util.PlaySound(endSoundString, ((EntityState)this).gameObject);
CreateBlinkEffect(Util.GetCorePosition(((EntityState)this).gameObject));
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).OnExit();
}
}
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", "ChildTweaks", "1.1.4")]
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.1.4";
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_011e: 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_0132: Unknown result type (might be due to invalid IL or missing references)
skillDef.skillName = "ChildBlink";
((Object)skillDef).name = "ChildBlink";
skillDef.activationState = new SerializableEntityStateType(typeof(ChildBlink));
skillDef.activationStateMachineName = "Body";
skillDef.interruptPriority = (InterruptPriority)1;
skillDef.baseMaxStock = 1;
skillDef.baseRechargeInterval = 4f;
skillDef.rechargeStock = 1;
skillDef.requiredStock = 1;
skillDef.stockToConsume = 1;
skillDef.dontAllowPastMaxStocks = true;
skillDef.beginSkillCooldownOnSkillEnd = false;
skillDef.canceledFromSprinting = false;
skillDef.forceSprintDuringState = true;
skillDef.fullRestockOnAssign = true;
skillDef.resetCooldownTimerOnUse = true;
skillDef.isCombatSkill = false;
skillDef.mustKeyPress = false;
skillDef.cancelSprintingOnActivation = false;
SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
((Object)val).name = "ChildSecondaryAltFamily";
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 = 14f;
};
}
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, 2.5f, 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_002c: 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_009f: 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.movementType = (MovementType)3;
val2.aimType = (AimType)4;
val2.shouldSprint = true;
val2.requiredSkill = null;
}
if (val2.customName == "RunAway")
{
val2.maxDistance = 20f;
}
if (val2.customName == "FireSparkBall")
{
val2.maxDistance = 45f;
val2.minDistance = 20f;
}
if (val2.customName == "PathFromAfar")
{
val2.movementType = (MovementType)1;
val2.minDistance = 25f;
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 = "2";
}
}
};
}
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;
};
}
}
}