Change to only enable when starting session as host, Disable progress.
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
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
|
||||
@@ -26,7 +22,7 @@ namespace AutomaticShipSystems
|
||||
[HarmonyPatch("SetState")]
|
||||
static void SetState(Enhancement __instance, EnhancementState newState)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled) return;
|
||||
|
||||
if (Configs.TrimConfig.Value &&
|
||||
ClientGame.Current?.PlayerShip?.GetModule<Helm>()?.Engine?.GetComponentsInChildren<Enhancement>()?.Contains(__instance) == true &&
|
||||
@@ -38,7 +34,7 @@ namespace AutomaticShipSystems
|
||||
|
||||
private static void ResetTrim(Enhancement trim)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient || !Tools.PlayerShipExists) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled || !Game.PlayerShipExists) return;
|
||||
|
||||
if (trim.CurrentState.Value == EnhancementState.Inactive)
|
||||
{
|
||||
@@ -48,7 +44,7 @@ namespace AutomaticShipSystems
|
||||
|
||||
internal static void ToggleAutomaticTrims(object sender, EventArgs e)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled) return;
|
||||
|
||||
Enhancement[] trims = ClientGame.Current?.PlayerShip?.GetModule<Helm>()?.Engine?.GetComponentsInChildren<Enhancement>();
|
||||
if (trims == null || trims.Length == 0) return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using CG.Game;
|
||||
using Gameplay.PowerSystem;
|
||||
using Gameplay.Power;
|
||||
using HarmonyLib;
|
||||
using Photon.Pun;
|
||||
using System;
|
||||
@@ -21,7 +21,7 @@ namespace AutomaticShipSystems
|
||||
[HarmonyPatch("OnPowerStateChange")]
|
||||
static void OnPowerStateChange(PowerBreaker __instance, bool isOn)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled) return;
|
||||
|
||||
if (!isOn && Configs.CircuitBreakerConfig.Value)
|
||||
{
|
||||
@@ -31,14 +31,14 @@ namespace AutomaticShipSystems
|
||||
|
||||
private static void ResetCircuitBreakers(PowerBreaker breaker)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient || !Tools.PlayerShipExists) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled || !Game.PlayerShipExists) return;
|
||||
|
||||
breaker.IsOn.RequestChange(true);
|
||||
}
|
||||
|
||||
internal static void ToggleAutomaticBreakers(object sender, EventArgs e)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled) return;
|
||||
|
||||
List<PowerBreaker> breakers = ClientGame.Current?.PlayerShip?.GetComponentInChildren<ProtectedPowerSystem>()?.Breakers;
|
||||
if (breakers == null) return;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace AutomaticShipSystems
|
||||
[HarmonyPatch("ChangeState")]
|
||||
static void ChangeState(ThrusterBooster __instance, ThrusterBoosterState state)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled) return;
|
||||
|
||||
if (state == ThrusterBoosterState.Off && Configs.ThrusterBoosterConfig.Value)
|
||||
{
|
||||
@@ -35,9 +35,9 @@ namespace AutomaticShipSystems
|
||||
|
||||
private static void ChargeThrusterBooster(ThrusterBooster booster)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient || !Tools.PlayerShipExists) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled || !Game.PlayerShipExists) return;
|
||||
|
||||
if (booster.state == ThrusterBoosterState.Off)
|
||||
if (booster.State == ThrusterBoosterState.Off)
|
||||
{
|
||||
SetLeverPositionMethod.Invoke(booster.ChargeLever, new object[] { 1f });
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace AutomaticShipSystems
|
||||
|
||||
internal static void ToggleAutomaticThrusterBoosters(object sender, EventArgs e)
|
||||
{
|
||||
if (!PhotonNetwork.IsMasterClient) return;
|
||||
if (!PhotonNetwork.IsMasterClient || !VoidManagerPlugin.ModEnabled) return;
|
||||
|
||||
List<ThrusterBooster> boosters = ClientGame.Current.PlayerShip?.Transform?.GetComponent<ThrusterBoosterController>()?.ThrusterBoosters;
|
||||
if (boosters == null) return;
|
||||
@@ -54,7 +54,7 @@ namespace AutomaticShipSystems
|
||||
{
|
||||
foreach (ThrusterBooster booster in boosters)
|
||||
{
|
||||
if (booster.state == ThrusterBoosterState.Off)
|
||||
if (booster.State == ThrusterBoosterState.Off)
|
||||
{
|
||||
Tools.DelayDoUnique(booster, () => ChargeThrusterBooster(booster), Configs.ThrusterBoosterDelay);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using Photon.Pun;
|
||||
using VoidManager;
|
||||
using VoidManager.MPModChecks;
|
||||
|
||||
namespace AutomaticShipSystems
|
||||
{
|
||||
public class VoidManagerPlugin : VoidManager.VoidPlugin
|
||||
public class VoidManagerPlugin : VoidPlugin
|
||||
{
|
||||
public VoidManagerPlugin()
|
||||
{
|
||||
VoidManager.Events.Instance.MasterClientSwitched += (_, _) => {
|
||||
Events.Instance.MasterClientSwitched += (_, _) => {
|
||||
if (PhotonNetwork.IsMasterClient)
|
||||
{
|
||||
PowerBreakerPatch.ToggleAutomaticBreakers(null, null);
|
||||
@@ -23,5 +24,28 @@ namespace AutomaticShipSystems
|
||||
public override string Description => MyPluginInfo.PLUGIN_DESCRIPTION;
|
||||
|
||||
public override string ThunderstoreID => MyPluginInfo.PLUGIN_THUNDERSTORE_ID;
|
||||
|
||||
public static bool ModEnabled = false;
|
||||
|
||||
internal static void Enable()
|
||||
{
|
||||
ModEnabled = true;
|
||||
VoidManager.Progression.ProgressionHandler.DisableProgression(MyPluginInfo.PLUGIN_GUID);
|
||||
}
|
||||
|
||||
public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
|
||||
{
|
||||
switch(input.CallType)
|
||||
{
|
||||
case CallType.Joining:
|
||||
ModEnabled = false;
|
||||
break;
|
||||
case CallType.SessionEscalated:
|
||||
case CallType.HostStartSession:
|
||||
Enable();
|
||||
return new SessionChangedReturn() { SetMod_Session = true};
|
||||
}
|
||||
return base.OnSessionChange(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user