Add files via upload
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
using BepInEx;
|
||||||
|
using BepInEx.Logging;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
internal static class MyPluginInfo
|
||||||
|
{
|
||||||
|
internal const string PLUGIN_GUID = "id107.automaticshipsystems";
|
||||||
|
internal const string PLUGIN_NAME = "AutomaticShipSystems";
|
||||||
|
internal const string PLUGIN_VERSION = "0.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
|
||||||
|
[BepInProcess("Void Crew.exe")]
|
||||||
|
[BepInDependency("VoidManager")]
|
||||||
|
public class BepinPlugin : BaseUnityPlugin
|
||||||
|
{
|
||||||
|
internal static ManualLogSource Log;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
Log = Logger;
|
||||||
|
Configs.Load(this);
|
||||||
|
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), MyPluginInfo.PLUGIN_GUID);
|
||||||
|
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using BepInEx.Configuration;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
internal class Configs
|
||||||
|
{
|
||||||
|
internal const double CircuitBreakerDelay = 30 * 1000;
|
||||||
|
internal const double ThrusterBoosterDelay = 60 * 1000;
|
||||||
|
internal const double TrimDelay = 5 * 60 * 1000;
|
||||||
|
|
||||||
|
internal static ConfigEntry<bool> CircuitBreakerConfig;
|
||||||
|
internal static ConfigEntry<bool> ThrusterBoosterConfig;
|
||||||
|
internal static ConfigEntry<bool> TrimConfig;
|
||||||
|
|
||||||
|
internal static void Load(BepinPlugin plugin)
|
||||||
|
{
|
||||||
|
CircuitBreakerConfig = plugin.Config.Bind("AutomaticShipSystems", "CircuitBreakers", true);
|
||||||
|
ThrusterBoosterConfig = plugin.Config.Bind("AutomaticShipSystems", "ThrusterBooster", true);
|
||||||
|
TrimConfig = plugin.Config.Bind("AutomaticShipSystems", "Trim", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using CG.Game;
|
||||||
|
using CG.Ship.Modules;
|
||||||
|
using Gameplay.Enhancements;
|
||||||
|
using Gameplay.Ship;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Photon.Pun;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using VoidManager.Utilities;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(Enhancement))]
|
||||||
|
internal class EnhancementPatch
|
||||||
|
{
|
||||||
|
[HarmonyPrepare]
|
||||||
|
static void HookEvents()
|
||||||
|
{
|
||||||
|
Configs.TrimConfig.SettingChanged += ToggleAutomaticTrims;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch("SetState")]
|
||||||
|
static void SetState(Enhancement __instance, EnhancementState newState)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient) return;
|
||||||
|
|
||||||
|
if (Configs.TrimConfig.Value &&
|
||||||
|
ClientGame.Current?.PlayerShip?.GetModule<Helm>()?.Engine?.GetComponentsInChildren<Enhancement>()?.Contains(__instance) == true &&
|
||||||
|
newState == EnhancementState.Inactive)
|
||||||
|
{
|
||||||
|
Tools.DelayDoUnique(__instance, () => ResetTrim(__instance), Configs.TrimDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ResetTrim(Enhancement trim)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient || !Tools.PlayerShipExists) return;
|
||||||
|
|
||||||
|
if (trim.CurrentState.Value == EnhancementState.Inactive)
|
||||||
|
{
|
||||||
|
trim.RequestStateChange(EnhancementState.Active, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ToggleAutomaticTrims(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient) return;
|
||||||
|
|
||||||
|
Enhancement[] trims = ClientGame.Current?.PlayerShip?.GetModule<Helm>()?.Engine?.GetComponentsInChildren<Enhancement>();
|
||||||
|
if (trims == null || trims.Length == 0) return;
|
||||||
|
|
||||||
|
if (Configs.TrimConfig.Value)
|
||||||
|
{
|
||||||
|
foreach (Enhancement trim in trims)
|
||||||
|
{
|
||||||
|
if (trim.CurrentState.Value == EnhancementState.Inactive)
|
||||||
|
{
|
||||||
|
Tools.DelayDoUnique(trim, () => ResetTrim(trim), Configs.TrimDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Enhancement trim in trims)
|
||||||
|
{
|
||||||
|
Tools.CancelDelayDoUnique(trim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using VoidManager.CustomGUI;
|
||||||
|
using VoidManager.Utilities;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
internal class GUI : ModSettingsMenu
|
||||||
|
{
|
||||||
|
public override string Name() => "Automatic Ship Systems";
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
GUITools.DrawCheckbox("Circuit Breakers", ref Configs.CircuitBreakerConfig);
|
||||||
|
GUITools.DrawCheckbox("Thruster Boosters", ref Configs.ThrusterBoosterConfig);
|
||||||
|
GUITools.DrawCheckbox("Trims", ref Configs.TrimConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using CG.Game;
|
||||||
|
using Gameplay.PowerSystem;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Photon.Pun;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using VoidManager.Utilities;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(PowerBreaker))]
|
||||||
|
internal class PowerBreakerPatch
|
||||||
|
{
|
||||||
|
[HarmonyPrepare]
|
||||||
|
static void HookEvents()
|
||||||
|
{
|
||||||
|
Configs.CircuitBreakerConfig.SettingChanged += ToggleAutomaticBreakers;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch("OnPowerStateChange")]
|
||||||
|
static void OnPowerStateChange(PowerBreaker __instance, bool isOn)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient) return;
|
||||||
|
|
||||||
|
if (!isOn && Configs.CircuitBreakerConfig.Value)
|
||||||
|
{
|
||||||
|
Tools.DelayDoUnique(__instance, () => ResetCircuitBreakers(__instance), Configs.CircuitBreakerDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ResetCircuitBreakers(PowerBreaker breaker)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient || !Tools.PlayerShipExists) return;
|
||||||
|
|
||||||
|
breaker.IsOn.RequestChange(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ToggleAutomaticBreakers(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient) return;
|
||||||
|
|
||||||
|
List<PowerBreaker> breakers = ClientGame.Current?.PlayerShip?.GetComponentInChildren<ProtectedPowerSystem>()?.Breakers;
|
||||||
|
if (breakers == null) return;
|
||||||
|
|
||||||
|
if (Configs.CircuitBreakerConfig.Value)
|
||||||
|
{
|
||||||
|
foreach (PowerBreaker powerBreaker in breakers)
|
||||||
|
{
|
||||||
|
if (!powerBreaker.IsOn.Value)
|
||||||
|
{
|
||||||
|
Tools.DelayDoUnique(powerBreaker, () => powerBreaker.IsOn.RequestChange(true), Configs.CircuitBreakerDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (PowerBreaker powerBreaker in breakers)
|
||||||
|
{
|
||||||
|
Tools.CancelDelayDoUnique(powerBreaker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
using CG.Client.Ship.Interactions;
|
||||||
|
using CG.Game;
|
||||||
|
using CG.Ship.Modules;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Photon.Pun;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using VoidManager.Utilities;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(ThrusterBooster))]
|
||||||
|
internal class ThrusterBoosterPatch
|
||||||
|
{
|
||||||
|
private static readonly MethodInfo SetLeverPositionMethod = AccessTools.Method(typeof(Lever), "set_LeverPosition");
|
||||||
|
|
||||||
|
[HarmonyPrepare]
|
||||||
|
static void HookEvents()
|
||||||
|
{
|
||||||
|
Configs.ThrusterBoosterConfig.SettingChanged += ToggleAutomaticThrusterBoosters;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch("ChangeState")]
|
||||||
|
static void ChangeState(ThrusterBooster __instance, ThrusterBoosterState state)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient) return;
|
||||||
|
|
||||||
|
if (state == ThrusterBoosterState.Off && Configs.ThrusterBoosterConfig.Value)
|
||||||
|
{
|
||||||
|
Tools.DelayDoUnique(__instance, () => ChargeThrusterBooster(__instance), Configs.ThrusterBoosterDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ChargeThrusterBooster(ThrusterBooster booster)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient || !Tools.PlayerShipExists) return;
|
||||||
|
|
||||||
|
if (booster.state == ThrusterBoosterState.Off)
|
||||||
|
{
|
||||||
|
SetLeverPositionMethod.Invoke(booster.ChargeLever, new object[] { 1f });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void ToggleAutomaticThrusterBoosters(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!PhotonNetwork.IsMasterClient) return;
|
||||||
|
|
||||||
|
List<ThrusterBooster> boosters = ClientGame.Current.PlayerShip?.Transform?.GetComponent<ThrusterBoosterController>()?.ThrusterBoosters;
|
||||||
|
if (boosters == null) return;
|
||||||
|
|
||||||
|
if (Configs.ThrusterBoosterConfig.Value)
|
||||||
|
{
|
||||||
|
foreach (ThrusterBooster booster in boosters)
|
||||||
|
{
|
||||||
|
if (booster.state == ThrusterBoosterState.Off)
|
||||||
|
{
|
||||||
|
Tools.DelayDoUnique(booster, () => ChargeThrusterBooster(booster), Configs.ThrusterBoosterDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (ThrusterBooster booster in boosters)
|
||||||
|
{
|
||||||
|
Tools.CancelDelayDoUnique(booster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using Photon.Pun;
|
||||||
|
using VoidManager.MPModChecks;
|
||||||
|
|
||||||
|
namespace AutomaticShipSystems
|
||||||
|
{
|
||||||
|
public class VoidManagerPlugin : VoidManager.VoidPlugin
|
||||||
|
{
|
||||||
|
public VoidManagerPlugin()
|
||||||
|
{
|
||||||
|
VoidManager.Events.Instance.MasterClientSwitched += (_, _) => {
|
||||||
|
if (PhotonNetwork.IsMasterClient)
|
||||||
|
{
|
||||||
|
PowerBreakerPatch.ToggleAutomaticBreakers(null, null);
|
||||||
|
ThrusterBoosterPatch.ToggleAutomaticThrusterBoosters(null, null);
|
||||||
|
EnhancementPatch.ToggleAutomaticTrims(null, null);
|
||||||
|
} };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override MultiplayerType MPType => MultiplayerType.Host;
|
||||||
|
|
||||||
|
public override string Author => "18107";
|
||||||
|
|
||||||
|
public override string Description => "Makes circuit breakers, thruster boosters, and trims self reset";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
[](https://github.com/Void-Crew-Modding-Team)
|
||||||
|

|
||||||
|
[](https://discord.gg/g2u5wpbMGu "Void Crew Modding Discord")
|
||||||
|
|
||||||
|
# AutomaticShipSystems
|
||||||
|
|
||||||
|
Version 0.0.0
|
||||||
|
For Game Version 0.26.3
|
||||||
|
Developed by 18107
|
||||||
|
Requires VoidManager 1.1.7
|
||||||
|
|
||||||
|
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
### 💡 Function - **Makes circuit breakers, thruster boosters, and trims self reset**
|
||||||
|
|
||||||
|
- Intended for solo play
|
||||||
|
|
||||||
|
### 🎮 Client Usage
|
||||||
|
|
||||||
|
- Install
|
||||||
|
- Configure at F5 > Mod Settings > Automatic Ship Systems
|
||||||
|
|
||||||
|
### 👥 Multiplayer Functionality
|
||||||
|
|
||||||
|
- ✅ Host
|
||||||
|
- This affects all players if the host has the mod
|
||||||
|
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
## 🔧 Install Instructions - **Install following the normal BepInEx procedure.**
|
||||||
|
|
||||||
|
Ensure that you have [BepInEx 5](https://thunderstore.io/c/void-crew/p/BepInEx/BepInExPack/) (stable version 5 **MONO**) and [VoidManager](https://thunderstore.io/c/void-crew/p/VoidCrewModdingTeam/VoidManager/) installed.
|
||||||
|
|
||||||
|
#### ✔️ Mod installation - **Unzip the contents into the BepInEx plugin directory**
|
||||||
|
|
||||||
|
Drag and drop `AutomaticShipSystems.dll` into `Void Crew\BepInEx\plugins`
|
||||||
Reference in New Issue
Block a user