Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Asgragrt committed Feb 16, 2024
0 parents commit 827f139
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vs
bin
obj
*.sln
54 changes: 54 additions & 0 deletions FadeIn.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<Target Name="CopyDLLs" AfterTargets="Build">
<Copy SourceFiles="$(TargetDir)$(ProjectName).dll" DestinationFolder="$(MD_NET6_DIRECTORY)\Mods" />
<Message Text="Copied DLL -&gt; $(MD_NET6_DIRECTORY)\Mods\$(ProjectName).dll" Importance="High" />
</Target>

<ItemGroup>
<Reference Include="0Harmony">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\net6\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Runtime">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\net6\Il2CppInterop.Runtime.dll</HintPath>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll</HintPath>
</Reference>
<Reference Include="Il2CppSystem">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Il2CppSystem.dll</HintPath>
</Reference>
<Reference Include="MelonLoader">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\net6\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="Il2Cppspine-unity">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Il2Cppspine-unity.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="Il2CppSirenix.Serialization">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\Il2CppSirenix.Serialization.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>$(MD_NET6_DIRECTORY)\MelonLoader\Il2CppAssemblies\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
30 changes: 30 additions & 0 deletions Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using MelonLoader;
using static FadeIn.ModManager;

namespace FadeIn
{
public class Main : MelonMod
{

public override void OnInitializeMelon()
{
base.OnInitializeMelon();
Enabled = false;
LoggerInstance.Msg("FadeIn has loaded correctly!");
}

public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
battleScene = sceneName == "GameMain";
if (!battleScene)
{
OnSceneWasLoadedFunc();
}
}
public override void OnUpdate()
{
if (!battleScene) return;
OnUpdateFunc();
}
}
}
80 changes: 80 additions & 0 deletions ModManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using Il2CppAssets.Scripts.PeroTools.Commons;
using Il2CppFormulaBase;
using Il2CppSpine;
using Il2CppSpine.Unity;
using System.Collections.Concurrent;
using UnityEngine;

namespace FadeIn
{
internal static class ModManager
{
internal static bool _enabled;
public static bool Enabled
{
get { return _enabled; }
set
{
_enabled = value;
if (_enabled)
{
OnSceneWasLoadedFunc = ClearSceneElements;
EnableVisiblePatch = EnqueueSkeleton;
OnUpdateFunc = UpdateQueueElements;
}
else
{
OnSceneWasLoadedFunc = () => { };
EnableVisiblePatch = (_) => { };
OnUpdateFunc = () => { };
}
}
}

public static GameObject FadeToggle = null;

public static bool battleScene = false;
public static readonly ConcurrentQueue<Skeleton> enemiesSkeletons = new();

internal delegate void OnSceneWasLoadedFuncType();
public static OnSceneWasLoadedFuncType OnSceneWasLoadedFunc;

internal delegate void EnableVisiblePatchFuncType(GameObject beoc);
public static EnableVisiblePatchFuncType EnableVisiblePatch;

internal delegate void OnUpdateFuncType();
public static OnUpdateFuncType OnUpdateFunc;

public static readonly float frequency = 1f / Time.fixedDeltaTime;

internal static void ClearSceneElements()
{
enemiesSkeletons.Clear();
}

internal static void EnqueueSkeleton(GameObject beoc)
{
Skeleton currentEnemySkeleton = beoc.GetComponent<SkeletonAnimation>().skeleton;
currentEnemySkeleton.a = 0.7f;
enemiesSkeletons.Enqueue(currentEnemySkeleton);
// Check airmusicnodecontroller for note particles
}

internal static void UpdateQueueElements()
{
StageBattleComponent sbc = Singleton<StageBattleComponent>.instance;
if ((!sbc?.isInGame ?? true) || (sbc?.isPause ?? true)) return;
float delta = 0.01f * frequency * Time.deltaTime;

foreach (Skeleton skeleton in enemiesSkeletons)
{
skeleton.a -= delta;
if (skeleton.a <= 0)
{
skeleton.a = 0f;
enemiesSkeletons.TryDequeue(out _);
}
}
}
}
}
17 changes: 17 additions & 0 deletions Patches/GetVisibleEnemiesPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using HarmonyLib;
using Il2Cpp;
using static FadeIn.ModManager;

