Skip to content

Commit

Permalink
Merge pull request #1 from VELD-Dev/nautilus
Browse files Browse the repository at this point in the history
Update to Nautilus
  • Loading branch information
VELD-Dev authored Jul 6, 2023
2 parents c2c5572 + a7a5063 commit d7bca12
Show file tree
Hide file tree
Showing 42 changed files with 871 additions and 536 deletions.
65 changes: 34 additions & 31 deletions AlterraWeaponry/AlterraWeaponry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'BZ|AnyCPU' ">
<OutputPath>bin\BZ\</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<DefineConstants>BZ; BELOWZERO; BELOW_ZERO;</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'SN1|AnyCPU' ">
<OutputPath>bin\SN1\</OutputPath>
<DefineConstants>SN1; SN; SUBNAUTICA;</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
Expand All @@ -55,20 +55,29 @@
<Reference Include="BepInEx">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="CuddleLibs">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\BepInEx\plugins\CuddleLibs\CuddleLibs.dll</HintPath>
</Reference>
<Reference Include="FMODUnity">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\SubnauticaZero_Data\Managed\FMODUnity.dll</HintPath>
</Reference>
<Reference Include="SMLHelper">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\QMods\SMLHelper_BZ\SMLHelper.dll</HintPath>
<Reference Include="Nautilus">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\BepInEx\plugins\Nautilus\Nautilus.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.Addressables, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.Addressables.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro">
<HintPath>B:\SteamLibrary\steamapps\common\SubnauticaZero\SubnauticaZero_Data\Managed\Unity.TextMeshPro.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -103,39 +112,32 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="behaviours\CustomTriggerEventAssigner.cs" />
<Compile Include="behaviours\ZapFunctionalityBehaviour.cs" />
<Compile Include="items\PrawnSelfDefenseModule.cs" />
<Compile Include="patches\ExosuitTorpedoArm_OpenTorpedoStorageExternal_Patch.cs" />
<Compile Include="patches\GameSettings_SaveAsync_Patch.cs" />
<Compile Include="patches\SeamothTorpedo_OnEnergyDepleted_Patch.cs" />
<Compile Include="patches\Vehicle_ChargeModule_Patch.cs" />
<Compile Include="patches\Vehicle_GetSlotCharge_Patch.cs" />
<Compile Include="patches\Vehicle_OnUpgradeModuleChange_Patch.cs" />
<Compile Include="patches\Vehicle_OnUpgradeModuleUse_Patch.cs" />
<Compile Include="utils\ExplosiveTorpedoInitializer.cs" />
<Compile Include="behaviours\TorpedoExplosionBehaviour.cs" />
<Compile Include="Behaviours\CustomTriggerEventAssigner.cs" />
<Compile Include="Behaviours\ZapFunctionalityBehaviour.cs" />
<Compile Include="Items\PrawnSelfDefenseModule.cs" />
<Compile Include="Patches\ExosuitTorpedoArm_OpenTorpedoStorageExternal_Patch.cs" />
<Compile Include="Patches\SeamothTorpedo_OnEnergyDepleted_Patch.cs" />
<Compile Include="Utils\ExplosiveTorpedoInitializer.cs" />
<Compile Include="Behaviours\TorpedoExplosionBehaviour.cs" />
<Compile Include="Global.cs" />
<Compile Include="items\BlackPowder.cs" />
<Compile Include="items\Coal.cs" />
<Compile Include="items\ExplosiveTorpedo.cs" />
<Compile Include="Items\BlackPowder.cs" />
<Compile Include="Items\Coal.cs" />
<Compile Include="Items\ExplosiveTorpedo.cs" />
<Compile Include="Main.cs" />
<Compile Include="patches\ItemGoalTracker_Start_Patch.cs" />
<Compile Include="patches\uGUISceneLoading_End_Patch.cs" />
<Compile Include="patches\Vehicle_Awake_Patch.cs" />
<Compile Include="Patches\ItemGoalTracker_Start_Patch.cs" />
<Compile Include="Patches\uGUISceneLoading_End_Patch.cs" />
<Compile Include="Patches\Vehicle_Awake_Patch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="utils\LanguagesHandler.cs" />
<Compile Include="Utils\GlobalInitializer.cs" />
<Compile Include="Utils\LanguagesHandler.cs" />
<Compile Include="Utils\Options.cs" />
<Compile Include="Utils\ResourcesCacheManager.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="assets\Coal.png" />
<Content Include="assets\ExplosiveTorpedo.png" />
<Content Include="assets\first_lethal_weapon_message.mp3" />
<Content Include="assets\first_lethal_weapon_message.ogg" />
<Content Include="assets\PrawnPerimeterDefense.png" />
<Content Include="assets\prawn_shield.png" />
<Content Include="assets\xenoworx_pda_presentation.mp3" />
<Content Include="Localizations.xml" />
<None Include="Sounds\AudioClip.FirstLethalMessage.wav" />
<None Include="Sounds\AudioClip.PWAPresentation.wav" />
</ItemGroup>
<ItemGroup>
<None Include="mod.json" />
Expand All @@ -145,6 +147,7 @@
<PostBuildEvent>mkdir "$(SubnauticaRootPath)\BepInEx\plugins\AlterraWeaponry"
copy /Y "$(TargetPath)" "$(SubnauticaRootPath)\BepInEx\plugins\AlterraWeaponry\"
copy /Y "$(ProjectDir)\alterraweaponry.assets" "$(SubnauticaRootPath)\BepInEx\plugins\AlterraWeaponry\"
copy /Y "$(ProjectDir)\alterraweaponry.assets.meta" "$(SubnauticaRootPath)\BepInEx\plugins\AlterraWeaponry\"
copy /Y "$(ProjectDir)\Localizations.xml" "$(SubnauticaRootPath)\BepInEx\plugins\AlterraWeaponry\"</PostBuildEvent>
</PropertyGroup>
</Project>
50 changes: 30 additions & 20 deletions AlterraWeaponry/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@
global using BepInEx.Bootstrap;
global using BepInEx.Configuration;
global using BepInEx.Logging;
global using SMLHelper.V2.Assets;
global using SMLHelper.V2.Commands;
global using SMLHelper.V2.Crafting;
global using SMLHelper.V2.FMod;
global using SMLHelper.V2.FMod.Interfaces;
global using SMLHelper.V2.Interfaces;
global using SMLHelper.V2.Json;
global using SMLHelper.V2.Json.Attributes;
global using SMLHelper.V2.Json.Converters;
global using SMLHelper.V2.Json.ExtensionMethods;
global using SMLHelper.V2.Json.Interfaces;
global using SMLHelper.V2.Handlers;
global using SMLHelper.V2.MonoBehaviours;
global using SMLHelper.V2.Options;
global using SMLHelper.V2.Options.Attributes;
global using SMLHelper.V2.Utility;
global using Nautilus.Assets;
global using Nautilus.Assets.Gadgets;
global using Nautilus.Assets.PrefabTemplates;
global using Nautilus.Commands;
global using Nautilus.Crafting;
global using Nautilus.Extensions;
global using Nautilus.FMod;
global using Nautilus.FMod.Interfaces;
global using Nautilus.Handlers;
global using Nautilus.Json;
global using Nautilus.Json.Attributes;
global using Nautilus.Json.Converters;
global using Nautilus.Json.ExtensionMethods;
global using Nautilus.Json.Interfaces;
global using Nautilus.Options;
global using Nautilus.Options.Attributes;
global using Nautilus.Utility;
global using Nautilus.Utility.MaterialModifiers;
global using HarmonyLib;
global using HarmonyLib.Public;
global using HarmonyLib.Public.Patching;
Expand All @@ -44,9 +46,17 @@
global using UWE;
global using UWE.Timeline;
global using UWEScript;
global using FMOD;

