using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using On;
using Steamworks.Data;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WeeklyMoonInviteMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("WeeklyMoonInviteMode")]
[assembly: AssemblyTitle("WeeklyMoonInviteMode")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace WeeklyMoonInviteMode
{
[BepInPlugin("amashi.WeeklyMoonInviteMode", "WeeklyMoonInviteMode", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string plugin_GUID = "amashi.WeeklyMoonInviteMode";
public const string plugin_NAME = "WeeklyMoonInviteMode";
public const string plugin_VERSION = "1.0.0";
private Type gamenetworkmanager_type = typeof(GameNetworkManager);
private MethodInfo method_SaveItemsInShip;
public Plugin Instance;
private void Awake()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
method_SaveItemsInShip = gamenetworkmanager_type.GetMethod("SaveItemsInShip", BindingFlags.Instance | BindingFlags.NonPublic);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin amashi.WeeklyMoonInviteMode is loaded!");
GameNetworkManager.SetLobbyJoinable += new hook_SetLobbyJoinable(GameNetworkManager_SetLobbyJoinable);
}
private void GameNetworkManager_SaveGameValues(orig_SaveGameValues orig, GameNetworkManager self)
{
//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
if (StartOfRound.Instance.isChallengeFile && GameNetworkManager.Instance.gameHasStarted)
{
ES3.Save<bool>("FinishedChallenge", true, "LCChallengeFile");
if (!StartOfRound.Instance.displayedLevelResults)
{
ES3.Save<int>("ProfitEarned", 0, "LCChallengeFile");
}
else
{
Debug.Log((object)$"Saved challenge score as {StartOfRound.Instance.scrapCollectedLastRound}; total scrap in level: {RoundManager.Instance.totalScrapValueInLevel}");
ES3.Save<int>("ProfitEarned", StartOfRound.Instance.scrapCollectedLastRound, "LCChallengeFile");
}
}
if (!self.isHostingGame)
{
return;
}
if (!ES3.KeyExists("FileGameVers", self.currentSaveFileName))
{
ES3.Save<int>("FileGameVers", GameNetworkManager.Instance.gameVersionNum, self.currentSaveFileName);
}
if (!StartOfRound.Instance.inShipPhase || StartOfRound.Instance.isChallengeFile)
{
return;
}
try
{
TimeOfDay val = Object.FindObjectOfType<TimeOfDay>();
if ((Object)(object)val != (Object)null)
{
ES3.Save<int>("QuotaFulfilled", val.quotaFulfilled, self.currentSaveFileName);
ES3.Save<int>("QuotasPassed", val.timesFulfilledQuota, self.currentSaveFileName);
ES3.Save<int>("ProfitQuota", val.profitQuota, self.currentSaveFileName);
}
ES3.Save<int>("CurrentPlanetID", StartOfRound.Instance.currentLevelID, self.currentSaveFileName);
Terminal val2 = Object.FindObjectOfType<Terminal>();
if ((Object)(object)val2 != (Object)null)
{
ES3.Save<int>("GroupCredits", val2.groupCredits, self.currentSaveFileName);
if (val2.unlockedStoryLogs.Count > 0)
{
ES3.Save<int[]>("StoryLogs", val2.unlockedStoryLogs.ToArray(), self.currentSaveFileName);
}
if (val2.scannedEnemyIDs.Count > 0)
{
ES3.Save<int[]>("EnemyScans", val2.scannedEnemyIDs.ToArray(), self.currentSaveFileName);
}
}
StartOfRound val3 = Object.FindObjectOfType<StartOfRound>();
if ((Object)(object)val3 != (Object)null)
{
List<int> list = new List<int>();
for (int i = 0; i < val3.unlockablesList.unlockables.Count; i++)
{
if (val3.unlockablesList.unlockables[i].hasBeenUnlockedByPlayer || val3.unlockablesList.unlockables[i].hasBeenMoved || val3.unlockablesList.unlockables[i].inStorage)
{
list.Add(i);
}
if (val3.unlockablesList.unlockables[i].IsPlaceable)
{
if (val3.unlockablesList.unlockables[i].canBeStored)
{
ES3.Save<bool>("ShipUnlockStored_" + val3.unlockablesList.unlockables[i].unlockableName, val3.unlockablesList.unlockables[i].inStorage, self.currentSaveFileName);
}
if (val3.unlockablesList.unlockables[i].hasBeenMoved)
{
ES3.Save<bool>("ShipUnlockMoved_" + val3.unlockablesList.unlockables[i].unlockableName, val3.unlockablesList.unlockables[i].hasBeenMoved, self.currentSaveFileName);
ES3.Save<Vector3>("ShipUnlockPos_" + val3.unlockablesList.unlockables[i].unlockableName, val3.unlockablesList.unlockables[i].placedPosition, self.currentSaveFileName);
ES3.Save<Vector3>("ShipUnlockRot_" + val3.unlockablesList.unlockables[i].unlockableName, val3.unlockablesList.unlockables[i].placedRotation, self.currentSaveFileName);
}
}
}
if (list.Count > 0)
{
ES3.Save<int[]>("UnlockedShipObjects", list.ToArray(), self.currentSaveFileName);
}
ES3.Save<int>("DeadlineTime", (int)Mathf.Clamp(val.timeUntilDeadline, 0f, 99999f), self.currentSaveFileName);
ES3.Save<int>("RandomSeed", val3.randomMapSeed, self.currentSaveFileName);
ES3.Save<int>("Stats_DaysSpent", val3.gameStats.daysSpent, self.currentSaveFileName);
ES3.Save<int>("Stats_Deaths", val3.gameStats.deaths, self.currentSaveFileName);
ES3.Save<int>("Stats_ValueCollected", val3.gameStats.scrapValueCollected, self.currentSaveFileName);
ES3.Save<int>("Stats_StepsTaken", val3.gameStats.allStepsTaken, self.currentSaveFileName);
}
method_SaveItemsInShip.Invoke(self, null);
}
catch (Exception arg)
{
Debug.LogError((object)$"Error while trying to save game values when disconnecting as host: {arg}");
}
}
private void GameNetworkManager_SaveItemsInShip(orig_SaveItemsInShip orig, GameNetworkManager self)
{
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsInactive)0, (FindObjectsSortMode)0);
if (array == null || array.Length == 0)
{
ES3.DeleteKey("shipGrabbableItemIDs", self.currentSaveFileName);
ES3.DeleteKey("shipGrabbableItemPos", self.currentSaveFileName);
ES3.DeleteKey("shipScrapValues", self.currentSaveFileName);
ES3.DeleteKey("shipItemSaveData", self.currentSaveFileName);
return;
}
List<int> list = new List<int>();
List<Vector3> list2 = new List<Vector3>();
List<int> list3 = new List<int>();
List<int> list4 = new List<int>();
int num = 0;
for (int i = 0; i < array.Length && i <= StartOfRound.Instance.maxShipItemCapacity; i++)
{
if (!StartOfRound.Instance.allItemsList.itemsList.Contains(array[i].itemProperties) || array[i].deactivated)
{
continue;
}
if ((Object)(object)array[i].itemProperties.spawnPrefab == (Object)null)
{
Debug.LogError((object)("Item '" + array[i].itemProperties.itemName + "' has no spawn prefab set!"));
}
else
{
if (array[i].itemUsedUp)
{
continue;
}
for (int j = 0; j < StartOfRound.Instance.allItemsList.itemsList.Count; j++)
{
if ((Object)(object)StartOfRound.Instance.allItemsList.itemsList[j] == (Object)(object)array[i].itemProperties)
{
list.Add(j);
list2.Add(((Component)array[i]).transform.position);
break;
}
}
if (array[i].itemProperties.isScrap)
{
list3.Add(array[i].scrapValue);
}
if (array[i].itemProperties.saveItemVariable)
{
try
{
num = array[i].GetItemDataToSave();
}
catch
{
Debug.LogError((object)$"An error occured while getting item data to save for item type: {array[i].itemProperties}; gameobject '{((Object)((Component)array[i]).gameObject).name}'");
}
list4.Add(num);
Debug.Log((object)$"Saved data for item type: {array[i].itemProperties.itemName} - {num}");
}
}
}
if (list.Count <= 0)
{
Debug.Log((object)"Got no ship grabbable items to save.");
return;
}
ES3.Save<Vector3[]>("shipGrabbableItemPos", list2.ToArray(), self.currentSaveFileName);
ES3.Save<int[]>("shipGrabbableItemIDs", list.ToArray(), self.currentSaveFileName);
if (list3.Count > 0)
{
ES3.Save<int[]>("shipScrapValues", list3.ToArray(), self.currentSaveFileName);
}
else
{
ES3.DeleteKey("shipScrapValues", self.currentSaveFileName);
}
if (list4.Count > 0)
{
ES3.Save<int[]>("shipItemSaveData", list4.ToArray(), self.currentSaveFileName);
}
else
{
ES3.DeleteKey("shipItemSaveData", self.currentSaveFileName);
}
}
private void GameNetworkManager_SetLobbyJoinable(orig_SetLobbyJoinable orig, GameNetworkManager self, bool joinable)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, joinable);
if (GameNetworkManager.Instance.currentLobby.HasValue && (Object)(object)StartOfRound.Instance != (Object)null)
{
Lobby value = GameNetworkManager.Instance.currentLobby.Value;
((Lobby)(ref value)).SetData("chal", "f");
}
}
}
}