/// <summary> /// Write error log message. /// </summary> /// <param name="message">Message to write.</param> public static void Error(string message) { _logFile?.WriteLine($"Error: {message}"); ModConsole.Error(message); }
public override void Run(string[] args) { // Make sure the command is executed with arguments. if (args.Length < 1) { ModConsole.Error("Incorrect number of arguments. See 'gps help' for details."); return; } // Print the help text if (Array.Exists(args, e => e.ToLowerInvariant() == "help" || e == "-?")) { ModConsole.Print(_helpString); return; } // When starting or restarting, try to find -p and try to validate the following argument as a port number if (Array.Exists(args, e => e.ToLowerInvariant() == "start" || e.ToLowerInvariant() == "restart")) { int p; if ((p = Array.IndexOf(args, "-p")) >= 0 || (p = Array.IndexOf(args, "--port")) >= 0) { if (args.Length >= p + 1 && int.TryParse(args[p + 1], out int portNumber) && portNumber <= 65535 && portNumber >= 1) { _mod._port = portNumber; } else { ModConsole.Print(_helpString); } } } // Restart if (Array.Exists(args, e => e.ToLowerInvariant() == "restart")) { _mod.StopServer(); _mod.StartServer(); return; } // Start if (Array.Exists(args, e => e.ToLowerInvariant() == "start")) { _mod.StartServer(); return; } // Stop if (Array.Exists(args, e => e.ToLowerInvariant() == "stop")) { _mod.StopServer(); return; } // Write to file if (Array.Exists(args, e => e.ToLowerInvariant() == "write")) { if (Array.Exists(args, e => e.ToLowerInvariant() == "json")) { using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.json"))) { writer.Write(_mod.GetJsonContent()); } } else if (Array.Exists(args, e => e.ToLowerInvariant() == "xml")) { using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.xml"))) { writer.Write(_mod.GetXmlContent()); } } else { using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.json"))) { writer.Write(_mod.GetJsonContent()); } using (StreamWriter writer = new StreamWriter(Path.Combine(ModLoader.GetModConfigFolder(_mod), "out.xml"))) { writer.Write(_mod.GetXmlContent()); } } ModConsole.Print("Completed writing - check the mod's config folder."); return; } // If this point is reached, there were no valid commands to execute. ModConsole.Error("Invalid arguments. See 'gps help' for details."); }
public override void OnLoad() { if (ModLoader.MSCLoader_Ver.ToString() != minMSCLoaderVersion) { versionOK = false; } else { versionOK = true; } if (versionOK) { ModConsole.Print("Passed MSCLoader version check. Setting up..."); try { _satsuma = GameObject.Find("SATSUMA(557kg, 248)"); player = GameObject.Find("PLAYER"); AssetBundle ab; try { ab = LoadAssets.LoadBundle(this, "satsumamaster.unity3d"); } catch (Exception) { ModConsole.Error("You have not installed this mod correctly. Please copy all files from the downloaded archive. Missing Assets/Satsuma Master/satsumamaster.unity3d file."); return; } uiHandler = new UIHandler(this, ab); SetupGradient(); uiHandler.ToggleStats(); uiHandler.ToggleXFSPanel(); uiHandler.ToggleTPPanel(); uiHandler.ShowUI(); soundControllerMod = new SoundController(this, ab); ab.Unload(false); wheelSuspensionMod = new SuspensionWheelController(this); teleportMod = new Teleport(player, _satsuma); sixGearsMod = new SixGears(this); engineFixerMod = new EngineFixer(this); if (_satsuma != null) { _satsumaDriveTrain = _satsuma.GetComponent <Drivetrain>(); if (_satsumaDriveTrain != null) { defaultRPM = _satsumaDriveTrain.maxRPM; defaultShiftUpRPM = _satsumaDriveTrain.shiftUpRPM; defaultShiftDownRPM = _satsumaDriveTrain.shiftDownRPM; sixGearsMod.oldRatio = _satsumaDriveTrain.gearRatios; enableBoost = true; engineFixerMod.OptimizeEngineFixer(); } } ModConsole.Print(Name + ": Success!"); setupOK = true; Keybind.Add(this, ShowUIBind); } catch (Exception e) { ModConsole.Error("Asset load and setup failed. Message: " + e); return; } } else { ModConsole.Error("Wrong version of MSCLoader detected. MSCLoader 1.1.4 is supported. If MSCLoader has been updated, contact the mod author."); } }
/// <summary> /// Initialize class /// </summary> public Satsuma(string gameObject) : base(gameObject) { instance = this; SatsumaScript = this; whiteList = Properties.Resources.whitelist_satsuma.Replace("\n", "").Split(','); disableableObjects = GetDisableableChilds(); Toggle = ToggleActive; // Get engine bay renderers engineBayRenderers = new List <Renderer>(); Transform block = this.gameObject.transform.Find("Chassis/sub frame(xxxxx)/CarMotorPivot"); engineBayRenderers = block.GetComponentsInChildren <Renderer>(true).ToList(); pivotHood = this.gameObject.transform.Find("Body/pivot_hood"); // Get all the other renderers renderers = new List <Renderer>(); if (Rules.instance.IgnoreRules.Count > 0) { renderers = this.gameObject.transform.GetComponentsInChildren <Renderer>(true) .Where(t => !t.gameObject.name.ContainsAny("Sphere", "Capsule", "Cube", "Mokia") && Rules.instance.IgnoreRules.Find(g => g.ObjectName == t.gameObject.name) == null).ToList(); } else { renderers = this.gameObject.transform.GetComponentsInChildren <Renderer>(true) .Where(t => !t.gameObject.name.ContainsAny("Sphere", "Capsule", "Cube", "Mokia")).ToList(); } // Ignore Rule IgnoreRule vehicleRule = Rules.instance.IgnoreRules.Find(v => v.ObjectName == this.gameObject.name); if (vehicleRule != null) { Toggle = IgnoreToggle; if (vehicleRule.TotalIgnore) { IsActive = false; } } lastGoodRotation = transform.localRotation; lastGoodPosition = transform.localPosition; // Adding components to normal and bucket seats. GameObject.Find("seat driver(Clone)").AddComponent <SatsumaSeatsManager>(); GameObject.Find("seat passenger(Clone)").AddComponent <SatsumaSeatsManager>(); GameObject bucketDriver = GameObject.Find("bucket seat driver(Clone)"); GameObject bucketPassanger = GameObject.Find("bucket seat passenger(Clone)"); if (bucketDriver == null) { bucketDriver = Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "bucket seat driver(Clone)" && g.transform.parent.gameObject.name == "Parts"); bucketPassanger = Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "bucket seat passenger(Clone)" && g.transform.parent.gameObject.name == "Parts"); } bucketDriver.AddComponent <SatsumaSeatsManager>(); bucketPassanger.AddComponent <SatsumaSeatsManager>(); // Fix for mechanical wear of the car. PlayMakerFSM mechanicalWearFsm = transform.Find("CarSimulation/MechanicalWear").gameObject.GetComponent <PlayMakerFSM>(); FsmState loadGame = mechanicalWearFsm.FindFsmState("Load game"); List <FsmStateAction> loadArrayActions = new List <FsmStateAction> { new CustomNullState() }; loadGame.Actions = loadArrayActions.ToArray(); loadGame.SaveActions(); // Fix for not working handbrake after respawn. GameObject.Find("HandBrake").GetComponent <PlayMakerFSM>().enabled = true; // Fixes handbrake lever position. transform.Find("MiscParts/HandBrake/handbrake(xxxxx)/handbrake lever").gameObject.GetPlayMakerByName("Use").Fsm.RestartOnEnable = false; // Battery terminal. // For some reason in the vanilla game, the negative battery terminal sometimes gets disabled, and the game doesn't allow to reenable it. FsmState wiringBatteryDisable = transform.Find("Wiring").gameObject.GetPlayMakerByName("Status").FindFsmState("Disable battery wires"); List <FsmStateAction> disableBatteryActions = new List <FsmStateAction>(); disableBatteryActions.Add(new CustomBatteryDisable()); wiringBatteryDisable.Actions = disableBatteryActions.ToArray(); // Get all bolts. satsumaBoltsAntiReloads = new List <SatsumaBoltsAntiReload>(); GameObject[] bolts = Resources.FindObjectsOfTypeAll <GameObject>().Where(obj => obj.name == "BoltPM").ToArray(); foreach (GameObject bolt in bolts) { Transform parent = bolt.transform.parent; // Elements with that name have their BoltCheck parents as a grandparent (water_pump and Hooks are exception) if (parent.name.EqualsAny("Bolts", "_Motor", "water_pump_pulley_mesh", "Hooks", "hooks")) { // Great-great grandparents for these ones. if (parent.parent.gameObject.name.EqualsAny("water_pump_pulley_mesh", "Hooks", "hooks")) { parent = parent.parent.parent; } else { parent = parent.parent; } } // Great-great grandparents for these too... else if (parent.name.ContainsAny("Masked", "ValveAdjust")) { parent = parent.parent.parent; } // Sibling of bolt if the parent is IK_wishbone. else if (parent.name.StartsWith("IK_wishbone_")) { string suffix = parent.gameObject.name.Replace("IK_wishbone_", ""); parent = parent.Find($"wishbone {suffix}(xxxxx)"); } // Skip those if the assigned parent is one of these. if (parent.name.ContainsAny("bolts_shock", "shock_bottom", "halfshaft_", "pivot_steering_arm_", "OFFSET", "pivot_shock_")) { continue; } // Skip if the parent is Pivot and the grandparent name starts with "alternator". if (parent.name == "Pivot" && parent.parent.gameObject.name.StartsWith("alternator")) { continue; } if (parent.gameObject.name == "hood(Clone)") { continue; } if (parent.gameObject.GetComponent <SatsumaBoltsAntiReload>() == null) { SatsumaBoltsAntiReload s = parent.gameObject.AddComponent <SatsumaBoltsAntiReload>(); satsumaBoltsAntiReloads.Add(s); } } // Halfshafts hook. GameObject[] halfshafts = Resources.FindObjectsOfTypeAll <GameObject>().Where(g => g.name == "halfshaft(xxxxx)").ToArray(); foreach (GameObject halfshaft in halfshafts) { if (halfshaft.GetComponent <SatsumaBoltsAntiReload>() == null) { satsumaBoltsAntiReloads.Add(halfshaft.AddComponent <SatsumaBoltsAntiReload>()); } } // Engine Block. satsumaBoltsAntiReloads.Add(GameObject.Find("block(Clone)").AddComponent <SatsumaBoltsAntiReload>()); // Steering rods. satsumaBoltsAntiReloads.Add(transform.Find("Chassis/steering rod fr(xxxxx)").gameObject.AddComponent <SatsumaBoltsAntiReload>()); satsumaBoltsAntiReloads.Add(transform.Find("Chassis/steering rod fl(xxxxx)").gameObject.AddComponent <SatsumaBoltsAntiReload>()); // Destroy all bolt anti reloads. ModConsole.Print($"[MOP] Found {satsumaBoltsAntiReloads.Count} bolts."); // If there's less bolts found than the value, warn user. if (satsumaBoltsAntiReloads.Count < MinimumBolts) { ModConsole.Error($"[MOP] Only {satsumaBoltsAntiReloads.Count}/{MinimumBolts} have been reset!"); } // Fixes car body color resetting to default. PlayMakerFSM carBodyPaintFsm = transform.Find("Body/car body(xxxxx)").gameObject.GetPlayMakerByName("Paint"); FsmState carBodyLoadState = carBodyPaintFsm.FindFsmState("Load"); carBodyLoadState.Actions = new FsmStateAction[] { new CustomNullState() }; carBodyLoadState.SaveActions(); // Wiping Load for alternator belts, oil filters, spark plugs and batteries. GameObject[] parts = Resources.FindObjectsOfTypeAll <GameObject>() .Where(obj => obj.name.ContainsAny("alternator belt(Clone)", "oil filter(Clone)", "spark plug(Clone)", "battery(Clone)")) .ToArray(); foreach (GameObject part in parts) { if (part.transform.root.gameObject.name == "GAZ24(1420kg)") { continue; } PlayMakerFSM useFsm = part.GetPlayMakerByName("Use"); FsmState state1 = useFsm.FindFsmState("State 1"); List <FsmStateAction> emptyState1 = state1.Actions.ToList(); emptyState1.Insert(0, new CustomStopAction()); state1.Actions = emptyState1.ToArray(); state1.SaveActions(); FsmState loadState = useFsm.FindFsmState("Load"); List <FsmStateAction> emptyActions = loadState.Actions.ToList(); emptyActions.Insert(0, new CustomStopAction()); loadState.Actions = emptyActions.ToArray(); loadState.SaveActions(); if (part.name.Contains("_INVENTORY")) { continue; } // Fix for a bug that prevents player detaching the some of the parts. if (part.name == "spark plug(Clone)") { // Spark plugs save their shit differently (because f**k you)... for (int i = 1; i <= 4; i++) { FsmState installState = useFsm.FindFsmState(i.ToString()); FsmStateAction[] installActions = installState.Actions; installActions[1] = new CustomNullState(); installState.Actions = installActions; installState.SaveActions(); } } else { FsmState installState = useFsm.FindFsmState("Install"); FsmStateAction[] installActions = installState.Actions; installActions[2] = new CustomNullState(); installState.Actions = installActions; installState.SaveActions(); } } // Fix for cd player disabling other vehicles radio. Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "cd player(Clone)") .transform.Find("ButtonsCD/RadioVolume").gameObject.GetPlayMakerByName("Knob").Fsm.RestartOnEnable = false; GameObject.Find("radio(Clone)").transform.Find("ButtonsRadio/RadioVolume").gameObject.GetPlayMakerByName("Knob").Fsm.RestartOnEnable = false; // Fix for window grille paint resetting to the default. Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "window grille(Clone)" && g.GetPlayMakerByName("Paint") != null) .GetPlayMakerByName("Paint").Fsm.RestartOnEnable = false; // Apply hood fix. GameFixes.Instance.HoodFix(transform.Find("Body/pivot_hood"), transform.Find("MiscParts/trigger_battery"), transform.Find("MiscParts/pivot_battery")); // Rear bumper detachng fix. rearBumper = GameObject.Find("bumper rear(Clone)"); if (rearBumper.transform.parent == null) { GameObject databaseBumper = GameObject.Find("Database/DatabaseBody/Bumper_Rear"); databaseBumper.SetActive(false); databaseBumper.SetActive(true); if (databaseBumper.GetComponent <PlayMakerFSM>().FsmVariables.GetFsmBool("Bolted").Value) { GameObject triggerBumper = transform.Find("Body/trigger_bumper_rear").gameObject; GameObject bumper = GameObject.Find("bumper rear(Clone)"); GameFixes.Instance.RearBumperFix(triggerBumper, bumper); } } // Fix suspension adding a weight to the car on each car respawn. GameObject[] suspensionParts = Resources.FindObjectsOfTypeAll <GameObject>() .Where(g => g.name.ContainsAny("strut", "coil spring", "shock absorber") && g.transform.root != null && g.transform.root == this.gameObject.transform) .ToArray(); foreach (GameObject part in suspensionParts) { part.AddComponent <SatsumaPartMassManager>(); } // Appparently not only suspension f***s over the Satsuma... GameObject[] others = Resources.FindObjectsOfTypeAll <GameObject>() .Where(g => g.name.EqualsAny("grille gt(Clone)", "grille(Clone)", "subwoofer panel(Clone)", "seat rear(Clone)", "amplifier(Clone)", "rearlight(leftx)", "rearlight(right)", "racing radiator(xxxxx)", "radiator(xxxxx)", "radiator hose1(xxxxx)", "radiator hose3(xxxxx)", "marker light left(xxxxx)", "marker light right(xxxxx)", "antenna(leftx)", "antenna(right)", "dashboard(Clone)")).ToArray(); foreach (GameObject other in others) { other.AddComponent <SatsumaPartMassManager>(); } if (Rules.instance.SpecialRules.ExperimentalSatsumaTrunk) { // Create trunk trigger. Trunks = new List <SatsumaTrunk>(); // Boot GameObject trunkTrigger = new GameObject("MOP_Trunk"); SatsumaTrunk trunk = trunkTrigger.AddComponent <SatsumaTrunk>(); trunk.Initialize(new Vector3(0, 0.15f, -1.37f), new Vector3(1.25f, 0.4f, 0.75f), GameObject.Find("bootlid(Clone)").transform.Find("Handles").gameObject); Trunks.Add(trunk); // Glovebox GameObject gloveboxTrigger = new GameObject("MOP_Glovebox"); SatsumaTrunk glovebox = gloveboxTrigger.AddComponent <SatsumaTrunk>(); glovebox.Initialize(new Vector3(0.32f, 0.3f, 0.6f), new Vector3(0.3f, 0.12f, 0.1f), GameObject.Find("dashboard(Clone)").transform.Find("glovbox").gameObject); Trunks.Add(glovebox); foreach (var storage in Trunks) { storage.Initialize(); } } key = transform.Find("Dashboard/Steering/steering_column2/Ignition/Keys/Key").gameObject; // Fix for reg plates Z fighting. try { GameObject.Find("bootlid(Clone)").transform.Find("RegPlateRear").gameObject.GetComponent <Renderer>().material.renderQueue = 100; GameObject.Find("bumper front(Clone)").transform.Find("RegPlateFront").gameObject.GetComponent <Renderer>().material.renderQueue = 100; // Z-fighting of the Satsuma dashboard meters. if (!Rules.instance.SpecialRules.SatsumaIgnoreRenderers) { dashboardMaterials = new List <Material>(); dashboardMaterials.Add(GameObject.Find("dashboard meters(Clone)").transform.Find("Gauges/Fuel/needle_small").gameObject.GetComponent <Renderer>().material); dashboardMaterials.Add(GameObject.Find("dashboard meters(Clone)").transform.Find("Gauges/Temp/needle_small").gameObject.GetComponent <Renderer>().material); dashboardMaterials.Add(GameObject.Find("dashboard meters(Clone)").transform.Find("Gauges/Speedometer/needle_large").gameObject.GetComponent <Renderer>().material); dashboardMaterials.Add(GameObject.Find("rpm gauge(Clone)").transform.Find("Pivot/needle").gameObject.GetComponent <Renderer>().material); dashboardMaterials.Add(GameObject.Find("clock gauge(Clone)").transform.Find("ClockCar/hour/needle_hour").gameObject.GetComponent <Renderer>().material); dashboardMaterials.Add(GameObject.Find("clock gauge(Clone)").transform.Find("ClockCar/minute/needle_minute").gameObject.GetComponent <Renderer>().material); foreach (Material mat in dashboardMaterials) { mat.renderQueue = 100; } lightSelection = GameObject.Find("LightModes").GetComponent <PlayMakerFSM>().FsmVariables.GetFsmInt("Selection"); } } catch { } // Setup stuff that gets disabled using ToggleElements onEngineOffToggle = new List <GameObject>(); onCloseToggle = new List <GameObject>(); onFarToggle = new List <GameObject>(); onEngineOffToggle.Add(transform.Find("CarSimulation/MechanicalWear").gameObject); onEngineOffToggle.Add(transform.Find("CarSimulation/Fixes").gameObject); onEngineOffToggle.Add(transform.Find("CarSimulation/DynoDistance").gameObject); onEngineOffToggle.Add(transform.Find("CarSimulation/RandomBolt").gameObject); onCloseToggle.Add(transform.Find("RainScript").gameObject); onCloseToggle.Add(transform.Find("DriverHeadPivot").gameObject); onCloseToggle.Add(transform.Find("AirIntake").gameObject); onFarToggle.Add(transform.Find("Chassis").gameObject); onCloseTogglePlayMaker = new List <PlayMakerFSM>(); onCloseTogglePlayMaker.Add(this.gameObject.GetPlayMakerByName("ButtonShifter")); // Replace on assemble sound playing with custom script. PlayMakerFSM blockBoltCheck = GameObject.Find("block(Clone)").GetPlayMakerByName("BoltCheck"); FsmState boltsONState = blockBoltCheck.FindFsmState("Bolts ON"); FsmStateAction[] boltsONActions = boltsONState.Actions; boltsONActions[1] = new MasterAudioAssembleCustom(); boltsONState.Actions = boltsONActions; boltsONState.SaveActions(); // Disable the "Fix Collider" state in FSM Setup, so it won't make items fall through the car. this.gameObject.GetPlayMakerByName("Setup").Fsm.RestartOnEnable = false; MeshCollider bootFloor = transform.Find("Colliders/collider_floor3").gameObject.GetComponent <MeshCollider>(); bootFloor.isTrigger = false; bootFloor.enabled = true; maskedElements = new Dictionary <GameObject, bool>(); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedClutchCover"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedBearing2"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedBearing3"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedFlywheel"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedFlywheelRacing"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedPiston2"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedPiston3"), key.activeSelf); maskedElements.Add(Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "MaskedPiston4"), key.activeSelf); if (MopSettings.GenerateToggledItemsListDebug) { if (System.IO.File.Exists("sats.txt")) { System.IO.File.Delete("sats.txt"); } string vehiclez = ""; foreach (var w in disableableObjects) { vehiclez += w.gameObject.name + ", "; } System.IO.File.WriteAllText("sats.txt", vehiclez); System.Diagnostics.Process.Start("sats.txt"); } }
private void Update() { UpdateWhellsRotation(); if (Input.GetMouseButtonDown(0) && m_isCaught && Joint != null && !m_isConnect) { Support.localScale = new Vector3(1f, 1f, 1f); Destroy(Joint); m_isCaught = false; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit raycastHit; if (Physics.Raycast(ray, out raycastHit)) { if (raycastHit.collider.name == "ConnectTrigger") { //ModConsole.Print(m_connectColision + " - " + m_connectColisionV); if (m_connectColision || m_connectColisionV) { // ModConsole.Print("m_connectColision"); PlayMakerGlobals.Instance.Variables.FindFsmBool("GUIuse").Value = true; PlayMakerGlobals.Instance.Variables.FindFsmString("GUIinteraction").Value = this.m_isConnect ? "Disconnect" : "Connect"; if (cInput.GetButtonDown("Use")) { //ModConsole.Print("Use Comand " + m_isConnect); if (!m_isConnect) { //ModConsole.Print("Conneting"); try { if (Joint != null) { Destroy(Joint); } Joint = base.gameObject.AddComponent <HingeJoint>(); //ModConsole.Print("ridgbody localizado"); if (m_connectColisionV && HitchV != null) { //ModConsole.Print("HiutchV localizado"); CreateJoint(new Vector3(0f, 0f, 0f), HitchV.GetComponent <Rigidbody>(), false); } else if (Hitch != null) { //ModConsole.Print("Hitch localizado"); CreateJoint(new Vector3(0f, 0f, 0f), Hitch.GetComponent <Rigidbody>(), false); } } catch (Exception e) { ModConsole.Error("Connect Erro: " + e.ToString()); } } else { ModConsole.Print("Desconnecting"); if (Joint != null) { Destroy(Joint); Support.localScale = new Vector3(1f, 1f, 1f); } } this.m_isConnect = !this.m_isConnect; return; } else { CreateJointToPlayer(); } } else { CreateJointToPlayer(); } } } }
/// <summary> /// Initialize class /// </summary> /// <param name="gameObjectName"></param> public Vehicle(string gameObjectName) { // gameObject the object by name gameObject = GameObject.Find(gameObjectName); // Use Resources.FindObjectsOfTypeAll method, if the vehicle was not found. if (gameObject == null) { gameObject = Resources.FindObjectsOfTypeAll <GameObject>().FirstOrDefault(g => g.name == gameObjectName); } if (gameObject == null) { ModConsole.Error($"[MOP] Could not find {gameObjectName} vehicle."); return; } // Get the object position and rotation Position = gameObject.transform.localPosition; Rotation = gameObject.transform.localRotation; // Creates a new gameobject that is names after the original file + '_TEMP' (ex. "SATSUMA(557kg, 248)_TEMP") temporaryParent = new GameObject($"{gameObject.name}_TEMP").transform; preventToggleOnObjects = new List <PreventToggleOnObject>(); // This should fix bug that leads to items inside of vehicles to fall through it. PlayMakerFSM lodFSM = gameObject.GetPlayMakerByName("LOD"); if (lodFSM != null) { lodFSM.Fsm.RestartOnEnable = false; FsmState resetState = lodFSM.FindFsmState("Fix Collider"); if (resetState != null) { resetState.Actions = new FsmStateAction[] { new CustomStopAction() }; resetState.SaveActions(); } lodFSM.FindFsmState("Load game").Actions = new FsmStateAction[] { new CustomNullState() }; } if (gameObject.name == "BOAT") { return; } // Get the object's child which are responsible for audio foreach (Transform audioObject in FindAudioObjects()) { preventToggleOnObjects.Add(new PreventToggleOnObject(audioObject)); } // Fix for fuel level resetting after respawn Transform fuelTank = gameObject.transform.Find("FuelTank"); if (fuelTank != null) { PlayMakerFSM fuelTankFSM = fuelTank.GetComponent <PlayMakerFSM>(); if (fuelTankFSM) { fuelTankFSM.Fsm.RestartOnEnable = false; } } // If the vehicle is Gifu, find knobs and add them to list of unloadable objects if (gameObject.name == "GIFU(750/450psi)") { Transform knobs = gameObject.transform.Find("Dashboard/Knobs"); foreach (PlayMakerFSM knobsFSMs in knobs.GetComponentsInChildren <PlayMakerFSM>()) { knobsFSMs.Fsm.RestartOnEnable = false; } PlayMakerFSM shitFsm = gameObject.transform.Find("ShitTank").gameObject.GetComponent <PlayMakerFSM>(); FsmState loadGame = shitFsm.FindFsmState("Load game"); List <FsmStateAction> loadArrayActions = new List <FsmStateAction> { new CustomNullState() }; loadArrayActions.Add(new CustomNullState()); loadGame.Actions = loadArrayActions.ToArray(); loadGame.SaveActions(); } // Fixed kickstand resetting to the default value. if (gameObject.name == "JONNEZ ES(Clone)") { PlayMakerFSM kickstandFsm = gameObject.transform.Find("Kickstand").gameObject.GetComponent <PlayMakerFSM>(); FsmState loadGame = kickstandFsm.FindFsmState("Load game"); List <FsmStateAction> loadArrayActions = new List <FsmStateAction> { new CustomNullState() }; loadArrayActions.Add(new CustomNullState()); loadGame.Actions = loadArrayActions.ToArray(); loadGame.SaveActions(); // Disable on restart for wheels script. Transform wheelsParent = transform.Find("Wheels"); foreach (Transform wheel in wheelsParent.GetComponentsInChildren <Transform>()) { if (!wheel.gameObject.name.StartsWith("Moped_wheel")) { continue; } wheel.gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false; } } carDynamics = gameObject.GetComponent <CarDynamics>(); axles = gameObject.GetComponent <Axles>(); rb = gameObject.GetComponent <Rigidbody>(); // Hook HookFront and HookRear // Get hooks first Transform hookFront = transform.Find("HookFront"); Transform hookRear = transform.Find("HookRear"); // If hooks exists, attach the RopeHookUp and RopeUnhook to appropriate states if (hookFront != null) { fsmHookFront = hookFront.GetComponent <PlayMakerFSM>(); } if (hookRear != null) { fsmHookRear = hookRear.GetComponent <PlayMakerFSM>(); } // If vehicle is flatbed, hook SwitchToggleMethod to Add scale script if (gameObject.name == "FLATBED") { PlayMakerFSM logTriggerFsm = transform.Find("Bed/LogTrigger").gameObject.GetComponent <PlayMakerFSM>(); FsmState loadGame = logTriggerFsm.FindFsmState("Load game"); List <FsmStateAction> loadArrayActions = new List <FsmStateAction> { new CustomNullState() }; loadGame.Actions = loadArrayActions.ToArray(); loadGame.SaveActions(); GameObject trailerLogUnderFloorCheck = new GameObject("MOP_TrailerLogUnderFloorFix"); trailerLogUnderFloorCheck.transform.parent = gameObject.transform; trailerLogUnderFloorCheck.AddComponent <TrailerLogUnderFloor>(); } // Set default toggling method - that is entire vehicle Toggle = ToggleActive; isHayosiko = gameObject.name == "HAYOSIKO(1500kg, 250)"; isKekmet = gameObject.name == "KEKMET(350-400psi)"; // If the user selected to toggle vehicle's physics only, it overrided any previous set for Toggle method if (Rules.instance.SpecialRules.ToggleAllVehiclesPhysicsOnly) { Toggle = IgnoreToggle; } // Get all HingeJoints and add HingeManager to them // Ignore for Satsuma or cars that use ToggleUnityCar method (and force for Hayosiko - no matter what) if (SatsumaScript == null && Toggle != ToggleUnityCar || isHayosiko) { HingeJoint[] joints = gameObject.transform.GetComponentsInChildren <HingeJoint>(); foreach (HingeJoint joint in joints) { joint.gameObject.AddComponent <HingeManager>(); } } // Get one of the wheels. wheel = axles.allWheels[0]; drivetrain = gameObject.GetComponent <Drivetrain>(); // Ignore Rules. IgnoreRule vehicleRule = Rules.instance.IgnoreRules.Find(v => v.ObjectName == this.gameObject.name); if (vehicleRule != null) { Toggle = IgnoreToggle; if (vehicleRule.TotalIgnore) { IsActive = false; } } // Prevent Toggle On Object Rule. IgnoreRuleAtPlace[] preventToggleOnObjectRule = Rules.instance.IgnoreRulesAtPlaces .Where(v => v.Place == this.gameObject.name).ToArray(); if (preventToggleOnObjectRule.Length > 0) { foreach (var p in preventToggleOnObjectRule) { Transform t = transform.FindRecursive(p.ObjectName); if (t == null) { ModConsole.Error($"[MOP] Couldn't find {p.ObjectName} in {p.Place}."); continue; } preventToggleOnObjects.Add(new PreventToggleOnObject(t)); } } eventSounds = gameObject.GetComponent <EventSounds>(); // Odometers fix. switch (gameObject.name) { case "GIFU(750/450psi)": transform.Find("Dashboard/Odometer").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false; break; case "HAYOSIKO(1500kg, 250)": transform.Find("Odometer").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false; break; case "KEKMET(350-400psi)": transform.Find("Dashboard/HourMeter").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false; break; case "SATSUMA(557kg, 248)": GameObject.Find("dashboard meters(Clone)").transform.Find("Gauges/Odometer").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false; break; } }
IEnumerator DownloadAndUpdateRoutine() { string lastModList = File.Exists(lastModListPath) ? File.ReadAllText(lastModListPath) : ""; Mod[] mods = ModLoader.LoadedMods.Where(m => !m.ID.ContainsAny("MSCLoader_", "MOP")).ToArray(); string modListString = ""; ModConsole.Print("[MOP] Checking for new mods..."); bool isUpdateTime = !File.Exists(lastDateFilePath) || IsUpdateTime(); if (isUpdateTime) { ModConsole.Print("[MOP] Looking for updates..."); } foreach (Mod mod in mods) { string modId = mod.ID; modListString += $"{modId}\n"; string ruleUrl = $"{RemoteServer}{modId}.mopconfig"; string filePath = $"{MOP.ModConfigPath}/{modId}.mopconfig"; // Prevent downloading, if file is on the server. if (lastModList.Contains(mod.ID) && !isUpdateTime) { continue; } // Check if rule file for mod is on the server. // If not, continue. if (!IsFileOnServer(modId)) { continue; } // Check if the newer file is available on the server. if (!overrideUpdateCheck) { if (serverContent == null) { GetServerContent(); } DateTime lastLocalFileWrite = GetFileWriteTime(filePath); ServerContentData data = serverContent.First(t => t.ID == modId); DateTime lastRemoteFileWrite = data.UpdateTime; if (lastRemoteFileWrite <= lastLocalFileWrite) { ModConsole.Print($"<color=orange>[MOP] Skipping {modId}, because local file and remote file are the same.</color>"); continue; } } // Check if file actually exists on remote server. if (!RemoteFileExists(ruleUrl)) { ModConsole.Error($"[MOP] Rule file for mod doesn't exist!\nID: {modId}\nURL: {ruleUrl}"); continue; } fileDownloadCompleted = false; using (WebClient web = new WebClient()) { ModConsole.Print($"<color=yellow>[MOP] Downloading new rule file for {mod.Name}...</color>"); NewMessage($"MOP: Downloading new rule file for {mod.Name}..."); #if DEBUG web.Headers.Add("user-agent", $"MOP/{MOP.ModVersion}_DEBUG {ExceptionManager.GetSystemInfo()}"); #else web.Headers.Add("user-agent", $"MOP/{MOP.ModVersion} {ExceptionManager.GetSystemInfo()}"); #endif if (File.Exists(filePath)) { File.Delete(filePath); } web.DownloadFileCompleted += DownloadFileCompleted; web.DownloadFileAsync(new Uri(ruleUrl), filePath); int waitTime = 0; while (!fileDownloadCompleted) { yield return(new WaitForSeconds(.5f)); waitTime++; // If wait time is longer than 30 seconds, abandon downloading. if (waitTime > 60) { ModConsole.Error("[MOP] Downloading failed. Skipping downloading."); NewMessage("MOP: Downloading failed. Skipping downloading."); GetAndReadRules(); yield break; } } web.Dispose(); } ModConsole.Print("<color=green>[MOP] Downloading completed!</color>"); } File.WriteAllText(lastModListPath, modListString); if (isUpdateTime) { File.WriteAllText(lastDateFilePath, DateTime.Now.ToString()); } // File downloading and updating completed! // Start reading those files. GetAndReadRules(); }
// You know the rules and so do I // A full commitment's what I'm thinking of // You wouldn't get this from any other guy // I just wanna tell you how I'm feeling // Gotta make you understand // Never gonna give you up // Never gonna let you down // Never gonna run around and desert you // Never gonna make you cry // Never gonna say goodbye // Never gonna tell a lie and hurt you void ReadRulesFromFile(string rulePath) { try { string[] content = File.ReadAllLines(rulePath).Where(s => s.Length > 0 && !s.StartsWith("##")).ToArray(); string fileName = Path.GetFileName(rulePath); int lines = File.ReadAllLines(rulePath).Where(s => s.StartsWith("##")).ToArray().Length; int currentLine = 0; foreach (string s in content) { lines++; currentLine++; string[] splitted = s.Split(':'); // Read flag and rules. string flag = splitted[0]; string[] objects = new string[0]; if (splitted.Length > 1) { objects = splitted[1].Trim().Split(' '); for (int i = 0; i < objects.Length; i++) { objects[i] = objects[i].Replace("%20", " "); } } if (objects.Length > 0 && objects.ContainsAny(illegalValues)) { ModConsole.Error($"[MOP] Illegal object: {objects[0]} in rule file {fileName}."); continue; } // Apply these rules switch (flag) { default: ModConsole.Error($"[MOP] Unrecognized flag '{flag}' in {fileName} ({lines})."); break; case "ignore": // Ignore at place if (objects.Length > 1) { Rules.instance.IgnoreRulesAtPlaces.Add(new IgnoreRuleAtPlace(objects[0], objects[1])); break; } Rules.instance.IgnoreRules.Add(new IgnoreRule(objects[0], false)); break; case "ignore_full": Rules.instance.IgnoreRules.Add(new IgnoreRule(objects[0], true)); break; case "toggle": ToggleModes mode = ToggleModes.Normal; if (objects.Length > 1) { switch (objects[1]) { default: ModConsole.Error($"[MOP] Unrecognized method '{objects[1]}' in {fileName} ({lines})."); break; case "renderer": mode = ToggleModes.Renderer; break; case "item": mode = ToggleModes.Item; break; case "vehicle": mode = ToggleModes.Vehicle; break; case "vehicle_physics": mode = ToggleModes.VehiclePhysics; break; } } Rules.instance.ToggleRules.Add(new ToggleRule(objects[0], mode)); break; case "satsuma_ignore_renderer": Rules.instance.SpecialRules.SatsumaIgnoreRenderers = true; break; case "dont_destroy_empty_beer_bottles": Rules.instance.SpecialRules.DontDestroyEmptyBeerBottles = true; break; case "sector": Vector3 pos = ParseToVector3(objects[0]); Vector3 scale = ParseToVector3(objects[1]); Vector3 rot = ParseToVector3(objects[2]); string[] whitelist = GetWhitelist(objects); Rules.instance.NewSectors.Add(new NewSector(pos, scale, rot, whitelist)); break; case "min_ver": if (fileName == "Custom.txt") { break; } if (currentLine != 1) { ModConsole.Print($"\n=================================" + $"\n\n<color=cyan>[MOP] Flag '{flag}' must be first in the order!\n\n" + $"File: {fileName}\n" + $"Line: {lines}\n" + $"You can ignore that message.</color>"); } int major, minor, revision = 0; string[] verSplitted = objects[0].Split('.'); major = int.Parse(verSplitted[0]); minor = int.Parse(verSplitted[1]); if (verSplitted.Length == 3) { revision = int.Parse(verSplitted[2]); } int modMajor, modMinor, modRevision = 0; string[] modVersionSpliited = MOP.ModVersion.Split('.'); modMajor = int.Parse(modVersionSpliited[0]); modMinor = int.Parse(modVersionSpliited[1]); if (modVersionSpliited.Length == 3) { modRevision = int.Parse(modVersionSpliited[2]); } bool isOutdated = false; if (major > modMajor) { isOutdated = true; } else { if (minor > modMinor && major == modMajor) { isOutdated = true; } else { if (revision > modRevision && minor == modMinor && major == modMajor) { isOutdated = true; } } } if (isOutdated) { ModConsole.Error($"[MOP] Rule file {fileName} is for the newer version of MOP. Please update MOP right now!\n\n" + $"Your MOP version: {modMajor}.{modMinor}.{modRevision}\n" + $"Required version: {major}.{minor}.{revision}"); return; } break; // Custom.txt exclusives. case "ignore_mod_vehicles": if (fileName != "Custom.txt") { ModConsole.Error($"[MOP] Flag: {flag} is only allowed to be used in custom rule file."); continue; } Rules.instance.SpecialRules.IgnoreModVehicles = true; break; case "toggle_all_vehicles_physics_only": if (fileName != "Custom.txt") { ModConsole.Error($"[MOP] Flag: {flag} is only allowed to be used in custom rule file."); continue; } Rules.instance.SpecialRules.ToggleAllVehiclesPhysicsOnly = true; break; case "experimental_driveway_sector": if (fileName != "Custom.txt") { ModConsole.Error($"[MOP] Flag: {flag} is only allowed to be used in custom rule file."); continue; } Rules.instance.SpecialRules.DrivewaySector = true; break; case "experimental_satsuma_trunk": if (fileName != "Custom.txt") { ModConsole.Error($"[MOP] Flag: {flag} is only allowed to be used in custom rule file."); continue; } Rules.instance.SpecialRules.ExperimentalSatsumaTrunk = true; break; case "experimental_optimization": if (fileName != "Custom.txt") { ModConsole.Error($"[MOP] Flag: {flag} is only allowed to be used in custom rule file."); continue; } Rules.instance.SpecialRules.ExperimentalOptimization = true; break; case "experimental_save_optimization": if (fileName != "Custom.txt") { ModConsole.Error($"[MOP] Flag: {flag} is only allowed to be used in custom rule file."); continue; } Rules.instance.SpecialRules.ExperimentalSaveOptimization = true; break; } } } catch (Exception ex) { ModConsole.Error($"[MOP] Error loading rule {Path.GetFileName(rulePath)}: {ex}."); NewMessage($"<color=red>MOP: Error loading rule :("); } }
public void Render() { if (hadError) { return; } //This causes memory corruption due to multithreaded access without using the hook thing unityRenderer.ImmediateContext.CopyResource(rig.leftTexture, leftHandle); unityRenderer.ImmediateContext.CopyResource(rig.rightTexture, rightHandle); //unityRenderer.ImmediateContext.Flush(); //Potential methods to speed this up: //1. Graphics.Blit //2. Using same method as SteamVR_Camera, eg. use material with the steamvr blit shader // to which you then assign each texture at a time and render into it /*RenderTexture.active = rig.leftRt; * leftUnityTexture.ReadPixels(new Rect(0, 0, leftUnityTexture.width, leftUnityTexture.height), 0, 0); * RenderTexture.active = rig.rightRt; * rightUnityTexture.ReadPixels(new Rect(0, 0, rightUnityTexture.width, rightUnityTexture.height), 0, 0); * RenderTexture.active = null; * leftUnityTexture.Apply(); * rightUnityTexture.Apply();*/ //This produces a pink screen, and white screen on HMD? //Graphics.Blit(rig.leftRt, leftMat); //Graphics.Blit(rig.rightRt, rightMat); /*Graphics.SetRenderTarget(rig.leftRt); * //SteamVR_Camera.blitMaterial.mainTexture = src; * * GL.PushMatrix(); * GL.LoadOrtho(); * SteamVR_Camera.blitMaterial.SetPass(0); * GL.Begin(GL.QUADS); * GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0); * GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0); * GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0); * GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0); * GL.End(); * GL.PopMatrix(); * * Graphics.SetRenderTarget(null);*/ TrackedDevicePose_t[] renderPoses = new TrackedDevicePose_t[3]; TrackedDevicePose_t[] gamePoses = new TrackedDevicePose_t[3]; var posesError = OpenVR.Compositor.WaitGetPoses(renderPoses, gamePoses); if (posesError != EVRCompositorError.None) { ModConsole.Error("Error in WaitGetPoses"); ModConsole.Print(posesError); } OpenVR.Compositor.SetTrackingSpace(ETrackingUniverseOrigin.TrackingUniverseStanding); OpenVR.Compositor.CompositorBringToFront(); var compError = OpenVR.Compositor.Submit(EVREye.Eye_Left, ref leftEye, ref bounds, EVRSubmitFlags.Submit_Default); if (compError != EVRCompositorError.None) { ModConsole.Error("Compositor left error"); ModConsole.Print(compError); if (compError == EVRCompositorError.TextureUsesUnsupportedFormat) { ModConsole.Print("You probably need to enable -force-d3d11 launch option in Steam"); } hadError = compError != EVRCompositorError.DoNotHaveFocus; } compError = OpenVR.Compositor.Submit(EVREye.Eye_Right, ref rightEye, ref bounds, EVRSubmitFlags.Submit_Default); if (compError != EVRCompositorError.None) { ModConsole.Print("Compositor right error"); ModConsole.Print(compError); hadError = compError != EVRCompositorError.DoNotHaveFocus; } OpenVR.Compositor.PostPresentHandoff(); }
public UIHandler(SatsumaMaster _modParent, AssetBundle assets) { modParent = _modParent; try { GameObject UI = assets.LoadAsset("SatsumaMaster.prefab") as GameObject; rootUI = GameObject.Instantiate(UI); statsPanel = GameObject.Find("StatsPanel"); sfxPanel = GameObject.Find("SFXPanel"); teleportPanel = GameObject.Find("TPPanel"); currentHP = GameObject.Find("CurrentPowerText").GetComponent <Text>(); currentSpeed = GameObject.Find("CurrentSpeedText").GetComponent <Text>(); currentRPM = GameObject.Find("CurrentRPMText").GetComponent <Text>(); currentEngineTemp = GameObject.Find("CurrentEngineTempText").GetComponent <Text>(); wearAlternator = GameObject.Find("AltinatorWearText").GetComponent <Text>(); wearCrankshaft = GameObject.Find("CrankSharftWearText").GetComponent <Text>(); wearGearbox = GameObject.Find("GearBoxWearText").GetComponent <Text>(); wearHeadgasket = GameObject.Find("HeadGasketWearText").GetComponent <Text>(); wearPiston1 = GameObject.Find("Piston1WearText").GetComponent <Text>(); wearPiston2 = GameObject.Find("Piston2WearText").GetComponent <Text>(); wearPiston3 = GameObject.Find("Piston3WearText").GetComponent <Text>(); wearPiston4 = GameObject.Find("Piston4WearText").GetComponent <Text>(); wearRockershaft = GameObject.Find("RockerShaftWearText").GetComponent <Text>(); wearStarter = GameObject.Find("StarterWearText").GetComponent <Text>(); wearWaterpump = GameObject.Find("WaterPumpWearText").GetComponent <Text>(); oilLevel = GameObject.Find("OilLevelText").GetComponent <Text>(); satsumaFuel = GameObject.Find("FuelLevelText").GetComponent <Text>(); racingWater = GameObject.Find("WaterLevelText").GetComponent <Text>(); brakeFluidF = GameObject.Find("BreakFluidFText").GetComponent <Text>(); brakeFluidR = GameObject.Find("BreakFluidRText").GetComponent <Text>(); cluthFluid = GameObject.Find("ClutchFluidText").GetComponent <Text>(); boostPowerText = GameObject.Find("BoostPowerText").GetComponent <Text>(); statsButton = GameObject.Find("ShowStatsButton").GetComponent <Button>(); sfxButton = GameObject.Find("SFXButton").GetComponent <Button>(); tpButton = GameObject.Find("TPButton").GetComponent <Button>(); boostButton = GameObject.Find("BoostButton").GetComponent <Button>(); boostMinusButton = GameObject.Find("MinusButton").GetComponent <Button>(); boostPlusButton = GameObject.Find("PlusButton").GetComponent <Button>(); engineFixerButton = GameObject.Find("EngineFixerButton").GetComponent <Button>(); eightGearButton = GameObject.Find("GearBoxButton").GetComponent <Button>(); transTypeButton = GameObject.Find("TransmissionButton").GetComponent <Button>(); driveTypeButton = GameObject.Find("DrivetypeButton").GetComponent <Button>(); espButton = GameObject.Find("ESPButton").GetComponent <Button>(); absButton = GameObject.Find("ABSButton").GetComponent <Button>(); suspensionbutton = GameObject.Find("SuspensionButton").GetComponent <Button>(); rightButton = GameObject.Find("SRightButton").GetComponent <Button>(); leftButton = GameObject.Find("SLeftButton").GetComponent <Button>(); upButton = GameObject.Find("SUpButton").GetComponent <Button>(); downButton = GameObject.Find("SDownButton").GetComponent <Button>(); inButton = GameObject.Find("_CamberIn").GetComponent <Button>(); outButton = GameObject.Find("_CamberOut").GetComponent <Button>(); bovButton = GameObject.Find("BovSoundButton").GetComponent <Button>(); bovMinusButton = GameObject.Find("MinusButton2").GetComponent <Button>(); bovPlusButton = GameObject.Find("PlusButton2").GetComponent <Button>(); bovVol = GameObject.Find("BovSoundVolume").GetComponent <Text>(); bovSFXButton = GameObject.Find("BovSoundSFXButton").GetComponent <Button>(); carHome = GameObject.Find("tp_CarHome").GetComponent <Button>(); carMech = GameObject.Find("tp_CarMechanic").GetComponent <Button>(); carHighway = GameObject.Find("tp_CarHighway").GetComponent <Button>(); carShop = GameObject.Find("tp_CarToShop").GetComponent <Button>(); carStrip = GameObject.Find("tp_CarToStrip").GetComponent <Button>(); carPoker = GameObject.Find("tp_CarToPoker").GetComponent <Button>(); carStrawberry = GameObject.Find("tp_CarToBerry").GetComponent <Button>(); carGrandma = GameObject.Find("tp_CarToGrandma").GetComponent <Button>(); carSki = GameObject.Find("tp_CarToSki").GetComponent <Button>(); playerHome = GameObject.Find("tp_PlayerToHome").GetComponent <Button>(); playerMech = GameObject.Find("tp_PlayerToMechanic").GetComponent <Button>(); playerHighway = GameObject.Find("tp_PlayerToHighway").GetComponent <Button>(); playerShop = GameObject.Find("tp_PlayerToShop").GetComponent <Button>(); playerStrip = GameObject.Find("tp_PlayerToStrip").GetComponent <Button>(); playerPoker = GameObject.Find("tp_PlayerToPoker").GetComponent <Button>(); playerStrawberry = GameObject.Find("tp_PlayerToBerry").GetComponent <Button>(); playerGrandma = GameObject.Find("tp_PlayerToGrandma").GetComponent <Button>(); playerCottage = GameObject.Find("tp_PlayerToCottage").GetComponent <Button>(); playerCar = GameObject.Find("tp_PlayerToCar").GetComponent <Button>(); statsButton.onClick.AddListener(delegate { ToggleStats(); }); sfxButton.onClick.AddListener(delegate { ToggleXFSPanel(); }); tpButton.onClick.AddListener(delegate { ToggleTPPanel(); }); boostButton.onClick.AddListener(delegate { ToggleBoost(); }); boostMinusButton.onClick.AddListener(delegate { ChangePower(-.1f); }); boostPlusButton.onClick.AddListener(delegate { ChangePower(.1f); }); engineFixerButton.onClick.AddListener(delegate { ToggleEngineFixer(); }); eightGearButton.onClick.AddListener(delegate { ToggleSixGears(); }); transTypeButton.onClick.AddListener(delegate { ToggleTransType(); }); driveTypeButton.onClick.AddListener(delegate { ToggleDriveType(); }); espButton.onClick.AddListener(delegate { ToggleESP(); }); absButton.onClick.AddListener(delegate { ToggleABS(); }); suspensionbutton.onClick.AddListener(delegate { ToggleSuspensionFix(); }); rightButton.onClick.AddListener(delegate { modParent.wheelSuspensionMod.SetNewWheelXPositions(IsDirectionLeft: true, IsFrontWheels: true, IsRearWheels: true); }); leftButton.onClick.AddListener(delegate { modParent.wheelSuspensionMod.SetNewWheelXPositions(IsDirectionLeft: false, IsFrontWheels: true, IsRearWheels: true); }); upButton.onClick.AddListener(delegate { modParent.wheelSuspensionMod.SetNewWheelPositions(IsDirectionUp: true, IsFrontWheels: true, IsRearWheels: true); }); downButton.onClick.AddListener(delegate { modParent.wheelSuspensionMod.SetNewWheelPositions(IsDirectionUp: false, IsFrontWheels: true, IsRearWheels: true); }); inButton.onClick.AddListener(delegate { modParent.wheelSuspensionMod.SetWheelCambers(true, true, 0); }); outButton.onClick.AddListener(delegate { modParent.wheelSuspensionMod.SetWheelCambers(true, true, 1); }); bovButton.onClick.AddListener(delegate { ToggleSFX(); }); bovMinusButton.onClick.AddListener(delegate { ChangeBovVolume(-.1f); }); bovPlusButton.onClick.AddListener(delegate { ChangeBovVolume(.1f); }); bovSFXButton.onClick.AddListener(delegate { ToggleBovSoundSFX(); }); carHome.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Home); }); carMech.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Mechanic); }); carHighway.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Highway); }); carShop.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Shop); }); carStrip.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Strip); }); carPoker.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Poker); }); carStrawberry.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Strawberry); }); carGrandma.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Grandma); }); carSki.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Car, Teleport.tpLocation.Ski); }); playerHome.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Home); }); playerMech.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Mechanic); }); playerHighway.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Highway); }); playerShop.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Shop); }); playerStrip.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Strip); }); playerPoker.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Poker); }); playerStrawberry.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Strawberry); }); playerGrandma.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Grandma); }); playerCottage.onClick.AddListener(delegate { modParent.teleportMod.TeleportMode(Teleport.tpType.Player, Teleport.tpLocation.Cottage); }); //playerCar.onClick.AddListener(delegate { TeleportMode(tpType.Player, tpLocation.Car); }); } catch (Exception) { ModConsole.Error("UIHandler failed setup."); } }
public override void OnGUI() { if (_listVisible) { GUI.Label(new Rect(_listPosLeft - 20.0f, Screen.height - _listPosBottom - _listLineHeight, Screen.width, _listLineHeight), $"Backpack ({Items.Count} / {Items.Capacity})", _listStyle); for (int i = 0; i < Items.Count; ++i) { float top = Screen.height - _listPosBottom - (_listLineHeight * ((Items.Count - i) + 1)); string name = Items[i].name.Replace("(Clone)", "").Replace("(itemx)", "").Replace("(xxxxx)", ""); if (i == Items.SelectedIndex) { GUI.Label(new Rect(_listPosLeft - 20.0f, top, 20.0f, _listLineHeight), ">", _listStyle); } GUI.Label(new Rect(_listPosLeft, top, Screen.width, _listLineHeight), name, _listStyle); } } if (MySettings.GuiVisible) { _playerInMenu.Value = true; GUI.Box(MySettings.GuiBackground, "Settings"); GUILayout.BeginArea(MySettings.GuiArea); GUILayout.BeginVertical(); MySettings.Temporary.LogAll = GUILayout.Toggle(MySettings.Temporary.LogAll, "Log everything"); MySettings.Temporary.LogSome = GUILayout.Toggle(MySettings.Temporary.LogSome, "Log pick-up and drop events"); MySettings.Temporary.AddIfOpen = GUILayout.Toggle(MySettings.Temporary.AddIfOpen, "Pick up only if the list is visible"); MySettings.Temporary.DropIfOpen = GUILayout.Toggle(MySettings.Temporary.DropIfOpen, "Drop only if the list is visible"); GUILayout.Label(string.Format("\nCapacity: {0}", MySettings.Temporary.MaxItems)); MySettings.Temporary.MaxItems = Mathf.RoundToInt(GUILayout.HorizontalSlider(MySettings.Temporary.MaxItems, 1.0f, 50.0f)); GUILayout.Label("WARNING:\nBackpack must be emptied in order to apply the settings."); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button("OK")) { if (Items.Count > 0) { ModConsole.Error($"[Backpack] Can't apply settings - backpack is not empty ({Items.Count})"); } else { MySettings.Settings.AddIfOpen = MySettings.Temporary.AddIfOpen; MySettings.Settings.DropIfOpen = MySettings.Temporary.DropIfOpen; MySettings.Settings.LogAll = MySettings.Temporary.LogAll; MySettings.Settings.LogSome = MySettings.Temporary.LogSome; MySettings.Settings.MaxItems = MySettings.Temporary.MaxItems; Items.Realloc(); MySettings.Save(SavePath); MySettings.GuiVisible = false; if (!_pauseMenu.activeInHierarchy) { _playerInMenu.Value = false; } } } if (GUILayout.Button("Cancel")) { MySettings.GuiVisible = false; if (!_pauseMenu.activeInHierarchy) { _playerInMenu.Value = false; } } GUILayout.EndHorizontal(); GUILayout.EndArea(); } }
private IEnumerator SetupMod() { while (GameObject.Find("PLAYER") == null) { yield return(null); } var fsms = GameObject.Find("PLAYER").GetComponents <PlayMakerFSM>(); foreach (var playMakerFsm in fsms) { if (playMakerFsm.FsmStates.Any(x => x.Name == "In Menu")) { m_playerViewFsm = playMakerFsm; } } var path = PaintMagazine.assetPath; if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL") && Application.platform == RuntimePlatform.WindowsPlayer) { path = Path.Combine(path, "bundle-linux"); // apparently fixes opengl } else if (Application.platform == RuntimePlatform.WindowsPlayer) { path = Path.Combine(path, "bundle-windows"); } else if (Application.platform == RuntimePlatform.OSXPlayer) { path = Path.Combine(path, "bundle-osx"); } else if (Application.platform == RuntimePlatform.LinuxPlayer) { path = Path.Combine(path, "bundle-linux"); } if (!File.Exists(path)) { ModConsole.Error("Couldn't find asset bundle from path " + path); } else { m_bundle = AssetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(path)); SetupGUI(); SetupMagazine(); var www = new WWW("https://zamp.github.io/mscskins.txt"); yield return(www); var lines = www.text.Split(new [] { "\r\n", "\n" }, StringSplitOptions.None); foreach (var line in lines) { var splits = line.Split('|'); if (splits.Length >= 4) { m_paintJobs.Add(new PaintJob { name = splits[0], creator = splits[1], url = splits[2], previewUrl = splits[3] }); } } ModConsole.Print("Loaded " + m_paintJobs.Count + " paintjobs!"); ModConsole.Print("Custom Paint Setup!"); path = Path.Combine(Application.persistentDataPath, "lastpainturl.txt"); if (File.Exists(path)) { LoadImageAndSetSatsuma(File.ReadAllText(path)); } m_bundle.Unload(false); } }
// Update is called once per frame public override void Update() { if (Application.loadedLevelName == "GAME") { try { if (!this.m_isLoaded) { if (GameObject.Find("PLAYER/Pivot/Camera/FPSCamera/1Hand_Assemble/Hand") == null) { return; } if (GameObject.Find("SATSUMA(557kg, 248)") == null) { return; } string patch = Path.Combine(ModLoader.GetModAssetsFolder(this), "trailerbundle"); if (!File.Exists(patch)) { ModConsole.Error("Couldn't find asset bundle from path " + patch); return; } else { this.m_bundle = LoadAssets.LoadBundle(this, patch); if (m_bundle != null) { hitch = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("hitch")); hitch.AddComponent <HitchBehaviour>(); hitchv = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("hitch")); hitchv.AddComponent <HitchVBehaviour>(); trailer = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("carreta")); trailer.AddComponent <TrailerBehaviour>(); trailer.GetComponent <TrailerBehaviour>().Hitch = hitch; trailer.GetComponent <TrailerBehaviour>().HitchV = hitchv; this.m_bundle.Unload(false); } else { ModConsole.Print("Bundle Null: " + patch); } } this.m_isLoaded = true; } return; } catch (Exception ex) { this.m_isLoaded = false; ModConsole.Error(ex.ToString()); return; } } if (Application.loadedLevelName != "GAME" && this.m_isLoaded) { this.m_isLoaded = false; } }