// LOCAL
global using VELD.AlterraWeaponry.items;
global using VELD.AlterraWeaponry.patches;
global using VELD.AlterraWeaponry.utils;
global using VELD.AlterraWeaponry.behaviours;
global using VELD.AlterraWeaponry.Items;
global using VELD.AlterraWeaponry.Patches;
global using VELD.AlterraWeaponry.Utils;
global using VELD.AlterraWeaponry.Behaviours;

// MY LIBS
global using CuddleLibs;
global using CuddleLibs.Assets;
global using CuddleLibs.Assets.Gadgets;
global using CuddleLibs.Interfaces;
global using CuddleLibs.Utility;
Binary file modified AlterraWeaponry/Localizations.xml
Binary file not shown.
157 changes: 38 additions & 119 deletions AlterraWeaponry/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,149 +4,68 @@
public class Main : BaseUnityPlugin
{
// MOD INFO
private const string modName = "Alterra Weaponry";
private const string modGUID = "com.VELD.AlterraWeaponry";
private const string modVers = "1.0.3";
internal const string modName = "Alterra Weaponry";
internal const string modGUID = "com.VELD.AlterraWeaponry";
internal const string modVers = "1.0.5";
internal const string modLongVers = "1.0.5.1";

// BepInEx/Harmony/Unity
private static readonly Harmony harmony = new(modGUID);
public static ManualLogSource logger;

// STORY GOALS
#if BZ
internal static StoryGoal AWPresentationGoal = new("Log_PDA_Goal_AWPresentation", Story.GoalType.PDA, 0f) { playInCreative = true, playInCinematics = false, delay = 8f };
#endif
internal static StoryGoal AWPresentationGoal;
internal static ItemGoal AWFirstLethal;

public static readonly AssetBundle assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "alterraweaponry.assets"));
public static ResourcesCacheManager AssetsCache { get; private set; }

