Jump to content

ve2dmn

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by ve2dmn

  1. I wrote my own code to detect which asteroid are heading for kerbin and when. That bit is working great and It auto-add the SOI change to KAC. The part that is not working is making custom contracts based on that information. Because the orbits are only available during the FLIGHT and TRACKSTATION GameScenes, I have my code try to generate a custom contract and add it to the current ones. Problem is, it doesn't seems to do anything. The contracts doesn't show up, even in the debug menu. Here is the code: private void AddContract(String vID) { //Add Contract if possible Debug.Log ("Try to find Contract for " + vID); Debug.Log ("number of Contracts to check : " + ContractSystem.Instance.Contracts.Count ()); Debug.Log ("Status of Contract system: " + (ContractSystem.Instance == null)); Debug.Log ("ContractSystem.Instance.enabled: " + ContractSystem.Instance.enabled); Debug.Log ("Generating new Contract "); AsteroidRedirectContract GeneratedContractType = new AsteroidRedirectContract (); Contract GeneratedContract = null; Debug.Log ("Generating Contract of Type:" + GeneratedContractType.GetType ()); GeneratedContract = ContractSystem.Instance.GenerateContract (0, Contract.ContractPrestige.Trivial, GeneratedContractType.GetType ()); if (GeneratedContract != null) { GeneratedContract.AddParameter (new AsteroidRedirectAltitudeParameters (vID)); GeneratedContract.AddParameter (new AsteroidRedirectDockingParameters (vID)); } if (!ContractSystem.Instance.Contracts.Contains(GeneratedContract)) { //Generate new Contract GeneratedContract.Accept (); ContractSystem.Instance.Contracts.Add (GeneratedContract); Debug.Log ("Generated Contract:" + GeneratedContract.ToString ()); } } Now, I am obvious not a C# or Unity developper, so I have no clue if I'm doing something that is obviously wrong.... I've tried to debug this for hours trying various way and none seems to work, which is why I am posting here... ContractSystem.Instance.Contracts.Count (), keeps going up with every contract that I Add(). So that seems to be working. Except, it doesn't do anything. Any Ideas?
  2. Asteroids do not spawn if the tracking station is not upgraded...
  3. To reply to my own post, This is code that made Patches possible. if (!v.PatchedConicsAttached) { print("No PatchedConicSolver. Creating a New One. "); v.patchedConicSolver = new PatchedConicSolver (); v.AttachPatchedConicsSolver (); v.patchedConicSolver.Update (); } I still have to figure out why it works Sometimes, and sometimes, it gives my a NullReference Exception for AttachPatchedConicsSolver ()... But at least now I have Encouters and NextPatch in the robit of each vessel (just need to remember to run v.DetachPatchedConicsSolver () once I have the info I need....)
  4. I'm trying to find which Asteroid are on a collision course for Kerbin and I can't seem to get the info from the orbit Class. Vessel.orbit.closestEncounterLevel always seems to be None for not active vessel; Similar results for (all return false, none, null, etc...) : orbit.closestEncounterBody orbit.closestEncounterPatch orbit.nextPatch The only information I need is the altitude at periapsis around Kerbin, if there is one. (Then set to Asteroid to be auto-tracked, Which I know how to do thanks to http://forum.kerbalspaceprogram.com/threads/75376-Asteroid-Spawn-API ) But so far, if the vessel is OnRail (AKA not the active one), I cannot get any orbit information besides the current orbit. (and I can't get Orbit.SolveClosestApproach to work) Any idea?
×
×
  • Create New...