public static void Lock(CPU cpu) { LockedCpu = cpu; CameraManager.Instance.enabled = false; InputLockManager.SetControlLock(ControlTypes.All, "kOSInputManager"); }
public override void AddTo(BindingManager manager) { cpu = manager.cpu; vessel = manager.cpu.Vessel; controls.Add(new LockableControl("THROTTLE", "throttle", cpu, manager)); controls.Add(new LockableControl("STEERING", "steering", cpu, manager)); controls.Add(new LockableControl("WHEELSTEERING", "wheelsteering", cpu, manager)); controls.Add(new LockableControl("WHEELTHROTTLE", "wheelthrottle", cpu, manager)); manager.AddGetter("SAS", delegate(CPU c) { return vessel.Autopilot.Mode.ToString(); }); manager.AddSetter("SAS", delegate(CPU c, object val) { if (val is bool) cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)val); else { try { Type t = typeof(VesselAutopilot.AutopilotMode); vessel.Autopilot.SetMode((VesselAutopilot.AutopilotMode)Enum.Parse(t, val.ToString(), true)); cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)true); } catch { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)false); } } }); vessel.OnFlyByWire += OnFlyByWire; }
public TerminalButton(CPU cpu, int number) { this.cpu = cpu; this.ButtonNumber = number; AddSuffix("LIGHT", (object val) => { LightState = (bool)val; }, () => { return LightState; }); AddSuffix("ACTIVE", (object val) => { ClickState = (bool)val; }, () => { return ClickState; }); }
private static float getLongitude(CPU cpu) { float retVal = (float)cpu.Vessel.longitude; while (retVal > 180) retVal -= 360; while (retVal < -180) retVal += 360; return retVal; }
private static float getLattitude(CPU cpu) { float retVal = (float)cpu.Vessel.latitude; if (retVal > 90) return 90; if (retVal < -90) return -90; return retVal; }
public void initCpu() { if (cpu == null) { cpu = new CPU(this, "ksp"); cpu.AttachHardDisk(hardDisk); cpu.Boot(); } }
public override void AddTo(BindingManager manager) { cpu = manager.cpu; vessel = manager.cpu.Vessel; controls.Add(new LockableControl("THROTTLE", "throttle", cpu, manager)); controls.Add(new LockableControl("STEERING", "steering", cpu, manager)); controls.Add(new LockableControl("WHEELSTEERING", "wheelsteering", cpu, manager)); controls.Add(new LockableControl("WHEELTHROTTLE", "wheelthrottle", cpu, manager)); vessel.OnFlyByWire += OnFlyByWire; }
public override void AddTo(BindingManager manager) { cpu = manager.cpu; vessel = manager.cpu.Vessel; controls.Add(new LockableControl("THROTTLE", "throttle", cpu, manager)); controls.Add(new LockableControl("STEERING", "steering", cpu, manager)); controls.Add(new LockableControl("WHEELSTEERING", "wheelsteering", cpu, manager)); controls.Add(new LockableControl("WHEELTHROTTLE", "wheelthrottle", cpu, manager)); if (RTHook.Instance == null || !RTHook.Instance.HasFlightComputer(vessel.id)) { vessel.OnFlyByWire += OnFlyByWire; } }
public void Start() { var prop = internalProp; Cpu = part.GetComponent<kOSProcessor>().cpu; var size = 0.1f; var m = new Mesh(); m.name = "Scripted_Plane_New_Mesh"; m.vertices = new Vector3[] { new Vector3(size, -size, 0.01f), new Vector3(size, size, 0.01f), new Vector3(-size, size, 0.01f), new Vector3(-size, -size, 0.01f) }; m.uv = new Vector2[] { new Vector2(0, 0.4f), new Vector2(0, 1), new Vector2(0.79f, 1), new Vector2(0.79f, 0.4f) }; m.triangles = new int[] { 0, 1, 2, 0, 2, 3 }; m.RecalculateNormals(); MeshFilter mf = prop.FindModelComponents<MeshFilter>()[0]; prop.FindModelComponents<MeshFilter>()[1].mesh = null; mf.mesh = m; screenGo = mf.gameObject; BoxCollider b = screenGo.GetComponent<BoxCollider>() ?? screenGo.AddComponent<BoxCollider>(); ClickHandler handler = screenGo.GetComponent<ClickHandler>() ?? screenGo.AddComponent<ClickHandler>(); handler.OnClick = OnMouseDown; foreach (MeshRenderer renderer in prop.FindModelComponents<MeshRenderer>()) { Material mat = new Material(Shader.Find(" Diffuse")); mat.SetTexture("_MainTex", InternalDisplayTexture); mat.SetTextureScale("_MainTex", new Vector2(1, 1)); renderer.material = mat; } foreach (PartModule module in part.Modules) { if (module is kOSProcessor) { var k = (kOSProcessor)module; k.InternalDisplayTexture = InternalDisplayTexture; } } }
public BindingManager(CPU cpu, String context) { this.cpu = cpu; var contexts = new string[1]; contexts[0] = context; foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { kOSBinding attr = (kOSBinding)t.GetCustomAttributes(typeof(kOSBinding), true).FirstOrDefault(); if (attr != null) { if (attr.Contexts.Count() == 0 || attr.Contexts.Intersect(contexts).Any()) { Binding b = (Binding)Activator.CreateInstance(t); b.AddTo(this); Bindings.Add(b); } } } }
public LockableControl(String name, String propertyName, CPU cpu, BindingManager manager) { Name = name; Cpu = cpu; Vessel = cpu.Vessel; Locked = false; Value = 0; manager.AddGetter(name, c => Value); manager.AddSetter(name, delegate { }); this.propertyName = propertyName; }
public override void Execute(CPU cpu) { cpu.EndWait(); }
internal static void ToggleWindow(CPU cpu) { Fetch.Window.AttachTo(cpu); Fetch.Window.Toggle(); }
public LockableControl(String name, String propertyName, CPU cpu, BindingManager manager) { this.name = name; this.cpu = cpu; this.vessel = cpu.Vessel; locked = false; Value = 0; manager.AddGetter(name, delegate(CPU c) { return Value; }); manager.AddSetter(name, delegate(CPU c, object val) { }); this.propertyName = propertyName; }
public static void CloseWindow(CPU cpu) { Fetch.Window.AttachTo(cpu); Fetch.Window.Close(); }
public static void OpenWindow(CPU cpu) { Fetch.Window.AttachTo(cpu); Fetch.Window.Open(); }
internal void AttachTo(CPU cpu) { this.Cpu = cpu; }
public override void OnStart(PartModule.StartState state) { //Do not start from editor and at KSP first loading if (state == StartState.Editor || state == StartState.None) { return; } cpu = new CPU(this, "ksp"); if (hardDisk == null) hardDisk = new Harddisk(MemSize); cpu.AttachHardDisk(hardDisk); cpu.Boot(); }
public override void Execute(CPU cpu) { int functionPointer = (int)cpu.PopValue(); cpu.RemoveTrigger(functionPointer); }
public virtual void Execute(CPU cpu) { }
public SpecialValueTester(CPU cpu) { this.cpu = cpu; }
public override void Execute(CPU cpu) { DeltaInstructionPointer = distance; }
public override void Execute(CPU cpu) { cpu.PushStack(argument); }