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 On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
[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 = "")]
[assembly: AssemblyCompany("MultiplayerLivesMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MultiplayerLivesMod")]
[assembly: AssemblyTitle("MultiplayerLivesMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ExamplePlugin;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("hellfireJune.MultiplayerLives", "MultiplayerLives", "0.0.0")]
public class ExamplePlugin : BaseUnityPlugin
{
public class MultiLivesComponent : MonoBehaviour
{
public int lives;
public bool rapture = false;
public void OnDisable()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
CharacterMaster.OnBodyDeath -= new hook_OnBodyDeath(ReviveMe);
Stage.onServerStageBegin -= Stage_onServerStageBegin;
}
public void OnEnable()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
CharacterMaster.OnBodyDeath += new hook_OnBodyDeath(ReviveMe);
Stage.onServerStageBegin += Stage_onServerStageBegin;
}
private void Stage_onServerStageBegin(Stage obj)
{
lives = PlayerCharacterMasterController.instances.Count - 1;
UpdateLivesCounter();
}
public void UpdateLivesCounter()
{
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
CharacterMaster master = instance.master;
master.voidCoins = (uint)lives;
}
}
public void Rapture()
{
rapture = true;
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
CharacterMaster master = instance.master;
master.TrueKill();
}
rapture = false;
}
private void ReviveMe(orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
{
if (!body.isPlayerControlled || rapture)
{
orig.Invoke(self, body);
return;
}
if (self.IsDeadAndOutOfLivesServer() && lives > 0)
{
lives--;
UpdateLivesCounter();
body.AddBuff(Buffs.ExtraLifeBuff);
}
orig.Invoke(self, body);
if (!self.preventGameOver)
{
Rapture();
}
}
}
public const string PluginGUID = "hellfireJune.MultiplayerLives";
public const string PluginAuthor = "hellfireJune";
public const string PluginName = "MultiplayerLives";
public const string PluginVersion = "0.0.0";
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Run.onRunStartGlobal += delegate(Run run)
{
if (NetworkServer.active)
{
((Component)run).gameObject.AddComponent<MultiLivesComponent>();
}
};
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}