Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<AssemblyName>BepInEx5Plugins.Ash.Alisa.Stairs</AssemblyName>
<Description>Stairs</Description>
<Version>1.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="5.6.7" IncludeAssets="compile" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\lib\SteamRelease\Assembly-CSharp.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy /Y /Q /C /I &quot;$(OutDir)&quot; &quot;..\$(OutDir)\$(TargetName)\&quot;" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using HarmonyLib;
using System;
using UnityEngine;

namespace BepInEx5Plugins.Ash.Alisa.Stairs.HarmonyPatches
{
[HarmonyPatch(typeof(Interaction), "FixedUpdate")]
public class Interaction_FixedUpdate
{
public static float stairsWalkSpeed = 2f;

public static bool ignoreAnimation = false;

public static bool newGamePlusOnly = false;

// Add speed modifier when moving on stairs.
private static bool Prefix(Interaction __instance, ref float? __state
, ref GameObject ___player
, ref bool ___playerMovingDown
, ref bool ___playerMovingUp
, ref Animator ___anim
)
{
__state = null;

if (newGamePlusOnly
&& ProgressManager.instance.data.newGamePlus < 1)
{
return true;
}

try
{
___anim.SetBool("WalkingDownStairs", ___playerMovingDown);
___anim.SetBool("WalkingUpStairs", ___playerMovingUp);

if (!ignoreAnimation)
{
__state = ___anim.speed;
}

if (___playerMovingDown)
{
if (!ignoreAnimation)
{
__state = stairsWalkSpeed;
}
___player.transform.Translate(stairsWalkSpeed * Vector3.forward * 0.7f * Time.fixedDeltaTime);
___player.transform.Translate(stairsWalkSpeed * Vector3.down * 0.475f * Time.fixedDeltaTime);
___player.GetComponent<Rigidbody>().velocity = Vector3.zero;
}

if (___playerMovingUp)
{
if (!ignoreAnimation)
{
__state = stairsWalkSpeed;
}
___player.transform.Translate(stairsWalkSpeed * Vector3.forward * 0.7f * Time.fixedDeltaTime);
___player.transform.Translate(stairsWalkSpeed * Vector3.up * 0.48f * Time.fixedDeltaTime);
___player.GetComponent<Rigidbody>().velocity = Vector3.zero;
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}

return false;
}

// Modify the animation speed if necessary.
private static void Postfix(Interaction __instance, ref float? __state
, ref Animator ___anim
)
{
try
{
__state = null;

if (__state.HasValue)
{
___anim.speed = __state.Value;
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
6 changes: 6 additions & 0 deletions BepInEx5Plugins.Ash.Alisa.Stairs/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
</packageSources>
</configuration>
63 changes: 63 additions & 0 deletions BepInEx5Plugins.Ash.Alisa.Stairs/Plugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using System;

namespace BepInEx5Plugins.Ash.Alisa.Stairs
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
private static ConfigEntry<bool> ignoreAnimation;

private static ConfigEntry<bool> newGamePlusOnly;

private static ConfigEntry<float> stairsWalkSpeed;

private Plugin()
{
try
{
stairsWalkSpeed = Config.Bind("Stairs", "Walk Speed", 2f);
ignoreAnimation = Config.Bind("Stairs", "Ignore Animation", false);
newGamePlusOnly = Config.Bind("Stairs", "New Game Plus Only", false);

Config.SettingChanged += Config_SettingChanged;

ApplySettings();
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}

private static void Config_SettingChanged(object sender, EventArgs e)
{
ApplySettings();
}

private static void ApplySettings()
{
HarmonyPatches.Interaction_FixedUpdate.stairsWalkSpeed = stairsWalkSpeed.Value;
HarmonyPatches.Interaction_FixedUpdate.ignoreAnimation = ignoreAnimation.Value;
HarmonyPatches.Interaction_FixedUpdate.newGamePlusOnly = newGamePlusOnly.Value;
}

private void Awake()
{
try
{
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");

var harmony = new Harmony(Info.Metadata.GUID);

harmony.PatchAll();
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}
}
}