public void CopyFrom(ControlInputs other) { state.CopyFrom(other.state); ThrottleUpdated = other.ThrottleUpdated; WheelThrottleUpdated = other.WheelThrottleUpdated; WheelSteerUpdated = other.WheelSteerUpdated; }
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); }
internal static ControlInputs Get(Vessel vessel) { if (!currentInputs.ContainsKey(vessel)) { currentInputs [vessel] = new ControlInputs(); } return(currentInputs [vessel]); }
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]; }
public void StartSimHandler(ControlInputs newBehavior) { carController.input = newBehavior; //set current states //position //rotation //wheel speed //velocity }
internal static ControlInputs Set(Vessel vessel) { manualInputClients.Add(CallContext.Client); if (!manualInputs.ContainsKey(vessel)) { manualInputs [vessel] = new ControlInputs(); } return(manualInputs [vessel]); }
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; } }
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; } }
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); }
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; }
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; }
/// <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; }
/// <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; }
internal static ControlInputs Set(Vessel vessel) { manualInputClients.Add (KRPC.KRPCServer.Context.RPCClient); if (!manualInputs.ContainsKey (vessel)) manualInputs [vessel] = new ControlInputs (); return manualInputs [vessel]; }
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); }
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; }
public void CopyFrom(ControlInputs other) { state.CopyFrom (other.state); ThrottleUpdated = other.ThrottleUpdated; }
static void AddClient(IClient client) { if (!controlInputs.ContainsKey (client)) controlInputs [client] = new ControlInputs (); }
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; }