Exemplo n.º 1
0
 public void CopyFrom(ControlInputs other)
 {
     state.CopyFrom(other.state);
     ThrottleUpdated      = other.ThrottleUpdated;
     WheelThrottleUpdated = other.WheelThrottleUpdated;
     WheelSteerUpdated    = other.WheelSteerUpdated;
 }
Exemplo n.º 2
0
        static void OnFlyByWire(Vessel vessel, FlightCtrlState state)
        {
            var inputs = new ControlInputs(state);

            // Manual inputs
            if (!manualInputs.ContainsKey(vessel))
            {
                manualInputs [vessel] = new ControlInputs();
            }
            HandleThrottle(vessel, manualInputs [vessel]);
            inputs.Add(manualInputs [vessel]);

            // Auto-pilot inputs
            if (!autoPilotInputs.ContainsKey(vessel))
            {
                autoPilotInputs [vessel] = new ControlInputs();
            }
            if (Services.AutoPilot.Fly(vessel, autoPilotInputs [vessel]))
            {
                inputs.Add(autoPilotInputs [vessel]);
            }

            // Update current inputs
            if (!currentInputs.ContainsKey(vessel))
            {
                currentInputs [vessel] = new ControlInputs();
            }
            currentInputs [vessel].CopyFrom(inputs);
        }
Exemplo n.º 3
0
 internal static ControlInputs Get(Vessel vessel)
 {
     if (!currentInputs.ContainsKey(vessel))
     {
         currentInputs [vessel] = new ControlInputs();
     }
     return(currentInputs [vessel]);
 }
Exemplo n.º 4
0
 internal static ControlInputs Get(Vessel vessel)
 {
     var client = KRPC.KRPCServer.Context.RPCClient;
     if (!controlInputs.ContainsKey (vessel))
         controlInputs [vessel] = new Dictionary<IClient, ControlInputs> ();
     if (!controlInputs [vessel].ContainsKey (client))
         controlInputs [vessel] [client] = new ControlInputs ();
     return controlInputs [vessel] [client];
 }
Exemplo n.º 5
0
 public void StartSimHandler(ControlInputs newBehavior)
 {
     carController.input = newBehavior;
     //set current states
     //position
     //rotation
     //wheel speed
     //velocity
 }
Exemplo n.º 6
0
 internal static ControlInputs Set(Vessel vessel)
 {
     manualInputClients.Add(CallContext.Client);
     if (!manualInputs.ContainsKey(vessel))
     {
         manualInputs [vessel] = new ControlInputs();
     }
     return(manualInputs [vessel]);
 }
Exemplo n.º 7
0
 public void Add(ControlInputs other)
 {
     if (other.ThrottleUpdated)
     {
         state.mainThrottle = other.state.mainThrottle;
     }
     ThrottleUpdated |= other.ThrottleUpdated;
     if (other.InputMode == Services.ControlInputMode.Additive)
     {
         state.pitch += other.state.pitch;
         state.yaw   += other.state.yaw;
         state.roll  += other.state.roll;
         state.X     += other.state.X;
         state.Y     += other.state.Y;
         state.Z     += other.state.Z;
     }
     else
     {
         if (Math.Abs(other.state.pitch) > 0.001)
         {
             state.pitch = other.state.pitch;
         }
         if (Math.Abs(other.state.yaw) > 0.001)
         {
             state.yaw = other.state.yaw;
         }
         if (Math.Abs(other.state.roll) > 0.001)
         {
             state.roll = other.state.roll;
         }
         if (Math.Abs(other.state.X) > 0.001)
         {
             state.X = other.state.X;
         }
         if (Math.Abs(other.state.Y) > 0.001)
         {
             state.Y = other.state.Y;
         }
         if (Math.Abs(other.state.Z) > 0.001)
         {
             state.Z = other.state.Z;
         }
     }
     if (other.WheelThrottleUpdated)
     {
         state.wheelThrottle = other.state.wheelThrottle;
     }
     if (other.WheelSteerUpdated)
     {
         state.wheelSteer = other.state.wheelSteer;
     }
 }
