Skip to content

Commit

Permalink
Fixes for the "Living Large" update.
Browse files Browse the repository at this point in the history
A first draft for the "Living Large" update. Tested successfully with the updated version of QMM (v4.5.0) & Cyclops Docking Mod.
  • Loading branch information
K07H committed Dec 18, 2022
1 parent 4124baa commit 25da9bf
Show file tree
Hide file tree
Showing 48 changed files with 90 additions and 265 deletions.
Binary file not shown.
Binary file not shown.
Binary file added Dependencies/Subnautica.stable/FMODUnity.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/Newtonsoft.Json.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.AudioModule.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.TextRenderingModule.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Example mod/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"Id": "SMLHelperExampleMod",
"DisplayName": "Example Mod For SMLHelper",
"Author": "The SMLHelper Dev Team",
"Version": "2.14.1",
"Version": "2.15.0",
"Enable": true,
"AssemblyName": "Example mod.dll",
"VersionDependencies": {
"SMLHelper": "2.14.1"
"SMLHelper": "2.15.0"
},
"Game": "Both",
"NitroxCompat": true
Expand Down
29 changes: 19 additions & 10 deletions SMLHelper/Assets/CustomFabricator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ protected CustomFabricator(string classId, string friendlyName, string descripti
/// <returns></returns>
public override GameObject GetGameObject()
{
#if SUBNAUTICA_EXP || BELOWZERO
#if BELOWZERO
return null;
#else
GameObject prefab = this.Model switch
{
Models.Fabricator => GameObject.Instantiate(CraftData.GetPrefabForTechType(TechType.Fabricator)),
Models.Workbench => GameObject.Instantiate(CraftData.GetPrefabForTechType(TechType.Workbench)),
Models.Fabricator => GameObject.Instantiate(CraftData.GetPrefabForTechTypeAsync(TechType.Fabricator).GetResult()),
Models.Workbench => GameObject.Instantiate(CraftData.GetPrefabForTechTypeAsync(TechType.Workbench).GetResult()),
#if SUBNAUTICA
Models.MoonPool => GameObject.Instantiate(Resources.Load<GameObject>("Submarine/Build/CyclopsFabricator")),
Models.MoonPool => GameObject.Instantiate(GetCyclopsFabricatorPrefab()),
#endif
Models.Custom => GetCustomCrafterPreFab(),
_ => null
Expand All @@ -169,6 +169,20 @@ public override GameObject GetGameObject()
#endif
}

#if SUBNAUTICA
private static GameObject _loadedCyclopsFabricatorPrefab = null;
private GameObject GetCyclopsFabricatorPrefab(bool forceReload = false)
{
if (_loadedCyclopsFabricatorPrefab == null || forceReload)
{
var cyclopsFabricatorRequest = AddressablesUtility.LoadAsync<GameObject>("Submarine/Build/CyclopsFabricator.prefab");
cyclopsFabricatorRequest.WaitForCompletion();
_loadedCyclopsFabricatorPrefab = cyclopsFabricatorRequest.Result;
}
return _loadedCyclopsFabricatorPrefab;
}
#endif

/// <summary>
/// The in-game <see cref="GameObject"/>, async way.
/// </summary>
Expand All @@ -191,12 +205,7 @@ public override IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject)
break;
#if SUBNAUTICA
case Models.MoonPool:
#pragma warning disable CS0618 // obsolete
var request = UWE.PrefabDatabase.GetPrefabForFilenameAsync("Submarine/Build/CyclopsFabricator.prefab");
#pragma warning restore CS0618
yield return request;
request.TryGetPrefab(out prefab);
prefab = GameObject.Instantiate(prefab);
prefab = GameObject.Instantiate(GetCyclopsFabricatorPrefab());
break;
#endif
case Models.Custom:
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Assets/FishPrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ public sealed override GameObject GetGameObject()
forces.handleGravity = true;
forces.underwaterDrag = 1f;
forces.underwaterGravity = 0;
#if BELOWZERO || SUBNAUTICA_EXP
forces.waterDepth = Ocean.GetOceanLevel();
#else
forces.waterDepth = Ocean.main.GetOceanLevel();
#endif
forces.enabled = false;
forces.enabled = true;

Expand Down
2 changes: 0 additions & 2 deletions SMLHelper/Assets/ModPrefabRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ public bool MoveNext()

public void Reset() {}

#if BELOWZERO || SUBNAUTICA_EXP
public void Release()
{
}
#endif
}
}
4 changes: 0 additions & 4 deletions SMLHelper/Handlers/CoordinatedSpawnsHandler.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Handlers
{
Expand Down
4 changes: 1 addition & 3 deletions SMLHelper/Interfaces/IBasicText.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#if BELOWZERO
using Text = TMPro.TextMeshPro;
using Text = TMPro.TextMeshPro;
using Font = TMPro.TMP_FontAsset;
using FontStyle = TMPro.FontStyles;
#endif

using UnityEngine;

Expand Down
5 changes: 0 additions & 5 deletions SMLHelper/Json/ConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
using System.IO;
using System.Reflection;
using System.Linq;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
using Oculus.Newtonsoft.Json.Converters;
#else
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
#endif

namespace SMLHelper.V2.Json
{
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Json/Converters/FloatConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
{
using System;
using System.Globalization;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

/// <summary>
/// A <see cref="JsonConverter"/> for rounding floats or doubles to a given number of decimal places,
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Json/Converters/KeyCodeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
using System;
using SMLHelper.V2.Utility;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

/// <summary>
/// A <see cref="JsonConverter"/> for handling <see cref="KeyCode"/>s.
Expand Down
5 changes: 1 addition & 4 deletions SMLHelper/Json/Converters/QuaternionConverter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json.Converters
{
/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions SMLHelper/Json/Converters/Vector2Converter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json.Converters
{
/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions SMLHelper/Json/Converters/Vector2IntConverter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json.Converters
{
/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions SMLHelper/Json/Converters/Vector3Converter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json.Converters
{
/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions SMLHelper/Json/Converters/Vector3IntConverter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json.Converters
{
/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions SMLHelper/Json/Converters/Vector4Converter.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using UnityEngine;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json.Converters
{
/// <summary>
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Json/ExtensionMethods/JsonExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
namespace SMLHelper.V2.Json.ExtensionMethods
{
using SMLHelper.V2.Utility;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

/// <summary>
/// Extension methods for parsing objects as JSON data.
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Json/Interfaces/IJsonFile.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
namespace SMLHelper.V2.Json.Interfaces
{
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

/// <summary>
/// A simple interface for a JSON file framework.
Expand Down
5 changes: 0 additions & 5 deletions SMLHelper/Json/JsonFile.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Linq;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
using Oculus.Newtonsoft.Json.Converters;
#else
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
#endif

namespace SMLHelper.V2.Json
{
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Json/SaveDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
using System;
using System.IO;
using System.Reflection;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

namespace SMLHelper.V2.Json
{
Expand Down
8 changes: 0 additions & 8 deletions SMLHelper/Options/Attributes/ConfigFileMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@
using System.Reflection;
using UnityEngine;
using Logger = Logger;
#if SUBNAUTICA
using Text = UnityEngine.UI.Text;
#elif BELOWZERO
using Text = TMPro.TextMeshProUGUI;
#endif
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif

internal class ConfigFileMetadata<T> where T : ConfigFile, new()
{
Expand Down
13 changes: 0 additions & 13 deletions SMLHelper/Options/KeybindModOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
using SMLHelper.V2.Utility;
using UnityEngine;
using UnityEngine.Events;
#if SUBNAUTICA
using Text = UnityEngine.UI.Text;
#elif BELOWZERO
using Text = TMPro.TextMeshProUGUI;
#endif

/// <summary>
/// Contains all the information about a keybind changed event.
Expand Down Expand Up @@ -139,11 +135,6 @@ internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
// Update bindings
binding.device = Device;
binding.value = KeyCodeUtils.KeyCodeToString(Key);
#if SUBNAUTICA
binding.onValueChanged.RemoveAllListeners();
var callback = new UnityAction<KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));
binding.onValueChanged.AddListener(new UnityAction<string>((string s) => callback?.Invoke(KeyCodeUtils.StringToKeyCode(s))));
#elif BELOWZERO
binding.gameObject.EnsureComponent<ModBindingTag>();
binding.bindingSet = GameInput.BindingSet.Primary;
binding.bindCallback = new Action<GameInput.Device, GameInput.Button, GameInput.BindingSet, string>((_, _1, _2, s) =>
Expand All @@ -152,15 +143,11 @@ internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
parentOptions.OnKeybindChange(Id, KeyCodeUtils.StringToKeyCode(s));
binding.RefreshValue();
});
#endif

base.AddToPanel(panel, tabIndex);
}

#if BELOWZERO
internal class ModBindingTag: MonoBehaviour { };
#endif


private class BindingOptionAdjust: ModOptionAdjust
{
Expand Down
4 changes: 0 additions & 4 deletions SMLHelper/Options/ModOptionTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ internal class ModOptionTooltip : MonoBehaviour, ITooltip

void Awake() => Destroy(GetComponent<LayoutElement>());

#if BELOWZERO
public bool showTooltipOnDrag => true;

public void GetTooltip(TooltipData tooltip)
{
tooltip.prefix.Append(Tooltip);
}
#else
public void GetTooltip(out string tooltipText, List<TooltipIcon> _) => tooltipText = Tooltip;
#endif
}
}
8 changes: 0 additions & 8 deletions SMLHelper/Options/SliderModOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
#if SUBNAUTICA
using Text = UnityEngine.UI.Text;
#elif BELOWZERO
using Text = TMPro.TextMeshProUGUI;
#endif

/// <summary>
/// Contains all the information about a slider changed event.
Expand Down Expand Up @@ -166,11 +162,7 @@ internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
});
#endif

#if SUBNAUTICA
panel.AddSliderOption(tabIndex, Label, Value, MinValue, MaxValue, DefaultValue, callback);
#elif BELOWZERO
panel.AddSliderOption(tabIndex, Label, Value, MinValue, MaxValue, DefaultValue, Step, callback, SliderLabelMode.Default, "0.0");
#endif

// AddSliderOption for some reason doesn't return created GameObject, so we need this little hack
Transform options = panel.tabs[tabIndex].container.transform;
Expand Down
10 changes: 10 additions & 0 deletions SMLHelper/Patchers/CraftDataPatcher_Subnautica.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ private static void GetUseEatSoundPrefix(TechType techType)
{
DictionaryPrefix(techType, CustomEatingSounds, CraftData.useEatSound);
}

/*
[PatchUtils.Prefix]
[HarmonyPatch(typeof(CraftData), nameof(CraftData.IsInvUseable))]
private static bool IsInvUseablePrefix(TechType techType, ref bool __result)
Expand All @@ -110,6 +112,14 @@ private static bool IsInvUseablePrefix(TechType techType, ref bool __result)
__result = false;
return true;
}
*/
[PatchUtils.Postfix]
[HarmonyPatch(typeof(Inventory), nameof(Inventory.GetAllItemActions))]
private static void GetAllItemActionsPostfix(InventoryItem item, ref ItemAction __result)
{
if (item != null && item.item != null && SurvivalPatcher.InventoryUseables.Contains(item.item.GetTechType()))
__result |= ItemAction.Use;
}

private static void DictionaryPrefix<T>(TechType techType, IDictionary<TechType, T> smlCollection, IDictionary<TechType, T> craftDataCollection)
{
Expand Down
Loading

0 comments on commit 25da9bf

Please sign in to comment.