Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Ship Plus v1.0.8
ShipPlusA.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalNetworkAPI; using ShipPlusA.Patches; using ShipPlusA.Scripts; using ShipPlusAMod; using TerminalApi; using TerminalApi.Classes; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ShipPlusA")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ShipPlusA")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9b9017b2-1373-4557-8fa4-0f5555ed3b11")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ShipPlusAMod { [BepInPlugin("Anonymouse.ShipPlusAMod", "Skip Plus", "1.0.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ShipModBase : BaseUnityPlugin { public class BalanceNetwork { public int balance { get; set; } } public class ShotNetwork { public IShockableWithGun target; } public class Upgrades { public float radius; public int amount; public float time; public float uses; public int price; } private const string modGUID = "Anonymouse.ShipPlusAMod"; private const string modName = "Skip Plus"; private const string modVersion = "1.0.0.0"; public static List<Upgrades> upgrades = new List<Upgrades>(); public static Vector3 center = new Vector3(0.6f, 7.3623f, -14.177f); public static bool bought = false; private const int spawnAmount = 5; private static int zapGunID = 15; public static List<GameObject> lasers = new List<GameObject>(); public static List<ushort> shockingEntities = new List<ushort>(); private readonly Harmony harmony = new Harmony("Anonymouse.ShipPlusAMod"); private static ShipModBase Instance; public static ShipLights lights; public static int upgradeLevel = 0; internal static ManualLogSource Logger; private static ShipLights shipLightsScript = null; public static int used = 0; private LethalServerMessage<GameObject> serverShockMessage = new LethalServerMessage<GameObject>("shock", (Action<GameObject, ulong>)null); private LethalClientMessage<GameObject> clientShockMessage = new LethalClientMessage<GameObject>("shock", (Action<GameObject>)null, (Action<GameObject, ulong>)RShock); private LethalClientMessage<int> clientBalanceMessage = new LethalClientMessage<int>("balance", (Action<int>)null, (Action<int, ulong>)updateBalance); public static LethalClientMessage<int> clientUpgradeMessage = new LethalClientMessage<int>("upgrade", (Action<int>)null, (Action<int, ulong>)updateUpgrade); private LethalClientMessage<int> clientUpdateUsesMessage = new LethalClientMessage<int>("uses", (Action<int>)null, (Action<int, ulong>)updateUses); private LethalClientMessage<float> clientUpdateCountDown = new LethalClientMessage<float>("cd", (Action<float>)null, (Action<float, ulong>)updateCd); private LethalClientMessage<bool> clientTriggerSound = new LethalClientMessage<bool>("sounds", (Action<bool>)null, (Action<bool, ulong>)RPlaySound); private static ConfigEntry<bool> configDebug; public static bool HostCheck => NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer; public static bool checkShow() { return configDebug.Value; } private void Awake() { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } configDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugMessages", false, "Whether or not to show the debug messages"); upgrades.Add(new Upgrades { amount = 2, radius = 25f, price = 700, time = 3f, uses = 2f }); upgrades.Add(new Upgrades { amount = 3, radius = 35f, price = 750, time = 4f, uses = 2f }); upgrades.Add(new Upgrades { amount = 5, radius = 40f, price = 850, time = 5f, uses = 3f }); upgrades.Add(new Upgrades { amount = 7, radius = 50f, price = 1200, time = 8f, uses = 3f }); Logger = Logger.CreateLogSource("Anonymouse.ShipPlusAMod"); if (checkShow()) { Logger.LogInfo((object)"Ship Plus awaken :DD"); } harmony.PatchAll(typeof(ShipModBase)); harmony.PatchAll(typeof(StartOfRoundPatch)); TerminalApi.AddCommand("zapwaveB", new CommandInfo { DisplayTextSupplier = () => "play\n", Category = "Other", Description = "play audio" }, (string)null, true); TerminalApi.AddCommand("zapwave", new CommandInfo { DisplayTextSupplier = delegate { if (bought) { return "You already bought it...\n"; } Terminal val2 = Object.FindObjectOfType<Terminal>(); if (val2.groupCredits < 700) { return "Not enoguh credits to buy\n"; } if (checkShow()) { Logger.LogWarning((object)"Bought ZAP Wave protection"); } clientBalanceMessage.SendAllClients(val2.groupCredits - upgrades[upgradeLevel].price, true, false); return "Bought ZAP WAVE protection\nTo use type: wave\n"; }, Category = "Other", Description = "* 700 *\nUse to buy ZAP WAVE tool that protects the ship.\nType 'wave' to use." }, (string)null, true); TerminalApi.AddCommand("waveup", new CommandInfo { DisplayTextSupplier = delegate { if (!bought) { return "You have to buy ZAP WAVE first to upgrade it\n"; } if (upgradeLevel == upgrades.Count - 1) { return "You already got MAX upgraded ZAP WAVE\n"; } Terminal val = Object.FindObjectOfType<Terminal>(); if (val.groupCredits < upgrades[upgradeLevel + 1].price) { return "Not enoguh credits to buy\nPrice *" + upgrades[upgradeLevel + 1].price + "*\n"; } if (checkShow()) { Logger.LogWarning((object)"Bought ZAP Wave upgrade"); } upgradeLevel++; clientBalanceMessage.SendAllClients(val.groupCredits - upgrades[upgradeLevel].price, true, false); clientUpgradeMessage.SendAllClients(upgradeLevel, true, false); return "Bought ZAP WAVE upgrade\nRadius " + upgrades[upgradeLevel].radius + "\nShock time " + upgrades[upgradeLevel].time + "\nTargets " + upgrades[upgradeLevel].amount + "\n"; }, Category = "Other", Description = "Use to upgrade ZAP WAVE. Upgrade: \nRadius ?\nShock time ?\nTargets ?\n" }, (string)null, true); TerminalApi.AddCommand("wave", new CommandInfo { DisplayTextSupplier = delegate { if (checkShow()) { Logger.LogWarning((object)"USED wave cmd"); } if (!bought) { return "You need to buy it first...\n"; } if ((float)used >= upgrades[upgradeLevel].uses) { return "The ship's energy is almost exhausted!\nYou can't use it now\n"; } if (!StartOfRoundPatch.moznaUzyc) { return "You need to wait " + StartOfRoundPatch.czasDoOdblokowania.ToString("F1") + "s before using wave again\n"; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>> name " + (object)localPlayerController)); } var (array, array2) = getShockableAround(); if (array.Length == 0 && array2.Length == 0) { return "There are no targets around the ship to zap\n"; } sendToAll(array, array2); return "Used ZAP WAVE\n\n Try stun (max" + upgrades[upgradeLevel].amount + " targets): \npl: " + array.Count() + "\n enemies: " + array2.Count() + "\nUsed waves [" + used + "/" + upgrades[upgradeLevel].uses + "]\n"; }, Title = "WAVE", Category = "Other", Description = "Use ZAP WAVE to protect allies before they die!!!" }, (string)null, true); } private void sendToAll(IShockableWithGun[] targets, EnemyAI[] enemyAITargets) { targets = targets.OrderBy((IShockableWithGun e) => Vector3.Distance(((Component)e.GetShockableTransform()).transform.position, center)).ToArray(); enemyAITargets = enemyAITargets.OrderBy((EnemyAI e) => Vector3.Distance(((Component)e).transform.position, center)).ToArray(); for (int i = 0; i < targets.Length; i++) { clientShockMessage.SendAllClients(((Component)targets[i].GetShockableTransform()).gameObject, true, false); } for (int j = 0; j < enemyAITargets.Length; j++) { clientShockMessage.SendAllClients(((Component)enemyAITargets[j]).gameObject, true, false); } clientTriggerSound.SendAllClients(true, true, false); clientUpdateUsesMessage.SendAllClients(used + 1, true, false); clientUpdateCountDown.SendAllClients(upgrades[upgradeLevel].time + 2f, true, false); } private static IEnumerator stopSounds() { if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>stop call " + upgrades[upgradeLevel].time)); } yield return (object)new WaitForSeconds(upgrades[upgradeLevel].time); if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>check null " + (object)StartOfRoundPatch.laserAudio)); } if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>check null " + (object)StartOfRoundPatch.laserAudio2)); } StartOfRoundPatch.laserAudio.Stop(); StartOfRoundPatch.laserAudio2.Stop(); } private static void stopSoundsNow() { if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>now stop call " + upgrades[upgradeLevel].time)); } if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>now check null " + (object)StartOfRoundPatch.laserAudio)); } if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>now check null " + (object)StartOfRoundPatch.laserAudio2)); } StartOfRoundPatch.laserAudio.Stop(); StartOfRoundPatch.laserAudio2.Stop(); } private static void RPlaySound(bool x, ulong clientId) { if (checkShow()) { Logger.LogInfo((object)(">>>>>>>>>>>>>>>play audio..." + upgrades[upgradeLevel].time)); } StartOfRoundPatch.laserAudio2.Play(); StartOfRoundPatch.laserAudio.PlayDelayed(2f); ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(stopSounds()); } private static void RShock(GameObject objs, ulong clientId) { if (HostCheck) { if (checkShow()) { Logger.LogWarning((object)">>>>>>>>>>>>lights off???? "); } if ((Object)(object)shipLightsScript == (Object)null && (Object)(object)Object.FindObjectOfType<ShipLights>() != (Object)null) { shipLightsScript = Object.FindObjectOfType<ShipLights>(); shipLightsScript.ToggleShipLights(); } else if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>lights else " + ((Object)(object)shipLightsScript == (Object)null) + "\nscript??? " + ((Object)(object)Object.FindObjectOfType<ShipLights>() == (Object)null))); } } if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>GOT RPC METHOD CALL, count of objs " + ((Object)(object)objs == (Object)null))); } if ((Object)(object)objs.GetComponent<PlayerControllerB>() == (Object)null) { if (checkShow()) { Logger.LogWarning((object)">>>>>>>>>>>>GOT RPC METHOD CALL FOR ENEMY??? "); } EnemyAICollisionDetect componentInChildren = objs.GetComponentInChildren<EnemyAICollisionDetect>(); EnemyAICollisionDetect component = objs.GetComponent<EnemyAICollisionDetect>(); if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>check if null " + ((Object)(object)componentInChildren == (Object)null))); } if (checkShow()) { Logger.LogWarning((object)(">>>>>>>>>>>>check if null " + ((Object)(object)component == (Object)null))); } ((MonoBehaviour)RoundManager.Instance).StartCoroutine(shootClient((IShockableWithGun)(object)(((Object)(object)componentInChildren != (Object)null) ? componentInChildren : component), LethalNetworkExtensions.GetPlayerController(clientId))); } else { if (checkShow()) { Logger.LogWarning((object)">>>>>>>>>>>>rpc for player only "); } ((MonoBehaviour)RoundManager.Instance).StartCoroutine(shootClient((IShockableWithGun)(object)objs.GetComponent<PlayerControllerB>(), LethalNetworkExtensions.GetPlayerController(clientId))); } } private (IShockableWithGun[] shockableTargets, EnemyAI[] enemyAITargets) getShockableAround() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown float radius = upgrades[upgradeLevel].radius; List<IShockableWithGun> list = new List<IShockableWithGun>(); List<EnemyAI> list2 = new List<EnemyAI>(); Collider[] array = Physics.OverlapSphere(center, radius); shockingEntities.Clear(); Collider[] array2 = array; foreach (Collider val in array2) { Transform transform = ((Component)val).transform; IShockableWithGun component = ((Component)transform).GetComponent<IShockableWithGun>(); EnemyAI component2 = ((Component)transform).GetComponent<EnemyAI>(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.stunnedByPlayer == (Object)null && !shockingEntities.Contains(((NetworkBehaviour)component2).NetworkBehaviourId)) { list2.Add(component2); shockingEntities.Add(((NetworkBehaviour)component2).NetworkBehaviourId); } if (component == null || !component.CanBeShocked()) { continue; } Vector3 shockablePosition = component.GetShockablePosition(); if (component is PlayerControllerB) { PlayerControllerB val2 = (PlayerControllerB)component; if (!val2.isInHangarShipRoom && !shockingEntities.Contains(((NetworkBehaviour)val2).NetworkBehaviourId)) { list.Add((IShockableWithGun)(object)val2); shockingEntities.Add(((NetworkBehaviour)val2).NetworkBehaviourId); } } } shockingEntities.Clear(); return (list.ToArray(), list2.ToArray()); } private static IEnumerator shoot(LightningScript sc, IShockableWithGun shock, PlayerControllerB sender) { float elapsedTime = 0f; Vector3 up2 = shock.GetShockablePosition(); Vector3 pos1 = new Vector3(up2.x, up2.y - 1f, up2.z); if (checkShow()) { Logger.LogWarning((object)(">>>>>>>> script?? " + ((Object)(object)sc == (Object)null))); } sc.ShootLightning(center, pos1); shock.ShockWithGun(sender); while (elapsedTime < upgrades[upgradeLevel].time) { Vector3 up = shock.GetShockablePosition(); sc.updateLoc(loc2: new Vector3(up.x, up.y - 1f, up.z), loc1: center); elapsedTime += Time.deltaTime; yield return null; } shock.StopShockingWithGun(); yield return (object)new WaitForSeconds(0.001f); stopSoundsNow(); shock.StopShockingWithGun(); ((Component)sc).gameObject.SetActive(false); } private static IEnumerator shootClient(IShockableWithGun target, PlayerControllerB sender) { GameObject myScriptObject = StartOfRoundPatch.laser.Find((GameObject e) => !e.gameObject.activeSelf); if ((Object)(object)myScriptObject != (Object)null) { if (checkShow()) { Logger.LogWarning((object)">>>>>>>> script not null"); } yield return (object)new WaitForEndOfFrame(); myScriptObject.SetActive(true); if (checkShow()) { Logger.LogWarning((object)">>>>>>>> shot"); } LightningScript sc = myScriptObject.GetComponent<LightningScript>(); if (checkShow()) { Logger.LogWarning((object)(">>>>>>>> check " + ((Object)(object)sc == (Object)null))); } ((MonoBehaviour)sc).StartCoroutine(shoot(sc, target, sender)); } else if (checkShow()) { Logger.LogWarning((object)(">>>>>>>> script null, not free laser from count of " + StartOfRoundPatch.laser.Count)); } } public static void updateBalance(int balance, ulong clientId) { if (checkShow()) { Logger.LogInfo((object)"===============sync balance==============="); } if (!bought) { bought = true; ((MonoBehaviour)RoundManager.Instance).StartCoroutine(StartOfRoundPatch.reCreateLasers(RoundManager.Instance)); } Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)StartOfRoundPatch.terminalBuy != (Object)null) { if (checkShow()) { Logger.LogInfo((object)"===============sound not null???? =============== "); } val.terminalAudio.PlayOneShot(StartOfRoundPatch.terminalBuy); } else if (checkShow()) { Logger.LogInfo((object)"===============sound null...!!! =============== "); } if (checkShow()) { Logger.LogInfo((object)("===============null???? =============== " + ((Object)(object)val == (Object)null))); } val.groupCredits = balance; } public static void updateUses(int uses, ulong clientId) { if (checkShow()) { Logger.LogInfo((object)("===============sync uses===============" + used)); } used = uses; } public static void updateCd(float cd, ulong clientId) { if (checkShow()) { Logger.LogInfo((object)("===============sync cd===============" + cd)); } StartOfRoundPatch.coundDown(cd); } public static void updateUpgrade(int level, ulong clientId) { if (checkShow()) { Logger.LogInfo((object)("===============sync level=============== " + level)); } if (!bought) { bought = true; } if (checkShow()) { Logger.LogInfo((object)"===============null???? =============== "); } ((MonoBehaviour)RoundManager.Instance).StartCoroutine(StartOfRoundPatch.reCreateLasers(RoundManager.Instance)); upgradeLevel = level; used = 0; } } } namespace ShipPlusA.Scripts { public class LightningScript : MonoBehaviour { public static float offsetScale = 1.25f; public Vector3 startLocation; public Vector3 endLocation; public static float duration = 6f; public int amount = 4; public List<Transform> lineObjects; public List<LineRenderer> lineRenderers; public static float noiseScale = 20f; public bool shootingAlready = false; private void Start() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) lineObjects = new List<Transform>(); lineRenderers = new List<LineRenderer>(); for (int i = 0; i < amount; i++) { GameObject val = new GameObject("LightningLine" + i); val.transform.SetParent(((Component)this).transform); lineObjects.Add(val.transform); LineRenderer val2 = val.AddComponent<LineRenderer>(); val2.positionCount = 2; val2.useWorldSpace = true; lineRenderers.Add(val2); if (i % 2 == 0) { SetLineProperties(val2, Color.white); } else { SetLineProperties(val2, Color.yellow); } } ((Component)this).gameObject.SetActive(false); } private void SetLineProperties(LineRenderer ln, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("HDRP/Lit"); ((Renderer)ln).material = new Material(val); ln.startWidth = 0.04f; ln.endWidth = 0.01f; ln.startColor = color; ln.endColor = color; ((Renderer)ln).material.SetColor("_BaseColor", color); ((Renderer)ln).material.SetFloat("_EmissiveIntensity", 1f); ((Renderer)ln).material.EnableKeyword("_EMISSION"); } public void updateLoc(Vector3 loc1, Vector3 loc2) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) startLocation = loc1; endLocation = loc2; } public void ShootLightning(Vector3 loc1, Vector3 loc2) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) startLocation = loc1; endLocation = loc2; duration = ShipModBase.upgrades[ShipModBase.upgradeLevel].time; int num = Mathf.RoundToInt(Vector3.Distance(loc1, loc2)); for (int i = 0; i < amount; i++) { lineRenderers[i].positionCount = num * 2; } ((MonoBehaviour)this).StartCoroutine(ShootLightningCoroutine(num)); } private IEnumerator ShootLightningCoroutine(int dis) { float startTime = Time.time; Vector3[][] positions = new Vector3[amount][]; for (int n = 0; n < amount; n++) { LineRenderer ln = lineRenderers[n]; positions[n] = (Vector3[])(object)new Vector3[ln.positionCount]; for (int i = 0; i < ln.positionCount; i++) { positions[n][i] = Vector3.Lerp(startLocation, endLocation, (float)i / (float)(ln.positionCount - 1)); } ln.SetPositions(positions[n]); UpdateLineObjects(positions[n], lineObjects[n]); } while (Time.time - startTime < duration) { for (int l = 0; l < amount; l++) { LineRenderer ln2 = lineRenderers[l]; for (int j = 0; j < ln2.positionCount; j++) { float noise = Mathf.PerlinNoise((float)j * noiseScale, Time.time * noiseScale) + Mathf.Sin((float)l * 0.1f); float verticalOffset = Random.Range(-0.2f, 0.2f); positions[l][j] = Vector3.Lerp(startLocation, endLocation, (float)j / (float)(ln2.positionCount - 1)) + new Vector3(0f, noise + verticalOffset, 0f); } ln2.SetPositions(positions[l]); UpdateLineObjects(positions[l], lineObjects[l]); } yield return (object)new WaitForSeconds(0.001f); yield return (object)new WaitForEndOfFrame(); } for (int m = 0; m < amount; m++) { Transform lineObject = lineObjects[m]; for (int k = 0; k < lineObject.childCount; k++) { Object.Destroy((Object)(object)((Component)lineObject.GetChild(k)).gameObject); } } yield return (object)new WaitForSeconds(0.001f); yield return (object)new WaitForEndOfFrame(); ((Component)this).gameObject.SetActive(false); } private void UpdateLineObjects(Vector3[] positions, Transform lineObject) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) int childCount = lineObject.childCount; if (childCount != positions.Length) { while (lineObject.childCount < positions.Length) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)2); Object.Destroy((Object)(object)val.GetComponent<Collider>()); val.transform.SetParent(lineObject); } while (lineObject.childCount > positions.Length) { Transform child = lineObject.GetChild(lineObject.childCount - 1); Object.Destroy((Object)(object)((Component)child).gameObject); } } for (int i = 0; i < positions.Length; i++) { Transform child2 = lineObject.GetChild(i); child2.position = positions[i]; if (i < positions.Length - 1) { child2.LookAt(positions[i + 1]); } } } } } namespace ShipPlusA.Patches { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { public static List<GameObject> laser = new List<GameObject>(); public static AudioClip clipToLoad; public static AudioClip clipToLoad2; public static AudioClip terminalBuy; public static GameObject audioSourceObject1; public static GameObject audioSourceObject2; public static AudioSource laserAudio; public static AudioSource laserAudio2; public static bool moznaUzyc = true; private static float czasOstatniegoUzycia; public static float czasDoOdblokowania = 0f; private static float countDown = 5f; public static bool HostCheck => NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer; [HarmonyPatch("Update")] [HarmonyPostfix] private static void updateCountdown() { if (!moznaUzyc) { float num = Time.time - czasOstatniegoUzycia; czasDoOdblokowania = countDown - num; if (num >= countDown) { moznaUzyc = true; } } } public static void coundDown(float cd) { countDown = cd; czasOstatniegoUzycia = Time.time; moznaUzyc = false; } [HarmonyPatch("openingDoorsSequence")] [HarmonyPostfix] private static void refr(ref RoundManager __instance) { if (ShipModBase.checkShow() && ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>open door call"); } if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>check host"); } if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>host ..."); } ((MonoBehaviour)__instance).StartCoroutine(reCreateLasers(__instance)); } [HarmonyPatch("ShipHasLeft")] [HarmonyPostfix] private static void refclose(ref RoundManager __instance) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)(">>>>>>>>>>>>>>>close door call " + GameNetworkManager.Instance.currentSaveFileName)); } if (HostCheck && ES3.FileExists(GameNetworkManager.Instance.currentSaveFileName)) { if (ES3.KeyExists("ZapGunBought", GameNetworkManager.Instance.currentSaveFileName)) { bool flag = ES3.Load<bool>("ZapGunBought", GameNetworkManager.Instance.currentSaveFileName); if (ShipModBase.bought != flag) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)(">>>>>>>>>>>>>>>save buy = " + ShipModBase.bought)); } SaveData(ShipModBase.bought); } else if (ShipModBase.bought && ES3.KeyExists("ZapGunLevel", GameNetworkManager.Instance.currentSaveFileName)) { int num = ES3.Load<int>("ZapGunLevel", GameNetworkManager.Instance.currentSaveFileName); if (num != ShipModBase.upgradeLevel) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)(">>>>>>>>>>>>>>>save level = " + ShipModBase.upgradeLevel)); } SaveLevel(); } } } else { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)(">>>>>>>>>>>>>>>save data = " + ShipModBase.bought + " " + ShipModBase.upgradeLevel)); } SaveData(ShipModBase.bought); } } if (ShipModBase.bought) { ShipModBase.used = 0; } } [HarmonyPatch("StartGame")] [HarmonyPostfix] private static void startGame(ref RoundManager __instance) { if (!HostCheck) { return; } if (ES3.FileExists(GameNetworkManager.Instance.currentSaveFileName)) { try { bool flag = ES3.Load<bool>("ZapGunBought", GameNetworkManager.Instance.currentSaveFileName); if (ShipModBase.bought != flag && ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)(">>>>>>>>>>>>>>>Loaded bought state = " + flag)); } int num = ES3.Load<int>("ZapGunLevel", GameNetworkManager.Instance.currentSaveFileName); if (num != ShipModBase.upgradeLevel) { ShipModBase.clientUpgradeMessage.SendAllClients(num, true, false); if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)(">>>>>>>>>>>>>>>Loaded level state = " + num)); } } return; } catch (Exception ex) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogError((object)(">>>>>>>>>>>>>loading error " + ex)); } return; } } if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>Load fail no file"); } } public static IEnumerator reCreateLasers(RoundManager __instance) { for (int i = 0; i < laser.Count; i++) { Object.Destroy((Object)(object)laser[i]); } laser.Clear(); yield return (object)new WaitForSeconds(0.2f); Transform existingChild = ((Component)__instance).transform.Find("LightningScript"); if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>check"); } if ((Object)(object)existingChild == (Object)null) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>no child, creating..."); } for (int j = 0; j < ShipModBase.upgrades[ShipModBase.upgradeLevel].amount; j++) { GameObject childOb = ((j == 0) ? new GameObject("LightningScript") : new GameObject("LightningScript" + j)); childOb.AddComponent<LightningScript>(); childOb.transform.SetParent(((Component)__instance).transform); laser.Add(childOb); } } else if (ShipModBase.checkShow()) { ShipModBase.Logger.LogInfo((object)">>>>>>>>>>>>>>>had child, doing nothing..."); } AudioClip[] audioClips = Resources.FindObjectsOfTypeAll<AudioClip>(); AudioClip[] array = audioClips; foreach (AudioClip clip in array) { if (((Object)clip).name.Equals("ShockBeam2")) { clipToLoad2 = clip; } if (((Object)clip).name.Equals("ShockBeam1")) { clipToLoad = clip; } if (((Object)clip).name.Equals("PurchaseSFX")) { terminalBuy = clip; } } Object.Destroy((Object)(object)audioSourceObject1); Object.Destroy((Object)(object)audioSourceObject2); audioSourceObject1 = new GameObject("LaserAudio2"); audioSourceObject1.transform.position = ShipModBase.center; laserAudio = audioSourceObject1.AddComponent<AudioSource>(); ((Component)laserAudio).transform.position = ShipModBase.center; laserAudio.clip = clipToLoad2; laserAudio.volume = 1f; laserAudio.spatialBlend = 1f; laserAudio.minDistance = 20f; laserAudio.maxDistance = 50f; laserAudio.loop = true; audioSourceObject2 = new GameObject("LaserAudio1"); audioSourceObject2.transform.position = ShipModBase.center; laserAudio2 = audioSourceObject2.AddComponent<AudioSource>(); ((Component)laserAudio2).transform.position = ShipModBase.center; laserAudio2.clip = clipToLoad; laserAudio2.volume = 1f; laserAudio2.spatialBlend = 1f; laserAudio2.minDistance = 20f; laserAudio2.maxDistance = 50f; laserAudio2.loop = true; } private static void SaveData(bool bought = false) { try { ES3.Save<bool>("ZapGunBought", bought, GameNetworkManager.Instance.currentSaveFileName); ES3.Save<int>("ZapGunLevel", ShipModBase.upgradeLevel, GameNetworkManager.Instance.currentSaveFileName); } catch (Exception ex) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogError((object)(">>>>>>>>>>>>>save error " + ex)); } } } private static void SaveLevel() { try { ES3.Save<int>("ZapGunLevel", ShipModBase.upgradeLevel, GameNetworkManager.Instance.currentSaveFileName); } catch (Exception ex) { if (ShipModBase.checkShow()) { ShipModBase.Logger.LogError((object)(">>>>>>>>>>>>>save lvl serror " + ex)); } } } } }