Skip to content

Commit

Permalink
Merge pull request #1 from MrPurple6411/dev
Browse files Browse the repository at this point in the history
Convert to Bepinex and Fix a few other issues.
  • Loading branch information
K07H committed Dec 23, 2022
2 parents baf3d4c + ce4e537 commit bc1041b
Show file tree
Hide file tree
Showing 116 changed files with 9,120 additions and 4,146 deletions.
Binary file not shown.
Binary file not shown.
Binary file removed Dependencies/Subnautica.stable/0Harmony.dll
Binary file not shown.
2,849 changes: 0 additions & 2,849 deletions Dependencies/Subnautica.stable/0Harmony.xml

This file was deleted.

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 removed Dependencies/Subnautica.stable/QModInstaller.dll
Binary file not shown.
569 changes: 0 additions & 569 deletions Dependencies/Subnautica.stable/QModInstaller.xml

This file was deleted.

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.CoreModule.dll
Binary file not shown.
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.PhysicsModule.dll
Binary file not shown.
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.UI.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.UIModule.dll
Binary file not shown.
Binary file modified Dependencies/Subnautica.stable/UnityEngine.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
3 changes: 2 additions & 1 deletion SMLHelper/Assets/Craftable.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace SMLHelper.V2.Assets
{
using SMLHelper.V2.Interfaces;
using SMLHelper.V2.Utility;

/// <summary>
/// An item that can be crafted into the game world from a fabricator.
Expand Down Expand Up @@ -45,7 +46,7 @@ private void PatchCraftingData()
{
if (this.FabricatorType == CraftTree.Type.None)
{
Logger.Debug($"Craftable '{this.ClassID}' was not automatically patched into a crafting tree.");
InternalLogger.Debug($"Craftable '{this.ClassID}' was not automatically patched into a crafting tree.");
}
else
{
Expand Down
31 changes: 9 additions & 22 deletions SMLHelper/Assets/CustomFabricator.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace SMLHelper.V2.Assets
using SMLHelper.V2.Utility;

namespace SMLHelper.V2.Assets
{
using System;
using System.Collections;
using System.Collections.Generic;
using SMLHelper.V2.Crafting;
using SMLHelper.V2.Handlers;
using UnityEngine;
using Logger = V2.Logger;
using InternalLogger = InternalLogger;

#if SUBNAUTICA
using Sprite = Atlas.Sprite;
Expand Down Expand Up @@ -151,22 +153,7 @@ protected CustomFabricator(string classId, string friendlyName, string descripti
/// <returns></returns>
public override GameObject GetGameObject()
{
#if SUBNAUTICA_EXP || 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)),
#if SUBNAUTICA
Models.MoonPool => GameObject.Instantiate(Resources.Load<GameObject>("Submarine/Build/CyclopsFabricator")),
#endif
Models.Custom => GetCustomCrafterPreFab(),
_ => null
};

return PreProcessPrefab(prefab);
#endif
}

/// <summary>
Expand Down Expand Up @@ -350,7 +337,7 @@ public void AddTabNode(string tabId, string displayText, Sprite tabSprite, strin
/// When this value is null, the craft node will be added to the root of the craft tree.</param>
public void AddCraftNode(TechType techType, string parentTabId = null)
{
Logger.Debug($"'{techType.AsString()}' will be added to the custom craft tree '{this.ClassID}'");
InternalLogger.Debug($"'{techType.AsString()}' will be added to the custom craft tree '{this.ClassID}'");
OrderedCraftTreeActions.Add(() =>
{
ModCraftTreeLinkingNode parentTab = CraftTreeLinkingNodes[parentTabId ?? RootNode];
Expand All @@ -367,7 +354,7 @@ public void AddCraftNode(TechType techType, string parentTabId = null)
/// When this value is null, the craft node will be added to the root of the craft tree.</param>
public void AddCraftNode(string moddedTechType, string parentTabId = null)
{
Logger.Debug($"'{moddedTechType}' will be added to the custom craft tree '{this.ClassID}'");
InternalLogger.Debug($"'{moddedTechType}' will be added to the custom craft tree '{this.ClassID}'");
OrderedCraftTreeActions.Add(() =>
{
if (this.TechTypeHandler.TryGetModdedTechType(moddedTechType, out TechType techType))
Expand All @@ -377,7 +364,7 @@ public void AddCraftNode(string moddedTechType, string parentTabId = null)
}
else
{
Logger.Info($"Did not find a TechType value for '{moddedTechType}' to add to the custom craft tree '{this.ClassID}'");
InternalLogger.Info($"Did not find a TechType value for '{moddedTechType}' to add to the custom craft tree '{this.ClassID}'");
}
});
}
Expand All @@ -392,12 +379,12 @@ public void AddCraftNode(string moddedTechType, string parentTabId = null)
/// The craft node will be added to the root of the craft tree if both are null.</param>
public void AddCraftNode(Craftable item, string parentTabId = null)
{
Logger.Debug($"'{item.ClassID}' will be added to the custom craft tree '{this.ClassID}'");
InternalLogger.Debug($"'{item.ClassID}' will be added to the custom craft tree '{this.ClassID}'");
OrderedCraftTreeActions.Add(() =>
{
if (item.TechType == TechType.None)
{
Logger.Info($"'{item.ClassID} had to be patched early to obtain its TechType value for the custom craft tree '{this.ClassID}'");
InternalLogger.Info($"'{item.ClassID} had to be patched early to obtain its TechType value for the custom craft tree '{this.ClassID}'");
item.Patch();
}
Expand Down
6 changes: 1 addition & 5 deletions SMLHelper/Assets/FishPrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public FishPrefab(string classId, string prefabFileName, TechType techType = Tec
/// </summary>
public sealed override GameObject GetGameObject()
{
V2.Logger.Debug($"[FishFramework] Initializing fish: {this.ClassID}");
Utility.InternalLogger.Debug($"[FishFramework] Initializing fish: {this.ClassID}");
GameObject mainObj = modelPrefab;

Renderer[] renderers = mainObj.GetComponentsInChildren<Renderer>();
Expand All @@ -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
10 changes: 6 additions & 4 deletions SMLHelper/Assets/ModPrefabCache.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace SMLHelper.V2.Assets
using SMLHelper.V2.Utility;

namespace SMLHelper.V2.Assets
{
using System;
using System.Collections.Generic;
using UnityEngine;
using Logger = V2.Logger;
using InternalLogger = InternalLogger;

/// <summary>
/// Class that used by <see cref="ModPrefab"/> to store game objects that used as prefabs.
Expand All @@ -29,7 +31,7 @@ public void Update()
if (Time.time < prefabs[i].Item1 + cleanDelay || Builder.prefab == prefabs[i].Item2)
continue;

Logger.Debug($"ModPrefabCache: removing prefab {prefabs[i].Item2}");
InternalLogger.Debug($"ModPrefabCache: removing prefab {prefabs[i].Item2}");

Destroy(prefabs[i].Item2);
prefabs.RemoveAt(i);
Expand Down Expand Up @@ -85,7 +87,7 @@ private static void AddPrefabInternal(GameObject prefab, bool autoremove)
if (autoremove)
prefabs.Add(Tuple.Create(Time.time, prefab));

Logger.Debug($"ModPrefabCache: adding prefab {prefab}");
InternalLogger.Debug($"ModPrefabCache: adding prefab {prefab}");
}
}
}
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
}
}
3 changes: 2 additions & 1 deletion SMLHelper/Assets/PdaItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using Crafting;
using SMLHelper.V2.Interfaces;
using SMLHelper.V2.Utility;
using System.Collections.Generic;

/// <summary>
Expand Down Expand Up @@ -117,7 +118,7 @@ private void PatchTechDataEntry()
}
else
{
Logger.Error($"Failed to add {TechType} to {GroupForPDA}/{CategoryForPDA} as it is not a registered combination.");
InternalLogger.Error($"Failed to add {TechType} to {GroupForPDA}/{CategoryForPDA} as it is not a registered combination.");
}
}

Expand Down
14 changes: 8 additions & 6 deletions SMLHelper/Assets/Spawnable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SMLHelper.V2.Assets
using SMLHelper.V2.Utility;

namespace SMLHelper.V2.Assets
{
using Handlers;
using Interfaces;
Expand All @@ -10,7 +12,7 @@
using System.Reflection;
using UnityEngine;
using UWE;
using Logger = Logger;
using InternalLogger = InternalLogger;
#if SUBNAUTICA
using Sprite = Atlas.Sprite;
#endif
Expand Down Expand Up @@ -113,7 +115,7 @@ protected Spawnable(string classId, string friendlyName, string description)
{
if(string.IsNullOrEmpty(classId))
{
Logger.Log($"ClassID for Spawnables must be a non-empty value.", LogLevel.Error);
InternalLogger.Log($"ClassID for Spawnables must be a non-empty value.", LogLevel.Error);
throw new ArgumentException($"Error patching Spawnable");
}

Expand Down Expand Up @@ -222,8 +224,8 @@ internal virtual void PatchTechType()
protected virtual Sprite GetItemSprite()
{
// This is for backwards compatibility with mods that were using the "ModName/Assets" format
string path = this.AssetsFolder != ModFolderLocation
? IOUtilities.Combine(".", "QMods", this.AssetsFolder.Trim('/'), this.IconFileName)
string path = this.AssetsFolder != ModFolderLocation && !string.IsNullOrWhiteSpace(this.AssetsFolder)
? IOUtilities.Combine(ModFolderLocation, this.AssetsFolder.Trim('/'), this.IconFileName)
: Path.Combine(this.AssetsFolder, this.IconFileName);

if(File.Exists(path))
Expand All @@ -232,7 +234,7 @@ protected virtual Sprite GetItemSprite()
}

if(HasSprite)
Logger.Error($"Sprite for '{this.PrefabFileName}'{Environment.NewLine}Did not find an image file at '{path}'");
InternalLogger.Error($"Sprite for '{this.PrefabFileName}'{Environment.NewLine}Did not find an image file at '{path}'");

return SpriteManager.defaultSprite;
}
Expand Down
3 changes: 2 additions & 1 deletion SMLHelper/Assets/SubnauticaModSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace SMLHelper.V2.Assets
{
using System;
using System.Collections.Generic;
using SMLHelper.V2.Utility;

/// <summary>
/// A class that handles a custom sprite and what item it is associated to.
Expand All @@ -20,7 +21,7 @@ internal static void Add(SpriteManager.Group group, string name, Atlas.Sprite sp
ModSprites.Add(group, new Dictionary<string, Atlas.Sprite>(StringComparer.InvariantCultureIgnoreCase));

if(ModSprites[group].ContainsKey(name))
Logger.Debug($"ModSprite already registered for {group}/{name}. Old sprite will be overwritten.");
InternalLogger.Debug($"ModSprite already registered for {group}/{name}. Old sprite will be overwritten.");
ModSprites[group][name] = sprite;
}

Expand Down
5 changes: 2 additions & 3 deletions SMLHelper/Commands/ConsoleCommand.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace SMLHelper.V2.Commands
{
using HarmonyLib;
using QModManager.API;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -20,7 +19,7 @@ internal class ConsoleCommand
/// <summary>
/// The QMod that registered the command.
/// </summary>
public IQMod QMod { get; }
public string ModName { get; }

/// <summary>
/// The parameters for the command.
Expand Down Expand Up @@ -53,7 +52,7 @@ public ConsoleCommand(string trigger, MethodInfo targetMethod, bool isDelegate =
IsMethodStatic = targetMethod.IsStatic;
IsDelegate = isDelegate;
Instance = instance;
QMod = QModServices.Main.GetMod(DeclaringType.Assembly);
ModName = DeclaringType.Assembly.GetName().Name;
Parameters = targetMethod.GetParameters().Select(param => new Parameter(param));
ParameterTypes = Parameters.Select(param => param.ParameterType).ToArray();
}
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/FMod/FModMultiSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Channel IFModSound.PlaySound()
return AudioUtils.PlaySound(_sounds[Index], _bus);
}

Logger.Error("MultiSounds must have some sounds.");
InternalLogger.Error("MultiSounds must have some sounds.");
return default;
}
}
Expand Down
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
3 changes: 2 additions & 1 deletion SMLHelper/Handlers/FishHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using SMLHelper.V2.Assets;
using SMLHelper.V2.Interfaces;
using SMLHelper.V2.Utility;

/// <summary>
/// Class to manage registering of fish into the game
Expand Down Expand Up @@ -52,7 +53,7 @@ TechType IFishHandler.RegisterFish(Fish fish)

PrefabHandler.RegisterPrefab(fishPrefab);

Logger.Debug($"Successfully registered fish: '{fish.displayName}' with Tech Type: '{fish.id}'");
InternalLogger.Debug($"Successfully registered fish: '{fish.displayName}' with Tech Type: '{fish.id}'");

return type;
}
Expand Down
22 changes: 12 additions & 10 deletions SMLHelper/Handlers/KnownTechHandler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace SMLHelper.V2.Handlers
using SMLHelper.V2.Utility;

namespace SMLHelper.V2.Handlers
{
using Interfaces;
using Patchers;
using System.Collections.Generic;
using UnityEngine;
using Logger = V2.Logger;
using InternalLogger = InternalLogger;

/// <summary>
/// A handler class for configuring custom unlocking conditions for item blueprints.
Expand Down Expand Up @@ -66,33 +68,33 @@ internal void AddAnalysisTech(TechType techTypeToBeAnalysed, IEnumerable<TechTyp
}
else
{
Logger.Error("Cannot Add Unlock to TechType.None!");
InternalLogger.Error("Cannot Add Unlock to TechType.None!");
}
}

internal void AddCompoundUnlock(TechType techType, List<TechType> compoundTechsForUnlock)
{
if (techType == TechType.None)
{
Logger.Error("Cannot Add Unlock to TechType.None!");
InternalLogger.Error("Cannot Add Unlock to TechType.None!");
return;
}

if (compoundTechsForUnlock.Contains(techType))
{
Logger.Error("Cannot Add Compound Unlock that contains itself!");
InternalLogger.Error("Cannot Add Compound Unlock that contains itself!");
return;
}


if (KnownTechPatcher.CompoundTech.TryGetValue(techType, out KnownTech.CompoundTech compoundTech))
{
Logger.Debug($"Compound Unlock already found for {techType.AsString()}, Overwriting.");
InternalLogger.Debug($"Compound Unlock already found for {techType.AsString()}, Overwriting.");
compoundTech.dependencies = compoundTechsForUnlock;
}
else
{
Logger.Debug($"Adding Compound Unlock for {techType.AsString()}");
InternalLogger.Debug($"Adding Compound Unlock for {techType.AsString()}");
KnownTechPatcher.CompoundTech.Add(techType, new KnownTech.CompoundTech() { techType = techType, dependencies = compoundTechsForUnlock });
}
}
Expand All @@ -119,20 +121,20 @@ internal void RemoveAnalysisTechEntry(TechType targetTechType)
{
if (tech.unlockTechTypes.Contains(targetTechType))
{
Logger.Debug($"Removed {targetTechType.AsString()} from {tech.techType.AsString()} unlocks that was added by another mod!");
InternalLogger.Debug($"Removed {targetTechType.AsString()} from {tech.techType.AsString()} unlocks that was added by another mod!");
tech.unlockTechTypes.Remove(targetTechType);
}
}

if (KnownTechPatcher.CompoundTech.TryGetValue(targetTechType, out var types))
{
Logger.Debug($"Removed Compound Unlock for {targetTechType.AsString()} that was added by another mod!");
InternalLogger.Debug($"Removed Compound Unlock for {targetTechType.AsString()} that was added by another mod!");
KnownTechPatcher.CompoundTech.Remove(targetTechType);
}

if (KnownTechPatcher.UnlockedAtStart.Contains(targetTechType))
{
Logger.Debug($"Removed UnlockedAtStart for {targetTechType.AsString()} that was added by another mod!");
InternalLogger.Debug($"Removed UnlockedAtStart for {targetTechType.AsString()} that was added by another mod!");
KnownTechPatcher.UnlockedAtStart.Remove(targetTechType);
}

Expand Down
Loading

0 comments on commit bc1041b

Please sign in to comment.