Skip to content

Commit d4e4136

Browse files
committed
feat: init
0 parents  commit d4e4136

File tree

10 files changed

+466
-0
lines changed

10 files changed

+466
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bin/
2+
obj/
3+
*.user
4+
*.suo
5+
*.userprefs
6+
*.pidb
7+
*.sln.docstates

ExampleMod.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.6.33801.468
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleMod", "ExampleMod\ExampleMod.csproj", "{74D3D478-3571-4F41-B035-3B4AFC024790}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{74D3D478-3571-4F41-B035-3B4AFC024790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{74D3D478-3571-4F41-B035-3B4AFC024790}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{74D3D478-3571-4F41-B035-3B4AFC024790}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{74D3D478-3571-4F41-B035-3B4AFC024790}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5CF7A9B9-3173-45B5-AE70-F7F111E9AD2C}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
using System.Runtime.CompilerServices;
3+
using IPA.Config.Stores;
4+
5+
[assembly: InternalsVisibleTo(GeneratedStore.AssemblyVisibilityTarget)]
6+
namespace ExampleMod.Configuration
7+
{
8+
internal class PluginConfig
9+
{
10+
public static PluginConfig Instance { get; set; }
11+
public virtual int IntValue { get; set; } = 42; // Must be 'virtual' if you want BSIPA to detect a value change and save the config automatically.
12+
13+
/// <summary>
14+
/// This is called whenever BSIPA reads the config from disk (including when file changes are detected).
15+
/// </summary>
16+
public virtual void OnReload()
17+
{
18+
// Do stuff after config is read from disk.
19+
}
20+
21+
/// <summary>
22+
/// Call this to force BSIPA to update the config file. This is also called by BSIPA if it detects the file was modified.
23+
/// </summary>
24+
public virtual void Changed()
25+
{
26+
// Do stuff when the config is changed.
27+
}
28+
29+
/// <summary>
30+
/// Call this to have BSIPA copy the values from <paramref name="other"/> into this config.
31+
/// </summary>
32+
public virtual void CopyFrom(PluginConfig other)
33+
{
34+
// This instance's members populated from other
35+
}
36+
}
37+
}
38+
*/

ExampleMod/Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- This file contains project properties used by the build. -->
3+
<Project>
4+
<PropertyGroup>
5+
<ImportBSMTTargets>True</ImportBSMTTargets>
6+
<BSMTProjectType>BSIPA</BSMTProjectType>
7+
</PropertyGroup>
8+
</Project>

ExampleMod/ExampleMod.csproj

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{74D3D478-3571-4F41-B035-3B4AFC024790}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>ExampleMod</RootNamespace>
12+
<AssemblyName>ExampleMod</AssemblyName>
13+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<DebugSymbols>true</DebugSymbols>
16+
<DebugType>portable</DebugType>
17+
<LocalRefsDir Condition="Exists('..\Refs')">..\Refs</LocalRefsDir>
18+
<BeatSaberDir>$(LocalRefsDir)</BeatSaberDir>
19+
<AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase>
20+
<!--<PathMap>$(AppOutputBase)=X:\$(AssemblyName)\</PathMap>-->
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Debug\</OutputPath>
27+
<DefineConstants>DEBUG;TRACE</DefineConstants>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="$(DefineConstants.Contains('CIBuild')) OR '$(NCrunch)' == '1'">
36+
<DisableCopyToPlugins>True</DisableCopyToPlugins>
37+
</PropertyGroup>
38+
<PropertyGroup Condition="'$(NCrunch)' == '1'">
39+
<DisableCopyToPlugins>True</DisableCopyToPlugins>
40+
<DisableZipRelease>True</DisableZipRelease>
41+
</PropertyGroup>
42+
<ItemGroup>
43+
<Reference Include="System" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="System.Data.DataSetExtensions" />
47+
<Reference Include="System.Data" />
48+
<Reference Include="System.Xml" />
49+
<Reference Include="Main">
50+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
51+
<Private>False</Private>
52+
</Reference>
53+
<Reference Include="HMLib">
54+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
55+
<Private>False</Private>
56+
</Reference>
57+
<Reference Include="HMUI">
58+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
59+
<Private>False</Private>
60+
</Reference>
61+
<Reference Include="IPA.Loader">
62+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
63+
<Private>False</Private>
64+
</Reference>
65+
<Reference Include="Unity.TextMeshPro">
66+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
67+
<Private>False</Private>
68+
</Reference>
69+
<Reference Include="UnityEngine">
70+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
71+
<Private>False</Private>
72+
</Reference>
73+
<Reference Include="UnityEngine.CoreModule">
74+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
75+
<Private>False</Private>
76+
</Reference>
77+
<Reference Include="UnityEngine.UI">
78+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
79+
<Private>False</Private>
80+
</Reference>
81+
<Reference Include="UnityEngine.UIElementsModule">
82+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath>
83+
<Private>False</Private>
84+
</Reference>
85+
<Reference Include="UnityEngine.UIModule">
86+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath>
87+
<Private>False</Private>
88+
</Reference>
89+
<Reference Include="UnityEngine.VRModule">
90+
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
91+
<Private>False</Private>
92+
</Reference>
93+
</ItemGroup>
94+
<ItemGroup>
95+
<Compile Include="Plugin.cs" />
96+
<Compile Include="Configuration\PluginConfig.cs" />
97+
<Compile Include="ExampleModController.cs" />
98+
<Compile Include="Properties\AssemblyInfo.cs" />
99+
</ItemGroup>
100+
<ItemGroup>
101+
<EmbeddedResource Include="manifest.json" />
102+
</ItemGroup>
103+
<ItemGroup>
104+
<None Include="Directory.Build.props" Condition="Exists('Directory.Build.props')" />
105+
<None Include="ExampleMod.csproj.user" Condition="Exists('ExampleMod.csproj.user')" />
106+
</ItemGroup>
107+
<ItemGroup>
108+
<PackageReference Include="BeatSaberModdingTools.Tasks">
109+
<Version>2.0.0-beta1</Version>
110+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
111+
<PrivateAssets>all</PrivateAssets>
112+
</PackageReference>
113+
</ItemGroup>
114+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
115+
</Project>

