Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve move world branch. #8

Draft
wants to merge 13 commits into
base: move-world
Choose a base branch
from
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
{
"name": "C# (.NET)",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/dotnet/framework/sdk:4.8",
"features": {

}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],
// "portsAttributes": {
// "5001": {
// "protocol": "https"
// }
// }

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
68 changes: 43 additions & 25 deletions TerrainPatcher.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="netstandard2.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<LangVersion>8.0</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<WarningLevel>4</WarningLevel>
<OutputPath>bin/$(Configuration)</OutputPath>
<ProjectGuid>{CB2BA057-FC79-4FD3-A80B-90380681F75D}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<Optimize>false</Optimize>
Expand All @@ -19,60 +21,76 @@
<DocumentationFile>bin/Release/TerrainPatcher.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="Assembly-CSharp">
<HintPath>references\Assembly-CSharp-publicized.refasm.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>references\Assembly-CSharp-firstpass-publicized.refasm.dll</HintPath>
</Reference>
<Reference Include="SMLHelper">
<HintPath>..\..\.var\app\com.valvesoftware.Steam\.local\share\Steam\steamapps\common\Subnautica\BepInEx\plugins\Modding Helper\SMLHelper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="BepInEx">
<HintPath>references/BepInEx.refasm.dll</HintPath>
</Reference>
<Reference Include="0Harmony">
<HintPath>references/0Harmony.refasm.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>references/Assembly-CSharp-publicized.refasm.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>references/Assembly-CSharp-firstpass-publicized.refasm.dll</HintPath>
<Reference Include="Unity.Addressables">
<HintPath>..\..\.var\app\com.valvesoftware.Steam\.local\share\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\Unity.Addressables.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>references/UnityEngine.refasm.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>references/UnityEngine.CoreModule.refasm.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AIModule">
<HintPath>references/UnityEngine.AIModule.refasm.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>references/UnityEngine.InputLegacyModule.refasm.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>references/UnityEngine.ParticleSystemModule.refasm.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>references/UnityEngine.PhysicsModule.refasm.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VFXModule">
<HintPath>references/UnityEngine.VFXModule.refasm.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="src/Mod.cs"/>
<Compile Include="src/Terrain.cs"/>
<Compile Include="src/FileLoading.cs"/>
<Compile Include="src/Patches.cs"/>
<Compile Include="src/MoveWorld.cs"/>
<Compile Include="src/Mod.cs" />
<Compile Include="src/Terrain.cs" />
<Compile Include="src/FileLoading.cs" />
<Compile Include="src/Patches.cs" />
<Compile Include="src/MoveWorld.cs" />
<Compile Include="src\tracker.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets"/>
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />
<Target Name="CopyToTargetDir" AfterTargets="Build">
<Copy SourceFiles="$(TargetPath);LICENSE;$(DocumentationFile)" DestinationFolder="target/$(Configuration)"/>
<Copy SourceFiles="dist-readme.md" DestinationFiles="target/$(Configuration)/README.md"/>
<WriteLinesToFile File="target/$(Configuration)/load-order.txt" Overwrite="True"/>
<MakeDir Directories="target/$(Configuration)/patches"/>
<Copy SourceFiles="$(TargetPath);LICENSE;$(DocumentationFile)" DestinationFolder="target/$(Configuration)" />
<Copy SourceFiles="dist-readme.md" DestinationFiles="target/$(Configuration)/README.md" />
<WriteLinesToFile File="target/$(Configuration)/load-order.txt" Overwrite="True" />
<MakeDir Directories="target/$(Configuration)/patches" />
</Target>
<Target Name="CopyToModsDir" AfterTargets="CopyToTargetDir" Condition="'$(Configuration)' == 'Debug' And Exists('game-dirs.txt')">
<ReadLinesFromFile File="game-dirs.txt">
<Output TaskParameter="Lines" ItemName="GameDirs"/>
<Output TaskParameter="Lines" ItemName="GameDirs" />
</ReadLinesFromFile>
<CreateItem Include="target/$(Configuration)/*">
<Output TaskParameter="Include" ItemName="TargetFiles"/>
<Output TaskParameter="Include" ItemName="TargetFiles" />
</CreateItem>
<CreateProperty Value="BepInEx/plugins/$(ProjectName)">
<Output TaskParameter="Value" PropertyName="PluginDir"/>
<Output TaskParameter="Value" PropertyName="PluginDir" />
</CreateProperty>
<Copy SourceFiles="@(TargetFiles)" DestinationFolder="%(GameDirs.Identity)/$(PluginDir)"/>
<MakeDir Directories="%(GameDirs.Identity)/$(PluginDir)/patches"/>
<Copy SourceFiles="@(TargetFiles)" DestinationFolder="%(GameDirs.Identity)/$(PluginDir)" />
<MakeDir Directories="%(GameDirs.Identity)/$(PluginDir)/patches" />
</Target>
<Target Name="ZipDist" AfterTargets="CopyToTargetDir" Condition="'$(Configuration)' == 'Release'">
<ZipDirectory SourceDirectory="target/$(Configuration)" DestinationFile="target/dist.zip" Overwrite="True"/>
<ZipDirectory SourceDirectory="target/$(Configuration)" DestinationFile="target/dist.zip" Overwrite="True" />
</Target>
</Project>
Binary file added references/UnityEngine.AIModule.refasm.dll
Binary file not shown.
Binary file not shown.
Binary file added references/UnityEngine.VFXModule.refasm.dll
Binary file not shown.
61 changes: 53 additions & 8 deletions src/Mod.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,85 @@
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting.Channels;
using BepInEx;
using BepInEx.Logging;
using DefaultNamespace;
using HarmonyLib;
using SMLHelper.V2.Handlers;
using SMLHelper.V2.Json;
using SMLHelper.V2.Json.Attributes;
using UnityEngine;
using UnityEngine.SceneManagement;
using UWE;

