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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,7 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml
SubnauticaModSystem/AutosortLockersSML/BZ/AutosortLockersSML.dll
SubnauticaModSystem/AutosortLockersSML/BZ/AutosortLockersSML.dll
*.dll
*.xml
106 changes: 95 additions & 11 deletions SubnauticaModSystem/AutosortLockers/AutosortLocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
using SMLHelper.V2.Crafting;
using UnityEngine;
using UnityEngine.UI;
using UWE;
#if SUBNAUTICA
using RecipeData = SMLHelper.V2.Crafting.TechData;
using Sprite = Atlas.Sprite;
#elif BELOWZERO
using TMPro;
#endif


namespace AutosortLockers
{
Expand All @@ -28,10 +36,17 @@ public class AutosortLocker : MonoBehaviour
private Image background;
[SerializeField]
private Image icon;
#if SUBNAUTICA
[SerializeField]
private Text text;
[SerializeField]
private Text sortingText;
#elif BELOWZERO
[SerializeField]
private TextMeshProUGUI text;
[SerializeField]
private TextMeshProUGUI sortingText;
#endif
[SerializeField]
private bool isSorting;
[SerializeField]
Expand Down Expand Up @@ -302,6 +317,7 @@ public AutosortLockerBuildable()

public override TechCategory CategoryForPDA => TechCategory.InteriorModule;

#if SUBNAUTICA
public override GameObject GetGameObject()
{
GameObject originalPrefab = CraftData.GetPrefabForTechType(TechType.SmallLocker);
Expand Down Expand Up @@ -339,27 +355,95 @@ public override GameObject GetGameObject()

return prefab;
}
#endif

public override IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject)
{
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 1");
CoroutineTask<GameObject> task = CraftData.GetPrefabForTechTypeAsync(TechType.SmallLocker);
yield return task;

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 2");
GameObject originalPrefab = task.GetResult();
GameObject prefab = GameObject.Instantiate(originalPrefab);

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 3, prefab " + (prefab == null ? "is" : "is not") + " null");

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 4");
// TEST
StorageContainer container = prefab.GetComponent<StorageContainer>();
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 4.1, container.container is " + (container.container == null ? "is" : "is not") + " null");
container.width = Mod.config.AutosorterWidth;
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 4.2");
container.height = Mod.config.AutosorterHeight;
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 4.3");
container.Resize(Mod.config.AutosorterWidth, Mod.config.AutosorterHeight);

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 5");
var meshRenderers = prefab.GetComponentsInChildren<MeshRenderer>();
foreach (var meshRenderer in meshRenderers)
{
meshRenderer.material.color = new Color(1, 0, 0);
}

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 6");
var prefabText = prefab.GetComponentInChildren<TextMeshProUGUI>();
//Logger.Log($"AutosortLockerBuildable.GetGameObjectAsync: 6.1, prefabText == {prefabText.ToString()}");
var label = prefab.FindChild("Label");
DestroyImmediate(label);

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 7");
var autoSorter = prefab.AddComponent<AutosortLocker>();

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 8");
var canvas = LockerPrefabShared.CreateCanvas(prefab.transform);
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 8.1");
autoSorter.background = LockerPrefabShared.CreateBackground(canvas.transform);
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 8.2");
autoSorter.icon = LockerPrefabShared.CreateIcon(autoSorter.background.transform, MainColor, 40);
//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 8.3: prefabText " + (prefabText == null ? "is" : "is not") + " null");
autoSorter.text = LockerPrefabShared.CreateText(autoSorter.background.transform, prefabText, MainColor, 0, 14, "Autosorter");

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 9");
autoSorter.sortingText = LockerPrefabShared.CreateText(autoSorter.background.transform, prefabText, MainColor, -120, 12, "Sorting...");
#if SUBNAUTICA
autoSorter.sortingText.alignment = TextAnchor.UpperCenter;
#elif BELOWZERO
autoSorter.sortingText.alignment = TextAlignmentOptions.Top;
#endif

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 10");
autoSorter.background.gameObject.SetActive(false);
autoSorter.icon.gameObject.SetActive(false);
autoSorter.text.gameObject.SetActive(false);
autoSorter.sortingText.gameObject.SetActive(false);

//Logger.Log("AutosortLockerBuildable.GetGameObjectAsync: 11");
//return prefab;
gameObject.Set(prefab);
yield break;
}

