Updated Freecam to support the new BepInEx plugin loader for SPT-AKI
This commit is contained in:
parent
0c801c48c3
commit
a4424ecd09
21
README.md
21
README.md
@ -4,30 +4,31 @@ An SPT-AKI module mod that allows you to detach the camera and fly around freely
|
||||
|
||||
### Controls
|
||||
|
||||
For now, the keybinds are non-configurable (unless you change it in code and build from source).
|
||||
The default controls are as follows:
|
||||
- Keypad Plus - toggle free camera mode
|
||||
- Keypad Enter - teleport player to camera position
|
||||
- Keypad Multiply - toggle UI
|
||||
|
||||
If you need to change them, press F12 in-game and expand the `Freecam #.#.#` section and configure your keybinds there.
|
||||
Alternatively, you can find the `com.terkoiz.freecam.cfg` file in your `BepInEx/config/` folder after you've started up the game at least once with Freecam installed, and change the keybinds there.
|
||||
|
||||
|
||||
### How to install
|
||||
|
||||
1. Download the latest release here: [link](https://dev.sp-tarkov.com/Terkoiz/Freecam/releases) -OR- build from source (instructions below)
|
||||
2. Simply drop the folder `Terkoiz-Freecam` into your SPT-AKI `user/mods/` directory.
|
||||
2. Simply extract the zip file contents into your root SPT-AKI folder (where EscapeFromTarkov.exe is).
|
||||
3. Your `BepInEx/plugins` folder should now contain a `Terkoiz.Freecam.dll` file inside.
|
||||
|
||||
### Known issues
|
||||
|
||||
1. Your weapon doesn't turn invisible when you enter freecam mode
|
||||
2. When teleporting to camera position, the camera rotation gets copied exactly, potentially causing the player model to tilt
|
||||
3. Game version UI element is not hidden when toggling UI
|
||||
4. None of the camera settings (speed, senstivity, etc.) are user-configurable
|
||||
5. When flying to distant parts of the map in freecam mode, LODs are not triggered (these seem to follow the player)
|
||||
4. When flying to distant parts of the map in freecam mode, LODs are not triggered (these seem to follow the player)
|
||||
|
||||
### How to build from source
|
||||
|
||||
1. Download/clone this repository
|
||||
2. Download/clone the `SPT-AKI/Modules` repository: [link](https://dev.sp-tarkov.com/SPT-AKI/Modules)
|
||||
3. Move the contents of the `project` folder over to the SPT-AKI Modules `project` folder
|
||||
4. Add the `Terkoiz.Freecam` project to the SPT-AKI Modules solution
|
||||
5. Build modules - `Terkoiz.Freecam.dll` should appear under `Build/EscapeFromTarkov_Data/Managed` in the SPT-AKI Modules directory
|
||||
6. Copy the .dll into the `mod/Terkoiz-Freecam` folder and rename to `module.dll`
|
||||
7. That's it, you have a working release of this mod! Follow the `How to install` instructions on how to get the mod into your game
|
||||
2. Re-import dependencies. I recommend you do this from the SPT-AKI/Modules project's `Shared/Managed` folder, if you have the Modules project fully setup.
|
||||
3. Rebuild the project in the Release configuration.
|
||||
4. Grab the `Terkoiz.Freecam.dll` file from the `bin/Release` folder and use it wherever. Refer to the "How to install" section if you need help here.
|
@ -1,31 +0,0 @@
|
||||
Copyright (c) 2021 Martynas Gestautas. All rights reserved.
|
||||
|
||||
Developed by: SPT-Aki
|
||||
Martynas Gestautas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal with the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of Martynas Gestautas, SPT-Aki nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this Software without specific prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
|
||||
THE SOFTWARE.
|
Binary file not shown.
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
{
|
||||
"name": "Freecam",
|
||||
"author": "Terkoiz",
|
||||
"version": "1.0.1",
|
||||
"license": "NCSA Open Source",
|
||||
"dependencies": {}
|
||||
}
|
@ -11,31 +11,6 @@ namespace Terkoiz.Freecam
|
||||
/// </summary>
|
||||
public class Freecam : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Normal speed of camera movement.
|
||||
/// </summary>
|
||||
public float MovementSpeed = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// Speed of camera movement when shift is held down.
|
||||
/// </summary>
|
||||
public float FastMovementSpeed = 100f;
|
||||
|
||||
/// <summary>
|
||||
/// Sensitivity for free look.
|
||||
/// </summary>
|
||||
public float FreeLookSensitivity = 3f;
|
||||
|
||||
/// <summary>
|
||||
/// Amount to zoom the camera when using the mouse wheel.
|
||||
/// </summary>
|
||||
public float ZoomSensitivity = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// Amount to zoom the camera when using the mouse wheel (fast mode).
|
||||
/// </summary>
|
||||
public float FastZoomSensitivity = 50f;
|
||||
|
||||
public bool IsActive = false;
|
||||
|
||||
void Update()
|
||||
@ -44,9 +19,9 @@ namespace Terkoiz.Freecam
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var fastMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
|
||||
var movementSpeed = fastMode ? FastMovementSpeed : MovementSpeed;
|
||||
var movementSpeed = fastMode ? FreecamPlugin.CameraFastMoveSpeed.Value : FreecamPlugin.CameraMoveSpeed.Value;
|
||||
|
||||
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
|
||||
{
|
||||
@ -88,14 +63,14 @@ namespace Terkoiz.Freecam
|
||||
transform.position += (-Vector3.up * movementSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * FreeLookSensitivity;
|
||||
float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * FreeLookSensitivity;
|
||||
float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * FreecamPlugin.CameraLookSensitivity.Value;
|
||||
float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * FreecamPlugin.CameraLookSensitivity.Value;
|
||||
transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);
|
||||
|
||||
float axis = Input.GetAxis("Mouse ScrollWheel");
|
||||
if (axis != 0)
|
||||
{
|
||||
var zoomSensitivity = fastMode ? FastZoomSensitivity : ZoomSensitivity;
|
||||
var zoomSensitivity = fastMode ? FreecamPlugin.CameraFastZoomSpeed.Value : FreecamPlugin.CameraZoomSpeed.Value;
|
||||
transform.position += transform.forward * axis * zoomSensitivity;
|
||||
}
|
||||
}
|
||||
|
@ -13,30 +13,24 @@ namespace Terkoiz.Freecam
|
||||
private BattleUIScreen playerUi;
|
||||
private bool uiHidden;
|
||||
|
||||
// TODO:
|
||||
// Menu for adjusting settings
|
||||
// Config file for default settings
|
||||
// Configurable keybinds
|
||||
|
||||
// TODO MAYBE:
|
||||
// Hide player weapon
|
||||
// Hide version number UI element
|
||||
// FreeCam controller support (camera could be smoother with an analog stick, apparently)
|
||||
// Adjusting speed/sensitivity without a menu (Ctrl+ScrollWheel for example)
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.KeypadMultiply))
|
||||
if (FreecamPlugin.ToggleUi.Value.IsDown())
|
||||
{
|
||||
ToggleUi();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.KeypadPlus))
|
||||
if (FreecamPlugin.ToggleFreecamMode.Value.IsDown())
|
||||
{
|
||||
ToggleCamera();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.KeypadEnter))
|
||||
if (FreecamPlugin.TeleportToCamera.Value.IsDown())
|
||||
{
|
||||
MovePlayerToCamera();
|
||||
}
|
||||
|
98
project/Terkoiz.Freecam/FreecamPlugin.cs
Normal file
98
project/Terkoiz.Freecam/FreecamPlugin.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Terkoiz.Freecam
|
||||
{
|
||||
[BepInPlugin("com.terkoiz.freecam", "Terkoiz.Freecam", "1.1.0")]
|
||||
public class FreecamPlugin : BaseUnityPlugin
|
||||
{
|
||||
private static GameObject HookObject;
|
||||
|
||||
// Keyboard shortcut config entries
|
||||
private const string KeybindSectionName = "Keybinds";
|
||||
internal static ConfigEntry<KeyboardShortcut> ToggleFreecamMode;
|
||||
internal static ConfigEntry<KeyboardShortcut> TeleportToCamera;
|
||||
internal static ConfigEntry<KeyboardShortcut> ToggleUi;
|
||||
|
||||
// Camera settings config entries
|
||||
private const string CameraSettingsSectionName = "CameraSettings";
|
||||
internal static ConfigEntry<float> CameraMoveSpeed;
|
||||
internal static ConfigEntry<float> CameraFastMoveSpeed;
|
||||
internal static ConfigEntry<float> CameraLookSensitivity;
|
||||
internal static ConfigEntry<float> CameraZoomSpeed;
|
||||
internal static ConfigEntry<float> CameraFastZoomSpeed;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Logger.LogError("Loading Freecam...");
|
||||
|
||||
InitConfiguration();
|
||||
|
||||
HookObject = new GameObject();
|
||||
HookObject.AddComponent<FreecamController>();
|
||||
Object.DontDestroyOnLoad(HookObject);
|
||||
}
|
||||
|
||||
private void InitConfiguration()
|
||||
{
|
||||
ToggleFreecamMode = Config.Bind(
|
||||
KeybindSectionName,
|
||||
"ToggleCamera",
|
||||
new KeyboardShortcut(KeyCode.KeypadPlus),
|
||||
"The keyboard shortcut that toggles Freecam");
|
||||
|
||||
TeleportToCamera = Config.Bind(
|
||||
KeybindSectionName,
|
||||
"TeleportToCamera",
|
||||
new KeyboardShortcut(KeyCode.KeypadEnter),
|
||||
"The keyboard shortcut that teleports the player to camera position");
|
||||
|
||||
ToggleUi = Config.Bind(
|
||||
KeybindSectionName,
|
||||
"ToggleUi",
|
||||
new KeyboardShortcut(KeyCode.KeypadMultiply),
|
||||
"The keyboard shortcut that toggles the game UI");
|
||||
|
||||
CameraMoveSpeed = Config.Bind(
|
||||
CameraSettingsSectionName,
|
||||
"CameraMoveSpeed",
|
||||
10f,
|
||||
new ConfigDescription(
|
||||
"The speed at which the camera will move normally",
|
||||
new AcceptableValueRange<float>(0.01f, 100f)));
|
||||
|
||||
CameraFastMoveSpeed = Config.Bind(
|
||||
CameraSettingsSectionName,
|
||||
"CameraFastMoveSpeed",
|
||||
100f,
|
||||
new ConfigDescription(
|
||||
"The speed at which the camera will move when the Shift key is held down",
|
||||
new AcceptableValueRange<float>(0.01f, 1000f)));
|
||||
|
||||
CameraLookSensitivity = Config.Bind(
|
||||
CameraSettingsSectionName,
|
||||
"CameraLookSensitivity",
|
||||
3f,
|
||||
new ConfigDescription(
|
||||
"Camera free look mouse sensitivity",
|
||||
new AcceptableValueRange<float>(0.1f, 10f)));
|
||||
|
||||
CameraZoomSpeed = Config.Bind(
|
||||
CameraSettingsSectionName,
|
||||
"CameraMousewheelZoomSpeed",
|
||||
10f,
|
||||
new ConfigDescription(
|
||||
"Amount to zoom the camera when using the mouse wheel",
|
||||
new AcceptableValueRange<float>(0.01f, 100f)));
|
||||
|
||||
CameraFastZoomSpeed = Config.Bind(
|
||||
CameraSettingsSectionName,
|
||||
"CameraMousewheelFastZoomSpeed",
|
||||
50f,
|
||||
new ConfigDescription(
|
||||
"Amount to zoom the camera when using the mouse wheel while holding Shift",
|
||||
new AcceptableValueRange<float>(0.01f, 1000f)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Terkoiz.Freecam
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static GameObject HookObject;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Debug.LogError("Terkoiz.Freecam: Loading...");
|
||||
HookObject = new GameObject();
|
||||
HookObject.AddComponent<FreecamController>();
|
||||
Object.DontDestroyOnLoad(HookObject);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Terkoiz.Freecam</RootNamespace>
|
||||
<AssemblyName>Terkoiz.Freecam</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
@ -32,62 +32,48 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>..\Shared\References\0Harmony.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\Shared\References\Assembly-CSharp.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\Shared\Hollowed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ItemComponent.Types">
|
||||
<HintPath>..\Shared\References\ItemComponent.Types.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<Reference Include="BepInEx, Version=5.4.17.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BepInEx.BaseLib.5.4.17\lib\net35\BepInEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort">
|
||||
<HintPath>..\Shared\References\Comfort.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\Shared\Managed\Comfort.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Shared\References\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<Reference Include="ItemComponent.Types">
|
||||
<HintPath>..\Shared\Managed\ItemComponent.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\Shared\References\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\Shared\Managed\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\Shared\References\UnityEngine.CoreModule.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\Shared\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.PhysicsModule">
|
||||
<HintPath>..\Shared\References\UnityEngine.PhysicsModule.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
<Reference Include="UnityEngine.InputLegacyModule">
|
||||
<HintPath>..\Shared\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UIModule">
|
||||
<HintPath>..\Shared\Managed\UnityEngine.UIModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Freecam.cs" />
|
||||
<Compile Include="FreecamController.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="FreecamPlugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aki.Common\Aki.Common.csproj">
|
||||
<Project>{7584f43a-5937-417e-abf4-c5f680f300fb}</Project>
|
||||
<Name>Aki.Common</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="key.snk" />
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
11
project/Terkoiz.Freecam/app.config
Normal file
11
project/Terkoiz.Freecam/app.config
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Mono.Cecil" publicKeyToken="50cebf1cceb9d05e" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.11.4.0" newVersion="0.11.4.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
4
project/Terkoiz.Freecam/packages.config
Normal file
4
project/Terkoiz.Freecam/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BepInEx.BaseLib" version="5.4.17" targetFramework="net472" />
|
||||
</packages>
|
Reference in New Issue
Block a user