namespace TerrainPatcher
{
[BepInPlugin("Esper89.TerrainPatcher", "Terrain Patcher", "1.0.0")]
internal class Mod : BaseUnityPlugin
{
public static Vector3 oldoffset = Vector3.zero;

public static bool isloading = false;
// Initializes the mod.
private void Awake()
{
new Harmony("Esper89/TerrainPatcher").PatchAll();
var harmony = new Harmony("Esper89/TerrainPatcher");
LOGGER = this.Logger;
harmony.PatchAll();
FileLoading.FindAndLoadPatches();

var data = SaveDataHandler.Main.RegisterSaveDataCache<StorePos>();
data.OnFinishedLoading += (object sender, JsonFileEventArgs e) =>
{
var thedata = e.Instance as StorePos;
Player.main.transform.position += thedata.offsetpos;
twoloop.OriginShift.Recenter();
oldoffset = thedata.offsetpos;
};
data.OnStartedSaving += (object sender, JsonFileEventArgs e) =>
{
var tosave = e.Instance as StorePos;
tosave.offsetpos = twoloop.OriginShift.LocalOffset.ToVector3();
};
LogInfo("Done loading!");
}

private static ManualLogSource? LOGGER;

private void Update()
public void Update()
{
if (Input.GetKeyDown(KeyCode.F9))
if (Input.GetKeyUp(KeyCode.F9))
{
MoveWorld.Move(new Vector3(100.0f, 0.0f, 100.0f));
twoloop.OriginShift.Recenter();
}
}
private static ManualLogSource? LOGGER;



internal static void LogInfo(string message) => LOGGER!.LogInfo(message);
internal static void LogWarning(string message) => LOGGER!.LogWarning(message);
internal static void LogError(string message) => LOGGER!.LogError(message);
}
[FileName("Terrain_Patcher_Save_Offset")]
internal class StorePos : SaveDataCache
{
public Vector3 offsetpos { get; set; }
}
public static class WaitFor
{
public static IEnumerator Frames(int frameCount)
{
if (frameCount <= 0)
{
throw new ArgumentOutOfRangeException("frameCount", "Cannot wait for less that 1 frame");
}

while (frameCount > 0)
{
frameCount--;
yield return null;
}
}
}
internal static class Constants
{
// The current version number of the optoctreepatch format.
Expand Down
Loading