Skip to content

Commit

Permalink
add tas tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzo committed Aug 2, 2023
1 parent 7041d34 commit d191112
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 4 deletions.
7 changes: 7 additions & 0 deletions SlzSpeedrunTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ Project("{B89B2D75-808D-3383-5A2E-5C519DB49E93}") = "BonelabSpeedrunPractice", "
EndProject
Project("{D47BB0CA-36CA-0AA0-74ED-4117FDB1FCE4}") = "BonelabThirdPersonCamera", "projects\Bonelab\ThirdPersonCamera\ThirdPersonCamera.csproj", "{EE4562BC-A673-6C8A-9E73-57F7942FD510}"
EndProject
Project("{1D0D07E2-0C07-604C-1B55-2A84455C427E}") = "BonelabTasTool", "projects\Bonelab\TasTool\TasTool.csproj", "{BC8503B6-89E1-171A-9C86-3673F3F8EA13}"
EndProject

Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BC8503B6-89E1-171A-9C86-3673F3F8EA13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC8503B6-89E1-171A-9C86-3673F3F8EA13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC8503B6-89E1-171A-9C86-3673F3F8EA13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC8503B6-89E1-171A-9C86-3673F3F8EA13}.Release|Any CPU.Build.0 = Release|Any CPU

{EE4562BC-A673-6C8A-9E73-57F7942FD510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE4562BC-A673-6C8A-9E73-57F7942FD510}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE4562BC-A673-6C8A-9E73-57F7942FD510}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions projects/Bonelab/TasTool/AppVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace Sst.TasTool {
static class AppVersion { public const string Value = "0.0.0"; }
}
Empty file.
14 changes: 14 additions & 0 deletions projects/Bonelab/TasTool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Utilities for building tool assisted speedruns.

# Installation

