Skip to content

Commit

Permalink
Merge branch 'dev' into pr/285
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPurple6411 committed Dec 23, 2022
2 parents 25da9bf + 46b2d00 commit d9b4fa6
Show file tree
Hide file tree
Showing 91 changed files with 9,110 additions and 3,954 deletions.
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 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 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.
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
52 changes: 15 additions & 37 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,38 +153,9 @@ protected CustomFabricator(string classId, string friendlyName, string descripti
/// <returns></returns>
public override GameObject GetGameObject()
{
#if BELOWZERO
return null;
#else
GameObject prefab = this.Model switch
{
Models.Fabricator => GameObject.Instantiate(CraftData.GetPrefabForTechTypeAsync(TechType.Fabricator).GetResult()),
Models.Workbench => GameObject.Instantiate(CraftData.GetPrefabForTechTypeAsync(TechType.Workbench).GetResult()),
#if SUBNAUTICA
Models.MoonPool => GameObject.Instantiate(GetCyclopsFabricatorPrefab()),
#endif
Models.Custom => GetCustomCrafterPreFab(),
_ => null
};

return PreProcessPrefab(prefab);
#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 @@ -205,7 +178,12 @@ public override IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject)
break;
#if SUBNAUTICA
case Models.MoonPool:
prefab = GameObject.Instantiate(GetCyclopsFabricatorPrefab());
#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);
break;
#endif
case Models.Custom:
Expand Down Expand Up @@ -359,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 @@ -376,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 @@ -386,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 @@ -401,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
2 changes: 1 addition & 1 deletion 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 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}");
}
}
}
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
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
3 changes: 2 additions & 1 deletion SMLHelper/Handlers/LootDistributionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Interfaces;
using Patchers;
using SMLHelper.V2.Assets;
using SMLHelper.V2.Utility;
using UWE;

/// <summary>
Expand Down Expand Up @@ -165,7 +166,7 @@ void ILootDistributionHandler.AddLootDistributionData(ModPrefab prefab, IEnumera
void ILootDistributionHandler.AddLootDistributionData(string classId, LootDistributionData.SrcData data)
{
if (LootDistributionPatcher.CustomSrcData.ContainsKey(classId))
Logger.Log($"{classId}-{data.prefabPath} already has custom distribution data. Replacing with latest.", LogLevel.Debug);
InternalLogger.Log($"{classId}-{data.prefabPath} already has custom distribution data. Replacing with latest.", LogLevel.Debug);

LootDistributionPatcher.CustomSrcData[classId] = data;
}
Expand Down
Loading

0 comments on commit d9b4fa6

Please sign in to comment.