ExampleMod/ExampleModController.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using UnityEngine;
9+
10+
namespace ExampleMod
11+
{
12+
/// <summary>
13+
/// Monobehaviours (scripts) are added to GameObjects.
14+
/// For a full list of Messages a Monobehaviour can receive from the game, see https://docs.unity3d.com/ScriptReference/MonoBehaviour.html.
15+
/// </summary>
16+
public class ExampleModController : MonoBehaviour
17+
{
18+
public static ExampleModController Instance { get; private set; }
19+
20+
// These methods are automatically called by Unity, you should remove any you aren't using.
21+
#region Monobehaviour Messages
22+
/// <summary>
23+
/// Only ever called once, mainly used to initialize variables.
24+
/// </summary>
25+
private void Awake()
26+
{
27+
// For this particular MonoBehaviour, we only want one instance to exist at any time, so store a reference to it in a static property
28+
// and destroy any that are created while one already exists.
29+
if (Instance != null)
30+
{
31+
Plugin.Log?.Warn($"Instance of {GetType().Name} already exists, destroying.");
32+
GameObject.DestroyImmediate(this);
33+
return;
34+
}
35+
GameObject.DontDestroyOnLoad(this); // Don't destroy this object on scene changes
36+
Instance = this;
37+
Plugin.Log?.Debug($"{name}: Awake()");
38+
}
39+
/// <summary>
40+
/// Only ever called once on the first frame the script is Enabled. Start is called after any other script's Awake() and before Update().
41+
/// </summary>
42+
private void Start()
43+
{
44+
45+
}
46+
47+
/// <summary>
48+
/// Called every frame if the script is enabled.
49+
/// </summary>
50+
private void Update()
51+
{
52+
53+
}
54+
55+
/// <summary>
56+
/// Called every frame after every other enabled script's Update().
57+
/// </summary>
58+
private void LateUpdate()
59+
{
60+
61+
}
62+
63+
/// <summary>
64+
/// Called when the script becomes enabled and active
65+
/// </summary>
66+
private void OnEnable()
67+
{
68+
69+
}
70+
71+
/// <summary>
72+
/// Called when the script becomes disabled or when it is being destroyed.
73+
/// </summary>
74+
private void OnDisable()
75+
{
76+
77+
}
78+
79+
/// <summary>
80+
/// Called when the script is being destroyed.
81+
/// </summary>
82+
private void OnDestroy()
83+
{
84+
Plugin.Log?.Debug($"{name}: OnDestroy()");
85+
if (Instance == this)
86+
Instance = null; // This MonoBehaviour is being destroyed, so set the static instance property to null.
87+
88+
}
89+
#endregion
90+
}
91+
}

0 commit comments

Comments
 (0)