-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from YutoMaeda1209/dev
v1.0.0
- Loading branch information
Showing
5 changed files
with
362 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using HarmonyLib; | ||
using Il2Cpp; | ||
using MelonLoader; | ||
using UnityEngine; | ||
|
||
namespace YuchiGames.PrimitierDesktop.Patches | ||
{ | ||
[HarmonyPatch(typeof(HeightCalibrator), nameof(HeightCalibrator.Initialize))] | ||
public class HeightCalibrator_Initialize | ||
{ | ||
public static void Postfix() | ||
{ | ||
HeightCalibrator heightCalibrator = GameObject.FindObjectOfType<HeightCalibrator>(); | ||
heightCalibrator.Calibrate(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(HeightCalibrator), nameof(HeightCalibrator.Calibrate))] | ||
public class HeightCalibrator_Calibrate | ||
{ | ||
public static void Postfix() | ||
{ | ||
HeightCalibrator heightCalibrator = GameObject.FindObjectOfType<HeightCalibrator>(); | ||
heightCalibrator.ShowTitleMenu(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,161 @@ | ||
using MelonLoader; | ||
using Il2Cpp; | ||
using MelonLoader; | ||
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
using UnityEngine.InputSystem.XR; | ||
using UnityEngine.UI; | ||
|
||
namespace YuchiGames.PrimitierDesktop | ||
{ | ||
public class Program : MelonMod | ||
{ | ||
bool _initialized = false; | ||
GameObject _xrOrigin = new GameObject(); | ||
GameObject _leftHandCtrl = new GameObject(); | ||
GameObject _rightHandCtrl = new GameObject(); | ||
GameObject _mainCamera = new GameObject(); | ||
|
||
public override void OnSceneWasLoaded(int buildIndex, string sceneName) | ||
{ | ||
GameObject mainCanvas = GameObject.Find("/Player/XR Origin/Camera Offset/LeftHand Controller/RealLeftHand/MenuWindowL/Windows/MainCanvas"); | ||
mainCanvas.transform.Find("CameraTab").gameObject.SetActive(false); | ||
mainCanvas.transform.Find("CameraTabButton").gameObject.SetActive(false); | ||
|
||
GameObject.Find("/HandyCamera").SetActive(false); | ||
foreach (Canvas canvas in GameObject.FindObjectsOfType<Canvas>(true)) | ||
{ | ||
canvas.gameObject.AddComponent<GraphicRaycaster>(); | ||
} | ||
|
||
_xrOrigin = GameObject.Find("/Player/XR Origin"); | ||
InputActionMap inputActionMap = _xrOrigin.GetComponent<PlayerInput>() | ||
.actions.actionMaps[0]; | ||
// Move | ||
inputActionMap.actions[0].AddCompositeBinding("2DVector") | ||
.With("Up", "<Keyboard>/w") | ||
.With("Down", "<Keyboard>/s") | ||
.With("Left", "<Keyboard>/a") | ||
.With("Right", "<Keyboard>/d"); | ||
// Jump | ||
inputActionMap.actions[4].AddBinding("<Keyboard>/space"); | ||
// Grab | ||
inputActionMap.actions[7].AddBinding("<Keyboard>/h"); | ||
inputActionMap.actions[8].AddBinding("<Keyboard>/j"); | ||
// Bond | ||
inputActionMap.actions[9].AddBinding("<Keyboard>/t"); | ||
inputActionMap.actions[10].AddBinding("<Keyboard>/y"); | ||
// Menu | ||
inputActionMap.actions[11].AddBinding("<Keyboard>/n"); | ||
inputActionMap.actions[12].AddBinding("<Keyboard>/m"); | ||
// Separate | ||
inputActionMap.actions[13].AddBinding("<Keyboard>/u"); | ||
inputActionMap.actions[14].AddBinding("<Keyboard>/i"); | ||
|
||
_mainCamera = GameObject.Find("/Player/XR Origin/Camera Offset/Main Camera"); | ||
_mainCamera.GetComponent<Camera>().fieldOfView = 90f; | ||
_mainCamera.GetComponent<TrackedPoseDriver>().enabled = false; | ||
_mainCamera.transform.localPosition = new Vector3(0f, 1.8f, 0f); | ||
|
||
_leftHandCtrl = GameObject.Find("/Player/XR Origin/Camera Offset/LeftHand Controller"); | ||
Grabber leftGrabber = GameObject.Find("/Player/LeftHand").GetComponent<Grabber>(); | ||
Hand leftHand = leftGrabber.GetComponent<Hand>(); | ||
leftHand.maximumForce = float.PositiveInfinity; | ||
leftHand.maximumTorque = float.PositiveInfinity; | ||
leftHand.positionSpring = 1000000f; | ||
leftHand.rotationSpring = 1000000f; | ||
|
||
_rightHandCtrl = GameObject.Find("/Player/XR Origin/Camera Offset/RightHand Controller"); | ||
Grabber rightGrabber = GameObject.Find("/Player/RightHand").GetComponent<Grabber>(); | ||
Hand rightHand = rightGrabber.GetComponent<Hand>(); | ||
rightHand.maximumForce = float.PositiveInfinity; | ||
rightHand.maximumTorque = float.PositiveInfinity; | ||
rightHand.positionSpring = 1000000f; | ||
rightHand.rotationSpring = 1000000f; | ||
|
||
_initialized = true; | ||
} | ||
|
||
Vector3 _leftHandMove = new Vector3(-0.1f, -0.2f, 0.15f); | ||
Vector3 _leftHandRot = new Vector3(270f, 0f, 0f); | ||
Vector3 _rightHandMove = new Vector3(0.1f, -0.2f, 0.15f); | ||
Vector3 _rightHandRot = new Vector3(270f, 0f, 0f); | ||
bool _hideMouse = false; | ||
bool _isEscape = false; | ||
|
||
public override void OnUpdate() | ||
{ | ||
if (!_initialized) | ||
return; | ||
|
||
_leftHandCtrl.transform.position = _mainCamera.transform.TransformPoint(_leftHandMove); | ||
_leftHandCtrl.transform.rotation = _mainCamera.transform.rotation * Quaternion.Euler(_leftHandRot); | ||
|
||
if (Input.GetMouseButton(0)) | ||
{ | ||
if (Input.GetMouseButton(2)) | ||
{ | ||
_leftHandRot += new Vector3(Input.GetAxis("Mouse Y"), -Input.GetAxis("Mouse X")); | ||
return; | ||
} | ||
|
||
_leftHandMove += new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), Input.mouseScrollDelta.y) * 0.05f; | ||
} | ||
if (Input.GetKeyDown(KeyCode.Q)) | ||
{ | ||
_leftHandMove = new Vector3(-0.1f, -0.2f, 0.15f); | ||
_leftHandRot = new Vector3(270f, 0f, 0f); | ||
} | ||
|
||
_rightHandCtrl.transform.position = _mainCamera.transform.TransformPoint(_rightHandMove); | ||
_rightHandCtrl.transform.rotation = _mainCamera.transform.rotation * Quaternion.Euler(_rightHandRot); | ||
|
||
if (Input.GetMouseButton(1)) | ||
{ | ||
if (Input.GetMouseButton(2)) | ||
{ | ||
_rightHandRot += new Vector3(Input.GetAxis("Mouse Y"), -Input.GetAxis("Mouse X")); | ||
return; | ||
} | ||
|
||
_rightHandMove += new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), Input.mouseScrollDelta.y) * 0.05f; | ||
} | ||
if (Input.GetKeyDown(KeyCode.E)) | ||
{ | ||
_rightHandMove = new Vector3(0.1f, -0.2f, 0.15f); | ||
_rightHandRot = new Vector3(270f, 0f, 0f); | ||
} | ||
|
||
if (!(Input.GetMouseButton(0) || Input.GetMouseButton(1)) && _hideMouse) | ||
{ | ||
_xrOrigin.transform.rotation = Quaternion.Euler(0f, Input.GetAxis("Mouse X") + _xrOrigin.transform.rotation.eulerAngles.y, 0f); | ||
} | ||
if (!(Input.GetMouseButton(0) || Input.GetMouseButton(1)) && _hideMouse) | ||
{ | ||
_mainCamera.transform.localRotation = Quaternion.Euler(-Input.GetAxis("Mouse Y") + _mainCamera.transform.localRotation.eulerAngles.x, 0f, 0f); | ||
} | ||
|
||
if (Input.GetKeyDown(KeyCode.Escape)) | ||
{ | ||
_isEscape = !_isEscape; | ||
SwitchHideMouse(!_hideMouse); | ||
} | ||
if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) | ||
{ | ||
if (_isEscape) | ||
SwitchHideMouse(true); | ||
} | ||
if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) | ||
{ | ||
if (!_isEscape) | ||
SwitchHideMouse(false); | ||
} | ||
} | ||
|
||
public void SwitchHideMouse(bool isHideButton) | ||
{ | ||
_hideMouse = isHideButton; | ||
Cursor.lockState = _hideMouse ? CursorLockMode.Locked : CursorLockMode.None; | ||
Cursor.visible = !_hideMouse; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,109 @@ | ||
# PrimitierDesktop | ||
|
||
<p align=center> | ||
<a href="https://github.com/YutoMaeda1209/PrimitierDesktop/releases/latest"><img src="https://img.shields.io/badge/Download-latest-blue?style=for-the-badge"/></a> | ||
<a href="https://github.com/YutoMaeda1209/PrimitierDesktop/releases"><img src="https://img.shields.io/github/v/release/YutoMaeda1209/PrimitierDesktop?style=for-the-badge"/></a> | ||
<a href="https://store.steampowered.com/app/1745170/Primitier/"><img src="https://img.shields.io/badge/Primitier-v1.9.0-limegreen?style=for-the-badge"/></a> | ||
<a href="https://discord.com/channels/968161559387979876/1262816599174549524"><img src="https://img.shields.io/badge/-Discord-gray?style=for-the-badge&logo=Discord&logoColor=white"/></a> | ||
</p> | ||
|
||
<div align="center"> | ||
<h3 align="center">PrimitierDesktop</h3> | ||
<p align="center"> | ||
Mod to allow Primitier to be played without VR equipment. | ||
<br /> | ||
<br /> | ||
<a href="https://github.com/YutoMaeda1209/PrimitierDesktop/issues/new?labels=bug&template=bug-report---.md">Report Bug</a> | ||
· | ||
<a href="https://github.com/YutoMaeda1209/PrimitierDesktop/issues/new?labels=enhancement&template=feature-request---.md">Request Feature</a> | ||
</p> | ||
</div> | ||
|
||
<details> | ||
<summary>Table of Contents</summary> | ||
<ol> | ||
<li> | ||
<a href="#about-the-project">About The Project</a> | ||
</li> | ||
<li> | ||
<a href="#getting-started">Getting Started</a> | ||
<ul> | ||
<li><a href="#prerequisites">Prerequisites</a></li> | ||
<li><a href="#installation">Installation</a></li> | ||
</ul> | ||
</li> | ||
<li> | ||
<a href="#usage">Usage</a> | ||
<ul> | ||
<li><a href="#controls">Controls</a></li> | ||
</ul> | ||
</li> | ||
<li><a href="#contributing">Contributing</a></li> | ||
<li><a href="#license">License</a></li> | ||
<li><a href="#acknowledgments">Acknowledgments</a></li> | ||
</ol> | ||
</details> | ||
|
||
## About The Project | ||
|
||
This is a mod that allows Primitier to be controlled by keyboard and mouse. To avoid interfering with other mods, we have made it so that it does not directly enable or disable any objects in the game as much as possible. Therefore, it can be used as a debugging tool for mods. | ||
|
||
## Getting Started | ||
|
||
How to install the mod to Primitier. | ||
|
||
### Prerequisites | ||
|
||
Install the tools needed to install the mod. | ||
|
||
- [MelonLoader](https://melonwiki.xyz/) | ||
|
||
### Installation | ||
|
||
1. download the mod from the release page. | ||
2. put `PrimitierDesktop.dll` in Primitier/Mods folder. | ||
3. Play Primitier! | ||
|
||
## Usage | ||
|
||
### Controls | ||
|
||
| Action | Left hand | Right hand | | ||
|------------------|-----------|------------| | ||
| Toggle hand menu | N | M | | ||
| Toggle grab | H | J | | ||
| Bind cubes | T | Y | | ||
| Separate cubes | U | I | | ||
| Reset position | Q | E | | ||
|
||
| Action | Key | | ||
|---------------|-------------| | ||
| Toggle cursor | Escape | | ||
| Rotate hand | Mouse Wheel | | ||
|
||
## Contributing | ||
|
||
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. | ||
|
||
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". | ||
Don't forget to give the project a star! Thanks again! | ||
|
||
1. Fork the Project | ||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) | ||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) | ||
4. Push to the Branch (`git push origin feature/AmazingFeature`) | ||
5. Open a Pull Request | ||
|
||
### Top contributors: | ||
|
||
<a href="https://github.com/YutoMaeda1209/PrimitierOnlineMod/graphs/contributors"> | ||
<img src="https://contrib.rocks/image?repo=YutoMaeda1209/PrimitierOnlineMod" alt="contrib.rocks image" /> | ||
</a> | ||
|
||
## License | ||
|
||
Distributed under the MIT License. See `LICENSE.txt` for more information. | ||
|
||
## Acknowledgments | ||
|
||
This is the project I referred to in creating this project. | ||
|
||
* [PrimitierNOVRDBG](https://github.com/Seva167/PrimitierNOVRDBG) |