Skip to content

Commit b4e59e9

Browse files
committed
populate example plugin
1 parent 5984b05 commit b4e59e9

File tree

4 files changed

+79
-6
lines changed

4 files changed

+79
-6
lines changed

ExamplePlugin/ExamplePlugin.csproj

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.1</TargetFramework>
4+
<AssemblyName>com.sigurd.csync.example-plugin</AssemblyName>
5+
<RestoreAdditionalProjectSources>
6+
https://api.nuget.org/v3/index.json;
7+
https://nuget.bepinex.dev/v3/index.json;
8+
https://nuget.samboy.dev/v3/index.json
9+
</RestoreAdditionalProjectSources>
10+
<RootNamespace>CSync.ExamplePlugin</RootNamespace>
11+
<Title>ExamplePlugin</Title>
12+
<Product>$(Title)</Product>
13+
<NeutralLanguage>en-GB</NeutralLanguage>
14+
</PropertyGroup>
215

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
</PropertyGroup>
16+
<PropertyGroup>
17+
<IsThunderstorePackable>true</IsThunderstorePackable>
18+
<ThunderstoreName>CSync.ExamplePlugin</ThunderstoreName>
19+
<ThunderstoreDescription>Example plugin for CSync.</ThunderstoreDescription>
20+
<ThunderstoreIconPath>$(ProjectDir)assets/icons/icon.png</ThunderstoreIconPath>
21+
<HasBepInPlugin>true</HasBepInPlugin>
22+
<PluginRootNamespace>CSync.ExamplePlugin</PluginRootNamespace>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<ThunderstoreBuildCopyPath Include="$(TargetPath)" Destination="BepInEx/plugins/$(ProjectName)/"/>
27+
<ThunderstoreDependency Include="Sigurd-CSync" Version="5.0.0" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all"/>
32+
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.2" PrivateAssets="all"/>
33+
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all"/>
34+
</ItemGroup>
35+
36+
<ItemGroup>
37+
<PackageReference Include="BepInEx.Core" Version="5.*"/>
38+
<PackageReference Include="UnityEngine.Modules" Version="2022.3.9" IncludeAssets="compile"/>
39+
<ProjectReference Include="$(ProjectDir)../CSync/CSync.csproj" />
40+
</ItemGroup>
941

1042
</Project>

ExamplePlugin/MySyncedConfig.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using BepInEx.Configuration;
2+
using CSync.Extensions;
3+
using CSync.Lib;
4+
5+
namespace CSync.ExamplePlugin;
6+
7+
public class MySyncedConfig : SyncedConfig2<MySyncedConfig>
8+
{
9+
[field: SyncedEntryField]
10+
public SyncedEntry<float> ClimbSpeed { get; }
11+
12+
public MySyncedConfig(ConfigFile configFile) : base(MyPluginInfo.PLUGIN_GUID)
13+
{
14+
ClimbSpeed = ClimbSpeed = configFile.BindSyncedEntry(
15+
new ConfigDefinition("Movement", "Climb Speed"),
16+
3.9f,
17+
new ConfigDescription("The base speed at which the player climbs.")
18+
);
19+
20+
ConfigManager.Register(this);
21+
}
22+
}

ExamplePlugin/Plugin.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using BepInEx;
2+
using BepInEx.Logging;
3+
4+
namespace CSync.ExamplePlugin;
5+
6+
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
7+
[BepInDependency("com.sigurd.csync", "5.0.0")]
8+
public class Plugin : BaseUnityPlugin
9+
{
10+
internal new static ManualLogSource Logger { get; private set; } = null!;
11+
12+
internal new static MySyncedConfig Config { get; private set; }= null!;
13+
14+
private void Awake()
15+
{
16+
Logger = base.Logger;
17+
Config = new MySyncedConfig(base.Config);
18+
}
19+
}
24.7 KB
Loading

0 commit comments

Comments
 (0)