Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fixes and updates #6

Merged
merged 5 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,21 @@ paket-files/
__pycache__/
*.pyc
References/Subnautica/CustomBatteries.dll
/QMods/BiochemicalBatteries/0Harmony.xml
/QMods/BiochemicalBatteries/0Harmony.dll
/QMods/BiochemicalBatteries/BiochemicalBatteries.dll
/QMods/NitrogenMod/Unity.Timeline.dll
/QMods/NitrogenMod/SMLHelper.xml
/QMods/NitrogenMod/SMLHelper.dll
/QMods/NitrogenMod/QModInstaller.xml
/QMods/NitrogenMod/QModInstaller.dll
/QMods/NitrogenMod/PlatformUtilsDefault.dll
/QMods/NitrogenMod/PlatformIODefault.dll
/QMods/NitrogenMod/Mono.Cecil.dll
/QMods/NitrogenMod/LumenWorks.dll
/QMods/NitrogenMod/LibNoise.dll
/QMods/NitrogenMod/NitrogenMod.dll
/QMods/NitrogenMod/Assembly-CSharp_publicized.dll
/QMods/NitrogenMod/0Harmony.xml
/QMods/NitrogenMod/Assembly-CSharp-firstpass.dll
/QMods/NitrogenMod/0Harmony.dll
19 changes: 10 additions & 9 deletions BiochemicalBatteries/BiochemicalBatteries.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BiochemicalBatteries</RootNamespace>
<AssemblyName>BiochemicalBatteries</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
Expand All @@ -23,6 +23,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -31,25 +32,25 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony-1.2.0.1">
<HintPath>..\References\Subnautica\0Harmony-1.2.0.1.dll</HintPath>
<Private>False</Private>
<Reference Include="0Harmony">
<HintPath>..\..\..\..\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\References\Subnautica\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="CustomBatteries">
<HintPath>..\References\Subnautica\CustomBatteries.dll</HintPath>
<HintPath>..\..\..\..\QMods\CustomBatteries\CustomBatteries.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SMLHelper">
<HintPath>..\References\Subnautica\SMLHelper.dll</HintPath>
<HintPath>..\..\..\..\QMods\Modding Helper\SMLHelper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -59,11 +60,11 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\References\Subnautica\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\References\Subnautica\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BiochemicalBatteries/Items/BiochemicalPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class BiochemicalPack : IModPluginPack
// The capacity of your battery - power cells are always double this
public int BatteryCapacity { get; } = 2500;
// How to unlock your batteries
public TechType UnlocksWith { get; } = TechType.Warper;
public TechType UnlocksWith { get; } = BioPlasmaItems.BioPlasmaID;
// The techtype for the battery
public string BatteryID { get; } = "BiochemBattery";
// The user-facing name for the battery
Expand Down
4 changes: 2 additions & 2 deletions BiochemicalBatteries/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace BiochemicalBatteries
{
using System;
using System.Reflection;
using Harmony;
using HarmonyLib;
using Items;
using Common;
using CustomBatteries.API;
Expand All @@ -23,7 +23,7 @@ public static void Patch()
SeraLogger.PatchStart(modName, "1.0.0");
try
{
var harmony = HarmonyInstance.Create("seraphimrisen.biochemicalbattery.mod");
var harmony = new Harmony("seraphimrisen.biochemicalbattery.mod");

BioPlasmaItems.PatchBioPlasmaItems();

Expand Down
90 changes: 88 additions & 2 deletions NitrogenMod/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
{
using System;
using System.Reflection;
using Harmony;
using System.Collections.Generic;
using HarmonyLib;
using SMLHelper.V2.Handlers;
using Common;
using Items;
using UnityEngine;
using Patchers;
using Logger = QModManager.Utility.Logger;

public class Main
{
Expand All @@ -22,12 +24,93 @@ public class Main
public static bool nitrogenEnabled = true;
public static bool decompressionVehicles = false;

private static Dictionary<TechType, float> diveSuitDepths = new Dictionary<TechType, float>()
{
{ TechType.None, 200f },
{ TechType.RadiationSuit, 500f },
{ TechType.ReinforcedDiveSuit, 800f },
{ TechType.Stillsuit, 800f }
};

private static Dictionary<TechType, float> diveSuitMinTemps = new Dictionary<TechType, float>()
{
{ TechType.None, 0f },
{ TechType.ReinforcedDiveSuit, 15f }
};

private static Dictionary<TechType, float> diveSuitBreathModifiers = new Dictionary<TechType, float>()
{
{ TechType.RadiationSuit, 0.95f },
{ TechType.Stillsuit, 0.95f },
{ TechType.ReinforcedDiveSuit, 0.85f }
};

public static void AddDiveSuit(TechType diveSuit, float depth, float breathMultiplier = 1f, float minTempBonus = 0f)
{
Logger.Log(Logger.Level.Info, $"Received AddDiveSuit call with Dive Suit {diveSuit.ToString()}, depth {depth}, breathMultiplier {breathMultiplier} and minTempBonus {minTempBonus}");
if (diveSuitDepths.TryGetValue(diveSuit, out float value)) // We don't actually care about the value here, just whether it exists
{
Logger.Log(Logger.Level.Error, $"Received duplicated AddDiveSuit call for TechType {diveSuit.ToString()}");
return;
}
diveSuitDepths.Add(diveSuit, depth);
if (minTempBonus > 0)
diveSuitMinTemps.Add(diveSuit, minTempBonus);
if (breathMultiplier != 1f)
diveSuitBreathModifiers.Add(diveSuit, minTempBonus);
}

public static float GetDiveSuitDepth(TechType diveSuit)
{
if (diveSuitDepths.TryGetValue(diveSuit, out float depth))
return depth;

return 200f;
}

public static float GetDiveSuitBreathMult(TechType diveSuit)
{
if (diveSuitBreathModifiers.TryGetValue(diveSuit, out float breath))
return breath;
return 1.0f;
}

public static float GetDiveSuitTempBonus(TechType diveSuit)
{
if (diveSuitMinTemps.TryGetValue(diveSuit, out float tempBonus))
return tempBonus;

return 0f;
}

// The previous functions are for getting just one attribute at a time; this function is for when you need multiple attributes in succession.
// Make a single call here instead of multiple calls to the helpers above.
// Returns false if the suit's parameters could not be found.
public static bool GetDiveSuitParameters(TechType diveSuit, out float depth, out float minTemp, out float breathMult)
{
// The only mandatory parameter is depth. If it has a depth value, it's valid.
if (!diveSuitDepths.TryGetValue(diveSuit, out depth))
{
minTemp = 0f;
breathMult = 0f;
return false;
}

if (!diveSuitMinTemps.TryGetValue(diveSuit, out minTemp))
minTemp = 0f;

if (!diveSuitBreathModifiers.TryGetValue(diveSuit, out breathMult))
breathMult = 1.0f;

return true;
}

public static void Patch()
{
SeraLogger.PatchStart(modName, "1.5.1");
try
{
var harmony = HarmonyInstance.Create("seraphimrisen.nitrogenmod.mod");
var harmony = new Harmony("seraphimrisen.nitrogenmod.mod");

AssetBundle ab = AssetBundle.LoadFromFile(assetBundle);
N2HUD = ab.LoadAsset("NMHUD") as GameObject;
Expand All @@ -49,6 +132,9 @@ public static void Patch()
if(specialtyTanks)
O2TanksCore.PatchTanks();

AddDiveSuit(ReinforcedSuitsCore.ReinforcedStillSuit, 1300f, 0.75f, 15f);
AddDiveSuit(ReinforcedSuitsCore.ReinforcedSuit2ID, 1300f, 0.75f, 20f);
AddDiveSuit(ReinforcedSuitsCore.ReinforcedSuit3ID, 8000f, 0.55f, 35f);
Console.WriteLine(typeof(NitroDamagePatcher).AssemblyQualifiedName);
SeraLogger.PatchComplete(modName);
}
Expand Down
31 changes: 18 additions & 13 deletions NitrogenMod/NitrogenMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NitrogenMod</RootNamespace>
<AssemblyName>NitrogenMod</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -23,6 +24,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<LangVersion>7.1</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
Expand All @@ -35,20 +37,23 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<LangVersion>7.1</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony-1.2.0.1">
<HintPath>..\References\Subnautica\0Harmony-1.2.0.1.dll</HintPath>
<Private>False</Private>
<Reference Include="0Harmony">
<HintPath>..\..\..\..\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\References\Subnautica\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp_publicized">
<HintPath>..\References\Subnautica\Assembly-CSharp_publicized.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\publicized_assemblies\Assembly-CSharp_publicized.dll</HintPath>
</Reference>
<Reference Include="QModInstaller">
<HintPath>..\..\..\..\BepInEx\plugins\QModManager\QModInstaller.dll</HintPath>
</Reference>
<Reference Include="SMLHelper">
<HintPath>..\References\Subnautica\SMLHelper.dll</HintPath>
<HintPath>..\..\..\..\QMods\Modding Helper\SMLHelper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -57,27 +62,27 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\References\Subnautica\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>..\References\Subnautica\UnityEngine.AnimationModule.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>..\References\Subnautica\UnityEngine.AssetBundleModule.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\References\Subnautica\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\References\Subnautica\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\References\Subnautica\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\..\..\Subnautica_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions NitrogenMod/Patchers/BreathPatcher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace NitrogenMod.Patchers
{
using Harmony;
using HarmonyLib;
using Items;

[HarmonyPatch(typeof(NitrogenLevel))]
Expand All @@ -14,7 +14,7 @@ public static bool Prefix(ref NitrogenLevel __instance, Player player)
{
Inventory main = Inventory.main;
TechType bodySlot = Inventory.main.equipment.GetTechTypeInSlot("Body");
TechType headSlot = Inventory.main.equipment.GetTechTypeInSlot("Head");
//TechType headSlot = Inventory.main.equipment.GetTechTypeInSlot("Head");

if (GameModeUtils.RequiresOxygen())
{
Expand All @@ -24,7 +24,8 @@ public static bool Prefix(ref NitrogenLevel __instance, Player player)
float modifier = 1f;
if (depthOf > 0f)
{
if (bodySlot == ReinforcedSuitsCore.ReinforcedSuit3ID)
modifier = Main.GetDiveSuitBreathMult(bodySlot);
/*if (bodySlot == ReinforcedSuitsCore.ReinforcedSuit3ID)
modifier = 0.55f;
else if ((bodySlot == ReinforcedSuitsCore.ReinforcedSuit2ID || bodySlot == ReinforcedSuitsCore.ReinforcedStillSuit) && depthOf <= 1300f)
modifier = 0.75f;
Expand All @@ -33,6 +34,8 @@ public static bool Prefix(ref NitrogenLevel __instance, Player player)
else if ((bodySlot == TechType.RadiationSuit || bodySlot == TechType.Stillsuit) && depthOf <= 500f)
modifier = 0.95f;
if (headSlot == TechType.Rebreather)
modifier -= 0.05f;*/
if (Inventory.main.equipment.GetCount(TechType.Rebreather) > 0)
modifier -= 0.05f;
}
float num = __instance.depthCurve.Evaluate(depthOf / 2048f);
Expand Down
2 changes: 1 addition & 1 deletion NitrogenMod/Patchers/DepthClassPatchers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace NitrogenMod.Patchers
{
using Harmony;
using HarmonyLib;
using Items;
using NMBehaviours;
using Common;
Expand Down
Loading