- Make sure [Melon Loader](https://melonwiki.xyz/#/?id=what-is-melonloader) version 0.5.7 or newer is installed in Bonelab
- Download [the mod from Thunderstore](https://bonelab.thunderstore.io/package/jakzo/TasTool/) (click on "Manual Download")
- Open the downloaded `.zip` file and extract `Mods/TasTool.dll` into `BONELAB/Mods/TasTool.dll` which is usually at:
- Steam: `C:\Program Files (x86)\Steam\steamapps\common\BONELAB\BONELAB`
- Oculus: `C:\Program Files\Oculus\Software\Software\stress-level-zero-inc-bonelab`

# Links

- Source code: https://github.com/jakzo/SlzSpeedrunTools/tree/main/projects/Bonelab/TasTool
- Thunderstore: https://bonelab.thunderstore.io/package/jakzo/TasTool/
103 changes: 103 additions & 0 deletions projects/Bonelab/TasTool/TasTool.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProjectGuid>{EAE1410F-B5CF-47D6-8764-2FCAEE822C9D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TasTool</RootNamespace>
<AssemblyName>TasTool</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\references\Bonelab\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="SLZ.Marrow">
<HintPath>..\..\..\references\Bonelab\SLZ.Marrow.dll</HintPath>
</Reference>
<Reference Include="SLZ.Marrow.SDK">
<HintPath>..\..\..\references\Bonelab\SLZ.Marrow.SDK.dll</HintPath>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>..\..\..\references\Bonelab\Il2Cppmscorlib.dll</HintPath>
</Reference>
<Reference Include="MelonLoader">
<HintPath>..\..\..\references\Bonelab\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="Harmony">
<HintPath>..\..\..\references\Bonelab\0Harmony.dll</HintPath>
</Reference>
<Reference Include="UnhollowerBaseLib">
<HintPath>..\..\..\references\Bonelab\UnhollowerBaseLib.dll</HintPath>
</Reference>
<Reference Include="UnhollowerRuntimeLib">
<HintPath>..\..\..\references\Bonelab\UnhollowerRuntimeLib.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\references\Bonelab\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\..\references\Bonelab\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\..\references\Bonelab\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>..\..\..\references\Bonelab\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="Unity.Input">
<HintPath>..\..\..\references\Bonelab\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="Unity.XR">
<HintPath>..\..\..\references\Bonelab\UnityEngine.VRModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AppVersion.cs" />
<Compile Include="src/**/*.cs" />
<Compile Include="../../../common/Utilities/Metadata.cs" />
<Compile Include="../../../common/Utilities/Dbg.cs" />
<Compile Include="../../../common/Bonelab/LevelHooks.cs" />
<Compile Include="../../../common/Utilities/Unity.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<PostBuildEvent>
COPY "$(TargetPath)" "C:\Program
Files\Oculus\Software\Software\stress-level-zero-inc-bonelab\Mods"
</PostBuildEvent>
</PropertyGroup>
</Project>
30 changes: 30 additions & 0 deletions projects/Bonelab/TasTool/src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using MelonLoader;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;

[assembly:AssemblyTitle(Sst.TasTool.BuildInfo.NAME)]
[assembly:AssemblyDescription(Sst.TasTool.BuildInfo.DESCRIPTION)]
[assembly:AssemblyConfiguration("")]
[assembly:AssemblyCompany(Sst.Metadata.COMPANY)]
[assembly:AssemblyProduct(Sst.TasTool.BuildInfo.NAME)]
[assembly:AssemblyCopyright("Created by " + Sst.Metadata.AUTHOR)]
[assembly:AssemblyTrademark(Sst.Metadata.COMPANY)]
[assembly:AssemblyCulture("")]
[assembly:ComVisible(false)]
//[assembly: Guid("")]
[assembly:AssemblyVersion(Sst.TasTool.AppVersion.Value)]
[assembly:AssemblyFileVersion(Sst.TasTool.AppVersion.Value)]
[assembly:NeutralResourcesLanguage("en")]
[assembly:MelonInfo(
typeof(Sst.TasTool.Mod), Sst.TasTool.BuildInfo.NAME,
Sst.TasTool.AppVersion.Value, Sst.Metadata.AUTHOR,
"https://bonelab.thunderstore.io/package/jakzo/TasTool/")]
[assembly:MelonGame(Sst.Metadata.DEVELOPER, Sst.Metadata.GAME)]

namespace Sst.TasTool {
public static class BuildInfo {
public const string NAME = "TasTool";
public const string DESCRIPTION = "Utilities for building tool assisted speedruns.";
}
}
53 changes: 53 additions & 0 deletions projects/Bonelab/TasTool/src/Mod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using MelonLoader;
using UnityEngine;
using UnityEngine.SceneManagement;
using SLZ.SaveData;

namespace Sst.TasTool {
public class Mod : MelonMod {
public override void OnInitializeMelon() {
Dbg.Init(BuildInfo.NAME);
Tas.Initialize();
}
}
}

// Top level namespace to make calling via UnityExplorer easier
public static class Tas {
public static float CheatEngineTimescale = 1f;

public static void Initialize() {
Tas.SetResolution();
Sst.Utilities.LevelHooks.OnLevelStart += level =>
SlowdownAudio(CheatEngineTimescale);
}

public static void SetResolution() {
Screen.SetResolution(3840, 1080, FullScreenMode.Windowed);
}

public static void SlowdownAudio(float timescale) {
for (int i = 0; i < SceneManager.sceneCount; i++) {
var currentScene = SceneManager.GetSceneAt(i);
if (!currentScene.isLoaded)
continue;
foreach (var rootObj in currentScene.GetRootGameObjects()) {
var audioSources = new List<AudioSource>();
Sst.Utilities.Unity.FindDescendantComponentsOfType<AudioSource>(
ref audioSources, rootObj.transform);
foreach (var audioSource in audioSources) {
audioSource.pitch *= timescale;
}
}
}
}

public static void ToggleBodyLog() {
var progression = DataManager.Instance._activeSave.Progression;
var isEnabled = !progression.HasBodyLog;
progression.BodyLogEnabled = isEnabled;
progression.HasBodyLog = isEnabled;
}
}
Binary file added projects/Bonelab/TasTool/thunderstore/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions projects/Bonelab/TasTool/thunderstore/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "TasTool",
"version_number": "0.0.0",
"description": "Utilities for building tool assisted speedruns.",
"website_url": "https://github.com/jakzo/SlzSpeedrunTools/tree/main/projects/Bonelab/TasTool",
"dependencies": ["LavaGang-MelonLoader-0.5.7"]
}
4 changes: 0 additions & 4 deletions projects/Bonelab/ThirdPersonCamera/src/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public override void OnInitializeMelon() {
Utilities.LevelHooks.OnLevelStart += level => CreateThirdPersonCamera();
Utilities.LevelHooks.OnLoad += level => ResetState();
_prefCameraRatio.OnEntryValueChanged.Subscribe((a, b) => SetCameraRatios());

#if DEBUG // TAS
Screen.SetResolution(3840, 1080, FullScreenMode.Windowed);
#endif
}

public override void OnUpdate() {
Expand Down

0 comments on commit d191112

Please sign in to comment.