Skip to content

Commit

Permalink
Merge pull request #255 from SubnauticaModding/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Metious committed Sep 11, 2022
2 parents 8dc2aae + d5d5719 commit 9ea3579
Show file tree
Hide file tree
Showing 64 changed files with 613 additions and 34,549 deletions.
13 changes: 10 additions & 3 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ To get started, first fork the repo and then clone it to your local environment.

- As of version 2.8, SMLHelper has been updated for QModManager v4.0 and uses [HarmonyX](https://github.com/BepInEx/HarmonyX).

- As of version 2.2, SMLHelper is now using the _publicized_ versions of `Assembly-CSharp.dll` and `Assembly-CSharp-firstpass.dll` (the originals being located in your `Subnautica_Data/Managed` folder).
To create your own publiciezed DLLs, you will need to download or compile the [Assembly Publicizer](https://github.com/CabbageCrow/AssemblyPublicizer/releases) and follow the [instructions](https://github.com/CabbageCrow/AssemblyPublicizer/blob/master/README.md) to convert the original DLLs into `Assembly-CSharp_publicized.dll` and `Assembly-CSharp-firstpass_publicized.dll`.
You will need to copy these DLLs into the `Dependencies` folder of the solution before you can build it.
Make sure to use the _publicized_ versions of `Assembly-CSharp.dll` and `Assembly-CSharp-firstpass.dll` (the originals being located in your `Subnautica_Data/Managed` folder).

To create your own publicized DLLs, install the [BepinEx Plugin](https://github.com/elliotttate/Bepinex-Tools/releases) and run the game once to create the following files:

* `Subnautica_Data\Managed\publicized_assemblies\Assembly-CSharp_publicized.dll`
* `Subnautica_Data\Managed\publicized_assemblies\Assembly-CSharp-firstpass_publicized.dll`

Copy these DLLs into the `Dependencies` folder of SMLHelper so you can build it. Publicized version of the assemblies should make you able to call non-public members without reflection.

- As of version 2.14, SMLHelper developers are required to have .NET 6 installed for the project to build.

Then, load up the solution, make your edits, then create your Pull Request!
Binary file removed BepinexPackages/BelowZero_Packages/SMLHelper.zip
Binary file not shown.
Binary file not shown.
8,425 changes: 0 additions & 8,425 deletions BepinexPackages/BelowZero_Packages/SMLHelper/QMods/SMLHelper_BZ/SMLHelper.xml

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file removed BepinexPackages/Subnautica_Packages/SMLHelper.zip
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

76 changes: 17 additions & 59 deletions Example mod/Example mod.csproj
Original file line number Diff line number Diff line change
@@ -1,71 +1,39 @@
<?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')" />
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\common.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">SN.STABLE</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C8FB0981-77D2-47C7-BBEF-A3A9EBACACBF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFramework>net472</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<RootNamespace>Example_mod</RootNamespace>
<AssemblyName>Example mod</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>latest</LangVersion>
<Configurations>SN.STABLE;BZ.EXP;SN.EXP;BZ.STABLE</Configurations>
<Platforms>AnyCPU</Platforms>
<Copyright>Copyright © 2019</Copyright>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
</PropertyGroup>
<Import Project="$(SolutionDir)Version.targets" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'SN.STABLE|AnyCPU'">
<OutputPath>bin\SN.STABLE\</OutputPath>
<DefineConstants>SUBNAUTICA;SUBNAUTICA_STABLE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>
</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'SN.EXP|AnyCPU'">
<OutputPath>bin\SN.EXP\</OutputPath>
<DefineConstants>SUBNAUTICA;SUBNAUTICA_EXP</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>
</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'BZ.STABLE|AnyCPU'">
<OutputPath>bin\BZ.STABLE\</OutputPath>
<DefineConstants>BELOWZERO;BELOWZERO_STABLE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>
</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'BZ.EXP|AnyCPU'">
<OutputPath>bin\BZ.EXP\</OutputPath>
<DefineConstants>BELOWZERO;BELOWZERO_EXP</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>
</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
Expand All @@ -84,12 +52,6 @@
<HintPath>$(Dependencies)\QModInstaller.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SMLHelper">
<HintPath>..\SMLHelper\bin\$(Configuration)\SMLHelper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(Dependencies)\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
Expand All @@ -98,15 +60,11 @@
<HintPath>$(Dependencies)\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Mod.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<ProjectReference Include="..\SMLHelper\SMLHelper.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="mod.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
26 changes: 0 additions & 26 deletions Example mod/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Example mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Example mod")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c8fb0981-77d2-47c7-bbef-a3a9ebacacbf")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.13.4")]
[assembly: AssemblyFileVersion("2.13.4")]
7 changes: 4 additions & 3 deletions Example mod/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"Id": "SMLHelperExampleMod",
"DisplayName": "Example Mod For SMLHelper",
"Author": "The SMLHelper Dev Team",
"Version": "2.13.4",
"Version": "2.14.0",
"Enable": true,
"AssemblyName": "Example mod.dll",
"VersionDependencies": {
"SMLHelper": "2.13.4"
"SMLHelper": "2.14.0"
},
"Game": "Both"
"Game": "Both",
"NitroxCompat": true
}
14 changes: 14 additions & 0 deletions PostBuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
<PowerShell>powershell.exe</PowerShell>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' == 'Unix'">
<PowerShell>pwsh</PowerShell>
</PropertyGroup>
<Target Name="ZipFiles" AfterTargets="PostBuildEvent">
<Exec
Command="$(PowerShell) -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)Scripts/SMLHelper-post-build.ps1 -SolutionDir $(SolutionDir) -ConfigurationName $(ConfigurationName) -TargetDir $(OutDir) -ProjectDir $(ProjectDir)"
/>
</Target>
</Project>
14 changes: 8 additions & 6 deletions SMLHelper.Tests/PdaItemTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SMLHelper.Tests.AssestClassTests
using System.Reflection;

namespace SMLHelper.Tests.AssestClassTests
{
using NSubstitute;
using NUnit.Framework;
Expand Down Expand Up @@ -38,7 +40,7 @@ public void Patch_EventsInvoked()
IKnownTechHandler mockKnownTechHandler = Substitute.For<IKnownTechHandler>();

mockTechTypeHandler
.AddTechType(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>())
.AddTechType(Arg.Any<Assembly>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>())
.Returns(createdTechType);

var techData = new TechData();
Expand All @@ -58,9 +60,9 @@ public void Patch_EventsInvoked()

// ASSERT
mockCraftDataHandler.Received(1).SetTechData(createdTechType, techData);
mockCraftDataHandler.Received(1).AddToGroup(TechGroup.Cyclops, TechCategory.Cyclops, createdTechType);
mockCraftDataHandler.Received(1).AddToGroup(TechGroup.Constructor, TechCategory.Constructor, createdTechType);
mockKnownTechHandler.DidNotReceiveWithAnyArgs();
mockTechTypeHandler.Received(1).AddTechType(Arg.Any<string>(), "classId", "friendlyName", "description", true);
mockTechTypeHandler.Received(1).AddTechType(Arg.Any<Assembly>(), "classId", "friendlyName", "description", true);
}

private class SimpleTestPdaItem : PdaItem
Expand All @@ -78,8 +80,8 @@ public SimpleTestPdaItem(string classId, string friendlyName, string description
{
}

public override TechGroup GroupForPDA { get; } = TechGroup.Cyclops;
public override TechCategory CategoryForPDA { get; } = TechCategory.Cyclops;
public override TechGroup GroupForPDA { get; } = TechGroup.Constructor;
public override TechCategory CategoryForPDA { get; } = TechCategory.Constructor;

public override GameObject GetGameObject()
{
Expand Down
10 changes: 6 additions & 4 deletions SMLHelper.Tests/SMLHelper.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
<HintPath>$(Dependencies)\Assembly-CSharp_publicized.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SMLHelper">
<HintPath>..\SMLHelper\bin\$(Configuration)\SMLHelper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -93,6 +89,12 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SMLHelper\SMLHelper.csproj">
<Project>{418502dd-372d-4ef9-8021-b262552dfede}</Project>
<Name>SMLHelper</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
8 changes: 5 additions & 3 deletions SMLHelper.Tests/SpawnableTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SMLHelper.Tests.AssestClassTests
using System.Reflection;

namespace SMLHelper.Tests.AssestClassTests
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -56,7 +58,7 @@ public void Patch_EventsInvokedInCorrectOrder()
const TechType createdTechType = TechType.Accumulator;

_mockTechTypeHandler
.AddTechType(Arg.Any<string>(), Arg.Do<string>((c) => _recordedEvents.Add("AddTechType")), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>())
.AddTechType(Arg.Any<Assembly>(), Arg.Do<string>((c) => _recordedEvents.Add("AddTechType")), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>())
.Returns(createdTechType);

_mockPrefabHandler.RegisterPrefab(Arg.Do<Spawnable>((s) => _recordedEvents.Add("RegisterPrefab")));
Expand All @@ -83,7 +85,7 @@ public void Patch_WhenSizeDifferent_CallsSetItemSize()
// ARRANGE
const TechType createdTechType = TechType.Accumulator;

_mockTechTypeHandler.AddTechType(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>())
_mockTechTypeHandler.AddTechType(Arg.Any<Assembly>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<bool>())
.Returns(createdTechType);

var customSize = new Vector2int(2, 2);
Expand Down
Loading

0 comments on commit 9ea3579

Please sign in to comment.