Exemplo n.º 1
0
 void OnManeuverEvent(ManeuverEvent e)
 {
     //coroutine execute in x time?
     Debug.Log("ManeuverEvent fired");
     //StartCoroutine(AdjustOrbit(e));
     AdjustOrbit(e);
 }
Exemplo n.º 2
0
    public void TriggerIntercept()
    {
        if (mStartTime + mComputeTime <= eventManager.GetSimTime())
        {
            Debug.Log("Error: Intercept injection in the past");
            return;
        }
        Debug.Log("Trigger intercept event");
        var src = UXStateManager.GetSource();
        var tgt = UXStateManager.GetTarget();

        Debug.Log("InjVec: " + mInjectionVector.ToString());
        var e = new ManeuverEvent(src, tgt,
                                  (float)(mStartTime + mComputeTime), (float)mTravelTime,
                                  "intercepts", mInjectionVector);

        //Events.instance.Queue(e); //deprecated, should be made illegal
        eventManager.Queue(e);
    }
Exemplo n.º 3
0
    void AdjustOrbit(ManeuverEvent e)
    {
        /*
         * float time = (float)e.GetTime();
         *
         * while (time > 5)
         * {
         *  Debug.Log("Waiting for " + time + " seconds");
         *  yield return new WaitForSeconds(5);
         *  time -= 5;
         * }
         * Debug.Log("Waiting for " + time + " seconds");
         * yield return new WaitForSeconds(time);
         */
        Debug.Log("Name of source: " + e.GetSource().name);
        Debug.Log("Firing! " + OVTools.FormatDistance((float)e.velocity.magnitude) + "/s");
        Debug.Log("injection vector: " + e.velocity.ToString());
        Debug.Log("Injection time: " + eventManager.GetSimTime());

        var odata = e.GetSource().GetComponent <OrbitData>();

#if false
        //recompute firing solution
        Vector3d r1, r2, v1, v2, initVel, finalVel;
        //var oe1 = e.GetSource().GetComponent<OrbitData>().getOE();
        var oe2 = e.GetTarget().GetComponent <OrbitData>().getOE();
        //FindRV(oe1, eventManager.GetSimTime(), out r1, out v1);
        r1 = e.GetSource().GetComponent <OrbitData>().getR();
        FindRV(oe2, e.relTravelTime, out r2, out v2);
        MuMech.LambertSolver.Solve(r1, r2, e.relTravelTime, OrbitData.parentGM, true, out initVel, out finalVel);

        Debug.Log("Injection pos: " + odata.getR().ToString());
        var diff = (float)(odata.getR() - OVDebug.projectedR1).magnitude;
        Debug.Log("Difference: " + OVTools.FormatDistance(diff));

        Debug.Log("New injection vector: " + initVel.ToString());
        var diff2 = (float)(e.velocity - initVel).magnitude;
        Debug.Log("Diff: " + OVTools.FormatDistance(diff2));
#endif

        if (odata == null)
        {
            Debug.Log("no orbital data from ship!!");
        }

        odata.rv[3] = e.velocity.x;
        odata.rv[4] = e.velocity.y;
        odata.rv[5] = e.velocity.z;

        //update oe
        var oe = Util.rv2oe(OrbitData.parentGM, odata.rv);
        odata.SetOE(oe);

        Debug.Log("InjVec: " + e.velocity);
        //disable intercept line render
        interceptLine.enabled = false;
        var marker1 = GameObject.Find("Marker1");
        marker1.transform.localPosition = Vector3.zero;
        var marker2 = GameObject.Find("Marker2");
        marker2.transform.localPosition = Vector3.zero;
    }
Exemplo n.º 4
0
 void OnManeuverEvent(ManeuverEvent e)
 {
     Debug.Log("EventManager got an event");
     EventFired = true;
 }