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
12 changes: 11 additions & 1 deletion OCDheim/OCDheim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace OCDheim
{
[BepInDependency(Jotunn.Main.ModGuid)]
[BepInPlugin("dymek.dev.OCDheim", "OCDheim", "0.1.2")]
[BepInPlugin("dymek.dev.OCDheim", "OCDheim", "0.1.3")]
[NetworkCompatibility(CompatibilityLevel.EveryoneMustHaveMod, VersionStrictness.Minor)]
public class OCDheim : BaseUnityPlugin
{
Expand Down Expand Up @@ -41,6 +41,10 @@ private void AddOCDheimToolPieces()

private void AddToolPiece<TOverlayVisualizer>(string pieceName, string basePieceName, string pieceTable, Texture2D iconTexture, bool level = false, bool raise = false, bool smooth = false, bool paint = false) where TOverlayVisualizer: OverlayVisualizer
{
var pieceExists = PieceManager.Instance.GetPiece(pieceName) != null;
if (pieceExists)
return;

var pieceIcon = Sprite.Create(iconTexture, new Rect(0, 0, iconTexture.width, iconTexture.height), Vector2.zero);
var piece = new CustomPiece(pieceName, basePieceName, new PieceConfig
{
Expand All @@ -56,6 +60,8 @@ private void AddToolPiece<TOverlayVisualizer>(string pieceName, string basePiece
settings.m_paintCleared = paint;
piece.PiecePrefab.AddComponent<TOverlayVisualizer>();



PieceManager.Instance.AddPiece(piece);
}

Expand All @@ -71,6 +77,10 @@ private void AddOCDheimBuildPieces()

private void AddBrickBuildPiece(string brickSuffix, Vector3 brickScale, int brickPrice, Texture2D iconTexture)
{
var pieceExists = PieceManager.Instance.GetPiece($"stone_floor_{brickSuffix}") != null;
if (pieceExists)
return;

var brick = PrefabManager.Instance.CreateClonedPrefab($"stone_floor_{brickSuffix}", "stone_floor_2x2");
var brickIcon = Sprite.Create(iconTexture, new Rect(0, 0, iconTexture.width, iconTexture.height), Vector2.zero);
brick.transform.localScale = brickScale;
Expand Down
68 changes: 41 additions & 27 deletions OCDheim/OCDheim.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\JotunnLib.2.10.0\build\JotunnLib.props" Condition="Exists('..\packages\JotunnLib.2.10.0\build\JotunnLib.props')" />
<Import Project="..\packages\JotunnLib.2.12.1\build\JotunnLib.props" Condition="Exists('..\packages\JotunnLib.2.12.1\build\JotunnLib.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -45,32 +45,20 @@
<StartWorkingDirectory>$(VALHEIM_INSTALL)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.10.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HarmonyX.2.10.1\lib\net45\0Harmony.dll</HintPath>
<Reference Include="0Harmony">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Jotunn, Version=2.10.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\JotunnLib.2.10.0\lib\net462\Jotunn.dll</HintPath>
<Reference Include="assembly_utils">
<HintPath>..\..\VapokModBase\References\Valheim\0.216.9\assembly_utils_publicized.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.dll</HintPath>
<Reference Include="assembly_valheim">
<HintPath>..\..\VapokModBase\References\Valheim\0.216.9\assembly_valheim_publicized.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
<Reference Include="BepInEx">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="MonoMod, Version=22.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.22.5.1.1\lib\net452\MonoMod.exe</HintPath>
</Reference>
<Reference Include="MonoMod.RuntimeDetour, Version=22.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.RuntimeDetour.22.5.1.1\lib\net452\MonoMod.RuntimeDetour.dll</HintPath>
</Reference>
<Reference Include="MonoMod.Utils, Version=22.5.1.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.Utils.22.5.1.1\lib\net452\MonoMod.Utils.dll</HintPath>
<Reference Include="Jotunn, Version=2.12.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\JotunnLib.2.12.1\lib\net462\Jotunn.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -79,6 +67,33 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="ui_lib">
<HintPath>..\..\VapokModBase\References\Valheim\0.216.9\ui_lib_publicized.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\VapokModBase\References\BepInEx\5.4.2103\unstripped_corlib\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PreciseBuildPieceSnapper.cs" />
Expand All @@ -105,7 +120,6 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Package\plugins\" />
Expand All @@ -118,7 +132,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="JotunnPostBuildTaskWin" Condition="'$(OS)' == 'Windows_NT'">
<Exec Command="powershell.exe -ExecutionPolicy RemoteSigned -File &quot;$(SolutionDir)publish.ps1&quot; -Target &quot;$(ConfigurationName)&quot; -TargetPath &quot;$(TargetDir.TrimEnd('\'))&quot; -TargetAssembly &quot;$(TargetFileName)&quot; -ValheimPath &quot;$(VALHEIM_INSTALL.TrimEnd('\'))&quot; -DeployPath &quot;$(MOD_DEPLOYPATH.TrimEnd('\'))&quot; -ProjectPath &quot;$(ProjectDir.TrimEnd('\'))&quot; " />
<Exec Command="xcopy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;G:\Steam\steamapps\common\Valheim-Dev\BepInEx\plugins\$(ProjectName)\&quot; /q /y /i" />
</Target>
<PropertyGroup>
<BuildDependsOn>
Expand All @@ -128,8 +142,8 @@
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\JotunnLib.2.10.0\build\JotunnLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\JotunnLib.2.10.0\build\JotunnLib.props'))" />
<Error Condition="!Exists('..\packages\JotunnLib.2.12.1\build\JotunnLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\JotunnLib.2.12.1\build\JotunnLib.props'))" />
</Target>
</Project>
12 changes: 10 additions & 2 deletions OCDheim/PreciseBuildPieceSnapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OCDheim
{
[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
[HarmonyPatch(typeof(Player), nameof(Player.UpdatePlacementGhost))]
public static class PreciseBuildPieceSnapper
{
private const float NeighbourhoodSize = 3.5f;
Expand Down Expand Up @@ -110,11 +110,19 @@ private static Vector3 DeterminePerpendicularToPlayerPoVOn(Vector3 snapNode, int
return rayHit.normal;
}

private static void GetAllPiecesInRadius(Vector3 p, float radius, List<Piece> pieces)
{
foreach (Piece allPiece in Piece.s_allPieces)
{
if (allPiece.gameObject.layer != Piece.s_ghostLayer && (double) Vector3.Distance(p, allPiece.transform.position) < radius)
pieces.Add(allPiece);
}
}
private static List<Piece> FindNeighbourPieces(Vector3 playerPoV)
{
neighbourPieces.Clear();
snappableNeighbourPieces.Clear();
Piece.GetAllPiecesInRadius(playerPoV, NeighbourhoodSize, neighbourPieces);
GetAllPiecesInRadius(playerPoV, (float)NeighbourhoodSize, neighbourPieces);
foreach (var neighbourPiece in neighbourPieces)
{
if (neighbourPiece.IsSnappablePiece())
Expand Down
4 changes: 2 additions & 2 deletions OCDheim/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// 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("0.0.1.0")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyVersion("0.1.3.0")]
[assembly: AssemblyFileVersion("0.1.3.0")]

10 changes: 9 additions & 1 deletion OCDheim/Visualization/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ public class Overlay
public Vector3 locPosition { get { return transform.localPosition; } set { transform.localPosition = value; } }
public Quaternion rotation { get { return transform.rotation; } set { transform.rotation = value; } }
public Color color { get { ps.GetParticles(particles, 2); return particles[1].GetCurrentColor(ps); } }
public Color startColor { get { return ps.startColor; } set { ps.startColor = value; } }
public Color startColor
{
get { return psm.startColor.color; }
set
{
var psmainStartColor = psm.startColor;
psmainStartColor.color = value;
}
}
public float startSize { get { return psm.startSize.constant; } set { var psMain = ps.main; psMain.startSize = value; } }
public float startSpeed { get { return psm.startSize.constant; } set { var psMain = ps.main; psMain.startSpeed = value; } }
public float startLifetime { get { return psm.startLifetime.constant; } set { var psMain = ps.main; psMain.startLifetime = value; } }
Expand Down
26 changes: 19 additions & 7 deletions OCDheim/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Mono.Cecil" publicKeyToken="50cebf1cceb9d05e" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-0.11.4.0" newVersion="0.11.4.0"/>
<assemblyIdentity name="Mono.Cecil" publicKeyToken="50cebf1cceb9d05e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.11.4.0" newVersion="0.11.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Mono.Cecil.Mdb" publicKeyToken="50cebf1cceb9d05e" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-0.10.4.0" newVersion="0.10.4.0"/>
<assemblyIdentity name="Mono.Cecil.Mdb" publicKeyToken="50cebf1cceb9d05e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.10.4.0" newVersion="0.10.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Mono.Cecil.Pdb" publicKeyToken="50cebf1cceb9d05e" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-0.10.4.0" newVersion="0.10.4.0"/>
<assemblyIdentity name="Mono.Cecil.Pdb" publicKeyToken="50cebf1cceb9d05e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.10.4.0" newVersion="0.10.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="0Harmony" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.10.1.0" newVersion="2.10.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MonoMod.RuntimeDetour" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-22.5.1.1" newVersion="22.5.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MonoMod.Utils" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-22.5.1.1" newVersion="22.5.1.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration>
7 changes: 1 addition & 6 deletions OCDheim/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HarmonyX" version="2.10.1" targetFramework="net462" />
<package id="JotunnLib" version="2.10.0" targetFramework="net462" />
<package id="Mono.Cecil" version="0.11.4" targetFramework="net462" />
<package id="MonoMod" version="22.5.1.1" targetFramework="net462" />
<package id="MonoMod.RuntimeDetour" version="22.5.1.1" targetFramework="net462" />
<package id="MonoMod.Utils" version="22.5.1.1" targetFramework="net462" />
<package id="JotunnLib" version="2.12.1" targetFramework="net48" />
</packages>
6 changes: 6 additions & 0 deletions OCDheimUnity/.vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
33 changes: 0 additions & 33 deletions OCDheimUnity/Assets/Assemblies/Assembly-CSharp.dll.meta

This file was deleted.

33 changes: 0 additions & 33 deletions OCDheimUnity/Assets/Assemblies/assembly_googleanalytics.dll.meta

This file was deleted.

33 changes: 0 additions & 33 deletions OCDheimUnity/Assets/Assemblies/assembly_guiutils.dll.meta

This file was deleted.

Loading