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.Missions.BrotherEncounter; using HG; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MwSkinAdditions.Networking; using On.EntityStates; using On.EntityStates.Missions.BrotherEncounter; using On.RoR2; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RoR2; using RoR2.Audio; using RoR2.ContentManagement; using UnityEngine; using UnityEngine.Networking; [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("MwSkinAdditions")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+98d44d7b45b48914a746652dc1ccd8fde295a65d")] [assembly: AssemblyProduct("MwSkinAdditions")] [assembly: AssemblyTitle("MwSkinAdditions")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MwSkinAdditions { public class BlendShapeAnimation { public string meshName; public string blendShapeName; public int feature; public int priority; public float fadeInDuration; public float holdDuration; public float fadeOutDuration; public bool blockBlinking; public BlendShapeAnimation(string meshName, string blendShapeName, int feature, int priority, float fadeInDuration, float holdDuration, float fadeOutDuration, bool blockBlinking = false) { this.meshName = meshName; this.blendShapeName = blendShapeName; this.feature = feature; this.priority = priority; this.fadeInDuration = fadeInDuration; this.holdDuration = holdDuration; this.fadeOutDuration = fadeOutDuration; this.blockBlinking = blockBlinking; } } public class BlinkBlendShapeAnimation : BlendShapeAnimation { public BlinkBlendShapeAnimation(string meshName, string blendShapeName, int feature = -1, int priority = 0, float fadeInDuration = 0.1f, float holdDuration = 0f, float fadeOutDuration = 0.1f, bool blockBlinking = false) : base(meshName, blendShapeName, feature, priority, fadeInDuration, holdDuration, fadeOutDuration, blockBlinking) { } } public class BoneTransformation { public string armaturePath; public Vector3 localScale; public Vector3 position; public string relativeBonePath; public bool applyInLobby = true; public BoneTransformation(string armaturePath, Vector3 localScale, Vector3 position, string relativeBonePath = null) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_001f: Unknown result type (might be due to invalid IL or missing references) this.armaturePath = armaturePath; this.localScale = localScale; this.position = position; this.relativeBonePath = relativeBonePath; } public BoneTransformation(string armaturePath, Vector3 localScale, Vector3 position, bool applyInLobby, string relativeBonePath = null) : this(armaturePath, localScale, position, relativeBonePath) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) this.applyInLobby = applyInLobby; } } internal class ContentPacks : IContentPackProvider { internal ContentPack contentPack = new ContentPack(); public static List networkSoundEventDefs = new List(); public string identifier => "mwmw.MwSkinAdditions"; internal static NetworkSoundEventDef CreateAndAddNetworkSoundEventDef(string eventName) { NetworkSoundEventDef val = ScriptableObject.CreateInstance(); val.akId = AkSoundEngine.GetIDFromString(eventName); val.eventName = eventName; networkSoundEventDefs.Add(val); return val; } public void Initialize() { //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); } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.identifier = identifier; contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray()); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } public class EventSub { public SkinDef[] skinDefs; public BoneTransformation[] boneTransformations; public ExtraObject[] extraObjects; public bool useAnimations = false; public BlendShapeAnimation[] blinkAnimations; public IdleAnimation[] conditionalIdleAnimations; public VoiceGroup[] voiceGroups; public bool transformInCSS = true; public static Action DifferentSkinAppliedGlobal; public Action SkinAppliedLobby; public Action SkinAppliedRun; public Action TakeDamage; public Action Death; public Action DefeatBossGroup; public Action LeavePod; public Action UsePrimary; public Action UseSecondary; public Action UseUtility; public Action UseSpecial; public Action ShrineSuccess; public Action ShrineFailure; public Action TeleporterStart; public Action TeleporterEnd; public Action BearDamageBlock; public Action LevelUp; public Action MithrixDefeat; public Action UseEquipment; public Action Heal; public Action Jump; public Action LeaveStage; public Action Idle; public Action GetItem; public Action HoldoutZoneCharged; [Obsolete("Provide an EventSubOptions object instead.")] public EventSub(SkinDef skinDef, BoneTransformation[] boneTransformations = null, ExtraObject[] extraObjects = null, bool useAnimations = false, BlendShapeAnimation[] blinkAnimations = null, IdleAnimation[] conditionalIdleAnimations = null, VoiceGroup[] voiceGroups = null) { skinDefs = (SkinDef[])(object)new SkinDef[1] { skinDef }; this.boneTransformations = boneTransformations; this.extraObjects = extraObjects; this.useAnimations = useAnimations; this.blinkAnimations = blinkAnimations; this.conditionalIdleAnimations = conditionalIdleAnimations; this.voiceGroups = voiceGroups; } public EventSub(SkinDef skinDef, EventSubOptions eventSubOptions) { if (eventSubOptions == null) { eventSubOptions = new EventSubOptions(); } skinDefs = (SkinDef[])(object)new SkinDef[1] { skinDef }; UnpackOptions(eventSubOptions); } public EventSub(SkinDef[] skinDefs, EventSubOptions eventSubOptions) { if (eventSubOptions == null) { eventSubOptions = new EventSubOptions(); } this.skinDefs = skinDefs; UnpackOptions(eventSubOptions); } private void UnpackOptions(EventSubOptions eventSubOptions) { boneTransformations = eventSubOptions.boneTransformations; extraObjects = eventSubOptions.extraObjects; useAnimations = eventSubOptions.useAnimations; blinkAnimations = eventSubOptions.blinkAnimations; conditionalIdleAnimations = eventSubOptions.conditionalIdleAnimations; voiceGroups = eventSubOptions.voiceGroups; transformInCSS = eventSubOptions.transformInCSS; } public void Init() { SkinEvents.SubscribeEventSkins(this); if (boneTransformations != null) { SubscribeTransformEvents(); } if (extraObjects != null) { SubscribeExtraObjectEvents(); } if (useAnimations) { SubscribeAnimationEvents(); } if (voiceGroups != null) { SubscribeVoiceEvents(); } } private void SubscribeTransformEvents() { SkinAppliedRun = (Action)Delegate.Combine(SkinAppliedRun, new Action(AddTransformController)); SkinAppliedLobby = (Action)Delegate.Combine(SkinAppliedLobby, new Action(AddTransformController)); } private void AddTransformController(GameObject body) { if (!((Object)(object)Run.instance == (Object)null) || transformInCSS) { TransformController transformController = body.GetComponent(); if ((Object)(object)transformController == (Object)null || transformController.beingDeleted) { transformController = body.AddComponent(); } transformController.Init(this); } } private void SubscribeExtraObjectEvents() { SkinAppliedRun = (Action)Delegate.Combine(SkinAppliedRun, new Action(AddExtraObjects)); SkinAppliedLobby = (Action)Delegate.Combine(SkinAppliedLobby, new Action(AddExtraObjects)); } private void AddExtraObjects(GameObject body) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Transform transform = SkinEvents.GetModelFromEventBody(body).transform; ExtraObjectController extraObjectController = body.AddComponent(); ExtraObject[] array = extraObjects; foreach (ExtraObject extraObject in array) { GameObject val = Object.Instantiate(extraObject.prefab); val.transform.parent = transform.Find(extraObject.armatureParentPath); val.transform.localPosition = extraObject.localPosition; val.transform.localEulerAngles = extraObject.localEulerAngles; val.transform.localScale = extraObject.localScale; extraObjectController.extraObjs.Add(val); } } private void SubscribeAnimationEvents() { SkinAppliedRun = (Action)Delegate.Combine(SkinAppliedRun, new Action(AddExpressionController)); SkinAppliedLobby = (Action)Delegate.Combine(SkinAppliedLobby, new Action(AddExpressionController)); } private void AddExpressionController(GameObject body) { ExpressionController expressionController = body.GetComponent(); if ((Object)(object)expressionController == (Object)null) { expressionController = body.AddComponent(); } expressionController.Init(this); } private void SubscribeVoiceEvents() { SkinAppliedRun = (Action)Delegate.Combine(SkinAppliedRun, new Action(AddVoiceController)); SkinAppliedLobby = (Action)Delegate.Combine(SkinAppliedLobby, new Action(AddVoiceController)); } private void AddVoiceController(GameObject body) { VoiceController voiceController = body.GetComponent(); if ((Object)(object)voiceController == (Object)null) { voiceController = body.AddComponent(); } voiceController.Init(this); } } public class EventSubOptions { public BoneTransformation[] boneTransformations = null; public ExtraObject[] extraObjects = null; public bool useAnimations = false; public BlendShapeAnimation[] blinkAnimations = null; public IdleAnimation[] conditionalIdleAnimations = null; public VoiceGroup[] voiceGroups = null; public bool transformInCSS = true; } public class ExpressionController : MonoBehaviour { private class ExpressionState { public Coroutine coroutine; public BlendShapeAnimation animation; public SkinnedMeshRenderer skinnedMeshRenderer; public bool finished; } private EventSub eventSub; private CharacterBody cachedCharacterBody; private Dictionary cachedRenderers = new Dictionary(); private Dictionary cachedBlendShapes = new Dictionary(); private Dictionary featureStates = new Dictionary(); private Dictionary featureActive = new Dictionary(); public bool inDeathState; private float blinkInterval; private float blinkStopwatch; private bool doubleBlink; private int blinkStoppers; public CharacterBody characterBody { get { if ((Object)(object)cachedCharacterBody != (Object)null) { return cachedCharacterBody; } cachedCharacterBody = ((Component)this).GetComponent(); return cachedCharacterBody; } } public void Init(EventSub eventSub) { this.eventSub = eventSub; eventSub.Death = (Action)Delegate.Combine(eventSub.Death, (Action)delegate { inDeathState = true; }); } public void TryPlayAnimation(BlendShapeAnimation animation) { SkinnedMeshRenderer skinnedMeshRenderer = GetSkinnedMeshRenderer(animation.meshName); if (Object.op_Implicit((Object)(object)skinnedMeshRenderer)) { TrySetExpressionRoutine(animation, skinnedMeshRenderer); } } private SkinnedMeshRenderer GetSkinnedMeshRenderer(string meshName) { if (cachedRenderers.ContainsKey(meshName)) { SkinnedMeshRenderer val = cachedRenderers[meshName]; if (val != null) { return val; } } SkinnedMeshRenderer val2 = null; GameObject modelFromEventBody = SkinEvents.GetModelFromEventBody(((Component)this).gameObject); if (Object.op_Implicit((Object)(object)modelFromEventBody)) { Transform val3 = modelFromEventBody.transform.Find(meshName); if (Object.op_Implicit((Object)(object)val3)) { val2 = ((Component)val3).GetComponent(); } } cachedRenderers[meshName] = val2; return val2; } private void TrySetExpressionRoutine(BlendShapeAnimation animation, SkinnedMeshRenderer renderer) { ExpressionState featureState = GetFeatureState(animation.feature); if (featureState != null && animation.priority > featureState.animation.priority) { CancelExpressionSmooth(featureState); } if (!GetFeatureActive(animation.feature)) { ExpressionState expressionState = new ExpressionState { animation = animation, skinnedMeshRenderer = renderer }; expressionState.coroutine = ((MonoBehaviour)this).StartCoroutine(ExpressionRoutine(animation, renderer, expressionState)); featureStates[animation.feature] = expressionState; if (animation.blockBlinking) { blinkStoppers++; } } } private IEnumerator ExpressionRoutine(BlendShapeAnimation animation, SkinnedMeshRenderer renderer, ExpressionState expressionState) { float stopwatch = 0f; featureActive[animation.feature] = true; int index = GetBlendShapeIndex(animation, renderer); while (stopwatch < animation.fadeInDuration) { stopwatch += Time.deltaTime; renderer.SafeSetBlendShapeWeight(index, Mathf.Lerp(0f, 100f, stopwatch / animation.fadeInDuration)); yield return null; } renderer.SafeSetBlendShapeWeight(index, 100f); yield return (object)new WaitForSeconds(animation.holdDuration); stopwatch = 0f; while (stopwatch < animation.fadeOutDuration) { stopwatch += Time.deltaTime; renderer.SafeSetBlendShapeWeight(index, Mathf.Lerp(100f, 0f, stopwatch / animation.fadeOutDuration)); yield return null; } renderer.SafeSetBlendShapeWeight(index, 0f); featureActive[animation.feature] = false; if (animation.blockBlinking) { blinkStoppers--; } expressionState.finished = true; } public void CancelCurrentExpressionsSmooth() { foreach (ExpressionState value in featureStates.Values) { if (value != null) { CancelExpressionSmooth(value); } } } public void CancelCurrentExpressions() { foreach (ExpressionState value in featureStates.Values) { if (value != null) { CancelExpression(value); } } } private void CancelExpressionSmooth(ExpressionState expressionState) { CancelExpression(expressionState); ((MonoBehaviour)this).StartCoroutine(BlendToZero(expressionState)); } private void CancelExpression(ExpressionState expressionState) { ((MonoBehaviour)this).StopCoroutine(expressionState.coroutine); featureActive[expressionState.animation.feature] = false; if (!expressionState.finished && expressionState.animation.blockBlinking) { blinkStoppers--; expressionState.finished = true; } } private IEnumerator BlendToZero(ExpressionState expressionState) { int index = GetBlendShapeIndex(expressionState.animation, expressionState.skinnedMeshRenderer); float startWeight = expressionState.skinnedMeshRenderer.GetBlendShapeWeight(index); float stopwatch = 0f; while (stopwatch < expressionState.animation.fadeOutDuration) { stopwatch += Time.deltaTime; expressionState.skinnedMeshRenderer.SafeSetBlendShapeWeight(index, Mathf.Lerp(startWeight, 0f, stopwatch / expressionState.animation.fadeOutDuration)); yield return null; } } private ExpressionState GetFeatureState(int feature) { if (featureStates.ContainsKey(feature)) { return featureStates[feature]; } return null; } private bool GetFeatureActive(int feature) { if (featureActive.ContainsKey(feature)) { return featureActive[feature]; } return false; } private int GetBlendShapeIndex(BlendShapeAnimation animation, SkinnedMeshRenderer skinnedMeshRenderer) { if (cachedBlendShapes.ContainsKey(animation.blendShapeName)) { return cachedBlendShapes[animation.blendShapeName]; } int blendShapeIndex = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex(animation.blendShapeName); cachedBlendShapes[animation.blendShapeName] = blendShapeIndex; return blendShapeIndex; } private void Update() { if (eventSub.blinkAnimations != null && blinkStoppers <= 0) { BlinkUpdate(); } if (eventSub.conditionalIdleAnimations != null) { IdleUpdate(); } } private void BlinkUpdate() { blinkStopwatch += Time.deltaTime; if (!(blinkStopwatch >= blinkInterval)) { return; } if (!inDeathState) { BlendShapeAnimation[] blinkAnimations = eventSub.blinkAnimations; foreach (BlendShapeAnimation animation in blinkAnimations) { TryPlayAnimation(animation); } if (doubleBlink) { doubleBlink = false; } else if (Random.value <= 0.1f) { doubleBlink = true; } } else { doubleBlink = false; } blinkStopwatch = 0f; if (doubleBlink) { blinkInterval = 0.3f; } else { blinkInterval = Random.Range(3f, 8f); } } private void IdleUpdate() { IdleAnimation[] conditionalIdleAnimations = eventSub.conditionalIdleAnimations; foreach (IdleAnimation idleAnimation in conditionalIdleAnimations) { if (idleAnimation == null || idleAnimation.condition == null) { continue; } if (idleAnimation.condition(this)) { BlendShapeAnimation[] animations = idleAnimation.animations; foreach (BlendShapeAnimation animation in animations) { TryPlayAnimation(animation); } } else { if (!idleAnimation.cancelOnConditionFalse) { continue; } BlendShapeAnimation[] animations2 = idleAnimation.animations; foreach (BlendShapeAnimation blendShapeAnimation in animations2) { ExpressionState featureState = GetFeatureState(blendShapeAnimation.feature); if (GetFeatureActive(blendShapeAnimation.feature) && featureState?.animation == blendShapeAnimation) { CancelExpressionSmooth(featureState); } } } } } } public class ExtraObject { public GameObject prefab; public string armatureParentPath; public Vector3 localScale; public Vector3 localPosition; public Vector3 localEulerAngles; public ExtraObject(GameObject prefab, string armatureParentPath, Vector3 localScale, Vector3 localPosition, Vector3 localEulerAngles) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references) this.prefab = prefab; this.armatureParentPath = armatureParentPath; this.localScale = localScale; this.localPosition = localPosition; this.localEulerAngles = localEulerAngles; } } public class ExtraObjectController : MonoBehaviour { public List extraObjs; public void Awake() { extraObjs = new List(); } } public class IdleAnimation { public BlendShapeAnimation[] animations; public Func condition; public bool cancelOnConditionFalse; public IdleAnimation(BlendShapeAnimation[] animations, Func condition, bool cancelOnConditionFalse = true) { this.animations = animations; this.condition = condition; this.cancelOnConditionFalse = cancelOnConditionFalse; } } 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.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("mwmw.MwSkinAdditions", "MwSkinAdditions", "1.0.10")] public class MwSkinAdditions : BaseUnityPlugin { public const string PluginGUID = "mwmw.MwSkinAdditions"; public const string PluginAuthor = "mwmw"; public const string PluginName = "MwSkinAdditions"; public const string PluginVersion = "1.0.10"; public static PluginInfo pluginInfo; public static MwSkinAdditions instance; public void Awake() { instance = this; pluginInfo = ((BaseUnityPlugin)this).Info; Log.Init(((BaseUnityPlugin)this).Logger); NetworkMessages.Init(); SkinEvents.Init(); RoR2Application.onStart = (Action)Delegate.Combine(RoR2Application.onStart, (Action)delegate { new ContentPacks().Initialize(); }); } } public static class MwUtils { public static Random rand = new Random(); public static object RandomChoices(IEnumerable choices, IEnumerable weights) { List list = new List(); float num = 0f; foreach (float weight in weights) { num += weight; list.Add(num); } float num2 = (float)rand.NextDouble() * num; int num3 = 0; foreach (object choice in choices) { if (num2 <= list[num3]) { return choice; } num3++; } Log.Warning("RandomChoices: Couldn't make a choice - returning null!"); return null; } public static object RandomChoice(IEnumerable choices) { IList list = (choices as IList) ?? choices.ToList(); if (list.Count > 0) { return list[rand.Next(list.Count)]; } Log.Warning("RandomChoice: Got passed an empty enumerable - returning null!"); return null; } public static object RandomChoice(object[] choices) { if (choices.Length != 0) { return choices[rand.Next(choices.Length)]; } Log.Warning("RandomChoice: Got passed an empty enumerable - returning null!"); return null; } public static IEnumerator ExecuteWhenNearPosition(Action action, GameObject gameObject, Vector3 position, float maxWait = 1f) { //IL_0015: 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) float stopwatch = 0f; while (Vector3.Distance(gameObject.transform.position, position) > 0.5f && stopwatch < maxWait) { stopwatch += Time.deltaTime; yield return null; } action?.Invoke(); } public static void SafeSetBlendShapeWeight(this SkinnedMeshRenderer renderer, int index, float value) { if (Object.op_Implicit((Object)(object)renderer)) { renderer.SetBlendShapeWeight(index, value); } } } public static class SkinEvents { [CompilerGenerated] private static class <>O { public static hook_ApplySkinAsync <0>__OnSkinAppliedBody; public static hook_OnInteractionBegin <1>__OnTeleporterStart; public static hook_OnDeathStart <2>__OnDeath; public static hook_EjectPassenger_GameObject <3>__OnLeavePod; public static hook_OnSkillActivated <4>__OnSkillActivated; public static hook_AddShrineStack <5>__OnChanceShrineInteract; public static Manipulator <6>__OnPickupAttemptGrant; public static Manipulator <7>__OnBearDamageBlock; public static Action <8>__OnDefeatBossGroup; public static Action <9>__OnTeleporterEnd; public static Action <10>__OnTakeDamage; public static Action <11>__OnLevelUp; public static hook_OnEnter <12>__OnMithrixDefeat; public static Action <13>__OnUseEquipment; public static Action <14>__OnHeal; public static hook_ApplyJumpVelocity <15>__OnJump; public static hook_Begin <16>__OnLeaveStage; public static hook_Update <17>__OnBodyUpdate; public static Action <18>__RemoveTransformController; public static Action <19>__RemoveExtraObjects; public static Action <20>__RemoveVoiceController; public static Action <21>__RemoveExpressionController; } private static Dictionary skinDefToEventSub = new Dictionary(); public static HashSet holdOffIdleInvocation = new HashSet(); public static void Init() { SubscribeGlobalEvents(); SubscribeGameEvents(); } public static void SubscribeEventSkins(EventSub eventSub) { SkinDef[] skinDefs = eventSub.skinDefs; foreach (SkinDef val in skinDefs) { if ((Object)(object)val == (Object)null) { Log.Error("Received a null SkinDef! Ignoring..."); } else { skinDefToEventSub.Add(val, eventSub); } } } private static void SubscribeGameEvents() { //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_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0074: 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_007f: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00d7: 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_00e2: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_019d: 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_01a8: Expected O, but got Unknown //IL_0200: 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_020b: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown object obj = <>O.<0>__OnSkinAppliedBody; if (obj == null) { hook_ApplySkinAsync val = OnSkinAppliedBody; <>O.<0>__OnSkinAppliedBody = val; obj = (object)val; } ModelSkinController.ApplySkinAsync += (hook_ApplySkinAsync)obj; object obj2 = <>O.<1>__OnTeleporterStart; if (obj2 == null) { hook_OnInteractionBegin val2 = OnTeleporterStart; <>O.<1>__OnTeleporterStart = val2; obj2 = (object)val2; } TeleporterInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj2; object obj3 = <>O.<2>__OnDeath; if (obj3 == null) { hook_OnDeathStart val3 = OnDeath; <>O.<2>__OnDeath = val3; obj3 = (object)val3; } CharacterBody.OnDeathStart += (hook_OnDeathStart)obj3; object obj4 = <>O.<3>__OnLeavePod; if (obj4 == null) { hook_EjectPassenger_GameObject val4 = OnLeavePod; <>O.<3>__OnLeavePod = val4; obj4 = (object)val4; } VehicleSeat.EjectPassenger_GameObject += (hook_EjectPassenger_GameObject)obj4; object obj5 = <>O.<4>__OnSkillActivated; if (obj5 == null) { hook_OnSkillActivated val5 = OnSkillActivated; <>O.<4>__OnSkillActivated = val5; obj5 = (object)val5; } CharacterBody.OnSkillActivated += (hook_OnSkillActivated)obj5; object obj6 = <>O.<5>__OnChanceShrineInteract; if (obj6 == null) { hook_AddShrineStack val6 = OnChanceShrineInteract; <>O.<5>__OnChanceShrineInteract = val6; obj6 = (object)val6; } ShrineChanceBehavior.AddShrineStack += (hook_AddShrineStack)obj6; object obj7 = <>O.<6>__OnPickupAttemptGrant; if (obj7 == null) { Manipulator val7 = OnPickupAttemptGrant; <>O.<6>__OnPickupAttemptGrant = val7; obj7 = (object)val7; } GenericPickupController.AttemptGrant += (Manipulator)obj7; object obj8 = <>O.<7>__OnBearDamageBlock; if (obj8 == null) { Manipulator val8 = OnBearDamageBlock; <>O.<7>__OnBearDamageBlock = val8; obj8 = (object)val8; } HealthComponent.TakeDamageProcess += (Manipulator)obj8; BossGroup.onBossGroupDefeatedServer += OnDefeatBossGroup; TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterEnd; GlobalEventManager.onServerDamageDealt += OnTakeDamage; GlobalEventManager.onCharacterLevelUp += OnLevelUp; object obj9 = <>O.<12>__OnMithrixDefeat; if (obj9 == null) { hook_OnEnter val9 = OnMithrixDefeat; <>O.<12>__OnMithrixDefeat = val9; obj9 = (object)val9; } EncounterFinished.OnEnter += (hook_OnEnter)obj9; EquipmentSlot.onServerEquipmentActivated += OnUseEquipment; HealthComponent.onCharacterHealServer += OnHeal; object obj10 = <>O.<15>__OnJump; if (obj10 == null) { hook_ApplyJumpVelocity val10 = OnJump; <>O.<15>__OnJump = val10; obj10 = (object)val10; } GenericCharacterMain.ApplyJumpVelocity += (hook_ApplyJumpVelocity)obj10; object obj11 = <>O.<16>__OnLeaveStage; if (obj11 == null) { hook_Begin val11 = OnLeaveStage; <>O.<16>__OnLeaveStage = val11; obj11 = (object)val11; } SceneExitController.Begin += (hook_Begin)obj11; object obj12 = <>O.<17>__OnBodyUpdate; if (obj12 == null) { hook_Update val12 = OnBodyUpdate; <>O.<17>__OnBodyUpdate = val12; obj12 = (object)val12; } CharacterBody.Update += (hook_Update)obj12; } public static void SubscribeGlobalEvents() { EventSub.DifferentSkinAppliedGlobal = (Action)Delegate.Combine(EventSub.DifferentSkinAppliedGlobal, new Action(RemoveTransformController)); EventSub.DifferentSkinAppliedGlobal = (Action)Delegate.Combine(EventSub.DifferentSkinAppliedGlobal, new Action(RemoveExtraObjects)); EventSub.DifferentSkinAppliedGlobal = (Action)Delegate.Combine(EventSub.DifferentSkinAppliedGlobal, new Action(RemoveVoiceController)); EventSub.DifferentSkinAppliedGlobal = (Action)Delegate.Combine(EventSub.DifferentSkinAppliedGlobal, new Action(RemoveExpressionController)); } public static EventSub GetEventSubFromBody(GameObject body) { try { SkinDef skinDef = SkinCatalog.FindCurrentSkinDefForBodyInstance(body); return GetEventSubFromSkinDef(skinDef); } catch (NullReferenceException) { Log.Error("GetEventSubFromBody NRE! Returning null..."); return null; } } public static EventSub GetEventSubFromSkinDef(SkinDef skinDef) { if ((Object)(object)skinDef == (Object)null || !skinDefToEventSub.ContainsKey(skinDef)) { return null; } return skinDefToEventSub[skinDef]; } private static void ForEachBodySafe(Action action) { foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances)) { GameObject bodyObject = readOnlyInstances.GetBodyObject(); if (Object.op_Implicit((Object)(object)bodyObject)) { action(bodyObject); } } } } private static IEnumerator OnSkinAppliedBody(orig_ApplySkinAsync orig, ModelSkinController self, int skinIndex, AsyncReferenceHandleUnloadType unloadType) { //IL_001c: 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) yield return orig.Invoke(self, skinIndex, unloadType); GameObject bodyObject = null; EventSub bodyEventSub = null; if (Object.op_Implicit((Object)(object)self) && (Object.op_Implicit((Object)(object)self.characterModel) & Object.op_Implicit((Object)(object)self.characterModel.body))) { bodyObject = ((Component)self.characterModel.body).gameObject; } if (Object.op_Implicit((Object)(object)bodyObject)) { bodyEventSub = GetEventSubFromBody(bodyObject); } if (Object.op_Implicit((Object)(object)bodyObject) && bodyEventSub != null) { bodyEventSub.SkinAppliedRun?.Invoke(bodyObject); yield break; } SkinDef skinDef = default(SkinDef); int num; if (!Object.op_Implicit((Object)(object)bodyObject)) { skinDef = ArrayUtils.GetSafe(self.skins, self.currentSkinIndex); if (skinDef != null) { num = (skinDefToEventSub.ContainsKey(skinDef) ? 1 : 0); goto IL_0164; } } num = 0; goto IL_0164; IL_0164: if (num != 0) { bodyEventSub = GetEventSubFromSkinDef(skinDef); bodyEventSub.SkinAppliedLobby?.Invoke(((Component)self).gameObject); } else if (!Object.op_Implicit((Object)(object)bodyObject)) { EventSub.DifferentSkinAppliedGlobal?.Invoke(((Component)self).gameObject); } else { EventSub.DifferentSkinAppliedGlobal?.Invoke(bodyObject); } } private static void OnTeleporterStart(orig_OnInteractionBegin orig, TeleporterInteraction self, Interactor activator) { orig.Invoke(self, activator); if (Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && !TeleporterInteraction.instance.isCharged) { GetEventSubFromBody(((Component)activator).gameObject)?.TeleporterStart?.Invoke(((Component)activator).gameObject); } } private static void OnDeath(orig_OnDeathStart orig, CharacterBody self) { orig.Invoke(self); GetEventSubFromBody(((Component)self).gameObject)?.Death?.Invoke(((Component)self).gameObject); } private static void OnLeavePod(orig_EjectPassenger_GameObject orig, VehicleSeat self, GameObject body) { orig.Invoke(self, body); if (self.isSurvivorPod) { GetEventSubFromBody(body)?.LeavePod?.Invoke(body); } } private static void OnSkillActivated(orig_OnSkillActivated orig, CharacterBody self, GenericSkill skill) { orig.Invoke(self, skill); EventSub eventSubFromBody = GetEventSubFromBody(((Component)self).gameObject); if (eventSubFromBody != null) { if ((Object)(object)skill == (Object)(object)self.skillLocator.primary) { eventSubFromBody.UsePrimary?.Invoke(((Component)self).gameObject); } else if ((Object)(object)skill == (Object)(object)self.skillLocator.secondary) { eventSubFromBody.UseSecondary?.Invoke(((Component)self).gameObject); } else if ((Object)(object)skill == (Object)(object)self.skillLocator.utility) { eventSubFromBody.UseUtility?.Invoke(((Component)self).gameObject); } else if ((Object)(object)skill == (Object)(object)self.skillLocator.special) { eventSubFromBody.UseSpecial?.Invoke(((Component)self).gameObject); } } } private static void OnChanceShrineInteract(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator) { int successfulPurchaseCount = self.successfulPurchaseCount; orig.Invoke(self, activator); EventSub eventSubFromBody = GetEventSubFromBody(((Component)self).gameObject); if (eventSubFromBody != null) { if (successfulPurchaseCount < self.successfulPurchaseCount) { eventSubFromBody.ShrineSuccess?.Invoke(((Component)activator).gameObject); } else { eventSubFromBody.ShrineFailure?.Invoke(((Component)activator).gameObject); } } } private static void OnBearDamageBlock(ILContext il) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_00f6: 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) Action action = delegate(HealthComponent healthComponent) { GetEventSubFromBody(((Component)healthComponent.body).gameObject)?.BearDamageBlock?.Invoke(((Component)healthComponent.body).gameObject); }; ILCursor val = new ILCursor(il); int num = default(int); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.HealthComponent+AssetReferences", "bearEffectPrefab") }) && val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num) }) && val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num) }) && val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "RoR2.EffectManager", "SpawnEffect") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>(action); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.HealthComponent+AssetReferences", "bearVoidEffectPrefab") }) && val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num) }) && val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num) }) && val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "RoR2.EffectManager", "SpawnEffect") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>(action); } } else { Log.Error("OnBearDamageBlock ILHook failed. Tougher Times/Safer Spaces block events will not occur"); } } private static void OnLevelUp(CharacterBody characterBody) { if (Object.op_Implicit((Object)(object)characterBody)) { GetEventSubFromBody(((Component)characterBody).gameObject)?.LevelUp?.Invoke(((Component)characterBody).gameObject); } } private static void OnPickupAttemptGrant(ILContext il) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_00ac: 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) Action action = delegate(CharacterBody body, PickupDef pickupDef) { //IL_001c: 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) //IL_002c: Expected I4, but got Unknown EventSub eventSubFromBody = GetEventSubFromBody(((Component)body).gameObject); if (eventSubFromBody != null) { NetMessageExtensions.Send((INetMessage)(object)new SyncGetItem(body.master.bodyInstanceId, (int)pickupDef.itemIndex), (NetworkDestination)1); } }; ILCursor c = new ILCursor(il); int pickupLoc = 2; if (c.TryGotoNext(new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)typeof(PickupCatalog).GetMethod("GetPickupDef")), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref pickupLoc) }) && c.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "shouldDestroy") && c.TryGotoNext((MoveType)2, new Func[1] { (Instruction val) => ILPatternMatchingExt.MatchStfld(val, "consumed") }) })) { c.Emit(OpCodes.Ldarg_1); c.Emit(OpCodes.Ldloc, pickupLoc); c.EmitDelegate>(action); } else { Log.Error("OnPickupAttemptGrant ILHook failed. Pickup interaction related events will not occur"); } } private static void OnDefeatBossGroup(BossGroup bossGroup) { if (((Object)((Component)bossGroup).gameObject).name != "BrotherEncounter, Phase 4") { ForEachBodySafe(delegate(GameObject bodyObject) { GetEventSubFromBody(bodyObject)?.DefeatBossGroup?.Invoke(bodyObject); }); } } private static void OnTeleporterEnd(TeleporterInteraction teleporterInteraction) { ForEachBodySafe(delegate(GameObject bodyObject) { GetEventSubFromBody(bodyObject)?.TeleporterEnd?.Invoke(bodyObject); }); } private static void OnTakeDamage(DamageReport damageReport) { if (Object.op_Implicit((Object)(object)damageReport.victimBody) && Object.op_Implicit((Object)(object)damageReport.victimBody.healthComponent) && damageReport.victimBody.healthComponent.health > 0f) { GetEventSubFromBody(((Component)damageReport.victimBody).gameObject)?.TakeDamage?.Invoke(((Component)damageReport.victimBody).gameObject, damageReport); } } private static void OnMithrixDefeat(orig_OnEnter orig, EncounterFinished self) { orig.Invoke(self); ForEachBodySafe(delegate(GameObject bodyObject) { GetEventSubFromBody(bodyObject)?.MithrixDefeat?.Invoke(bodyObject); }); } private static void OnUseEquipment(EquipmentSlot self, EquipmentIndex index) { GetEventSubFromBody(((Component)self.characterBody).gameObject)?.UseEquipment?.Invoke(((Component)self.characterBody).gameObject); } private static void OnHeal(HealthComponent self, float amount, ProcChainMask procChainMask) { if (Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.body)) { GetEventSubFromBody(((Component)self.body).gameObject)?.Heal?.Invoke(((Component)self.body).gameObject, amount); } } private static void OnJump(orig_ApplyJumpVelocity orig, CharacterMotor characterMotor, CharacterBody characterBody, float horizontalBonus, float verticalBonus, bool vault) { orig.Invoke(characterMotor, characterBody, horizontalBonus, verticalBonus, vault); GetEventSubFromBody(((Component)characterBody).gameObject)?.Jump?.Invoke(((Component)characterBody).gameObject); } private static void OnLeaveStage(orig_Begin orig, SceneExitController self) { orig.Invoke(self); ForEachBodySafe(delegate(GameObject bodyObject) { GetEventSubFromBody(bodyObject)?.LeaveStage?.Invoke(bodyObject); }); } public static GameObject GetModelFromEventBody(GameObject body) { ModelLocator val = default(ModelLocator); if (Object.op_Implicit((Object)(object)Stage.instance) && Object.op_Implicit((Object)(object)body) && body.TryGetComponent(ref val) && Object.op_Implicit((Object)(object)val.modelTransform)) { return ((Component)val.modelTransform).gameObject; } return body; } public static ExpressionController GetExpressionController(GameObject body) { GameObject modelFromEventBody = GetModelFromEventBody(body); if (Object.op_Implicit((Object)(object)modelFromEventBody)) { return modelFromEventBody.GetComponent(); } return null; } public static void RemoveExtraObjects(GameObject body) { ExtraObjectController extraObjectController = default(ExtraObjectController); if (!Object.op_Implicit((Object)(object)body) || !body.TryGetComponent(ref extraObjectController)) { return; } foreach (GameObject extraObj in extraObjectController.extraObjs) { Object.Destroy((Object)(object)extraObj); } Object.Destroy((Object)(object)extraObjectController); } public static void RemoveTransformController(GameObject body) { TransformController transformController = default(TransformController); if (Object.op_Implicit((Object)(object)body) && body.TryGetComponent(ref transformController)) { transformController.beingDeleted = true; Object.Destroy((Object)(object)transformController); } } public static void RemoveVoiceController(GameObject body) { VoiceController voiceController = default(VoiceController); if (Object.op_Implicit((Object)(object)body) && body.TryGetComponent(ref voiceController)) { Object.Destroy((Object)(object)voiceController); } } public static void RemoveExpressionController(GameObject body) { ExpressionController expressionController = default(ExpressionController); if (Object.op_Implicit((Object)(object)body) && body.TryGetComponent(ref expressionController)) { expressionController.CancelCurrentExpressions(); Object.Destroy((Object)(object)expressionController); } } private static void OnBodyUpdate(orig_Update orig, CharacterBody self) { orig.Invoke(self); if (!((Object)(object)self == (Object)null) && self.notMovingStopwatch > 10f) { EventSub eventSubFromBody = GetEventSubFromBody(((Component)self).gameObject); if (eventSubFromBody != null && self.notMovingStopwatch % 10f < 0.1f && !holdOffIdleInvocation.Contains(self)) { eventSubFromBody.Idle?.Invoke(((Component)self).gameObject); ((MonoBehaviour)RoR2Application.instance).StartCoroutine(HoldBodyFromIdleUpdate(self)); } } } private static IEnumerator HoldBodyFromIdleUpdate(CharacterBody body) { holdOffIdleInvocation?.Add(body); yield return (object)new WaitForSeconds(1f); holdOffIdleInvocation?.Remove(body); } public static void InvokeGetItem(GameObject body, int itemIndex) { EventSub eventSubFromBody = GetEventSubFromBody(body.gameObject); eventSubFromBody.GetItem?.Invoke(body.gameObject, (ItemIndex)itemIndex); } public static void InvokeUseShrine(GameObject body, bool success) { EventSub eventSubFromBody = GetEventSubFromBody(body); if (success) { eventSubFromBody.ShrineSuccess?.Invoke(body); } else { eventSubFromBody.ShrineFailure?.Invoke(body); } } public static void InvokeHoldoutZoneCharged() { ForEachBodySafe(delegate(GameObject bodyObject) { GetEventSubFromBody(bodyObject)?.HoldoutZoneCharged?.Invoke(bodyObject); }); } } public class TransformController : MonoBehaviour { private Transform[] boneTransforms; private Dictionary boneRelativeTo = new Dictionary(); private CharacterBody characterBody; private Animator animator; public bool beingDeleted = false; public BoneTransformation[] boneTransformations; public BoneTransformation rtiBoneTransformation; private int _rtiIndex = 0; private Vector3 _rtiPositionVector; private Vector3 _rtiLocalScaleVector; public int rtiIndex { get { return _rtiIndex; } set { //IL_0022: 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_0033: 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) _rtiIndex = value; rtiBoneTransformation = boneTransformations[_rtiIndex]; _rtiPositionVector = rtiBoneTransformation.position; _rtiLocalScaleVector = rtiBoneTransformation.localScale; } } public Vector3 rtiPositionVector { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) return _rtiPositionVector; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) _rtiPositionVector = value; rtiBoneTransformation.position = _rtiPositionVector; } } public Vector3 rtiLocalScaleVector { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) return _rtiLocalScaleVector; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) _rtiLocalScaleVector = value; rtiBoneTransformation.localScale = _rtiLocalScaleVector; } } public void Init(EventSub eventSub) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) boneTransformations = eventSub.boneTransformations; rtiBoneTransformation = boneTransformations[rtiIndex]; _rtiPositionVector = rtiBoneTransformation.position; _rtiLocalScaleVector = rtiBoneTransformation.localScale; AssignLimbs(); } private void Start() { characterBody = ((Component)this).GetComponent(); animator = SkinEvents.GetModelFromEventBody(((Component)this).gameObject).GetComponent(); } private void AssignLimbs() { List list = new List(); for (int i = 0; i < boneTransformations.Length; i++) { Transform val = SkinEvents.GetModelFromEventBody(((Component)this).gameObject).transform.Find(boneTransformations[i].armaturePath); if ((Object)(object)val != (Object)null) { list.Add(SkinEvents.GetModelFromEventBody(((Component)this).gameObject).transform.Find(boneTransformations[i].armaturePath)); if (boneTransformations[i].relativeBonePath != null) { Transform val2 = SkinEvents.GetModelFromEventBody(((Component)this).gameObject).transform.Find(boneTransformations[i].relativeBonePath); if ((Object)(object)val2 != (Object)null) { boneRelativeTo[val] = val2; continue; } Log.Error("Received invalid relative bone path: " + boneTransformations[i].relativeBonePath); boneRelativeTo[val] = val; } else { boneRelativeTo[val] = val; } } else { Log.Error("Received invalid bone path: " + boneTransformations[i].armaturePath); } } boneTransforms = list.ToArray(); } private void LateUpdate() { if (!Object.op_Implicit((Object)(object)characterBody) || Object.op_Implicit((Object)(object)characterBody.modelLocator.modelTransform)) { if (Object.op_Implicit((Object)(object)characterBody) && !Object.op_Implicit((Object)(object)characterBody.currentVehicle) && Object.op_Implicit((Object)(object)animator) && ((Behaviour)animator).enabled) { ApplyPosition(); } ApplyScale(); } } private void ApplyScale() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < boneTransforms.Length; i++) { boneTransforms[i].localScale = boneTransformations[i].localScale; } } private void ApplyPosition() { //IL_0052: 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) for (int i = 0; i < boneTransforms.Length; i++) { if (!((Object)(object)Stage.instance == (Object)null) || boneTransformations[i].applyInLobby) { Transform val = boneRelativeTo[boneTransforms[i]]; boneTransforms[i].position = val.TransformPoint(boneTransformations[i].position); } } } } public class VoiceArray { public VoiceInfo[] voiceLines; public VoiceGroup group; public VoiceArray(VoiceInfo[] voiceLines) { this.voiceLines = voiceLines; } } public class VoiceController : MonoBehaviour { private float timeSinceLastRolledLine; private const float soundWaitPadding = 0.5f; private float currentSoundWait; private Dictionary voiceGroupStopwatches; private Dictionary lastPlayedIndex = new Dictionary(); public void Init(EventSub eventSub) { voiceGroupStopwatches = new Dictionary(); VoiceGroup[] voiceGroups = eventSub.voiceGroups; foreach (VoiceGroup key in voiceGroups) { voiceGroupStopwatches.Add(key, 0f); } } private void Awake() { if (!NetworkServer.active) { Object.Destroy((Object)(object)this); } } private void Update() { float deltaTime = Time.deltaTime; VoiceGroup[] array = voiceGroupStopwatches.Keys.ToArray(); foreach (VoiceGroup key in array) { voiceGroupStopwatches[key] += deltaTime; } timeSinceLastRolledLine += deltaTime; } public bool RollForSoundEvent(VoiceArray soundArray, float maxProbability = 1f) { if (timeSinceLastRolledLine < currentSoundWait) { return false; } float num = voiceGroupStopwatches[soundArray.group]; float num2 = soundArray.group.maxWait - soundArray.group.minWait; float num3 = ((num2 != 0f) ? Mathf.Min(maxProbability, (num - soundArray.group.minWait) / num2) : 1f); if (num > soundArray.group.minWait && Random.value <= num3) { voiceGroupStopwatches[soundArray.group] = 0f; timeSinceLastRolledLine = 0f; return true; } return false; } public void TryPlayRandomUniqueSoundServer(VoiceArray soundArray, GameObject source, float maxProbability = 1f) { if (!NetworkServer.active || !RollForSoundEvent(soundArray, maxProbability)) { return; } int num; if (lastPlayedIndex.ContainsKey(soundArray)) { num = MwUtils.rand.Next(soundArray.voiceLines.Length - 1); if (num >= lastPlayedIndex[soundArray]) { num++; num %= soundArray.voiceLines.Length; } } else { num = MwUtils.rand.Next(soundArray.voiceLines.Length); lastPlayedIndex.Add(soundArray, num); } lastPlayedIndex[soundArray] = num; PlaySoundServer(soundArray.voiceLines[num], source, this); } public void TryPlayRandomSoundServer(VoiceArray soundArray, GameObject source, float maxProbability = 1f) { if (NetworkServer.active && RollForSoundEvent(soundArray, maxProbability)) { PlayRandomSoundServer(soundArray, source, this); } } public void TryPlayRandomSoundServer(VoiceArray soundArray, Vector3 position, float maxProbability = 1f) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && RollForSoundEvent(soundArray, maxProbability)) { PlayRandomSoundServer(soundArray, position, this); } } public void TryPlayRandomSound(VoiceArray soundArray, GameObject source, float maxProbability = 1f) { if (RollForSoundEvent(soundArray, maxProbability)) { PlayRandomSound(soundArray, source, this); } } public void TryPlayRandomSound(VoiceArray soundArray, Vector3 position, float maxProbability = 1f) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (RollForSoundEvent(soundArray, maxProbability)) { PlayRandomSound(soundArray, position, this); } } public static void PlayRandomSoundServer(VoiceArray soundArray, GameObject source, VoiceController voiceController = null) { if (NetworkServer.active) { object[] voiceLines = soundArray.voiceLines; VoiceInfo voiceInfo = (VoiceInfo)MwUtils.RandomChoice(voiceLines); PlaySoundServer(voiceInfo, source, voiceController); } } public static void PlayRandomSoundServer(VoiceArray soundArray, Vector3 position, VoiceController voiceController = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { object[] voiceLines = soundArray.voiceLines; VoiceInfo voiceInfo = (VoiceInfo)MwUtils.RandomChoice(voiceLines); PlaySoundServer(voiceInfo, position, voiceController); } } public static void PlayRandomSound(VoiceArray soundArray, GameObject source, VoiceController voiceController = null) { object[] voiceLines = soundArray.voiceLines; VoiceInfo voiceInfo = (VoiceInfo)MwUtils.RandomChoice(voiceLines); PlaySound(voiceInfo, source, voiceController); } public static void PlayRandomSound(VoiceArray soundArray, Vector3 position, VoiceController voiceController = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) object[] voiceLines = soundArray.voiceLines; VoiceInfo voiceInfo = (VoiceInfo)MwUtils.RandomChoice(voiceLines); PlaySound(voiceInfo, position, voiceController); } public static void PlaySoundServer(VoiceInfo voiceInfo, GameObject source, VoiceController voiceController = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { EntitySoundManager.EmitSoundServer(AkEventIdArg.op_Implicit(voiceInfo.sound.akId), source); if ((Object)(object)voiceController != (Object)null) { voiceController.currentSoundWait = voiceInfo.approxDuration + 0.5f; } } } public static void PlaySoundServer(VoiceInfo voiceInfo, Vector3 position, VoiceController voiceController = null) { //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) if (NetworkServer.active) { EffectManager.SimpleSoundEffect(voiceInfo.sound.index, position, true); if ((Object)(object)voiceController != (Object)null) { voiceController.currentSoundWait = voiceInfo.approxDuration + 0.5f; } } } public static void PlaySound(VoiceInfo voiceInfo, GameObject source, VoiceController voiceController = null) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) EntitySoundManager.EmitSoundLocal(AkEventIdArg.op_Implicit(voiceInfo.sound.akId), source); if ((Object)(object)voiceController != (Object)null) { voiceController.currentSoundWait = voiceInfo.approxDuration + 0.5f; } } public static void PlaySound(VoiceInfo voiceInfo, Vector3 position, VoiceController voiceController = null) { //IL_0007: 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) EffectManager.SimpleSoundEffect(voiceInfo.sound.index, position, false); if ((Object)(object)voiceController != (Object)null) { voiceController.currentSoundWait = voiceInfo.approxDuration + 0.5f; } } } public class VoiceGroup { public VoiceArray[] voiceArrays; public float minWait; public float maxWait; public VoiceGroup(VoiceArray[] voiceArrays, float minWait, float maxWait) { this.voiceArrays = voiceArrays; this.minWait = minWait; this.maxWait = maxWait; foreach (VoiceArray voiceArray in voiceArrays) { voiceArray.group = this; } } } public class VoiceInfo { public float approxDuration; public NetworkSoundEventDef sound; public VoiceInfo(string soundString, float approxDuration) { this.approxDuration = approxDuration; sound = ContentPacks.CreateAndAddNetworkSoundEventDef(soundString); } } } namespace MwSkinAdditions.Networking { public static class NetworkMessages { public static void Init() { NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); } } public class SyncGetItem : INetMessage, ISerializableObject { private NetworkInstanceId netInstanceId; private int itemIndex; public SyncGetItem() { } public SyncGetItem(NetworkInstanceId netInstanceId, int itemIndex) { //IL_0009: 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) this.netInstanceId = netInstanceId; this.itemIndex = itemIndex; } public void Serialize(NetworkWriter writer) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) writer.Write(netInstanceId); writer.Write(itemIndex); } public void Deserialize(NetworkReader reader) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) netInstanceId = reader.ReadNetworkId(); itemIndex = reader.ReadInt32(); } public void OnReceived() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(netInstanceId); if ((Object)(object)val != (Object)null) { SkinEvents.InvokeGetItem(val, itemIndex); } } } public class SyncUseShrine : INetMessage, ISerializableObject { private NetworkInstanceId netInstanceId; private bool success; public SyncUseShrine() { } public SyncUseShrine(NetworkInstanceId netInstanceId, bool success) { //IL_0009: 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) this.netInstanceId = netInstanceId; this.success = success; } public void Serialize(NetworkWriter writer) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) writer.Write(netInstanceId); writer.Write(success); } public void Deserialize(NetworkReader reader) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) netInstanceId = reader.ReadNetworkId(); success = reader.ReadBoolean(); } public void OnReceived() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(netInstanceId); if ((Object)(object)val != (Object)null) { SkinEvents.InvokeUseShrine(val, success); } } } public class SyncHoldoutZoneCharged : INetMessage, ISerializableObject { public void Serialize(NetworkWriter writer) { } public void Deserialize(NetworkReader reader) { } public void OnReceived() { SkinEvents.InvokeHoldoutZoneCharged(); } } }