namespace FadeIn.Patches
{
[HarmonyPatch(typeof(BaseEnemyObjectController))]
internal static class GetVisibleEnemiesPatch
{
[HarmonyPostfix]
[HarmonyPatch(nameof(BaseEnemyObjectController.EnableVisible))]
public static void PostfixBEOC(BaseEnemyObjectController __instance)
{
EnableVisiblePatch(__instance.gameObject);
}
}
}
53 changes: 53 additions & 0 deletions Patches/TogglePatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppAssets.Scripts.PeroTools.Nice.Events;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using static FadeIn.ModManager;

namespace FadeIn.Patches
{
[HarmonyPatch(typeof(PnlPreparation))]
internal static class TogglePatch
{
[HarmonyPostfix]
[HarmonyPatch(nameof(PnlPreparation.Awake))]
public static void Postfix(PnlPreparation __instance)
{
if (FadeToggle != null) return;

FadeToggle = UnityEngine.Object.Instantiate(
GameObject.Find("Forward").transform.Find("PnlVolume").Find("LogoSetting").Find("Toggles").Find("TglOn").gameObject,
__instance.startButton.transform
);
FadeToggle.name = "FadeToggle";

Text txt = FadeToggle.transform.Find("Txt").GetComponent<Text>();
Image checkBox = FadeToggle.transform.Find("Background").GetComponent<Image>();
Image checkMark = FadeToggle.transform.Find("Background").GetChild(0).GetComponent<Image>();

FadeToggle.transform.position = new Vector3(-7.6f, -4.8f, 100f);
FadeToggle.GetComponent<OnToggle>().enabled = false;
FadeToggle.GetComponent<OnToggleOn>().enabled = false;
FadeToggle.GetComponent<OnActivate>().enabled = false;

Toggle toggleComp = FadeToggle.GetComponent<Toggle>();
toggleComp.onValueChanged.AddListener((UnityAction<bool>)
((bool val) => { Enabled = val; })
);
toggleComp.group = null;
toggleComp.SetIsOnWithoutNotify(Enabled);

txt.text = "Fade In";
txt.fontSize = 40;
txt.color = new Color(1, 1, 1, 76 / 255f);
RectTransform rect = txt.transform.Cast<RectTransform>();
Vector2 vect = rect.offsetMax;
rect.offsetMax = new Vector2(txt.text.Length * 25, vect.y);

checkBox.color = new(60 / 255f, 40 / 255f, 111 / 255f);
checkMark.color = new(103 / 255f, 93 / 255f, 130 / 255f);
}
}
}
19 changes: 19 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using MelonLoader;
using System.Reflection;
using Main = FadeIn.Main;

[assembly: MelonInfo(typeof(Main), "FadeIn", "0.1.0", "Asgragrt")]
[assembly: MelonGame("PeroPeroGames", "MuseDash")]
[assembly: MelonColor(255, 241, 196, 15)]

[assembly: AssemblyTitle("FadeIn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Muse Dash Modding Community")]
[assembly: AssemblyProduct("FadeIn")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Fade In
POC difficulty increase mod for md.
WIP.

### Features
* Fade in incoming notes.
* Toggle on music view menu to enable/disable the mod.

### Limitations
* Fade only depending on the time the note is visible. (E.g. Boss attacks appear later in the screen so they do not manage to fade completely ).
* Holds not working. ( Really hard lol ) ( Help ).
* Music notes particles are still visible.
* Hearts bonded with notes are visible.

0 comments on commit 827f139

Please sign in to comment.