Jump to content

Exception with custom making history node


Recommended Posts

I'm attempting to make another custom node for Making History, this time an action to change the focussed vessel. This one fires and changes the focus but seems to be causing an error in the MH code and preventing the next node from firing. Can anyone (probably @SQUAD) tell me what is wrong?

The code for the node

Spoiler

class ActionSwitchFocus : ActionVessel
    {

        public override IEnumerator Fire()
        {
            Debug.Log("Action switch focus is being called");
            Vessel v = FlightGlobals.ActiveVessel;

            bool swit = FlightGlobals.SetActiveVessel(vessel);
            Debug.Log("Switch vessel has finished with " + swit);
            //return base.Fire();
            return Enumerable.Empty<int>().GetEnumerator();
        }
    }

 

 

And the Logs

Spoiler

[HighLogic]: =========================== Scene Change : From FLIGHT to FLIGHT =====================
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

Switch vessel has finished with True
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.MonoBehaviour:StartCoroutine_Auto_Internal (System.Collections.IEnumerator)
  at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00000] in <filename unknown>:0 
  at Expansions.Missions.MENode.ActivateNode (Boolean Loading) [0x00000] in <filename unknown>:0 
  at Expansions.Missions.Mission.SwitchActiveNodes (Expansions.Missions.MENode newNode) [0x00000] in <filename unknown>:0 
  at Expansions.Missions.Mission.UpdateMission () [0x00000] in <filename unknown>:0 
  at Expansions.Missions.Runtime.MissionSystem.UpdateMissions () [0x00000] in <filename unknown>:0 
  at Expansions.Missions.Runtime.MissionSystem.FixedUpdate () [0x00000] in <filename unknown>:0 

 

 

Link to comment
Share on other sites

I'm not very experienced on MH mods but the Fire() method seems like a coroutine so instead of returning:

return Enumerable.Empty<int>().GetEnumerator();

I would just do:

return 0 

or other parameter that fills your needs.


+Info about coroutines on unity: 
http://www.unitygeek.com/coroutines-in-unity3d/

Edited by Dagger
Link to comment
Share on other sites

Yup, that got that exception. Still doesn't work though but there is one less exception in the logs. Now I get

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Transform:INTERNAL_get_position (UnityEngine.Vector3&)
  at UnityEngine.Transform.get_position () [0x00000] in <filename unknown>:0
  at FlightGlobals.getFoR (FoRModes mode, UnityEngine.Transform referenceTransform, .Orbit orbit, .CelestialBody body) [0x00000] in <filename unknown>:0
  at FlightGlobals.GetFoR (FoRModes mode) [0x00000] in <filename unknown>:0
  at FlightCamera+<Startup>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0
  at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in <filename unknown>:0
UnityEngine.MonoBehaviour:StartCoroutine_Auto_Internal(IEnumerator)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
FlightCamera:OnLevelLoaded(GameScenes)
FlightCamera:OnSceneLoaded(Scene, LoadSceneMode)
UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...