Skip to content

Commit

Permalink
Refactor build system... again
Browse files Browse the repository at this point in the history
This is the last time I ever want to have to do this. This was awful, but it works. And it works *so* well.
  • Loading branch information
Insprill committed Jun 16, 2023
1 parent 13315b4 commit 40462ef
Show file tree
Hide file tree
Showing 61 changed files with 231 additions and 120 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ Mapify_*.zip
# User-specific refrence paths
Directory.Build.targets

# User-specific environment variables
.env*
# User-specific properties
UserProperties.props

# Custom map used for testing
TestMap/
Expand Down
5 changes: 0 additions & 5 deletions Mapify.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBD}") = "MapifyEditor", "MapifyEdito
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Release|Any CPU.Build.0 = Release|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79983}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Release|Any CPU.Build.0 = Release|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57D181A9-9D9D-4EBA-BBDD-9172EEB79984}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Mapify/Components/DisableOnAwake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Mapify.Components
{
/// <summary>
/// Disables the attached <see cref="GameObject"/> when Awake is called.
/// Disables the attached <see cref="GameObject" /> when Awake is called.
/// </summary>
public class DisableOnAwake : MonoBehaviour
{
Expand Down
4 changes: 2 additions & 2 deletions Mapify/Map/Maps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static class Maps

public static MapInfo LoadedMap {
get {
if (_loadedMap == null) throw new InvalidOperationException("No map has been loaded!");

if (_loadedMap == null)
throw new InvalidOperationException("No map has been loaded!");
return _loadedMap;
}
private set => _loadedMap = value;
Expand Down
2 changes: 1 addition & 1 deletion Mapify/Mapify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void Awake()
}
catch (Exception ex)
{
LogException($"Failed to load", ex);
LogException("Failed to load", ex);
Destroy(this);
}
}
Expand Down
15 changes: 5 additions & 10 deletions Mapify/Mapify.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../UserProperties.props" Condition="Exists('../UserProperties.props')"/>
<PropertyGroup>
<TargetFramework>netframework4.8</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<RootNamespace>Mapify</RootNamespace>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../MapifyEditor/MapifyEditor.csproj"/>
</ItemGroup>
Expand Down Expand Up @@ -50,10 +47,8 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="mkdir -p ../build &amp;&amp; cp &quot;$(TargetPath)&quot; ../build/"/>
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="../copy_build $(ProjectDir)"/>

<Exec Condition="'$(OS)' == 'Windows_NT'" Command="xcopy /d /y &quot;$(TargetPath)&quot; ..\build\"/>
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="setlocal enabledelayedexpansion &amp;&amp; set DEST=C:\Program Files (x86)\Steam\steamapps\common\Derail Valley\Mods\Mapify &amp;&amp; if exist !DEST! xcopy /d /y &quot;$(TargetPath)&quot; &quot;!DEST!&quot;"/>
<!-- Copy files -->
<Copy SourceFiles="$(TargetPath)" DestinationFolder="../build/runtime"/>
<Copy Condition="'$(IsEditor)' != 'true' And Exists('$(DvInstallDir)')" SourceFiles="$(TargetPath)" DestinationFolder="$(DvInstallDir)"/>
</Target>
</Project>
2 changes: 1 addition & 1 deletion Mapify/SceneInitializers/RailwaySceneInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static void CreateJunction(Switch sw)
{
Transform swTransform = sw.transform;
VanillaAsset vanillaAsset = sw.GetComponent<VanillaObject>().asset;
GameObject prefabClone = AssetCopier.Instantiate(vanillaAsset, active: false);
GameObject prefabClone = AssetCopier.Instantiate(vanillaAsset, false);
Transform prefabCloneTransform = prefabClone.transform;
Transform inJunction = prefabCloneTransform.Find("in_junction");
Vector3 offset = prefabCloneTransform.position - inJunction.position;
Expand Down
3 changes: 2 additions & 1 deletion Mapify/Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ public static float ScaleNumber(this float value, float minValue, float maxValue
#region DV

private static readonly MethodInfo CommandArg_Method_TypeError = AccessTools.DeclaredMethod(typeof(CommandArg), "TypeError", new[] { typeof(string) });
private static readonly MethodInfo DisplayLoadingInfo_Method_OnLoadingStatusChanged = AccessTools.DeclaredMethod(typeof(DisplayLoadingInfo), "OnLoadingStatusChanged", new[] { typeof(string), typeof(bool), typeof(float) });
private static readonly MethodInfo DisplayLoadingInfo_Method_OnLoadingStatusChanged =
AccessTools.DeclaredMethod(typeof(DisplayLoadingInfo), "OnLoadingStatusChanged", new[] { typeof(string), typeof(bool), typeof(float) });

public static double Double(this CommandArg arg)
{
Expand Down
2 changes: 2 additions & 0 deletions MapifyEditor/BezierCurves/BezierCurveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This script was adapted from the free Unity Asset Store asset "Bezier Curve Edit
*/

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -251,3 +252,4 @@ public static void DrawOtherPoints(BezierCurve curve, BezierPoint caller)
}
}
}
#endif
2 changes: 2 additions & 0 deletions MapifyEditor/BezierCurves/BezierPointEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This script was adapted from the free Unity Asset Store asset "Bezier Curve Edit
*/

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -178,3 +179,4 @@ private static void HandleAbsent(BezierPoint p)
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/BuildUpdaters/BuildUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -109,3 +110,4 @@ private static BuildUpdater[] FindUpdaters()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;
Expand Down Expand Up @@ -36,3 +37,4 @@ protected override void Cleanup(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;
using UnityEngine;
Expand Down Expand Up @@ -63,3 +64,4 @@ protected override void Cleanup(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mapify.Editor.Utils;
#if UNITY_EDITOR
using Mapify.Editor.Utils;
using UnityEngine;

namespace Mapify.Editor.StateUpdaters
Expand All @@ -15,3 +16,4 @@ protected override void Update(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
#if UNITY_EDITOR
using System.Linq;
using Mapify.Editor.Utils;

namespace Mapify.Editor.StateUpdaters
Expand All @@ -12,3 +13,4 @@ protected override void Update(Scenes scenes)
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/BuildUpdaters/Railway/SwitchUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mapify.Editor.Utils;
#if UNITY_EDITOR
using Mapify.Editor.Utils;

namespace Mapify.Editor.StateUpdaters
{
Expand All @@ -20,3 +21,4 @@ protected override void Update(Scenes scenes)
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/BuildUpdaters/Railway/TrackUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mapify.Editor.Utils;
#if UNITY_EDITOR
using Mapify.Editor.Utils;

namespace Mapify.Editor.StateUpdaters
{
Expand All @@ -21,3 +22,4 @@ protected override void Update(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Mapify.Editor.Utils;
using UnityEngine;

#if UNITY_EDITOR
namespace Mapify.Editor.StateUpdaters
{
public class StreamingUpdater : BuildUpdater
Expand All @@ -18,3 +19,4 @@ protected override void Cleanup(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Mapify.Editor.Utils;
#if UNITY_EDITOR

using Mapify.Editor.Utils;
using UnityEngine;

namespace Mapify.Editor.StateUpdaters
Expand Down Expand Up @@ -28,3 +30,4 @@ protected override void Update(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Linq;
using Mapify.Editor.Utils;
using UnityEngine;
Expand All @@ -16,3 +17,4 @@ protected override void Update(Scenes scenes)
}
}
}
#endif
2 changes: 2 additions & 0 deletions MapifyEditor/Export/Gui/ExportMapGui.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -69,3 +70,4 @@ private void OnGUI()
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/Gui/MapValidationGui.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;
using Mapify.Editor.Validators;
Expand Down Expand Up @@ -79,3 +80,4 @@ private void DrawResults(IEnumerable<Result> results, string color, GUIStyle sty
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/MapExporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -245,3 +246,4 @@ private static string GetLinuxMapsFolder()
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/Validators/GameContent/LightValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;
using UnityEngine;
Expand All @@ -16,3 +17,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;
using UnityEngine;
Expand Down Expand Up @@ -40,3 +41,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;

Expand Down Expand Up @@ -53,3 +54,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/Validators/GameContent/StoreValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;

Expand Down Expand Up @@ -45,3 +46,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor.Utils;

Expand Down Expand Up @@ -27,3 +28,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
4 changes: 3 additions & 1 deletion MapifyEditor/Export/Validators/Project/MapInfoValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Mapify.Editor;
using Mapify.Editor.Utils;
Expand Down Expand Up @@ -44,3 +45,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using Mapify.Editor;
using Mapify.Editor.Validators;
Expand All @@ -13,3 +14,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using Mapify.Editor;
using Mapify.Editor.Validators;
Expand All @@ -21,3 +22,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Collections.Generic;
using Mapify.Editor;
using Mapify.Editor.Utils;
using Mapify.Editor.Validators;
Expand All @@ -23,3 +24,4 @@ protected override IEnumerator<Result> Validate(Scenes scenes)
}
}
}
#endif
Loading

0 comments on commit 40462ef

Please sign in to comment.