internal static Options Options { get; } = OptionsPanelHandler.RegisterModOptions<Options>();

private void Awake()
{
logger = Logger;
try
{
AssetsCache = ResourcesCacheManager.LoadResources(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "alterraweaponry.assets"));
}
catch (Exception ex)
{
logger.LogFatal($"Fatal error occured: Unable to load resources to cache.\n{ex}");
}
logger.LogInfo($"{modName} {modVers} started patching.");
harmony.PatchAll();
logger.LogInfo($"{modName} {modVers} harmony patched.");

Coal coal = new();
BlackPowder blackPowder = new();
ExplosiveTorpedo explosiveTorpedo = new();
PrawnSelfDefenseModule prawnSelfDefenseModule = new();

coal.Patch();
blackPowder.Patch();
explosiveTorpedo.Patch();
prawnSelfDefenseModule.Patch();

logger.LogInfo($"{modName} {modVers} items registered.");

LanguagesHandler.LanguagePatch();
LanguagesHandler.GlobalPatch();
logger.LogInfo($"{modName} {modVers} languages lines patched.");

RegisterPDAEncyEntries();
GlobalInitializer.PatchPDAEncyEntries();
logger.LogInfo($"{modName} {modVers} PDA encyclopedia entries registered.");
RegisterPDALogs();
GlobalInitializer.PatchGoals();
logger.LogInfo($"{modName} {modVers} PDA goals initialized.");
GlobalInitializer.PatchPDALogs();
logger.LogInfo($"{modName} {modVers} PDA logs registered.");

}

