using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu.Elements;
using GangBeastsGamemode;
using GangBeastsGamemode.ProxyScripts;
using HarmonyLib;
using LabFusion.Data;
using LabFusion.MarrowIntegration;
using LabFusion.Network;
using LabFusion.Representation;
using LabFusion.SDK.Gamemodes;
using LabFusion.Utilities;
using MelonLoader;
using SLZ.Interaction;
using SLZ.Marrow.SceneStreaming;
using SLZ.Marrow.Warehouse;
using SLZ.Rig;
using SLZ.SFX;
using SLZ.Utilities;
using SwipezGamemodeLib.Events;
using SwipezGamemodeLib.Extensions;
using SwipezGamemodeLib.Spawning;
using SwipezGamemodeLib.Spectator;
using SwipezGamemodeLib.Utilities;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MainClass), "GangBeastsGamemode", "1.0.0", "notnotnotswipez", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("GangBeastsGamemode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GangBeastsGamemode")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9f31f1ea-ebac-4ddf-b358-aa7dcd63a0d6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GangBeastsGamemode
{
[RegisterTypeInIl2Cpp]
public class KnockOutter : MonoBehaviour
{
public int previousKnockouts = 0;
public float knockoutTime = 0f;
public float minimumKnockoutTime = 3f;
public float randomizationRate = 1f;
public float maxKnockoutTime = 13f;
public float knockoutChance = 0.15f;
public bool knockedOut = false;
public static KnockOutter Instance;
public KnockOutter(IntPtr intPtr)
: base(intPtr)
{
}
public void Awake()
{
Instance = this;
}
public void Punch()
{
if (!knockedOut && Random.Range(0f, 1f) < knockoutChance)
{
Knockout();
knockoutChance = Mathf.Clamp(knockoutChance, 0f, 0.5f);
}
}
public void Update()
{
if (knockoutTime > 0f && knockedOut)
{
knockoutTime -= Time.deltaTime;
if (knockoutTime < 0f)
{
UnKnockout();
}
}
}
private void UnKnockout()
{
knockoutTime = 0f;
knockedOut = false;
Player.rigManager.physicsRig.UnRagdollRig();
}
public void Knockout()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!knockedOut)
{
SwipezGamemodeLibEvents.SendPlayerEvent("InternalGangBeastsMetadata.KnockOut");
FusionAudio.Play3D(((Rig)Player.rigManager.physicsRig).m_pelvis.position, GangBeastsAssets.elimination, 1f, false);
previousKnockouts++;
for (int i = 0; i < previousKnockouts; i++)
{
knockoutTime += minimumKnockoutTime - Random.RandomRange(0f, randomizationRate);
}
knockoutTime = Mathf.Clamp(knockoutTime, 0f, maxKnockoutTime);
knockedOut = true;
Player.rigManager.physicsRig.RagdollRig();
Player.leftHand.DetachJoint(false, (Grip)null);
Player.rightHand.DetachJoint(false, (Grip)null);
Player.leftHand.DetachObject();
Player.rightHand.DetachObject();
}
}
}
[RegisterTypeInIl2Cpp]
public class StaminaSystem : MonoBehaviour
{
public float stamina = 0f;
public float maxStamina = 7f;
public static StaminaSystem Instance;
public StaminaSystem(IntPtr intPtr)
: base(intPtr)
{
}
public void Awake()
{
Instance = this;
stamina = maxStamina;
}
public void Update()
{
if (!GangBeastsMode.IsFullActive())
{
return;
}
if (!Player.physicsRig.physG.isGrounded && isGrabbingStaticObject())
{
if (!(stamina < maxStamina))
{
return;
}
stamina += Time.deltaTime;
float num = map(stamina, 0f, maxStamina, 0f, 2f);
if (num > 1.3f)
{
Player.leftController.haptor.SENDHAPTIC(0f, 0.2f, 0.2f, num);
Player.rightController.haptor.SENDHAPTIC(0f, 0.2f, 0.2f, num);
}
if (stamina > maxStamina)
{
if (Object.op_Implicit((Object)(object)Player.leftHand.joint) && !Object.op_Implicit((Object)(object)((Joint)Player.leftHand.joint).connectedBody))
{
Player.leftHand.DetachJoint(false, (Grip)null);
Player.leftHand.DetachObject();
}
if (Object.op_Implicit((Object)(object)Player.rightHand.joint) && !Object.op_Implicit((Object)(object)((Joint)Player.rightHand.joint).connectedBody))
{
Player.rightHand.DetachJoint(false, (Grip)null);
Player.rightHand.DetachObject();
}
}
}
else if (stamina > 0f)
{
stamina -= Time.deltaTime;
}
}
private float map(float value, float min, float max, float newMin, float newMax)
{
return (value - min) * (newMax - newMin) / (max - min) + newMin;
}
public bool isGrabbingStaticObject()
{
if (Object.op_Implicit((Object)(object)Player.leftHand.joint) && !Object.op_Implicit((Object)(object)((Joint)Player.leftHand.joint).connectedBody))
{
return true;
}
if (Object.op_Implicit((Object)(object)Player.rightHand.joint) && !Object.op_Implicit((Object)(object)((Joint)Player.rightHand.joint).connectedBody))
{
return true;
}
return false;
}
}
public class MainClass : MelonMod
{
public override void OnInitializeMelon()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
Hooking.OnLevelInitialized += OnLevelInitialized;
SwipezGamemodeLibEvents.OnPlayerSendEvent += OnPlayerSendEvent;
MultiplayerHooking.OnLoadingBegin += new UpdateEvent(OnLoadingBegin);
GamemodeRegistration.LoadGamemodes(Assembly.GetExecutingAssembly());
AssetBundle bundle = (HelperMethods.IsAndroid() ? EmbeddedAssetBundle.LoadFromAssembly(Assembly.GetExecutingAssembly(), "GangBeastsGamemode.Resources.gangbeasts.android.gamemode") : EmbeddedAssetBundle.LoadFromAssembly(Assembly.GetExecutingAssembly(), "GangBeastsGamemode.Resources.gangbeasts.gamemode"));
GangBeastsAssets.LoadAssets(bundle);
}
private void OnLoadingBegin()
{
if (GangBeastsMode.IsFullActive() && NetworkInfo.IsServer)
{
GangBeastsMode.Instance.BeginLoadState();
}
GangBeastsMode.selfLoaded = false;
GangBeastsMode.lockGameState = false;
}
private void OnPlayerSendEvent(PlayerId playerId, string eventName)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (eventName == "InternalGangBeastsMetadata.KnockOut" && GangBeastsMode.IsFullActive())
{
PlayerRep val = default(PlayerRep);
PlayerRepManager.TryGetPlayerRep(PlayerId.op_Implicit(playerId), ref val);
FusionAudio.Play3D(((Rig)val.RigReferences.RigManager.physicsRig).m_pelvis.position, GangBeastsAssets.elimination, 1f, false);
}
}
private void OnLevelInitialized(LevelInfo info)
{
((Component)Player.physicsRig).gameObject.AddComponent<KnockOutter>();
((Component)Player.physicsRig).gameObject.AddComponent<StaminaSystem>();
GangBeastsMode.selfLoaded = true;
if (GangBeastsMode.Instance != null && ((Gamemode)GangBeastsMode.Instance).IsActive())
{
GangBeastsMode.Instance.OnLoadingFinished();
}
}
}
public class GangBeastsAssets
{
public static AudioClip knockout;
public static AudioClip elimination;
public static AudioClip ding;
public static GameObject scoreCard;
public static GameObject playerScore;
public static GameObject singlePoint;
public static Dictionary<string, Texture2D> mappedTextures = new Dictionary<string, Texture2D>();
public static void LoadAssets(AssetBundle bundle)
{
knockout = AssetBundleExtensioner.LoadPersistentAsset<AudioClip>(bundle, "assets/bundleassets/knockout.mp3");
elimination = AssetBundleExtensioner.LoadPersistentAsset<AudioClip>(bundle, "assets/bundleassets/final.mp3");
ding = AssetBundleExtensioner.LoadPersistentAsset<AudioClip>(bundle, "assets/bundleassets/ding.ogg");
scoreCard = AssetBundleExtensioner.LoadPersistentAsset<GameObject>(bundle, "assets/bundleassets/scorecard.prefab");
playerScore = AssetBundleExtensioner.LoadPersistentAsset<GameObject>(bundle, "assets/bundleassets/playerscore.prefab");
singlePoint = AssetBundleExtensioner.LoadPersistentAsset<GameObject>(bundle, "assets/bundleassets/singlepoint.prefab");
foreach (string item in (Il2CppArrayBase<string>)(object)bundle.GetAllAssetNames())
{
if (item.EndsWith("png"))
{
Texture2D value = AssetBundleExtensioner.LoadPersistentAsset<Texture2D>(bundle, item);
string key = item.Replace("assets/bundleassets/", "").Replace(".png", "");
mappedTextures.Add(key, value);
}
}
}
}
[HarmonyPatch(typeof(PhysicsRig), "UnRagdollRig")]
public class OnUnRagdollKnockedOutPatch
{
public static bool Prefix(PhysicsRig __instance)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
if (((Object)((Rig)__instance).manager).GetInstanceID() != ((Object)Player.rigManager).GetInstanceID())
{
return true;
}
if (GangBeastsMode.IsFullActive())
{
if (KnockOutter.Instance.knockedOut)
{
__instance.RagdollRig();
return false;
}
Vector3 val = Player.physicsRig.feet.transform.position + new Vector3(0f, 0.25f, 0f);
Player.rigManager.Teleport(val, true);
}
return true;
}
}
[HarmonyPatch(typeof(Hand), "AttachObject")]
public class OnKnockOutHandGrabPatch
{
public static bool Prefix(Hand __instance)
{
if (((Object)__instance.manager).GetInstanceID() != ((Object)Player.rigManager).GetInstanceID())
{
return true;
}
if (GangBeastsMode.IsFullActive() && KnockOutter.Instance.knockedOut)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(HandSFX), "PunchAttack", new Type[]
{
typeof(Collision),
typeof(float),
typeof(float)
})]
public static class PunchDamagePatch
{
public static void Prefix(HandSFX __instance, Collision c)
{
if (GangBeastsMode.IsFullActive() && ((Object)__instance._hand.manager).GetInstanceID() != ((Object)Player.rigManager).GetInstanceID())
{
RigManager componentInParent = c.gameObject.GetComponentInParent<RigManager>();
if (Object.op_Implicit((Object)(object)componentInParent) && ((Object)componentInParent).GetInstanceID() == ((Object)Player.rigManager).GetInstanceID())
{
KnockOutter.Instance.Punch();
}
}
}
}
public class GangBeastsMode : Gamemode
{
public const string DefaultPrefix = "InternalGangBeastsMetadata";
public const string PlayerScoreKey = "InternalGangBeastsMetadata.Score";
public const string PlayerRoleKey = "InternalGangBeastsMetadata.Role";
public const string PlayerColorKey = "InternalGangBeastsMetadata.Color";
public const string PlayerKnockOutKey = "InternalGangBeastsMetadata.KnockOut";
public const string SPECTATOR_ROLE = "Spectator";
public const string PLAYER_ROLE = "Player";
public const string CONFETTI_BARCODE = "notnotnotswipez.GangBeasts.Spawnable.Confetti";
public const string GOLDEN_LOAF_BARCODE = "notnotnotswipez.GangBeasts.Spawnable.GoldenLoaf";
public bool roundRunning = false;
public static bool selfLoaded = false;
public GamemodeTimer mapTimer = new GamemodeTimer();
public GameObject scoreCard;
public int scoreToWin = 5;
public static float scoreCardDistance = 1f;
public bool lockMap = false;
public static bool lockGameState = false;
private static List<string> availableColors = new List<string> { "red", "yellow", "blue", "green", "orange", "purple", "tan", "pink" };
private static List<string> maps = new List<string> { "notnotnotswipez.GangBeasts.Level.GangBeastsSubway", "notnotnotswipez.GangBeasts.Level.GangBeastsGirders", "notnotnotswipez.GangBeasts.Level.GangBeastsGrind", "notnotnotswipez.GangBeasts.Level.GangBeastsIncinerator", "notnotnotswipez.GangBeasts.Level.GangBeastsRooftop" };
private static List<string> shuffle = new List<string>();
public static List<int> ignoredRigInstances = new List<int>();
public override string GamemodeCategory => "Gang Beasts";
public override string GamemodeName => "Gang Beasts Mode";
public override bool DisableDevTools => true;
public override bool DisableSpawnGun => true;
public override bool PreventNewJoins => true;
public override bool AutoStopOnSceneLoad => false;
public static GangBeastsMode Instance { get; private set; }
public override void OnGamemodeRegistered()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
((Gamemode)this).OnGamemodeRegistered();
Instance = this;
FusionOverrides.OnValidateNametag += new UserOverride(OnValidateNametag);
}
public override void OnGamemodeUnregistered()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
((Gamemode)this).OnGamemodeUnregistered();
if (Instance == this)
{
Instance = null;
}
FusionOverrides.OnValidateNametag -= new UserOverride(OnValidateNametag);
}
public override void OnBoneMenuCreated(MenuCategory category)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
((Gamemode)this).OnBoneMenuCreated(category);
category.CreateIntElement("Rounds To Win", Color.yellow, scoreToWin, 1, 2, 7, (Action<int>)delegate(int i)
{
scoreToWin = i;
});
category.CreateBoolElement("Lock Map", Color.yellow, lockMap, (Action<bool>)delegate(bool i)
{
lockMap = i;
});
}
protected override void OnStartGamemode()
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
((Gamemode)this).OnStartGamemode();
if (NetworkInfo.IsServer)
{
shuffle = new List<string>(maps);
for (int i = 0; i < shuffle.Count; i++)
{
string value = shuffle[i];
int index = Random.Range(i, shuffle.Count);
shuffle[i] = shuffle[index];
shuffle[index] = value;
}
if (!maps.Contains(Barcode.op_Implicit(((Scannable)FusionSceneManager.Level)._barcode)))
{
FusionNotifier.Send(new FusionNotification
{
title = new NotificationText("You are NOT on a Gang Beasts Map!", Color.cyan, true),
showTitleOnPopup = true,
popupLength = 3f,
isMenuItem = false,
isPopup = true
});
lockGameState = true;
((Gamemode)this).StopGamemode();
return;
}
List<string> list = new List<string>(availableColors);
foreach (PlayerId playerId in PlayerIdManager.PlayerIds)
{
SetRole(playerId, "Player");
SetScore(playerId, 0);
string text = list[Random.Range(0, list.Count)];
SetColor(playerId, text);
list.Remove(text);
}
}
FusionPlayer.SetMortality(false);
}
protected override void OnStopGamemode()
{
((Gamemode)this).OnStopGamemode();
roundRunning = false;
mapTimer.Reset();
if (Object.op_Implicit((Object)(object)scoreCard))
{
Object.Destroy((Object)(object)scoreCard);
}
lockGameState = false;
foreach (PlayerId playerId in PlayerIdManager.PlayerIds)
{
SetRole(playerId, "Player");
SetScore(playerId, 0);
PlayerIdExtensions.SetHeadIcon(playerId, (Texture2D)null);
}
FusionOverrides.ForceUpdateOverrides();
}
public void BeginLoadState()
{
roundRunning = false;
((Gamemode)this).TryInvokeTrigger("EndRoundState");
}
public void StartRoundState()
{
roundRunning = true;
((Gamemode)this).TryInvokeTrigger("StartRoundState");
}
private void SpawnConfetti(Vector3 pos)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
SpawnManager.SpawnGameObject("notnotnotswipez.GangBeasts.Spawnable.Confetti", pos, Quaternion.identity, (Action<GameObject>)delegate
{
});
}
private void SpawnLoaf(Vector3 pos)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
SpawnManager.SpawnGameObject("notnotnotswipez.GangBeasts.Spawnable.GoldenLoaf", pos, Quaternion.identity, (Action<GameObject>)delegate
{
});
}
protected bool OnValidateNametag(PlayerId id)
{
if (!((Gamemode)this).IsActive())
{
return true;
}
return false;
}
private void GoToRandomMap()
{
if (!NetworkInfo.IsServer)
{
return;
}
if (!lockMap)
{
string text = shuffle[Random.Range(0, shuffle.Count)];
shuffle.Remove(text);
SceneStreamer.Load(text, "");
if (shuffle.Count == 0)
{
shuffle = new List<string>(maps);
for (int i = 0; i < shuffle.Count; i++)
{
string value = shuffle[i];
int index = Random.Range(i, shuffle.Count);
shuffle[i] = shuffle[index];
shuffle[index] = value;
}
}
}
else
{
SceneStreamer.Load(Barcode.op_Implicit(((Scannable)SceneStreamer._session.Level)._barcode), "");
}
}
protected override void OnEventTriggered(string value)
{
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: 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_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Expected O, but got Unknown
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
if (value == "EndRoundState")
{
roundRunning = false;
FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
{
foreach (PlayerId playerId3 in PlayerIdManager.PlayerIds)
{
PlayerIdExtensions.Show(playerId3);
}
});
}
if (value == "StartRoundState")
{
roundRunning = true;
FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
{
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
foreach (PlayerId playerId4 in PlayerIdManager.PlayerIds)
{
if (!playerId4.IsSelf)
{
PlayerIdExtensions.SetHeadIcon(playerId4, (Texture2D)null);
PlayerIdExtensions.SetHeadIcon(playerId4, GangBeastsAssets.mappedTextures[GetColor(playerId4)]);
}
}
FusionPlayerExtended.SetWorldInteractable(true);
FusionPlayer.SetMortality(false);
List<Transform> list = new List<Transform>();
foreach (DeathmatchSpawnpoint component in DeathmatchSpawnpoint.Cache.Components)
{
list.Add(((Component)component).transform);
}
Transform val3 = list[Random.Range(0, list.Count)];
FusionPlayer.Teleport(val3.position, val3.forward, true);
lockGameState = false;
FusionNotifier.Send(new FusionNotification
{
title = new NotificationText("START!", Color.cyan, true),
showTitleOnPopup = true,
popupLength = 3f,
isMenuItem = false,
isPopup = true
});
FusionOverrides.ForceUpdateOverrides();
ignoredRigInstances.Clear();
Player_Health componentInChildren = ((Component)Player.rigManager).GetComponentInChildren<Player_Health>();
componentInChildren.Vignetter.gameObject.SetActive(false);
});
}
if (value.StartsWith("RoundWin"))
{
PlayerId playerId = PlayerIdManager.GetPlayerId(byte.Parse(value.Split(new char[1] { ';' })[1]));
string text = default(string);
MetadataHelper.TryGetDisplayName(playerId, ref text);
foreach (PlayerId playerId5 in PlayerIdManager.PlayerIds)
{
if (NetworkInfo.IsServer)
{
SetRole(playerId5, "Player");
}
PlayerIdExtensions.Show(playerId5);
}
lockGameState = true;
Vector3 pos;
if (!playerId.IsSelf)
{
PlayerRep val = default(PlayerRep);
PlayerRepManager.TryGetPlayerRep(PlayerId.op_Implicit(playerId), ref val);
pos = ((Rig)val.RigReferences.RigManager.physicsRig).m_head.position + new Vector3(0f, 1f, 0f);
}
else
{
pos = ((Rig)Player.physicsRig).m_head.position + new Vector3(0f, 1f, 0f);
}
SpawnConfetti(pos);
CreateScoreCard();
}
if (value.StartsWith("TotalWin"))
{
PlayerId playerId2 = PlayerIdManager.GetPlayerId(byte.Parse(value.Split(new char[1] { ';' })[1]));
string text2 = default(string);
MetadataHelper.TryGetDisplayName(playerId2, ref text2);
FusionNotifier.Send(new FusionNotification
{
title = new NotificationText(text2 + " wins!", Color.cyan, true),
showTitleOnPopup = true,
popupLength = 3f,
isMenuItem = false,
isPopup = true
});
Vector3 pos2;
if (!playerId2.IsSelf)
{
PlayerRep val2 = default(PlayerRep);
PlayerRepManager.TryGetPlayerRep(PlayerId.op_Implicit(playerId2), ref val2);
pos2 = ((Rig)val2.RigReferences.RigManager.physicsRig).m_head.position + new Vector3(0f, 2f, 0f);
}
else
{
pos2 = ((Rig)Player.physicsRig).m_head.position + new Vector3(0f, 2f, 0f);
}
SpawnLoaf(pos2);
}
}
private void CreateScoreCard()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
scoreCard = Object.Instantiate<GameObject>(GangBeastsAssets.scoreCard);
scoreCard.transform.position = ((Rig)Player.physicsRig).m_head.position + Player.controllerRig.hmdTransform.forward * scoreCardDistance;
scoreCard.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
Transform val = scoreCard.transform.Find("Canvas").Find("Lister");
foreach (PlayerId playerId in PlayerIdManager.PlayerIds)
{
GameObject val2 = Object.Instantiate<GameObject>(GangBeastsAssets.playerScore, val);
Texture2D texture = GangBeastsAssets.mappedTextures[GetColor(playerId)];
RawImage component = ((Component)val2.transform.Find("PlayerIcon")).GetComponent<RawImage>();
component.texture = (Texture)(object)texture;
for (int i = 0; i < GetScore(playerId); i++)
{
Object.Instantiate<GameObject>(GangBeastsAssets.singlePoint, val2.transform.Find("ScoreHolding"));
}
}
}
protected override void OnMetadataChanged(string key, string value)
{
if (key.StartsWith("InternalGangBeastsMetadata.Role"))
{
string[] array = key.Split(new char[1] { '.' });
byte b = byte.Parse(array[2]);
PlayerId playerId = PlayerIdManager.GetPlayerId(b);
OnRoleChanged(playerId, value);
}
}
private void OnRoleChanged(PlayerId playerId, string role)
{
if (role == "Spectator")
{
if (playerId.IsSelf)
{
FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
FusionPlayerExtended.SetCanDamageOthers(false);
FusionPlayerExtended.SetWorldInteractable(false);
List<Transform> list = new List<Transform>();
foreach (SpectatorSpawnpoint component in SpectatorSpawnpoint.Cache.Components)
{
list.Add(((Component)component).transform);
}
Transform val = list[Random.Range(0, list.Count)];
FusionPlayer.Teleport(val.position, val.forward, true);
FusionAudio.Play2D(GangBeastsAssets.ding, 1f);
QuicksandZone.ResetValues();
});
}
else
{
FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
{
PlayerIdExtensions.Hide(playerId);
PlayerIdExtensions.SetHeadIcon(playerId, (Texture2D)null);
FusionAudio.Play2D(GangBeastsAssets.ding, 1f);
});
}
}
else if (playerId.IsSelf)
{
FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
{
FusionPlayerExtended.SetCanDamageOthers(true);
FusionPlayerExtended.SetWorldInteractable(true);
});
}
else
{
FusionSceneManager.HookOnTargetLevelLoad((Action)delegate
{
PlayerIdExtensions.Show(playerId);
});
}
}
private List<PlayerId> GetAlivePlayers()
{
List<PlayerId> list = new List<PlayerId>();
foreach (PlayerId playerId in PlayerIdManager.PlayerIds)
{
if (GetRole(playerId) != "Spectator")
{
list.Add(playerId);
}
}
return list;
}
public void SetScore(PlayerId playerId, int score)
{
((Gamemode)this).TrySetMetadata(GetScoreKey(playerId), score.ToString() ?? "");
}
public void SetRole(PlayerId playerId, string role)
{
((Gamemode)this).TrySetMetadata(GetRoleKey(playerId), role);
}
public void SetColor(PlayerId playerId, string color)
{
((Gamemode)this).TrySetMetadata(GetColorKey(playerId), color);
}
public int GetScore(PlayerId playerId)
{
string text = default(string);
((Gamemode)this).TryGetMetadata(GetScoreKey(playerId), ref text);
if (text == null)
{
return 0;
}
return int.Parse(text);
}
public string GetRole(PlayerId playerId)
{
string text = default(string);
((Gamemode)this).TryGetMetadata(GetRoleKey(playerId), ref text);
if (text == null)
{
return "Player";
}
return text;
}
public string GetColor(PlayerId playerId)
{
string text = default(string);
((Gamemode)this).TryGetMetadata(GetColorKey(playerId), ref text);
if (text == null)
{
return "red";
}
return text;
}
private string GetScoreKey(PlayerId playerId)
{
return "InternalGangBeastsMetadata.Score." + playerId.SmallId;
}
private string GetRoleKey(PlayerId playerId)
{
return "InternalGangBeastsMetadata.Role." + playerId.SmallId;
}
private string GetColorKey(PlayerId playerId)
{
return "InternalGangBeastsMetadata.Color." + playerId.SmallId;
}
public void OnLoadingFinished()
{
if (!roundRunning)
{
FusionPlayer.SetMortality(false);
FusionPlayerExtended.SetWorldInteractable(false);
}
}
protected override void OnUpdate()
{
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
if (NetworkInfo.IsServer)
{
if (PlayerIdManager.PlayerIds.Count == 1)
{
((Gamemode)this).StopGamemode();
return;
}
if (mapTimer.isRunning && mapTimer.IsFinishedInSeconds(10))
{
foreach (PlayerId playerId in PlayerIdManager.PlayerIds)
{
SetRole(playerId, "Player");
}
mapTimer.Reset();
GoToRandomMap();
}
if (!roundRunning && selfLoaded && !lockGameState && EveryoneLoaded())
{
StartRoundState();
}
if (roundRunning && !mapTimer.isRunning && !lockGameState)
{
List<PlayerId> alivePlayers = GetAlivePlayers();
if (alivePlayers.Count == 1)
{
PlayerId val = alivePlayers[0];
SetScore(val, GetScore(val) + 1);
if (GetScore(val) >= scoreToWin - 1)
{
((Gamemode)this).TryInvokeTrigger("TotalWin;" + val.SmallId);
((Gamemode)this).StopGamemode();
roundRunning = false;
lockGameState = false;
mapTimer.Reset();
return;
}
((Gamemode)this).TryInvokeTrigger("RoundWin;" + val.SmallId);
mapTimer.Start();
}
}
}
if (Object.op_Implicit((Object)(object)scoreCard))
{
Vector3 val2 = ((Rig)Player.physicsRig).m_head.position + Player.controllerRig.hmdTransform.forward * scoreCardDistance;
scoreCard.transform.position = Vector3.Lerp(scoreCard.transform.position, val2, Time.deltaTime * 10f);
scoreCard.transform.LookAt(((Rig)Player.physicsRig).m_head.position);
}
if (roundRunning)
{
Player.rigManager.health.curr_Health = Player.rigManager.health.max_Health;
}
}
private bool EveryoneLoaded()
{
bool result = true;
foreach (PlayerRep playerRep in PlayerRepManager.PlayerReps)
{
if (!playerRep.IsCreated)
{
result = false;
}
}
return result;
}
public static bool IsFullActive()
{
if (Instance != null && ((Gamemode)Instance).IsActive())
{
return Instance.roundRunning;
}
return false;
}
}
}
namespace GangBeastsGamemode.ProxyScripts
{
[RegisterTypeInIl2Cpp]
public class KillZone : FusionMarrowBehaviour
{
public KillZone(IntPtr intPtr)
: base(intPtr)
{
}
public void OnTriggerEnter(Collider other)
{
if (!GangBeastsMode.IsFullActive() || GangBeastsMode.lockGameState || !Object.op_Implicit((Object)(object)other.attachedRigidbody) || !NetworkInfo.IsServer)
{
return;
}
RigManager componentInParent = ((Component)other.attachedRigidbody).GetComponentInParent<RigManager>();
if (!Object.op_Implicit((Object)(object)componentInParent) || GangBeastsMode.ignoredRigInstances.Contains(((Object)((Component)componentInParent).gameObject).GetInstanceID()))
{
return;
}
PlayerRep val = default(PlayerRep);
if (((Object)((Component)componentInParent).gameObject).GetInstanceID() == ((Object)((Component)Player.rigManager).gameObject).GetInstanceID())
{
string role = GangBeastsMode.Instance.GetRole(PlayerIdManager.LocalId);
if (!(role == "Spectator"))
{
GangBeastsMode.Instance.SetRole(PlayerIdManager.LocalId, "Spectator");
GangBeastsMode.ignoredRigInstances.Add(((Object)((Component)componentInParent).gameObject).GetInstanceID());
}
}
else if (PlayerRepManager.TryGetPlayerRep(componentInParent, ref val))
{
string role2 = GangBeastsMode.Instance.GetRole(val.PlayerId);
if (!(role2 == "Spectator"))
{
GangBeastsMode.Instance.SetRole(val.PlayerId, "Spectator");
GangBeastsMode.ignoredRigInstances.Add(((Object)((Component)componentInParent).gameObject).GetInstanceID());
}
}
}
}
[RegisterTypeInIl2Cpp]
public class KnockoutterZone : FusionMarrowBehaviour
{
public KnockoutterZone(IntPtr intPtr)
: base(intPtr)
{
}
public void OnTriggerEnter(Collider other)
{
if (GangBeastsMode.IsFullActive() && Object.op_Implicit((Object)(object)other.attachedRigidbody))
{
RigManager componentInParent = ((Component)other.attachedRigidbody).GetComponentInParent<RigManager>();
if (Object.op_Implicit((Object)(object)componentInParent) && ((Object)componentInParent).GetInstanceID() == ((Object)Player.rigManager).GetInstanceID())
{
KnockOutter.Instance.Knockout();
}
}
}
}
[RegisterTypeInIl2Cpp]
public class LauncherZone : FusionMarrowBehaviour
{
public LauncherZone(IntPtr intPtr)
: base(intPtr)
{
}
public void OnTriggerEnter(Collider other)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
if (GangBeastsMode.IsFullActive() && Object.op_Implicit((Object)(object)other.attachedRigidbody))
{
RigManager componentInParent = ((Component)other.attachedRigidbody).GetComponentInParent<RigManager>();
if (Object.op_Implicit((Object)(object)componentInParent) && ((Object)componentInParent).GetInstanceID() == ((Object)Player.rigManager).GetInstanceID())
{
((Component)((Rig)Player.rigManager.physicsRig).m_chest).GetComponent<Rigidbody>().AddForce(((Component)this).transform.forward * 200f, (ForceMode)1);
}
}
}
}
[RegisterTypeInIl2Cpp]
public class QuicksandSafeZone : FusionMarrowBehaviour
{
public QuicksandSafeZone(IntPtr intPtr)
: base(intPtr)
{
}
public void OnTriggerEnter(Collider other)
{
if (GangBeastsMode.IsFullActive() && Object.op_Implicit((Object)(object)other.attachedRigidbody))
{
RigManager componentInParent = ((Component)other.attachedRigidbody).GetComponentInParent<RigManager>();
if (Object.op_Implicit((Object)(object)componentInParent) && ((Object)componentInParent).GetInstanceID() == ((Object)Player.rigManager).GetInstanceID() && !QuicksandZone.isAvailable)
{
QuicksandZone.ResetValues();
}
}
}
}
[RegisterTypeInIl2Cpp]
public class QuicksandZone : FusionMarrowBehaviour
{
public static bool isAvailable = true;
public static bool isStuck = false;
public static Rigidbody currentDropper;
public static FixedJoint currentJoint;
public static GenericOnJointBreak currentJointBreak;
public QuicksandZone(IntPtr intPtr)
: base(intPtr)
{
}
public void Awake()
{
isAvailable = true;
}
public void OnTriggerEnter(Collider other)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
if (!GangBeastsMode.IsFullActive() || !isAvailable || !Object.op_Implicit((Object)(object)other.attachedRigidbody))
{
return;
}
RigManager componentInParent = ((Component)other.attachedRigidbody).GetComponentInParent<RigManager>();
if (!Object.op_Implicit((Object)(object)componentInParent))
{
return;
}
if (((Object)componentInParent).GetInstanceID() == ((Object)Player.rigManager).GetInstanceID())
{
isAvailable = false;
isStuck = true;
GameObject dropper = new GameObject();
Rigidbody component = ((Component)((Rig)Player.rigManager.physicsRig).m_pelvis).gameObject.GetComponent<Rigidbody>();
dropper.transform.position = component.position;
Rigidbody val = dropper.AddComponent<Rigidbody>();
val.drag = 70f;
val.angularDrag = 1f;
val.mass = 200f;
GenericOnJointBreak val2 = ((Component)component).gameObject.AddComponent<GenericOnJointBreak>();
FixedJoint val3 = ((Component)component).gameObject.AddComponent<FixedJoint>();
((Joint)val3).connectedBody = val;
((Joint)val3).breakForce = 60000f;
((Joint)val3).breakTorque = float.MaxValue;
currentDropper = val;
currentJoint = val3;
currentJointBreak = val2;
val2.JointBreakEvent = new UnityEvent();
val2.JointBreakEvent.AddListener(UnityAction.op_Implicit((Action)delegate
{
Object.Destroy((Object)(object)currentJointBreak);
Object.Destroy((Object)(object)dropper);
isStuck = false;
}));
}
}
public static void ResetValues()
{
isAvailable = true;
isStuck = false;
if (Object.op_Implicit((Object)(object)currentJoint))
{
Object.Destroy((Object)(object)currentJoint);
}
if (Object.op_Implicit((Object)(object)currentDropper))
{
Object.Destroy((Object)(object)((Component)currentDropper).gameObject);
}
if (Object.op_Implicit((Object)(object)currentJointBreak))
{
Object.Destroy((Object)(object)currentJointBreak);
}
}
}
[RegisterTypeInIl2Cpp]
public class SpectatorSpawnpoint : FusionMarrowBehaviour
{
public static readonly FusionComponentCache<GameObject, SpectatorSpawnpoint> Cache = new FusionComponentCache<GameObject, SpectatorSpawnpoint>();
public SpectatorSpawnpoint(IntPtr intPtr)
: base(intPtr)
{
}
private void OnEnable()
{
Cache.Add(((Component)this).gameObject, this);
}
private void OnDisable()
{
Cache.Remove(((Component)this).gameObject);
}
}
}