using System;
using System.Collections;
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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using StarterItems.Patch;
using Unity.Netcode;
using UnityEngine;
using nehax.StarterItem.NetcodePatcher;
[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("nehax.StarterItem")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StarterItems")]
[assembly: AssemblyTitle("nehax.StarterItem")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 StarterItems
{
internal class Config
{
}
internal class Helpers
{
[CompilerGenerated]
private sealed class <WaitForScrapToSpawnToSync>d__0 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public NetworkObjectReference[] spawnedScrap;
public int[] scrapValues;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForScrapToSpawnToSync>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
RoundManager.Instance.SyncScrapValuesClientRpc(spawnedScrap, scrapValues);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[IteratorStateMachine(typeof(<WaitForScrapToSpawnToSync>d__0))]
public static IEnumerator WaitForScrapToSpawnToSync(NetworkObjectReference[] spawnedScrap, int[] scrapValues)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForScrapToSpawnToSync>d__0(0)
{
spawnedScrap = spawnedScrap,
scrapValues = scrapValues
};
}
}
[BepInPlugin("nehax.StarterItem", "StarterItems", "1.0.0")]
public class StarterItems : BaseUnityPlugin
{
public static StarterItems Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Harmony.CreateAndPatchAll(typeof(StartMatchLeverPatch), (string)null);
Logger.LogInfo((object)"nehax.StarterItem v1.0.0 has loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "nehax.StarterItem";
public const string PLUGIN_NAME = "StarterItems";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace StarterItems.Patch
{
internal class StartMatchLeverPatch
{
private const string FlashlightItemName = "Flashlight";
private const int MaxFlashlights = 5;
private const float FlashlightSpawnChances = 0.8f;
private const float MinChance = 0.15f;
[HarmonyPatch(typeof(StartOfRound), "StartGame")]
[HarmonyPostfix]
public static void StartMatchLever_StartGame_Postfix(StartOfRound __instance)
{
StarterItems.Logger.LogDebug((object)"####### StartOfRound_OnShipLandedMiscEvents POSTFIX");
Terminal val = Object.FindObjectOfType<Terminal>();
if ((Object)(object)val == (Object)null)
{
StarterItems.Logger.LogError((object)"Terminal introuvable !");
return;
}
int num = -1;
for (int i = 0; i < val.buyableItemsList.Length; i++)
{
if (val.buyableItemsList[i].itemName == "Flashlight")
{
num = i;
break;
}
}
if (num == -1)
{
StarterItems.Logger.LogError((object)"Index de la lampe torche introuvable !");
return;
}
int num2 = 1;
float num3 = 0.8f;
while (num2 < 5 && Random.value <= num3)
{
num2++;
num3 = Mathf.Max(num3 - 0.16f, 0.15f);
}
StarterItems.Logger.LogDebug((object)$"Nombre de flash à donner {num2} !");
for (int j = 0; j < num2; j++)
{
val.orderedItemsFromTerminal.Add(num);
val.numberOfItemsInDropship++;
}
if (!((NetworkBehaviour)val).IsServer)
{
val.SyncBoughtItemsWithServer(val.orderedItemsFromTerminal.ToArray(), val.numberOfItemsInDropship);
}
else
{
val.SyncGroupCreditsClientRpc(val.groupCredits, val.numberOfItemsInDropship);
}
if (num2 != 0)
{
string text = $"La compagnie a décidé de vous fournir {num2} flashlight.";
List<string> list = new List<string> { "La compagnie demande à Makiiit d'être moins raciste.", "La compagnie demande à Wallou de laisser les chevaux tranquilles.", "La compagnie demande à Lunik de de-mute Nehax.", "La compagnie demande à Thomy de montrer ses panards.", "La compagnie demande à Nep de ralentir sur le cassoulet.", "La compagnie demande à l'équipage de faire attention au Minautore.", "La compagnie demande à l'équipage de faire un effort.", "La compagnie demande à l'équipage de jouer à PEAK." };
string[] array = new string[1] { text };
float num4 = Random.Range(0.01f, 1f);
if (num4 >= 0.7f)
{
int index = Random.Range(0, list.Count);
ref string reference = ref array[0];
reference = reference + "\n" + list[index];
}
}
}
public static void MessageComputer(params string[] messages)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[messages.Length];
for (int i = 0; i < messages.Length; i++)
{
array[i] = new DialogueSegment
{
speakerText = "Maitre Marc",
bodyText = messages[i]
};
}
HUDManager.Instance.ReadDialogue(array);
}
}
}
namespace nehax.StarterItem.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}