Exemplo n.º 8
0
 void Awake()
 {
     //destroy this object if there is already another one in the scene
     if (instance != null && instance != this)
     {
         Debug.LogWarning("Instance of this singleton object already exists, destroying this object");
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Exemplo n.º 9
0
        public Keys GetControlKey(ControlInputs action)
        {
            switch (action)
            {
            case ControlInputs.Pause:
                return(Keys.Space);

            case ControlInputs.Quit:
                return(Keys.Escape);

            case ControlInputs.Restart:
                return(Keys.Enter);
            }
            return(Keys.None);
        }
Exemplo n.º 10
0
 public void Add(ControlInputs other)
 {
     if (other.ThrottleUpdated)
     {
         state.mainThrottle = other.state.mainThrottle;
     }
     ThrottleUpdated     |= other.ThrottleUpdated;
     state.pitch         += other.state.pitch;
     state.yaw           += other.state.yaw;
     state.roll          += other.state.roll;
     state.X             += other.state.X;
     state.Y             += other.state.Y;
     state.Z             += other.state.Z;
     state.wheelThrottle += other.state.wheelThrottle;
     state.wheelSteer    += other.state.wheelSteer;
 }
Exemplo n.º 11
0
    public void SetStartValues(ControlInputs inputs)
    {
        startPosition = transform.position;
        startRotation = transform.rotation;
        startVelocity = rb.velocity;

        startWheelAngularVels = new Dictionary <WheelCollider, Vector3>();
        foreach (var axel in axels)
        {
            startWheelAngularVels.Add(axel.LWheelCollider, axel.LWheelCollider.attachedRigidbody.angularVelocity);
            startWheelAngularVels.Add(axel.RWheelCollider, axel.RWheelCollider.attachedRigidbody.angularVelocity);
        }

        startBehavior = input;

        rb.isKinematic = false;
    }
Exemplo n.º 12
0
 /// <summary>
 /// Handle throttle quirky operation...
 /// </summary>
 static void HandleThrottle(Vessel vessel, ControlInputs inputs)
 {
     if (!inputs.ThrottleUpdated)
     {
         return;
     }
     if (FlightGlobals.ActiveVessel != vessel)
     {
         return;
     }
     if (RemoteTech.IsAvailable && !(RemoteTech.HasLocalControl(vessel.id) || RemoteTech.HasAnyConnection(vessel.id)))
     {
         return;
     }
     FlightInputHandler.state.mainThrottle = inputs.Throttle;
     inputs.Throttle        = 0f;
     inputs.ThrottleUpdated = false;
 }
 private void StartSimHandler(ControlInputs inputs)
 {
     startCurvePos = cursor.Distance;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Handle throttle quirky operation...
 /// </summary>
 static void HandleThrottle(Vessel vessel, ControlInputs inputs)
 {
     if (!inputs.ThrottleUpdated)
         return;
     if (FlightGlobals.ActiveVessel != vessel)
         return;
     if (RemoteTech.IsAvailable && !(RemoteTech.HasLocalControl (vessel.id) || RemoteTech.HasAnyConnection (vessel.id)))
         return;
     FlightInputHandler.state.mainThrottle = inputs.Throttle;
     inputs.Throttle = 0f;
     inputs.ThrottleUpdated = false;
 }
Exemplo n.º 15
0
 internal static ControlInputs Set(Vessel vessel)
 {
     manualInputClients.Add (KRPC.KRPCServer.Context.RPCClient);
     if (!manualInputs.ContainsKey (vessel))
         manualInputs [vessel] = new ControlInputs ();
     return manualInputs [vessel];
 }
Exemplo n.º 16
0
        static void OnFlyByWire(Vessel vessel, FlightCtrlState state)
        {
            var inputs = new ControlInputs (state);

            // Manual inputs
            if (!manualInputs.ContainsKey (vessel))
                manualInputs [vessel] = new ControlInputs ();
            HandleThrottle (vessel, manualInputs [vessel]);
            inputs.Add (manualInputs [vessel]);

            // Auto-pilot inputs
            if (!autoPilotInputs.ContainsKey (vessel))
                autoPilotInputs [vessel] = new ControlInputs ();
            if (Services.AutoPilot.Fly (vessel, autoPilotInputs [vessel]))
                inputs.Add (autoPilotInputs [vessel]);

            // Update current inputs
            if (!currentInputs.ContainsKey (vessel))
                currentInputs [vessel] = new ControlInputs ();
            currentInputs [vessel].CopyFrom (inputs);
        }
Exemplo n.º 17
0
 public void Add(ControlInputs other)
 {
     if (other.ThrottleUpdated)
         state.mainThrottle = other.state.mainThrottle;
     ThrottleUpdated |= other.ThrottleUpdated;
     state.pitch += other.state.pitch;
     state.yaw += other.state.yaw;
     state.roll += other.state.roll;
     state.X += other.state.X;
     state.Y += other.state.Y;
     state.Z += other.state.Z;
     state.wheelThrottle += other.state.wheelThrottle;
     state.wheelSteer += other.state.wheelSteer;
 }
Exemplo n.º 18
0
 public void CopyFrom(ControlInputs other)
 {
     state.CopyFrom (other.state);
     ThrottleUpdated = other.ThrottleUpdated;
 }
Exemplo n.º 19
0
 static void AddClient(IClient client)
 {
     if (!controlInputs.ContainsKey (client))
         controlInputs [client] = new ControlInputs ();
 }
Exemplo n.º 20
0
 internal static ControlInputs Get(Vessel vessel)
 {
     if (!currentInputs.ContainsKey (vessel))
         currentInputs [vessel] = new ControlInputs ();
     return currentInputs [vessel];
 }
 public void StartCars(ControlInputs input)
 {
     StartSim?.Invoke(input);
 }
 public void StartSimHandler(ControlInputs inputs)
 {
     GetComponent <Collider>().enabled = false;
 }