public void StartTouchEmpty(Vector2 posWorld, int fingerId) { MyTouchStartHook myTouchStartHook = new MyTouchStartHook(); myTouchStartHook = MyHookSystem.executeHook <MyTouchStartHook>(myTouchStartHook); if (myTouchStartHook.isCanceled()) { return; } Ref.SceneType currentScene = Ref.currentScene; if (currentScene != Ref.SceneType.MainMenu) { if (currentScene != Ref.SceneType.Build) { if (currentScene != Ref.SceneType.Game) { } } else { Build.main.OnTouchStart(fingerId, posWorld); } } }
public void OnTouchEnd(int fingerId, Vector2 touchPosWorld) { if (Build.HoldingPart.isNull(this.holdingParts[fingerId])) { return; } Vector2 vector = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset); Vector2 autoCorrect = this.GetAutoCorrect(vector, fingerId); Vector2 a = Vector3.Lerp(vector, autoCorrect, 1f - this.roundStrength); Vector2 v = a + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : (this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation)); bool flag = Utility.IsInsideRange(v.x - this.buildGrid.transform.position.x, -0.5f, this.buildGrid.width + 0.5f, true) && Utility.IsInsideRange(v.y - this.buildGrid.transform.position.y, -0.5f, this.buildGrid.height + 0.5f, true); bool flag2 = this.pickGrid.IsInsideDropArea(Utility.ToDepth(v, this.pickMenuDistance)); if (flag && !flag2) { PlacedPart newPart = new PlacedPart(null, (Vector3)autoCorrect - this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData); MyPartCreatedHook hook = new MyPartCreatedHook(newPart); hook = MyHookSystem.executeHook <MyPartCreatedHook>(hook); if (hook.isCanceled()) { return; } this.dragAndDropInstruction.InvokeEvenets(); this.buildGrid.PlacePart(hook.target); } if (this.holdingParts[fingerId].part.partIcon != null) { UnityEngine.Object.Destroy(this.holdingParts[fingerId].part.partIcon.gameObject); } this.holdingParts[fingerId] = null; }
public void TakeResource(float removeAmount) { float newAmount = this.resourceAmount - removeAmount; MyDrainResourceHook hook = new MyDrainResourceHook(removeAmount, newAmount, this); hook = MyHookSystem.executeHook <MyDrainResourceHook>(hook); this.resourceAmount = Mathf.Max(this.resourceAmount - hook.amountToTake, 0f); this.SetTanks(); }
public static void LoadGame(GameSaving.GameSave loadedData) { GameSaving.ClearScene(); MySaveLoadedHook mySaveLoadedHook = new MySaveLoadedHook(loadedData); mySaveLoadedHook = MyHookSystem.executeHook <MySaveLoadedHook>(mySaveLoadedHook); if (mySaveLoadedHook.isCanceled()) { return; } Ref.planetManager.SwitchLocation(Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress), loadedData.vessels[loadedData.mainVesselId].globalPosition, false, true, 0.0); Ref.velocityOffset = loadedData.velocityOffset; Ref.controller.globalTime = loadedData.globalTime; Ref.controller.timewarpPhase = loadedData.timeWarpPhase; Ref.controller.startedTimewarpTime = loadedData.startedTimewapTime; Ref.timeWarping = (Ref.controller.timewarpPhase != 0); Ref.controller.SetCameraDistance(loadedData.camDistance); foreach (GameSaving.VesselSave vesselToLoad in loadedData.vessels) { GameSaving.LoadVessel(vesselToLoad); } Ref.planetManager.FullyLoadTerrain(Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress)); Ref.mainVessel = Ref.controller.vessels[loadedData.mainVesselId]; if (loadedData.selectedVesselId != -1) { Ref.map.SelectVessel(Ref.controller.vessels[loadedData.selectedVesselId], false); } Ref.map.UpdateVesselsMapIcons(); Ref.map.following = new OrbitLines.Target(Ref.GetPlanetByName(loadedData.mapFollowingAdress)); Ref.map.UpdateMapPosition(loadedData.mapPosition); Ref.map.UpdateMapZoom(-loadedData.mapPosition.z); Ref.map.ToggleMap(); if (Ref.mapView != loadedData.mapView) { Ref.map.ToggleMap(); } Ref.mainVessel.SetThrottle(Ref.mainVessel.throttle); Ref.map.DrawOrbitLines(); Ref.controller.RepositionFuelIcons(); Ref.controller.warpedTimeCounterUI.text = string.Empty; Ref.planetManager.UpdateAtmosphereFade(); Ref.mainVesselHeight = loadedData.vessels[loadedData.mainVesselId].globalPosition.magnitude2d - Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress).radius; Ref.mainVesselAngleToPlanet = (float)Math.Atan2(loadedData.vessels[loadedData.mainVesselId].globalPosition.y, loadedData.vessels[loadedData.mainVesselId].globalPosition.x) * 57.29578f; if (Ref.mainVesselHeight < Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress).cameraSwitchHeightM) { Ref.controller.camTargetAngle = Ref.mainVesselAngleToPlanet - 90f; } else { Ref.controller.camTargetAngle = 0f; } Ref.cam.transform.eulerAngles = new Vector3(0f, 0f, Ref.controller.camTargetAngle); Ref.controller.camAngularVelocity = 0f; }
private void GoForLaunch() { MyRocketToLaunchpadHook myRocketToLaunchpadHook = MyHookSystem.executeHook <MyRocketToLaunchpadHook>(new MyRocketToLaunchpadHook(this.buildGrid.parts)); bool flag = myRocketToLaunchpadHook.isCanceled(); if (!flag) { string jsonString = JsonUtility.ToJson(new Build.BuildSave("To Launch", Ref.cam.transform.position, myRocketToLaunchpadHook.rocket, this.GetOrientation())); Ref.SaveJsonString(jsonString, Saving.SaveKey.ToLaunch); Ref.LoadScene(Ref.SceneType.Game); } }
public static void AddQuicksave(Build.BuildSave newSave) { MyVesselSavedHook myVesselSavedHook = new MyVesselSavedHook(newSave); myVesselSavedHook = MyHookSystem.executeHook <MyVesselSavedHook>(myVesselSavedHook); if (myVesselSavedHook.isCanceled()) { return; } Build.BuildQuicksaves buildQuicksaves = Build.BuildQuicksaves.LoadBuildQuicksaves(); buildQuicksaves.buildSaves.Add(newSave); Build.BuildQuicksaves.SaveBuildQuicksaves(buildQuicksaves); }
private void GoForLaunch() { MyRocketToLaunchpadHook res = MyHookSystem.executeHook <MyRocketToLaunchpadHook>(new MyRocketToLaunchpadHook()); if (res.isCanceled()) { return; } string jsonString = JsonUtility.ToJson(new Build.BuildSave("To Launch", Ref.cam.transform.position, this.buildGrid.parts)); Ref.SaveJsonString(jsonString, Saving.SaveKey.ToLaunch); Ref.LoadScene(Ref.SceneType.Game); }
public static void LoadScene(Ref.SceneType sceneToLoad) { MySceneChangeHook mySceneChangeHook = MyHookSystem.executeHook <MySceneChangeHook>(new MySceneChangeHook(Ref.lastScene, sceneToLoad)); bool flag = mySceneChangeHook.isCanceled(); if (!flag) { sceneToLoad = mySceneChangeHook.newScene; Ref.SceneType current = Ref.lastScene; Ref.lastScene = Ref.currentScene; SceneManager.LoadScene(sceneToLoad.ToString(), LoadSceneMode.Single); MyHookSystem.executeHook <MySceneChangedHook>(new MySceneChangedHook(current, sceneToLoad)); } }
public static void LoadScene(Ref.SceneType sceneToLoad) { MySceneChangeHook res = MyHookSystem.executeHook <MySceneChangeHook>(new MySceneChangeHook(Ref.lastScene, sceneToLoad)); if (res.isCanceled()) { return; } sceneToLoad = res.newScene; Ref.SceneType oldScene = Ref.lastScene; Ref.lastScene = Ref.currentScene; SceneManager.LoadScene(sceneToLoad.ToString(), LoadSceneMode.Single); MyHookSystem.executeHook <MySceneChangedHook>(new MySceneChangedHook(oldScene, sceneToLoad)); }
public static void AddQuicksave(GameSaving.GameSave newQuicksave) { MySaveSavedHook mySaveSavedHook = new MySaveSavedHook(newQuicksave); mySaveSavedHook = MyHookSystem.executeHook <MySaveSavedHook>(mySaveSavedHook); if (mySaveSavedHook.isCanceled()) { return; } GameSaving.Quicksaves quicksaves = GameSaving.Quicksaves.LoadQuicksaves(); quicksaves.quicksaves.Add(newQuicksave); GameSaving.Quicksaves.SaveQuicksaves(quicksaves); }
private void KeyUpdate() { foreach (object obj in this.codes) { KeyCode keyCode = (KeyCode)obj; bool key = Input.GetKey(keyCode); if (key) { bool flag = !this.keyDown.Contains(keyCode); if (flag) { MyKeyDownHook myKeyDownHook = MyHookSystem.executeHook <MyKeyDownHook>(new MyKeyDownHook(keyCode)); bool flag2 = myKeyDownHook.isCanceled(); if (flag2) { bool register = myKeyDownHook.register; if (register) { this.keyDown.Add(keyCode); } return; } this.keyDown.Add(keyCode); } } } List <KeyCode> list = new List <KeyCode>(this.keyDown); foreach (KeyCode keyCode2 in list) { bool flag3 = !Input.GetKey(keyCode2); if (flag3) { MyKeyUpHook baseHook = new MyKeyUpHook(keyCode2); MyKeyUpHook myKeyUpHook = MyHookSystem.executeHook <MyKeyUpHook>(baseHook); bool flag4 = myKeyUpHook.isCanceled(); if (flag4) { bool register2 = myKeyUpHook.register; if (register2) { this.keyDown.Remove(keyCode2); } break; } this.keyDown.Remove(keyCode2); } } }
public void LoadSave(Build.BuildSave buildSaveToLoad) { MyVesselLoadedHook myVesselLoadedHook = new MyVesselLoadedHook(Build.BuildSave.PlacedPartSave.FromSave(buildSaveToLoad.parts, this.partDatabase)); myVesselLoadedHook = MyHookSystem.executeHook <MyVesselLoadedHook>(myVesselLoadedHook); if (myVesselLoadedHook.isCanceled()) { return; } this.buildGrid.DeleteAllIcons(); Camera.main.transform.position = buildSaveToLoad.cameraPosition; this.buildGrid.parts = myVesselLoadedHook.parts; this.buildGrid.LoadAllIcons(); this.MoveCamera(Vector3.zero); }
public void OnTouchEnd(int fingerId, Vector2 touchPosWorld) { if (Build.HoldingPart.isNull(this.holdingParts[fingerId])) { return; } Vector2 vector = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset); Vector2 vector2 = this.GetAutoCorrect(vector, fingerId); Vector2 a = Vector3.Lerp(vector, vector2, 1f - this.roundStrength); Vector2 v = a + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : (this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation)); bool flag = Utility.IsInsideRange(v.x - this.buildGrid.transform.position.x, -0.5f, this.buildGrid.width + 0.5f, true) && Utility.IsInsideRange(v.y - this.buildGrid.transform.position.y, -0.5f, this.buildGrid.height + 0.5f, true); bool flag2 = this.pickGrid.IsInsideDropArea(Utility.ToDepth(v, this.pickMenuDistance)); if (flag && !flag2) { PlacedPart targetPart = new PlacedPart(null, vector2 - (Vector2)this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData); MyPartCreatedHook myPartCreatedHook = new MyPartCreatedHook(targetPart); myPartCreatedHook = MyHookSystem.executeHook <MyPartCreatedHook>(myPartCreatedHook); bool flag5 = myPartCreatedHook.isCanceled(); if (flag5) { return; } if (this.holdingParts[fingerId].part.partData.flip2stickX && this.ConnectedSurface(vector2, fingerId) == 0f) { this.FlipX(); Vector2 vector3 = vector2; vector = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset); vector2 = this.GetAutoCorrect(vector, fingerId); if (this.ConnectedSurface(vector2, fingerId) == 0f) { this.FlipX(); vector2 = vector3; } } bool placeActive = !this.holdingParts[fingerId].part.partData.inFull || Ref.hasPartsExpansion; this.buildGrid.PlacePart(new PlacedPart(null, vector2 - (Vector2)this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData), placeActive); } if (this.holdingParts[fingerId].part.partIcon != null) { UnityEngine.Object.Destroy(this.holdingParts[fingerId].part.partIcon.gameObject); } this.holdingParts[fingerId] = null; }
private void KeyUpdate() { foreach (KeyCode code in codes) { if (Input.GetKey(code)) { if (!keyDown.Contains(code)) { MyKeyDownHook result = MyHookSystem.executeHook <MyKeyDownHook>(new MyKeyDownHook(code)); if (result.isCanceled()) { if (result.register) { keyDown.Add(code); } return; } keyDown.Add(code); } } } List <KeyCode> nList = new List <KeyCode>(keyDown); foreach (KeyCode down in nList) { if (!Input.GetKey(down)) { MyKeyUpHook hook = new MyKeyUpHook(down); MyKeyUpHook result = MyHookSystem.executeHook <MyKeyUpHook>(hook); if (result.isCanceled()) { if (result.register) { keyDown.Remove(down); } return; } keyDown.Remove(down); } } }
public virtual void UsePart() { MyPartUseHook myPartUseHook = new MyPartUseHook(this); myPartUseHook = MyHookSystem.executeHook <MyPartUseHook>(myPartUseHook); bool flag = myPartUseHook.isCanceled(); if (!flag) { if (this.useEvent) { this.onPartUsed.Invoke(); } for (int i = 0; i < this.modules.Length; i++) { this.modules[i].OnPartUsed(); } new MyPartUsedHook(this).executeDefault(); } }
public void UsePart() { try { MyPartUsedHook result = MyHookSystem.executeHook <MyPartUsedHook>(new MyPartUsedHook(this)); if (result.isCanceled()) { return; } } catch (Exception e) { ModLoader.mainConsole.logError(e); } if (this.useEvent) { this.onPartUsed.Invoke(); } for (int i = 0; i < this.modules.Length; i++) { this.modules[i].OnPartUsed(); } }
public void DestroyPart(bool createExplosion, bool disablePartToPartDamage) { MyPartUsedHook hook = new MyPartUsedHook(this); hook = MyHookSystem.executeHook <MyPartUsedHook>(hook); if (hook.isCanceled()) { return; } while (this.joints.Count > 0) { Part.DestroyJoint(this.joints[0], disablePartToPartDamage); } this.vessel.partsManager.parts.Remove(this); base.gameObject.SetActive(false); this.vessel.partsManager.UpdatePartsGruping(disablePartToPartDamage, this.vessel); if (createExplosion) { Transform transform = UnityEngine.Object.Instantiate <Transform>(Ref.controller.explosionParticle, base.transform.TransformPoint(this.centerOfMass), Quaternion.identity); transform.localScale = Vector3.one * (this.mass * 1.8f + 0.5f); UnityEngine.Object.Destroy(transform.gameObject, 8f); } UnityEngine.Object.Destroy(base.gameObject); }
public void StartRecovery() { Ref.inputController.leftArrow.parent.gameObject.SetActive(false); this.fuelIconsHolder.gameObject.SetActive(false); Vessel vessel = (!Ref.mapView) ? Ref.mainVessel : Ref.selectedVessel; MyVesselRecovering myVesselRecovering = new MyVesselRecovering(vessel); myVesselRecovering = MyHookSystem.executeHook <MyVesselRecovering>(myVesselRecovering); if (myVesselRecovering.isCanceled()) { return; } Ref.inputController.recoverMenuHolder.transform.GetChild(8).GetChild(1).GetComponent <Text>().text = ((!(vessel == Ref.mainVessel)) ? "Complete Recovery" : "Complete Mission"); List <string> list = (!(vessel != null)) ? new List <string>() : new List <string>(vessel.vesselAchievements); if (list.Contains("Reached 10 km altitude.") && list.Count > 2) { list.Remove("Reached 5 km altitude."); } if (list.Contains("Reached 15 km altitude.") && list.Count > 2) { list.Remove("Reached 10 km altitude."); } if (list.Contains("Passed the Karman Line, leaving the /atmosphere and reaching space.") && list.Count > 2) { list.Remove("Reached 15 km altitude."); } if (list.Contains("Reached low " + Ref.controller.startAdress + " orbit.") && list.Count > 4) { list.Remove("Passed the Karman Line, leaving the /atmosphere and reaching space."); } Ref.inputController.recoverMenuHolder.SetActive(true); bool flag = Ref.inputController.canvasScalers[0].referenceResolution.x == 750f; Text component = Ref.inputController.recoverMenuHolder.transform.GetChild(4).GetComponent <Text>(); Text component2 = Ref.inputController.recoverMenuHolder.transform.GetChild(6).GetComponent <Text>(); component.transform.localPosition = new Vector3(0f, component.transform.localPosition.y); Ref.inputController.recoverMenuHolder.transform.GetChild(3).localPosition = new Vector3(0f, component.transform.localPosition.y + 10f); Ref.inputController.recoverMenuHolder.transform.GetChild(5).localPosition = new Vector3(5000f, component.transform.localPosition.y + 10f); Ref.inputController.recoverMenuHolder.transform.GetChild(3).localScale = new Vector3(1f, (!flag) ? 0.51f : 1f); Ref.inputController.recoverMenuHolder.transform.GetChild(5).localScale = new Vector3(1f, (!flag) ? 0.51f : 1f); component.text = string.Empty; component2.text = string.Empty; int num = 0; Text text = component; foreach (string text2 in list) { Text text3 = text; text3.text += "- "; for (int i = 0; i < text2.Length; i++) { if (text2[i].ToString() == "/") { Text text4 = text; text4.text += "\r\n \r\n "; num += 2; } else { Text text5 = text; text5.text += text2[i].ToString(); } } Text text6 = text; text6.text += "\r\n \r\n \r\n"; num += 3; if (num > ((!flag) ? 24 : 51)) { if (text == component2 || flag) { break; } text = component2; num = 0; component.transform.localPosition = new Vector3(-300f, component.transform.localPosition.y); component2.transform.localPosition = new Vector3(300f, component.transform.localPosition.y); Ref.inputController.recoverMenuHolder.transform.GetChild(3).localPosition = new Vector3(-300f, component.transform.localPosition.y + 10f); Ref.inputController.recoverMenuHolder.transform.GetChild(5).localPosition = new Vector3(300f, component.transform.localPosition.y + 10f); } } }
private void loadModFromFile(String modFile) { try { if (Path.GetExtension(modFile) != ".dll") { return; } string modFileName = Path.GetFileNameWithoutExtension(modFile); mainConsole.log("Loading mod: " + modFileName, logTag); Assembly modAssembly = Assembly.LoadFrom(modFile); MyMod entryObject = null; foreach (Type modType in modAssembly.GetTypes()) { object[] attributeList = modType.GetCustomAttributes(typeof(MyModEntryPoint), true); if (attributeList.Length == 1) { entryObject = Activator.CreateInstance(modType) as MyMod; } } if (entryObject == null) { mainConsole.tryLogCustom("Mod does not contain a ModLoader entry point.", logTag, LogType.Generic); mainConsole.tryLogCustom("It is possible this mod is not compatible with ModLoader.", logTag, LogType.Generic); return; } string infoPath = Path.Combine(Path.GetDirectoryName(modFile), Path.GetFileNameWithoutExtension(modFile)); if (entryObject.LoadAssets(Path.Combine(infoPath, "Assets"))) { mainConsole.tryLogCustom("Loaded assets.", logTag, LogType.Generic); if (entryObject.fetchIcon()) { mainConsole.tryLogCustom("Loaded custom icon (Use UIE to display).", logTag, LogType.Generic); } } if (mods.ContainsKey(entryObject.myName)) { mainConsole.tryLogCustom("Mod by the name " + entryObject.myName + " already exists!", logTag, LogType.Generic); return; } string dataPath = this.getMyDataDirectory() + modFileName; entryObject.assignDataPath(dataPath); MethodInfo[] methods = modAssembly.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (MethodInfo method in methods) { MyListenerAttribute[] att = (MyListenerAttribute[])method.GetCustomAttributes(typeof(MyListenerAttribute), true); if (att.Length == 1) { new HookSystem.ReWork.MyHookListener(method, entryObject); } } entryObject.Load(); mainConsole.tryLogCustom("Loaded " + entryObject.myName + ".\n" + entryObject.myDescription + "\nVersion " + entryObject.myVersion, logTag, LogType.Generic); this.loadedMods++; mods[entryObject.myName] = entryObject; MyHookSystem.executeHook <MyModLoadedHook>(new MyModLoadedHook(entryObject)); } catch (MyCoreException e) { e.caller = new MyCoreException.MyCaller("loadModFromFile", "ModLoader.cs"); } catch (Exception e) { mainConsole.logError(e); } }
private void loadModFromFile(string modFile) { try { bool flag = Path.GetExtension(modFile) != ".dll"; if (!flag) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(modFile); ModLoader.mainConsole.log("Loading mod: " + fileNameWithoutExtension, ModLoader.logTag); Assembly assembly = Assembly.LoadFrom(modFile); MyMod myMod = null; foreach (Type type in assembly.GetTypes()) { object[] customAttributes = type.GetCustomAttributes(typeof(MyModEntryPoint), true); bool flag2 = customAttributes.Length == 1; if (flag2) { myMod = (Activator.CreateInstance(type) as MyMod); } } bool flag3 = myMod == null; if (flag3) { ModLoader.mainConsole.tryLogCustom("Mod does not contain a ModLoader entry point.", ModLoader.logTag, LogType.Generic); ModLoader.mainConsole.tryLogCustom("It is possible this mod is not compatible with ModLoader.", ModLoader.logTag, LogType.Generic); } else { List <string> list = new List <string>(); foreach (AssemblyName assemblyName in assembly.GetReferencedAssemblies()) { list.Add(assemblyName.FullName); } ModLoader.mainConsole.tryLogCustom("Assemblies: [" + string.Join(",", list.ToArray()) + "]", ModLoader.logTag, LogType.Generic); string path = Path.Combine(Path.GetDirectoryName(modFile), Path.GetFileNameWithoutExtension(modFile)); bool flag4 = myMod.LoadAssets(Path.Combine(path, "Assets")); if (flag4) { ModLoader.mainConsole.tryLogCustom("Loaded assets.", ModLoader.logTag, LogType.Generic); bool flag5 = myMod.fetchIcon(); if (flag5) { ModLoader.mainConsole.tryLogCustom("Loaded custom icon (Use UIE to display).", ModLoader.logTag, LogType.Generic); } } bool flag6 = this.mods.ContainsKey(myMod.myName); if (flag6) { ModLoader.mainConsole.tryLogCustom("Mod by the name " + myMod.myName + " already exists!", ModLoader.logTag, LogType.Generic); } else { string path2 = Path.Combine(this.getMyDataDirectory(), fileNameWithoutExtension); myMod.assignDataPath(path2); MethodInfo[] methods = myMod.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { MyListenerAttribute[] array2 = (MyListenerAttribute[])methodInfo.GetCustomAttributes(typeof(MyListenerAttribute), true); bool flag7 = array2.Length == 1; if (flag7) { new MyHookListener(methodInfo, myMod); } } FieldInfo[] fields = myMod.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { MyHookListenerContainer[] array4 = (MyHookListenerContainer[])fieldInfo.GetCustomAttributes(typeof(MyHookListenerContainer), true); bool flag8 = array4.Length == 1; if (flag8) { MethodInfo[] methods2 = fieldInfo.GetValue(myMod).GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo listenMethod in methods2) { new MyHookListener(listenMethod, myMod); } } } myMod.Load(); ModLoader.mainConsole.tryLogCustom(ModLoader.translation.autoFormat("@ModEntry", new object[] { myMod.myName, myMod.myVersion, myMod.myDescription }), ModLoader.logTag, LogType.Generic); this.loadedMods++; this.mods[myMod.myName] = myMod; MyHookSystem.executeHook <MyModLoadedHook>(new MyModLoadedHook(myMod)); } } } } catch (MyCoreException ex) { ex.caller = new MyCoreException.MyCaller("loadModFromFile", "ModLoader.cs"); } catch (Exception e) { ModLoader.mainConsole.logError(e); } }
private void OnGUI() { MyHookSystem.executeHook <MyOnGuiHook>(new MyOnGuiHook(Ref.currentScene)); }