public static bool Prefix(ThrusterModel __instance, ref GamePad __result, int padIndex, string name) { GamePad result = null; if (name != null) { if (name == "Controller (Xbox One For Windows)" || name == "Xbox One Wireless Controller" || name == "Bluetooth XINPUT compatible input device") { result = new GamePad_PC_XB1(padIndex, GamePad.PadType.XB1); } else if (name.ToUpper().Contains("XBOX") || name.ToUpper().Contains("XINPUT")) { result = new GamePad_PC_XB1(padIndex, GamePad.PadType.X360); } } if (result != null) { ModConsole.Instance.WriteLine($"patched controller type: #{padIndex} \"{name}\"; resulting type = {result.GetPadType()}"); __result = result; return(false); } else { ModConsole.Instance.WriteLine($"normal controller type: #{padIndex} \"{name}\""); return(true); } }
public static void Postfix(ThrusterModel __instance) { if (SmoothThrust.container.ContainsKey(__instance)) { SmoothThrust.container.Remove(__instance); } }
public void TestThrusterMinStrength() { ThrusterModel t = new ThrusterModel(); t.setStrength(0); Assert.AreEqual(10, t.GetForce()); }
public void TestThrusterOn() { ThrusterModel t = new ThrusterModel(); t.setOn(true); Assert.IsTrue(t.isOn()); }
public void TestThrusterMinPower() { ThrusterModel t = new ThrusterModel(); t.setPower(-500); Assert.AreEqual(0, t.GetPower()); }
public void TestThrusterTestForce() { ThrusterModel t = new ThrusterModel(); t.setStrength(20); t.setPower(50f); Assert.AreEqual(1000, t.GetForce()); }
void Start() { //Create new ThrusterModel object if (truster == null) { truster = new ThrusterModel(); } //Get the Rigidbody of the shipobject(Parent object) rbody = GetComponentInParent <Rigidbody> (); }
public static void Prefix(ThrusterModel __instance, ref Vector3 ____translationalInput) { if (!SmoothThrust.container.ContainsKey(__instance)) { SmoothThrust.container.Add(__instance, new SmoothThrust.SmoothCont()); } SmoothThrust.SmoothCont iter = SmoothThrust.container[__instance]; if (OWInput.IsNewlyPressed(InputLibrary.interact)) { iter._prevTranslation = ____translationalInput; iter._buildupVelocity = Vector3.zero; } if (OWInput.IsPressed(InputLibrary.interact, 0.05f)) { iter._prevTranslation.x = Mathf.SmoothDamp(iter._prevTranslation.x, ____translationalInput.x, ref iter._buildupVelocity.x, SmoothThrust._analogSmoothTime); iter._prevTranslation.z = Mathf.SmoothDamp(iter._prevTranslation.z, ____translationalInput.z, ref iter._buildupVelocity.z, SmoothThrust._analogSmoothTime); iter._prevTranslation.y = Mathf.SmoothDamp(iter._prevTranslation.y, ____translationalInput.y, ref iter._buildupVelocity.y, SmoothThrust._analogSmoothTime); ____translationalInput = iter._prevTranslation; } if (SmoothThrust.anglerSafety && (SmoothThrust.ShipNMBody != null || SmoothThrust.PlayerNMBody != null)) { Vector3 myPos; if (__instance is ShipThrusterModel) { myPos = SmoothThrust.ShipNMBody.GetCenterOfMass(); } else { myPos = SmoothThrust.PlayerNMBody.GetCenterOfMass(); } float mindist = Mathf.Infinity; bool triggered = false; foreach (AnglerfishController fish in SmoothThrust.fishes) { if (fish.gameObject.activeSelf) { if (fish.GetAnglerState() == AnglerfishController.AnglerState.Chasing) { triggered = true; } float dist = Vector3.Distance(myPos, fish.transform.position); mindist = Mathf.Min(dist, mindist); } } if (triggered) { mindist = Mathf.Infinity; } SmoothThrust.limiter = Mathf.Infinity; if (__instance is ShipThrusterModel) { if (mindist <= 400.1f) { if (____translationalInput.magnitude * __instance.GetMaxTranslationalThrust() >= mindist / 20f) { ____translationalInput = ____translationalInput.normalized * (mindist / 21f) / __instance.GetMaxTranslationalThrust(); } } } else { if (mindist <= 210f) { if (____translationalInput.magnitude * 100f * __instance.GetMaxTranslationalThrust() >= mindist * 3f) { ____translationalInput = ____translationalInput.normalized * (mindist / 35f) / __instance.GetMaxTranslationalThrust(); } } } } iter._prevTranslation = ____translationalInput; SmoothThrust.container[__instance] = iter; }
public void Init(ThrusterModel model) => _thrusterModel = model;
public void TestThrusterOff() { ThrusterModel t = new ThrusterModel(); Assert.IsFalse(t.isOn()); }