private void Update()
{
if(UnityInput.Current.GetKeyDown(KeyCode.P))
ModDatabankHandler.RegisterMod(new ModDatabankHandler.ModData()
{
logger.LogInfo("Should play audio.");
GameObject cameraObject = Camera.main.gameObject;
AudioSource audioSource = cameraObject.GetComponent<AudioSource>();
audioSource.clip = Main.assets.LoadAsset<AudioClip>("AudioClip.PWAPresentation");
audioSource.Play();
logger.LogInfo("Should have played an audio.");
}
}

private static void RegisterPDALogs()
{
// Load audio clips
logger.LogInfo($"{modName} {modVers} Loading audio clips...");
#if BZ
AudioClip AWPresentationAudioClip = assets.LoadAsset<AudioClip>("pwa_presentation_message");
AudioClip AWFirstLethalAudioClip = assets.LoadAsset<AudioClip>("first_lethal_message");
#endif
logger.LogInfo($"{modName} {modVers} Audio clips loaded!");

logger.LogInfo($"{modName} {modVers} Registering PDA Logs...");

// Presentation PDA log "Hello xenoworker 91802..."
#if BZ
CustomSoundHandler.RegisterCustomSound(AWPresentationGoal.key, AWPresentationAudioClip, AudioUtils.BusPaths.PDAVoice);
FMODAsset presentation = ScriptableObject.CreateInstance<FMODAsset>();
presentation.path = AWPresentationGoal.key;
presentation.id = AWPresentationGoal.key;
PDALogHandler.AddCustomEntry(
AWPresentationGoal.key,
"Subtitles_AWPresentation",
sound: presentation
);
#endif
guid = modGUID,
version = modVers,
image = AssetsCache.GetAsset<Texture2D>("ModLogo"),
name = "Alterra Weaponry",
desc = "Since the return of the Aurora survivor, Alterra secretely added a few weapons blueprints.\nThis information is kept confidential, by using the PWA (Personal Weaponry Assistance) you agree the Alterra's NDA (Non-Divulgation Accord)."
});

// First lethal weapon PDA log "A lethal weapon have been detected into your inventory..."
#if BZ
CustomSoundHandler.RegisterCustomSound("Log_PDA_Goal_FirstLethal", AWFirstLethalAudioClip, AudioUtils.BusPaths.PDAVoice);
FMODAsset firstLethal = ScriptableObject.CreateInstance<FMODAsset>();
firstLethal.path = "Log_PDA_Goal_FirstLethal";
firstLethal.id = "Log_PDA_Goal_FirstLethal";
PDALogHandler.AddCustomEntry(
"Log_PDA_Goal_FirstLethal",
"Subtitles_AWFirstLethal",
sound: firstLethal
);
#endif
}
Coal coal = new();
coal.Patch();

private static void RegisterPDAEncyEntries()
{
// Register AWModInfo entry
PDAEncyclopediaHandler.AddCustomEntry(new()
{
key = "AWModInfo",
kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia,
nodes = new[] { "Meta" },
path = "Meta",
unlocked = true,
});
BlackPowder blackPowder = new();
blackPowder.Patch();

// Explosive torpedoes entry
#if BZ
PDAEncyclopediaHandler.AddCustomEntry(new()
{
key = "ExplosiveTorpedo",
kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia,
nodes = new[] { "Tech", "Weaponry" },
path = "Tech/Weaponry",
unlocked = false,
});
#endif
ExplosiveTorpedo explosiveTorpedo = new();
explosiveTorpedo.Patch();

// Prawn laser arm entry
#if BZ
PDAEncyclopediaHandler.AddCustomEntry(new()
{
key = "PrawnLaserArm",
kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia,
nodes = new[] { "Tech", "Weaponry" },
path = "Tech/Weaponry",
unlocked = false,
});
#endif
PrawnSelfDefenseModule prawnSelfDefenseModule = new();
prawnSelfDefenseModule.Patch();

// Prawn Self Defense Module
#if BZ
PDAEncyclopediaHandler.AddCustomEntry(new()
{
key = "PrawnDefensePerimeter",
kind = PDAEncyclopedia.EntryData.Kind.Encyclopedia,
nodes = new[] { "Tech", "Modules" },
path = "Tech/Modules",
unlocked = false,
});
#endif
logger.LogInfo($"{modName} {modVers} items registered.");
}

}
7 changes: 3 additions & 4 deletions AlterraWeaponry/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using VELD.AlterraWeaponry;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand Down Expand Up @@ -33,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyVersion(Main.modVers)]
[assembly: AssemblyFileVersion(Main.modLongVers)]
[assembly: NeutralResourcesLanguage("en")]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit d7bca12

Please sign in to comment.