protected override TechData GetBlueprintRecipe()
protected override RecipeData GetBlueprintRecipe()
{
return new TechData
return new RecipeData()
{
craftAmount = 1,
Ingredients = Mod.config.EasyBuild
? new List<Ingredient>
{
new Ingredient(TechType.Titanium, 2)
}
{
new Ingredient(TechType.Titanium, 2)
}
: new List<Ingredient>
{
new Ingredient(TechType.Titanium, 2),
new Ingredient(TechType.ComputerChip, 1),
new Ingredient(TechType.AluminumOxide, 2)
}
{
new Ingredient(TechType.Titanium, 2),
new Ingredient(TechType.ComputerChip, 1),
new Ingredient(TechType.AluminumOxide, 2)
}
};
}

protected override Atlas.Sprite GetItemSprite()
protected override Sprite GetItemSprite()
{
return SMLHelper.V2.Utility.ImageUtils.LoadSpriteFromFile(Mod.GetAssetPath("AutosortLocker.png"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?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')" />
<Import Project="..\GameDir.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -9,7 +10,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AutosortLockers</RootNamespace>
<AssemblyName>AutosortLockersSML</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<OutputPath>$(SolutionDir)$(AssemblyName)\$(Configuration)\</OutputPath>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -35,77 +37,104 @@
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'BZ|AnyCPU'">
<DefineConstants>BZ;BELOWZERO</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<GameDir>$(CommonDir)SubnauticaZero.Stable</GameDir>
<DataFolder>SubnauticaZero_Data</DataFolder>
<SMLHelperFolder>SMLHelper_BZ</SMLHelperFolder>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.1</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'SN1|AnyCPU'">
<DefineConstants>SN1;SUBNAUTICA_STABLE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<GameDir>$(CommonDir)Subnautica.Stable</GameDir>
<DataFolder>Subnautica_Data</DataFolder>
<SMLHelperFolder>Modding Helper</SMLHelperFolder>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.1</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony-1.2.0.1">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\0Harmony-1.2.0.1.dll</HintPath>
<Private>False</Private>
<Reference Include="0Harmony">
<HintPath>$(GameDir)\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\Newtonsoft.Json.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\NewtonSoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="QModInstaller">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\QModInstaller.dll</HintPath>
<HintPath>$(GameDir)\BepInEx\plugins\QModManager\QModInstaller.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SMLHelper">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\QMods\Modding Helper\SMLHelper.dll</HintPath>
<HintPath>$(GameDir)\QMods\$(SMLHelperFolder)\SMLHelper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="UnityEngine">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.Physics2DModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.Physics2DModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.Physics2DModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextCoreModule">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.TextCoreModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.TextCoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIElementsModule">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.UIElementsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>D:\SteamLibrary\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<HintPath>$(GameDir)\$(DataFolder)\Managed\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Unity.TextMeshPro" Condition="$(Configuration.Contains('BZ'))">
<HintPath>$(GameDir)\$(DataFolder)\Managed\Unity.TextMeshPro.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand All @@ -114,6 +143,7 @@
<Compile Include="AutosortTarget.cs" />
<Compile Include="AutosortLocker.cs" />
<Compile Include="AutosortTypePicker.cs" />
<Compile Include="CanvasLink_Patch.cs" />
<Compile Include="ColorPicker.cs" />
<Compile Include="ColorPickerButton.cs" />
<Compile Include="ColorPickerPageButton.cs" />
Expand All @@ -139,27 +169,22 @@
</Compile>
<Compile Include="SaveData.cs" />
</ItemGroup>
<ItemGroup>
<None Include="mod.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="mod_BZ.json" />
<None Include="mod_SN1.json" />
</ItemGroup>
<Import Project="..\Common\Common.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy $(TargetPath) D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(ProjectName)\ /q /y
xcopy $(ProjectDir)mod.json D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(ProjectName)\ /q /y
xcopy $(ProjectDir)Assets D:\SteamLibrary\steamapps\common\Subnautica\QMods\$(ProjectName)\Assets\ /q /y /i

xcopy $(TargetPath) D:\EpicGames\Subnautica\QMods\$(ProjectName)\ /q /y
xcopy $(ProjectDir)mod.json D:\EpicGames\Subnautica\QMods\$(ProjectName)\ /q /y
xcopy $(ProjectDir)Assets D:\EpicGames\Subnautica\QMods\$(ProjectName)\Assets\ /q /y /i</PostBuildEvent>
<PostBuildEvent>xcopy $(TargetPath) $(GameDir)\QMods\$(ProjectName)\ /q /y
copy $(ProjectDir)mod_$(ConfigurationName).json $(GameDir)\QMods\$(ProjectName)\mod.json /y
xcopy $(ProjectDir)Assets $(GameDir)\QMods\$(ProjectName)\Assets\ /q /y /i
</PostBuildEvent>
</PropertyGroup>
</Project>
Loading