using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BeetleballSandbox; using HarmonyLib; using Il2Cpp; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppNuiN.NExtensions; using Il2CppSteamworks; using Il2CppSystem; using MelonLoader; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using Unity.Netcode.Components; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(SandboxMod), "Beetleball Sandbox", "0.3.5", "cody + Codex", null)] [assembly: MelonGame("Bugfight Studio", "Beetleball")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("BeetleballSandbox")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BeetleballSandbox")] [assembly: AssemblyTitle("BeetleballSandbox")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace BeetleballSandbox { public sealed class SandboxMod : MelonMod { private sealed class AdminPlayerEntry { public ulong ClientId; public ulong SteamId; public string Name = string.Empty; public TeamType Team; public int ClassIndex; public bool HasBeetle; public bool IsModded; } private sealed class HostAdminPlayerState { public ulong ClientId; public float Scale = 1f; public bool Frozen; public float NextStunAt; public IntPtr ActorPointer; public BeetleActor? Actor; public Vector3 BaseScale = Vector3.one; public Vector3 LastAppliedScale = Vector3.one; } private sealed class GlobalBallSnapshot { public Vector3 BaseScale; public Vector3 LastAppliedScale; public DungBall Ball { get; } public GlobalBallSnapshot(DungBall ball, Vector3 scale) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) Ball = ball; BaseScale = scale; LastAppliedScale = scale; } } private sealed class GlobalCooldownSnapshot { public BeetleActor Actor { get; } public BeetleStatModifiersController Controller { get; } public float GrabCooldown { get; } public float HeadbuttCooldown { get; } public float ShootRecovery { get; } public float JumpCooldown { get; } public float BallJumpCooldown { get; } public float GrabTimer { get; } public float JumpTimer { get; } public float HeadbuttTimer { get; } public float BallJumpTimer { get; } public float ShootRecoveryTimer { get; } public float RestoreGrabCooldown { get; } public float RestoreHeadbuttCooldown { get; } public float RestoreShootRecovery { get; } public float RestoreJumpCooldown { get; } public float RestoreBallJumpCooldown { get; } public float RestoreGrabTimer { get; } public float RestoreJumpTimer { get; } public float RestoreHeadbuttTimer { get; } public float RestoreBallJumpTimer { get; } public float RestoreShootRecoveryTimer { get; } public GlobalCooldownSnapshot(BeetleActor actor, BeetleStatModifiersController controller, BeetleStats baselineStats, float baselineJumpCooldown, float baselineBallJumpCooldown) { Actor = actor; Controller = controller; BeetleStats stats = actor.Stats; RestoreGrabCooldown = stats.GrabCooldownDuration; RestoreHeadbuttCooldown = stats.HeadbuttCooldown; RestoreShootRecovery = stats.ShootBallRecoveryDuration; RestoreJumpCooldown = actor.jumpCooldown; RestoreBallJumpCooldown = actor.ballJumpCooldown; RestoreGrabTimer = ReadLiveCooldownDuration(actor.GrabCooldownTimer, RestoreGrabCooldown); RestoreJumpTimer = ReadLiveCooldownDuration(actor.JumpCooldownTimer, RestoreJumpCooldown); RestoreHeadbuttTimer = ReadLiveCooldownDuration(actor.HeadbuttCooldownTimer, RestoreHeadbuttCooldown); RestoreBallJumpTimer = ReadLiveCooldownDuration(actor.BallJumpCooldownTimer, RestoreBallJumpCooldown); RestoreShootRecoveryTimer = ReadLiveCooldownDuration(actor.ShootBallRecoveryTimer, RestoreShootRecovery); GrabCooldown = baselineStats.GrabCooldownDuration; HeadbuttCooldown = baselineStats.HeadbuttCooldown; ShootRecovery = baselineStats.ShootBallRecoveryDuration; JumpCooldown = baselineJumpCooldown; BallJumpCooldown = baselineBallJumpCooldown; GrabTimer = GrabCooldown; JumpTimer = JumpCooldown; HeadbuttTimer = HeadbuttCooldown; BallJumpTimer = BallJumpCooldown; ShootRecoveryTimer = ShootRecovery; } } private enum ServerAdminAction : byte { ForceIntoMatch = 1, FreezePlayer, ReleasePlayer, SetPlayerScale, ResetRound, RestartMatch, AddSpectators, ClearDung, ReleaseAllFreezes, RestoreAllPlayerSizes, SetGlobalCooldown, SetGlobalBallScale, SetPlayerTeam } private enum WorldAction : byte { Ping, ChangeBallSize, SpawnLooseDung, RecallBall, LaunchBall, StopBall, SpinBall, ExplodeBall, ConfigureBall, ClearBallTuning, SpawnBall, Announcement } private enum AdminClientAction : byte { AddExperience = 1, NextLevel, SetLevel, UnlockSkins, SetScale, SetGlobalCooldown } private sealed class WorldRequest { public WorldAction Action; public ulong TargetBallId; public int IntValue; public int SecondaryIntValue; public float FloatValue; public float SecondaryFloatValue; public Vector3 VectorValue; public byte Flags; } private sealed class RemoteBallTuning { public DungBall Ball { get; } public Rigidbody Rigidbody { get; } public ulong BallId { get; } public float BaseMass { get; } public bool BaseUseGravity { get; } public Vector3 BaseScale { get; } public float MassMultiplier { get; set; } = 1f; public float ScaleMultiplier { get; set; } = 1f; public bool UseGravity { get; set; } = true; public bool Freeze { get; set; } public float LastReceivedAt { get; set; } public RemoteBallTuning(DungBall ball) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Ball = ball; Rigidbody = ball.RB; BallId = GetBallNetworkId(ball); BaseMass = Rigidbody.mass; BaseUseGravity = Rigidbody.useGravity; BaseScale = ((Component)ball).transform.localScale; } } private sealed class RemotePlayerTuning { public BeetleActor Actor { get; } public BeetleStatModifiersController Controller { get; } public IntPtr ActorPointer { get; } public Vector3 BaseActorScale { get; } public float BaseSize { get; } public float BaseMoveSpeed { get; } public float BaseSprintSpeed { get; } public float BaseJumpForce { get; } public float BaseGravity { get; } public float BaseBallMinSpeed { get; } public float BaseBallMaxSpeed { get; } public float BaseThrowMin { get; } public float BaseThrowMax { get; } public float BaseChargedMultiplier { get; } public float BaseHeadbuttLaunch { get; } public float BaseHeadbuttForward { get; } public float BaseHeadbuttHit { get; } public float BaseGrabCooldown { get; } public float BaseHeadbuttCooldown { get; } public float BaseShootRecovery { get; } public float BaseJumpCooldown { get; } public float BaseBallJumpCooldown { get; } public float BaseGrabCooldownTimer { get; } public float BaseJumpCooldownTimer { get; } public float BaseHeadbuttCooldownTimer { get; } public float BaseBallJumpCooldownTimer { get; } public float BaseShootRecoveryTimer { get; } public bool BaseUnstunnable { get; } public float MoveSpeed { get; set; } = 1f; public float SprintSpeed { get; set; } = 1f; public float JumpForce { get; set; } = 1f; public float Gravity { get; set; } = 1f; public float Size { get; set; } = 1f; public float BallRollSpeed { get; set; } = 1f; public float ThrowForce { get; set; } = 1f; public float HeadbuttForce { get; set; } = 1f; public float CooldownFactor { get; set; } = 1f; public bool NoStun { get; set; } public float LastReceivedAt { get; set; } public RemotePlayerTuning(BeetleActor actor) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) Actor = actor; Controller = actor.StatModifiersController; ActorPointer = ((Il2CppObjectBase)actor).Pointer; BeetleStats stats = actor.Stats; BaseSize = stats.Size; BaseActorScale = Vector3.one * BaseSize; BaseMoveSpeed = stats.MoveSpeed; BaseSprintSpeed = stats.SprintSpeedMult; BaseJumpForce = stats.JumpForce; BaseGravity = stats.GravityMult; BaseBallMinSpeed = stats.BallMinSizeMaxSpeed; BaseBallMaxSpeed = stats.BallMaxSizeMaxSpeed; BaseThrowMin = stats.ShootBallForceMinSize; BaseThrowMax = stats.ShootBallForceMaxSize; BaseChargedMultiplier = stats.ShootBallForceChargedMult; BaseHeadbuttLaunch = stats.HeadbuttLaunchForce; BaseHeadbuttForward = stats.HeadbuttLaunchForceForwardBonus; BaseHeadbuttHit = stats.HeadbuttHitForce; BaseGrabCooldown = stats.GrabCooldownDuration; BaseHeadbuttCooldown = stats.HeadbuttCooldown; BaseShootRecovery = stats.ShootBallRecoveryDuration; BaseJumpCooldown = actor.jumpCooldown; BaseBallJumpCooldown = actor.ballJumpCooldown; BaseGrabCooldownTimer = ReadLiveCooldownDuration(actor.GrabCooldownTimer, BaseGrabCooldown); BaseJumpCooldownTimer = ReadLiveCooldownDuration(actor.JumpCooldownTimer, BaseJumpCooldown); BaseHeadbuttCooldownTimer = ReadLiveCooldownDuration(actor.HeadbuttCooldownTimer, BaseHeadbuttCooldown); BaseBallJumpCooldownTimer = ReadLiveCooldownDuration(actor.BallJumpCooldownTimer, BaseBallJumpCooldown); BaseShootRecoveryTimer = ReadLiveCooldownDuration(actor.ShootBallRecoveryTimer, BaseShootRecovery); BaseUnstunnable = actor.Unstunnable; } } private sealed class PlayerSnapshot { public BeetleActor Actor { get; } public BeetleStatModifiersController Controller { get; } public Transform? VisualRoot { get; } public IntPtr ActorPointer { get; } public IntPtr ControllerPointer { get; } public IntPtr VisualPointer { get; } public Vector3 VisualScale { get; } public float Size { get; } public float MoveSpeed { get; } public float SprintSpeedMult { get; } public float JumpForce { get; } public float GravityMult { get; } public float FlutterSpeed { get; } public float GlideSpeed { get; } public float BallMinSizeMaxSpeed { get; } public float BallMaxSizeMaxSpeed { get; } public float ShootBallForceMinSize { get; } public float ShootBallForceMaxSize { get; } public float ShootBallForceChargedMult { get; } public float HeadbuttLaunchForce { get; } public float HeadbuttLaunchForceForwardBonus { get; } public float HeadbuttHitForce { get; } public float GrabCooldownDuration { get; } public float HeadbuttCooldown { get; } public float ShootBallRecoveryDuration { get; } public float JumpCooldown { get; } public float BallJumpCooldown { get; } public float GrabCooldownTimerDuration { get; } public float JumpCooldownTimerDuration { get; } public float HeadbuttCooldownTimerDuration { get; } public float BallJumpCooldownTimerDuration { get; } public float ShootBallRecoveryTimerDuration { get; } public bool Unstunnable { get; } public PlayerSnapshot(BeetleActor actor, BeetleStatModifiersController controller, BeetleStats stats, Transform? visualRoot) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Actor = actor; Controller = controller; VisualRoot = visualRoot; ActorPointer = ((Il2CppObjectBase)actor).Pointer; ControllerPointer = ((Il2CppObjectBase)controller).Pointer; VisualPointer = ((visualRoot != null) ? ((Il2CppObjectBase)visualRoot).Pointer : IntPtr.Zero); VisualScale = (((Object)(object)visualRoot == (Object)null) ? Vector3.one : visualRoot.localScale); Size = stats.Size; MoveSpeed = stats.MoveSpeed; SprintSpeedMult = stats.SprintSpeedMult; JumpForce = stats.JumpForce; GravityMult = stats.GravityMult; FlutterSpeed = stats.FlutterSpeed; GlideSpeed = stats.GlideSpeed; BallMinSizeMaxSpeed = stats.BallMinSizeMaxSpeed; BallMaxSizeMaxSpeed = stats.BallMaxSizeMaxSpeed; ShootBallForceMinSize = stats.ShootBallForceMinSize; ShootBallForceMaxSize = stats.ShootBallForceMaxSize; ShootBallForceChargedMult = stats.ShootBallForceChargedMult; HeadbuttLaunchForce = stats.HeadbuttLaunchForce; HeadbuttLaunchForceForwardBonus = stats.HeadbuttLaunchForceForwardBonus; HeadbuttHitForce = stats.HeadbuttHitForce; GrabCooldownDuration = stats.GrabCooldownDuration; HeadbuttCooldown = stats.HeadbuttCooldown; ShootBallRecoveryDuration = stats.ShootBallRecoveryDuration; JumpCooldown = actor.jumpCooldown; BallJumpCooldown = actor.ballJumpCooldown; GrabCooldownTimerDuration = ReadLiveCooldownDuration(actor.GrabCooldownTimer, GrabCooldownDuration); JumpCooldownTimerDuration = ReadLiveCooldownDuration(actor.JumpCooldownTimer, JumpCooldown); HeadbuttCooldownTimerDuration = ReadLiveCooldownDuration(actor.HeadbuttCooldownTimer, HeadbuttCooldown); BallJumpCooldownTimerDuration = ReadLiveCooldownDuration(actor.BallJumpCooldownTimer, BallJumpCooldown); ShootBallRecoveryTimerDuration = ReadLiveCooldownDuration(actor.ShootBallRecoveryTimer, ShootBallRecoveryDuration); Unstunnable = actor.Unstunnable; } } private sealed class BallSnapshot { public DungBall Ball { get; } public Rigidbody Rigidbody { get; } public IntPtr BallPointer { get; } public float Mass { get; } public bool UseGravity { get; } public Vector3 LocalScale { get; } public BallSnapshot(DungBall ball) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Ball = ball; Rigidbody = ball.RB; BallPointer = ((Il2CppObjectBase)ball).Pointer; Mass = Rigidbody.mass; UseGravity = Rigidbody.useGravity; LocalScale = ((Component)ball).transform.localScale; } } private sealed class EggHatchTimingSnapshot { public EggScreen Screen { get; } public float HatchDuration { get; } public float FinalizeDelay { get; } public Animator? Animator { get; } public float AnimatorSpeed { get; } public EggHatchTimingSnapshot(EggScreen screen) { Screen = screen; HatchDuration = screen.hatchDuration; FinalizeDelay = screen.finalizeHatchDelay; Animator = screen.eggHatchAnimation; AnimatorSpeed = (((Object)(object)Animator == (Object)null) ? 1f : Animator.speed); } public void Restore() { if ((Object)(object)Screen != (Object)null) { Screen.hatchDuration = HatchDuration; Screen.finalizeHatchDelay = FinalizeDelay; } if ((Object)(object)Animator != (Object)null) { Animator.speed = AnimatorSpeed; } } } private sealed class HiddenUiSnapshot { public CanvasGroup CanvasGroup { get; } public bool AddedByMod { get; } public float Alpha { get; } public bool Interactable { get; } public bool BlocksRaycasts { get; } public HiddenUiSnapshot(CanvasGroup canvasGroup, bool addedByMod) { CanvasGroup = canvasGroup; AddedByMod = addedByMod; Alpha = canvasGroup.alpha; Interactable = canvasGroup.interactable; BlocksRaycasts = canvasGroup.blocksRaycasts; } } private const int PlayersPerAdminPage = 4; private const int MaxLocalProfileLevel = 1000000; private const string CustomLevelPlayerPrefsKey = "BeetleballSandbox.CustomLocalLevel.v1"; private readonly List _adminPlayers = new List(); private readonly Dictionary _hostAdminPlayerStates = new Dictionary(); private readonly Dictionary _joinedClientVisualPlayerStates = new Dictionary(); private readonly List _adminStateCleanup = new List(); private readonly Dictionary _globalBallSnapshots = new Dictionary(); private readonly List _globalBallCleanup = new List(); private readonly HashSet _globalBallSeen = new HashSet(); private readonly Dictionary _globalCooldownSnapshots = new Dictionary(); private readonly List _globalCooldownCleanup = new List(); private readonly HashSet _globalCooldownSeen = new HashSet(); private ulong _selectedAdminClientId = ulong.MaxValue; private int _adminPlayerPage; private float _nextAdminPlayerRefreshAt; private float _selectedPlayerScale = 1f; private int _localTargetLevel = 10; private bool _localTargetLevelInitialized; private int _customLocalLevelOverride; private int _exactLevelTypingMode; private string _exactLevelTypingText = string.Empty; private float _pendingForceSpectatorsAt; private int _pendingLocalSpawnStage; private TeamType _pendingLocalSpawnTeam; private int _pendingLocalSpawnClassIndex; private int _pendingLocalSpawnAttempts; private bool _pendingLocalSpawnSilent; private float _pendingLocalSpawnAt; private float _pendingLocalSpawnDeadline; private bool _globalBallScaleEnabled; private float _globalBallScale = 1f; private bool _globalCooldownEnabled; private float _globalCooldownFactor = 1f; private bool _cameraDistanceOverride; private bool _cameraAutoScale = true; private float _cameraDistance = 1f; private bool _cameraDistanceApplied; private const string WorldRequestMessage = "BeetleballSandbox.WorldRequest.v1"; private const string RelayResponseMessage = "BeetleballSandbox.RelayResponse.v1"; private const string AnnouncementRequestMessage = "BeetleballSandbox.AnnouncementRequest.v1"; private const string AnnouncementBroadcastMessage = "BeetleballSandbox.AnnouncementBroadcast.v1"; private const string ServerAnnouncementChatPrefix = "[SERVER ANNOUNCEMENT]"; private const string CustomAnnouncementChatPrefix = "[CUSTOM MESSAGE]"; private const string PlayerTuningRequestMessage = "BeetleballSandbox.PlayerTuningRequest.v1"; private const string AdminCommandMessage = "BeetleballSandbox.AdminCommand.v1"; private const string AdminResultMessage = "BeetleballSandbox.AdminResult.v1"; private const string ServerAdminRequestMessage = "BeetleballSandbox.ServerAdminRequest.v1"; private const string ServerAdminResponseMessage = "BeetleballSandbox.ServerAdminResponse.v1"; private bool _allowClientWorldRequests; private bool _hostRelayDetected; private bool _hostRelayAllowed; private float _lastRelayAckAt; private float _nextRelayHelloAt; private float _nextBallTuningRelayAt; private float _nextPlayerTuningRelayAt; private ulong _lastRelayedBallId; private bool _relayedPlayerTuningActive; private CustomMessagingManager? _bridgeMessaging; private IntPtr _bridgeMessagingPointer; private HandleNamedMessageDelegate? _worldRequestHandler; private HandleNamedMessageDelegate? _relayResponseHandler; private HandleNamedMessageDelegate? _announcementRequestHandler; private HandleNamedMessageDelegate? _announcementBroadcastHandler; private HandleNamedMessageDelegate? _playerTuningRequestHandler; private HandleNamedMessageDelegate? _adminCommandHandler; private HandleNamedMessageDelegate? _adminResultHandler; private HandleNamedMessageDelegate? _serverAdminRequestHandler; private HandleNamedMessageDelegate? _serverAdminResponseHandler; private readonly Dictionary _remoteBallTunings = new Dictionary(); private readonly List _expiredRemoteTuningClients = new List(); private readonly Dictionary _remotePlayerTunings = new Dictionary(); private readonly List _expiredRemotePlayerClients = new List(); private readonly Dictionary _lastAnnouncementTimes = new Dictionary(); private readonly HashSet _moddedClientIds = new HashSet(); private string _announcementText = "Welcome to the custom server!"; private float _announcementDuration = 6f; private int _announcementPosition = 1; private int _announcementColorPreset = 1; private float _nextAnnouncementSendAt; private string _lastLocalAnnouncementPopup = string.Empty; private float _lastLocalAnnouncementPopupAt = float.NegativeInfinity; private bool _serverCooldownOverrideActive; private float _serverCooldownOverrideFactor = 1f; private bool _serverCooldownForcedPlayerTuning; private const string MenuInputLockKey = "beetleballSandboxMenu"; private const float IntentionalFlightDescentThreshold = -0.65f; private const string AnonymousModePlayerPrefsKey = "BeetleballSandbox.AnonymousMode.v1"; private const string HideLeaderboardPlayerPrefsKey = "BeetleballSandbox.HideLeaderboard.v1"; private const string HidePlayerBoardPlayerPrefsKey = "BeetleballSandbox.HidePlayerBoard.v1"; private const string EggRarityBoostPlayerPrefsKey = "BeetleballSandbox.EggRarityBoost.v1"; private const string EggMythicalChancePlayerPrefsKey = "BeetleballSandbox.EggMythicalChance.v1"; private const string FastEggHatchPlayerPrefsKey = "BeetleballSandbox.FastEggHatch.v1"; private bool _menuOpen = true; private bool _guiUnavailable; private bool _cursorCaptured; private bool _menuInputLockApplied; private bool _menuInputLockWarningLogged; private CursorLockMode _savedCursorLock; private bool _savedCursorVisible; private Rect _panelRect = new Rect(24f, 24f, 620f, 860f); private int _menuPage; private float _uiX; private float _uiY; private float _uiWidth; private float _sceneObjectAccessReadyAt; private bool _anonymousMode; private bool _hideLeaderboard; private bool _hidePlayerBoard; private readonly Dictionary _hiddenLeaderboardObjects = new Dictionary(); private readonly Dictionary _hiddenPlayerBoardObjects = new Dictionary(); private readonly Dictionary _eggHatchTimingSnapshots = new Dictionary(); private bool _eggRarityBoost; private float _eggMythicalChance = 100f; private bool _fastEggHatch = true; private string _status = "Ready - F5 toggles this menu"; private float _statusUntil; private bool _playerTuning; private bool _playerApplied; private bool _noStun; private static SandboxMod? _activeInstance; private BeetleActor? _noStunActor; private bool _noStunOriginalUnstunnable; private bool _noStunOverrideApplied; private float _moveSpeed = 1f; private float _sprintSpeed = 1f; private float _jumpForce = 1f; private float _gravity = 1f; private float _flySpeed = 1f; private bool _holdFlightUntilGround = true; private bool _flightMomentumActive; private IntPtr _flightMomentumActorPointer; private Vector3 _flightMomentumVelocity; private float _flightBaseSpeed; private float _flightStateUpdatedAt = float.NegativeInfinity; private float _flightGroundGraceUntil; private static int _flightChargeDrainSuppressionDepth; private float _playerSize = 1f; private float _ballRollSpeed = 1f; private float _throwForce = 1f; private float _headbuttForce = 1f; private float _cooldownFactor = 1f; private PlayerSnapshot? _playerSnapshot; private bool _ballTuning; private bool _freezeBall; private bool _ballUseGravity = true; private float _ballMass = 1f; private float _ballScale = 1f; private float _launchPower = 30f; private float _spinPower = 20f; private int _dungSpawnSize = 1; private BallSnapshot? _ballSnapshot; private bool _fovOverride; private float _fov = 90f; private Camera? _cameraSnapshot; private float _originalFov; private bool _timeScaleOverride; private bool _timeScaleCaptured; private float _timeScale = 1f; private float _originalTimeScale = 1f; public bool ServerCooldownOverrideActive => _serverCooldownOverrideActive; public float ServerCooldownOverrideFactor => _serverCooldownOverrideFactor; public bool ServerCooldownForcedPlayerTuning => _serverCooldownForcedPlayerTuning; private void UpdateAdminTools() { RefreshAdminPlayerList(force: false); ApplyJoinedClientVisualPlayerStates(); UpdatePendingLocalSpectatorSpawn(); if (_pendingForceSpectatorsAt > 0f && Time.unscaledTime >= _pendingForceSpectatorsAt) { _pendingForceSpectatorsAt = 0f; ForceAllSpectatorsIntoMatch(); } } private void ShutdownAdminTools() { ResetCameraDistance(); ResetGlobalBallScale(); _globalCooldownEnabled = false; RestoreGlobalCooldowns(); RestoreAllHostAdminPlayerStates(); RestoreAllJoinedClientVisualPlayerStates(); _adminPlayers.Clear(); _selectedAdminClientId = ulong.MaxValue; _pendingForceSpectatorsAt = 0f; _exactLevelTypingMode = 0; _exactLevelTypingText = string.Empty; ClearPendingLocalSpectatorSpawn(); } private void DrawRawGlobalBallScaleControls() { RawSection("GLOBAL BALL SCALE"); bool flag = RawToggle("Apply one physical scale to every ball", _globalBallScaleEnabled); if (flag != _globalBallScaleEnabled) { _globalBallScaleEnabled = flag; if (!flag) { RestoreGlobalBallScale(); } RequestGlobalBallScaleFromServer(); SetStatus(flag ? "Global ball scale enabled" : "Global ball scale restored"); } float globalBallScale = _globalBallScale; _globalBallScale = RawUnboundedStepper("Global scale", _globalBallScale, 0.05f, 0.25f, 1f); if (_globalBallScaleEnabled && Math.Abs(globalBallScale - _globalBallScale) > 0.0001f) { RequestGlobalBallScaleFromServer(); } if (RawRowButton("1x", 0, 4)) { SetGlobalBallScalePreset(1f); } if (RawRowButton("5x", 1, 4)) { SetGlobalBallScalePreset(5f); } if (RawRowButton("25x", 2, 4)) { SetGlobalBallScalePreset(25f); } if (RawRowButton("Double", 3, 4)) { SetGlobalBallScalePreset(SafeDouble(_globalBallScale)); } RawNextRow(); } private void SetGlobalBallScalePreset(float scale) { _globalBallScale = Mathf.Max(0.05f, scale); _globalBallScaleEnabled = true; ApplyGlobalBallScale(); RequestGlobalBallScaleFromServer(); SetStatus($"Global ball scale set to {_globalBallScale:0.##}x"); } private void RequestGlobalBallScaleFromServer() { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsListening && !singleton.IsServer) { SendServerAdminRequest(ServerAdminAction.SetGlobalBallScale, ulong.MaxValue, _globalBallScaleEnabled ? 1 : 0, _globalBallScale, quiet: true); } } private void ApplyGlobalBallScale() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (!_globalBallScaleEnabled) { if (_globalBallSnapshots.Count > 0) { RestoreGlobalBallScale(); } return; } try { Il2CppArrayBase obj = Object.FindObjectsOfType(); _globalBallSeen.Clear(); foreach (DungBall item in obj) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).transform == (Object)null)) { IntPtr pointer = ((Il2CppObjectBase)item).Pointer; _globalBallSeen.Add(pointer); if (!_globalBallSnapshots.TryGetValue(pointer, out GlobalBallSnapshot value)) { value = new GlobalBallSnapshot(item, ((Component)item).transform.localScale); _globalBallSnapshots[pointer] = value; } Vector3 localScale = ((Component)item).transform.localScale; Vector3 val = localScale - value.LastAppliedScale; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { value.BaseScale = localScale; } EnableNetworkScaleSync((Component)(object)item); Vector3 val2 = value.BaseScale * _globalBallScale; ((Component)item).transform.localScale = val2; value.LastAppliedScale = val2; } } _globalBallCleanup.Clear(); foreach (KeyValuePair globalBallSnapshot in _globalBallSnapshots) { if (!_globalBallSeen.Contains(globalBallSnapshot.Key)) { _globalBallCleanup.Add(globalBallSnapshot.Key); } } foreach (IntPtr item2 in _globalBallCleanup) { _globalBallSnapshots.Remove(item2); } } catch (Exception exception) { ReportException("applying global ball scale", exception); } } private void RestoreGlobalBallScale() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) foreach (GlobalBallSnapshot value in _globalBallSnapshots.Values) { try { if ((Object)(object)value.Ball != (Object)null && (Object)(object)((Component)value.Ball).transform != (Object)null) { ((Component)value.Ball).transform.localScale = value.BaseScale; } } catch { } } _globalBallSnapshots.Clear(); } private void ResetGlobalBallScale() { _globalBallScaleEnabled = false; _globalBallScale = 1f; RestoreGlobalBallScale(); } private void DrawRawCameraDistanceControls() { RawSection("LARGE-BEETLE CAMERA"); bool flag = RawToggle("Auto-distance follows local beetle scale", _cameraAutoScale); if (flag != _cameraAutoScale) { _cameraAutoScale = flag; if (!flag && !_cameraDistanceOverride) { RestoreCameraDistance(); } } bool flag2 = RawToggle("Enable manual camera distance", _cameraDistanceOverride); if (flag2 != _cameraDistanceOverride) { _cameraDistanceOverride = flag2; if (!flag2 && !_cameraAutoScale) { RestoreCameraDistance(); } } _cameraDistance = RawUnboundedStepper("Manual distance", _cameraDistance, 0.25f, 0.25f, 1f); if (RawRowButton("1x", 0, 4)) { _cameraDistance = 1f; } if (RawRowButton("5x", 1, 4)) { _cameraDistance = 5f; } if (RawRowButton("20x", 2, 4)) { _cameraDistance = 20f; } if (RawRowButton("Double", 3, 4)) { _cameraDistance = SafeDouble(_cameraDistance); } RawNextRow(); } private void ApplyCameraDistance() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!_cameraDistanceOverride && !_cameraAutoScale) { if (_cameraDistanceApplied) { RestoreCameraDistance(); } return; } try { PlayerCamera instance = PlayerCamera.Instance; if ((Object)(object)instance == (Object)null) { return; } float num = (_cameraDistanceOverride ? Mathf.Max(0.25f, _cameraDistance) : 1f); if (_cameraAutoScale) { BeetleActor localBeetle = GetLocalBeetle(); if ((Object)(object)localBeetle != (Object)null) { float num2 = Mathf.Max(((Component)localBeetle).transform.localScale.x, Mathf.Max(((Component)localBeetle).transform.localScale.y, ((Component)localBeetle).transform.localScale.z)); num = Mathf.Max(num, Mathf.Max(1f, num2 * 1.15f)); } } instance.SetCameraDistanceMult(num); _cameraDistanceApplied = true; } catch { _cameraDistanceApplied = false; } } private void RestoreCameraDistance() { try { PlayerCamera instance = PlayerCamera.Instance; if ((Object)(object)instance != (Object)null) { instance.ResetCameraDistanceMult(); } } catch { } _cameraDistanceApplied = false; } private void ResetCameraDistance() { _cameraDistanceOverride = false; _cameraAutoScale = true; _cameraDistance = 1f; RestoreCameraDistance(); } private void DrawRawServerMatchControls() { RawSection("MATCH / SESSION REQUESTS"); RawLabel(IsNetworkServerHost() ? "Direct server authority." : "Attempts game RPCs or modded-host request."); if (RawRowButton("Spawn me Blue", 0, 4)) { SpawnLocalPlayerIntoMatch((TeamType)1); } if (RawRowButton("Spawn me Red", 1, 4)) { SpawnLocalPlayerIntoMatch((TeamType)2); } if (RawRowButton("Reset score + round", 2, 4)) { ResetHostedRound(); } if (RawRowButton("Restart + add players", 3, 4)) { RestartHostedMatch(); } RawNextRow(); if (RawRowButton("Add all spectators", 0, 4)) { ForceAllSpectatorsIntoMatch(); } if (RawRowButton("Clear all dung", 1, 4)) { ClearAllDungAsHost(); } if (RawRowButton("Release all freezes", 2, 4)) { ReleaseAllAdminFreezes(); } if (RawRowButton("Restore player sizes", 3, 4)) { RestoreAllAdminPlayerSizes(); } RawNextRow(); } private void DrawRawPlayersPage() { //IL_0266: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; bool flag = IsNetworkServerHost(); RawSection("CONNECTED PLAYER TOOLS"); if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { RawLabel("Join or host a connected session to view its player list."); return; } RawLabel(flag ? "Direct server authority." : "Vanilla RPCs + modded-host requests."); RawSection("CONNECTED PLAYER LIST"); RefreshAdminPlayerList(force: true); if (_adminPlayers.Count == 0) { RawLabel("No connected players are available yet."); return; } int num = Math.Max(1, (_adminPlayers.Count + 4 - 1) / 4); _adminPlayerPage = Math.Clamp(_adminPlayerPage, 0, num - 1); RawLabel($"Players {_adminPlayers.Count} | page {_adminPlayerPage + 1}/{num}"); int num2 = _adminPlayerPage * 4; int num3 = Math.Min(num2 + 4, _adminPlayers.Count); for (int i = num2; i < num3; i += 2) { AdminPlayerEntry adminPlayerEntry = _adminPlayers[i]; if (RawRowButton(BuildAdminPlayerButton(adminPlayerEntry), 0, 2)) { SelectAdminPlayer(adminPlayerEntry.ClientId); } if (i + 1 < num3) { AdminPlayerEntry adminPlayerEntry2 = _adminPlayers[i + 1]; if (RawRowButton(BuildAdminPlayerButton(adminPlayerEntry2), 1, 2)) { SelectAdminPlayer(adminPlayerEntry2.ClientId); } } RawNextRow(); } if (RawRowButton("Previous page", 0, 3)) { _adminPlayerPage = Math.Max(0, _adminPlayerPage - 1); } if (RawRowButton("Refresh", 1, 3)) { RefreshAdminPlayerList(force: true); } if (RawRowButton("Next page", 2, 3)) { _adminPlayerPage = Math.Min(num - 1, _adminPlayerPage + 1); } RawNextRow(); AdminPlayerEntry selectedAdminPlayer = GetSelectedAdminPlayer(); if (selectedAdminPlayer == null) { RawLabel("Select a player above."); return; } RawSection("SELECTED PLAYER"); RawLabel($"{selectedAdminPlayer.Name} | client {selectedAdminPlayer.ClientId} | {selectedAdminPlayer.Team}"); if (RawRowButton("Spawn Blue", 0, 4)) { ForceClientIntoMatch(selectedAdminPlayer, silent: false, (TeamType)1); } if (RawRowButton("Spawn Red", 1, 4)) { ForceClientIntoMatch(selectedAdminPlayer, silent: false, (TeamType)2); } if (RawRowButton("Freeze beetle", 2, 4)) { SetSelectedPlayerFrozen(frozen: true); } if (RawRowButton("Release / unstun", 3, 4)) { SetSelectedPlayerFrozen(frozen: false); } RawNextRow(); if (RawRowButton("Team Blue", 0, 3)) { SetSelectedPlayerTeam((TeamType)1); } if (RawRowButton("Team Red", 1, 3)) { SetSelectedPlayerTeam((TeamType)2); } if (RawRowButton("Auto team", 2, 3)) { SetSelectedPlayerTeam((TeamType)0); } RawNextRow(); float selectedPlayerScale = _selectedPlayerScale; _selectedPlayerScale = RawUnboundedStepper("Scale", _selectedPlayerScale, 0.05f, 0.25f, 1f); if (Math.Abs(selectedPlayerScale - _selectedPlayerScale) > 0.0001f) { SetSelectedPlayerScale(_selectedPlayerScale); } if (RawRowButton("Micro 0.05x", 0, 4)) { SetSelectedPlayerScalePreset(0.05f); } if (RawRowButton("Normal 1x", 1, 4)) { SetSelectedPlayerScalePreset(1f); } if (RawRowButton("Giant 25x", 2, 4)) { SetSelectedPlayerScalePreset(25f); } if (RawRowButton("Double", 3, 4)) { SetSelectedPlayerScalePreset(SafeDouble(_selectedPlayerScale)); } RawNextRow(); if (!flag && RawRowButton("Reset local-view state", 0, 1)) { RestoreAllJoinedClientVisualPlayerStates(); } RawNextRow(); DrawRawGlobalCooldownControls(); RawSection("PERSISTENT PROFILE LIMIT"); RawLabel("XP, levels, and skins are stored by each player's local Steam stats."); } private void RefreshAdminPlayerList(bool force) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_01ff: Unknown result type (might be due to invalid IL or missing references) if (!force && Time.unscaledTime < _nextAdminPlayerRefreshAt) { return; } _nextAdminPlayerRefreshAt = Time.unscaledTime + 1f; try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { _adminPlayers.Clear(); return; } ulong selectedAdminClientId = _selectedAdminClientId; _adminPlayers.Clear(); LobbyPlayerDataManager instance = LobbyPlayerDataManager.Instance; NetworkList val = ((instance != null) ? instance.Players : null); if (val != null) { for (int i = 0; i < val.Count; i++) { Player val2 = val[i]; ulong clientId = val2.clientId; AdminPlayerEntry item = new AdminPlayerEntry { ClientId = clientId, SteamId = val2.steamId, Name = ResolveSteamPlayerName(val2.steamId, clientId), Team = val2.team, ClassIndex = Math.Max(0, val2.classIndex), IsModded = (clientId == singleton.LocalClientId || _moddedClientIds.Contains(clientId)), HasBeetle = ((Object)(object)FindActorForClient(clientId) != (Object)null) }; _adminPlayers.Add(item); } } foreach (BeetleActor actor in Object.FindObjectsOfType()) { if (!((Object)(object)actor == (Object)null) && ((NetworkBehaviour)actor).IsSpawned) { AdminPlayerEntry adminPlayerEntry = _adminPlayers.FirstOrDefault((AdminPlayerEntry p) => p.ClientId == ((NetworkBehaviour)actor).OwnerClientId); if (adminPlayerEntry != null) { adminPlayerEntry.HasBeetle = true; continue; } _adminPlayers.Add(new AdminPlayerEntry { ClientId = ((NetworkBehaviour)actor).OwnerClientId, Name = $"Client {((NetworkBehaviour)actor).OwnerClientId}", Team = ((NetworkActor)actor).Team, IsModded = (((NetworkBehaviour)actor).OwnerClientId == singleton.LocalClientId || _moddedClientIds.Contains(((NetworkBehaviour)actor).OwnerClientId)), HasBeetle = true }); } } if (_adminPlayers.Count == 0) { ulong localClientId = singleton.LocalClientId; _adminPlayers.Add(new AdminPlayerEntry { ClientId = localClientId, Name = $"Client {localClientId}", Team = (TeamType)0, IsModded = true, HasBeetle = ((Object)(object)FindActorForClient(localClientId) != (Object)null) }); } _adminPlayers.Sort((AdminPlayerEntry a, AdminPlayerEntry b) => a.ClientId.CompareTo(b.ClientId)); _selectedAdminClientId = selectedAdminClientId; if (GetSelectedAdminPlayer() == null && _adminPlayers.Count > 0) { SelectAdminPlayer(_adminPlayers[0].ClientId); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not refresh player list: " + ex.Message); } } private static string ResolveSteamPlayerName(ulong steamId, ulong clientId) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (steamId == 0L) { return $"Client {clientId}"; } try { SteamId id = new SteamId { Value = steamId }; string text = SteamUsersCache.SafeName(new Friend { Id = id }); return string.IsNullOrWhiteSpace(text) ? $"Steam {steamId}" : text; } catch { return $"Steam {steamId}"; } } private string BuildAdminPlayerButton(AdminPlayerEntry entry) { string value = ((entry.ClientId == _selectedAdminClientId) ? "> " : ""); string value2 = (entry.HasBeetle ? "PLAY" : "SPEC"); string value3 = ((entry.Name.Length > 20) ? entry.Name.Substring(0, 20) : entry.Name); return $"{value}{value3} [{value2}]"; } private void SelectAdminPlayer(ulong clientId) { _selectedAdminClientId = clientId; Dictionary dictionary = (IsNetworkServerHost() ? _hostAdminPlayerStates : _joinedClientVisualPlayerStates); _selectedPlayerScale = (dictionary.TryGetValue(clientId, out var value) ? value.Scale : 1f); AdminPlayerEntry selectedAdminPlayer = GetSelectedAdminPlayer(); if (selectedAdminPlayer != null) { SetStatus("Selected " + selectedAdminPlayer.Name); } } private AdminPlayerEntry? GetSelectedAdminPlayer() { return _adminPlayers.FirstOrDefault((AdminPlayerEntry p) => p.ClientId == _selectedAdminClientId); } private void SpawnLocalPlayerIntoMatch(TeamType requestedTeam) { //IL_00b6: 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) NetworkManager manager = NetworkManager.Singleton; if ((Object)(object)manager == (Object)null || !manager.IsListening) { SetStatus("Join or host a session first."); return; } RefreshAdminPlayerList(force: true); AdminPlayerEntry adminPlayerEntry = _adminPlayers.FirstOrDefault((AdminPlayerEntry p) => p.ClientId == manager.LocalClientId); if (adminPlayerEntry == null) { adminPlayerEntry = new AdminPlayerEntry { ClientId = manager.LocalClientId, Name = $"Client {manager.LocalClientId}", ClassIndex = 0, Team = (TeamType)0 }; } ForceClientIntoMatch(adminPlayerEntry, silent: false, requestedTeam); } private void ForceClientIntoMatch(AdminPlayerEntry entry, bool silent, TeamType requestedTeam = (TeamType)0) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) try { ForceClientIntoMatchUnsafe(entry, silent, requestedTeam); } catch (Exception exception) { ReportException("requesting a player spawn", exception); } } private void ForceClientIntoMatchUnsafe(AdminPlayerEntry entry, bool silent, TeamType requestedTeam) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected I4, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected I4, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { if (!silent) { SetStatus("Join or host a session first."); } } else if (singleton.IsServer) { TeamType val = ResolveRequestedSpawnTeam(entry, requestedTeam); ForceClientIntoMatchOnServer(entry, val); if (!silent) { SetStatus($"Spawned {entry.Name} on {val}"); } } else if (entry.ClientId == singleton.LocalClientId) { TeamType val2 = ResolveRequestedSpawnTeam(entry, requestedTeam); if (HasReadyHostRelay()) { SendServerAdminRequest(ServerAdminAction.ForceIntoMatch, entry.ClientId, (int)val2, 0f, silent); if (!silent) { SetStatus($"Requested a {val2} spawn from the modded host"); } } else { BeginPendingLocalSpectatorSpawn(entry, val2, silent); } } else { SendServerAdminRequest(ServerAdminAction.ForceIntoMatch, entry.ClientId, (int)ResolveRequestedSpawnTeam(entry, requestedTeam), 0f, silent); } } private void BeginPendingLocalSpectatorSpawn(AdminPlayerEntry entry, TeamType team, bool silent) { //IL_004b: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; NetworkPrefabSpawner instance = NetworkPrefabSpawner.Instance; if ((Object)(object)singleton == (Object)null || (Object)(object)instance == (Object)null || !singleton.IsListening || !singleton.IsConnectedClient) { if (!silent) { SetStatus("Spawner is not ready for a client spawn."); } return; } ClearPendingLocalSpectatorSpawn(); _pendingLocalSpawnStage = 1; _pendingLocalSpawnTeam = team; _pendingLocalSpawnClassIndex = Math.Max(0, entry.ClassIndex); _pendingLocalSpawnAttempts = 0; _pendingLocalSpawnSilent = silent; _pendingLocalSpawnAt = Time.unscaledTime + 0.35f; _pendingLocalSpawnDeadline = Time.unscaledTime + 5f; try { instance.BecomeSpectator_ServerRpc(CreateDefaultSpawnPositionData(), new RpcParams()); if (!silent) { SetStatus($"Resetting spectator state; {team} spawn queued"); } } catch (Exception ex) { ClearPendingLocalSpectatorSpawn(); if (!silent) { ReportException("resetting local spectator state", ex); } else { ((MelonBase)this).LoggerInstance.Warning("Could not reset local spectator state: " + ex.Message); } } } private void UpdatePendingLocalSpectatorSpawn() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) if (_pendingLocalSpawnStage == 0) { return; } float unscaledTime = Time.unscaledTime; NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.IsConnectedClient || singleton.IsServer) { bool pendingLocalSpawnSilent = _pendingLocalSpawnSilent; ClearPendingLocalSpectatorSpawn(); if (!pendingLocalSpawnSilent) { SetStatus("Queued spectator spawn cancelled because the session changed"); } } else if (unscaledTime >= _pendingLocalSpawnDeadline) { bool pendingLocalSpawnSilent2 = _pendingLocalSpawnSilent; ClearPendingLocalSpectatorSpawn(); if (!pendingLocalSpawnSilent2) { SetStatus("The server did not create a local beetle after two spawn requests"); } } else { if (unscaledTime < _pendingLocalSpawnAt) { return; } if (_pendingLocalSpawnStage == 1) { if (!SendPendingLocalSpawnRpc()) { ClearPendingLocalSpectatorSpawn(); return; } _pendingLocalSpawnAttempts = 1; _pendingLocalSpawnStage = 2; _pendingLocalSpawnAt = unscaledTime + 1.25f; return; } BeetleActor val = FindActorForClient(singleton.LocalClientId); if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsSpawned) { TeamType pendingLocalSpawnTeam = _pendingLocalSpawnTeam; int pendingLocalSpawnAttempts = _pendingLocalSpawnAttempts; bool pendingLocalSpawnSilent3 = _pendingLocalSpawnSilent; ClearPendingLocalSpectatorSpawn(); _nextAdminPlayerRefreshAt = 0f; if (!pendingLocalSpawnSilent3) { SetStatus($"Spawned locally on {pendingLocalSpawnTeam} after {pendingLocalSpawnAttempts} request(s)"); } } else if (_pendingLocalSpawnAttempts < 2) { if (!SendPendingLocalSpawnRpc()) { ClearPendingLocalSpectatorSpawn(); return; } _pendingLocalSpawnAttempts++; _pendingLocalSpawnAt = unscaledTime + 1.5f; if (!_pendingLocalSpawnSilent) { SetStatus($"Server has not spawned the beetle yet; retrying {_pendingLocalSpawnTeam}"); } } else { bool pendingLocalSpawnSilent4 = _pendingLocalSpawnSilent; ClearPendingLocalSpectatorSpawn(); if (!pendingLocalSpawnSilent4) { SetStatus("The server ignored both local spectator spawn requests"); } } } } private bool SendPendingLocalSpawnRpc() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) try { NetworkPrefabSpawner instance = NetworkPrefabSpawner.Instance; if ((Object)(object)instance == (Object)null) { throw new InvalidOperationException("Network prefab spawner is unavailable."); } try { LobbyPlayerDataManager instance2 = LobbyPlayerDataManager.Instance; if (instance2 != null) { instance2.SetPlayerClassIndexData(_pendingLocalSpawnClassIndex); } if (instance2 != null) { instance2.SetPlayerTeamData(_pendingLocalSpawnTeam); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not update local lobby spawn data: " + ex.Message); } SetTeamData val = new SetTeamData { setTeam = true, team = _pendingLocalSpawnTeam }; instance.SpawnClass_ServerRpc(_pendingLocalSpawnClassIndex, CreateDefaultSpawnPositionData(), val, new RpcParams()); return true; } catch (Exception ex2) { if (!_pendingLocalSpawnSilent) { ReportException("sending the local spectator spawn request", ex2); } else { ((MelonBase)this).LoggerInstance.Warning("Could not send local spectator spawn request: " + ex2.Message); } return false; } } private static SpawnPositionData CreateDefaultSpawnPositionData() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new SpawnPositionData { usePosition = false, useRotation = false, position = Vector3.zero, rotation = Quaternion.identity }; } private void ClearPendingLocalSpectatorSpawn() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) _pendingLocalSpawnStage = 0; _pendingLocalSpawnTeam = (TeamType)0; _pendingLocalSpawnClassIndex = 0; _pendingLocalSpawnAttempts = 0; _pendingLocalSpawnSilent = false; _pendingLocalSpawnAt = 0f; _pendingLocalSpawnDeadline = 0f; } private static TeamType ResolveRequestedSpawnTeam(AdminPlayerEntry entry, TeamType requestedTeam) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if ((int)requestedTeam == 1 || (int)requestedTeam == 2) { return requestedTeam; } if ((int)entry.Team == 1 || (int)entry.Team == 2) { return entry.Team; } if ((int)MatchStateController.GetLeastRepresentedTeam() == 2) { return (TeamType)2; } return (TeamType)1; } private void ForceClientIntoMatchOnServer(AdminPlayerEntry entry, TeamType requestedTeam = (TeamType)0) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; NetworkPrefabSpawner instance = NetworkPrefabSpawner.Instance; if ((Object)(object)singleton == (Object)null || (Object)(object)instance == (Object)null) { throw new InvalidOperationException("Spawner not ready."); } NetworkSpawnManager spawnManager = singleton.SpawnManager; NetworkObject val = ((spawnManager != null) ? spawnManager.GetPlayerNetworkObject(entry.ClientId) : null); if ((Object)(object)val != (Object)null && val.IsSpawned) { val.Despawn(true); } TeamType val2 = ResolveRequestedSpawnTeam(entry, requestedTeam); instance.SpawnClassAndSetTeam(entry.ClientId, val2, Math.Max(0, entry.ClassIndex)); } private void ForceAllSpectatorsIntoMatch() { NetworkManager manager = NetworkManager.Singleton; if ((Object)(object)manager == (Object)null || !manager.IsListening) { SetStatus("Join or host a session first."); return; } if (manager.IsServer) { int num = ForceAllSpectatorsIntoMatchOnServer(); SetStatus((num == 0) ? "No spectators." : $"Added {num} spectator(s)."); return; } RefreshAdminPlayerList(force: true); AdminPlayerEntry adminPlayerEntry = _adminPlayers.FirstOrDefault((AdminPlayerEntry p) => p.ClientId == manager.LocalClientId && !p.HasBeetle); if (adminPlayerEntry != null) { ForceClientIntoMatch(adminPlayerEntry, silent: true, (TeamType)0); } SendServerAdminRequest(ServerAdminAction.AddSpectators, ulong.MaxValue); } private int ForceAllSpectatorsIntoMatchOnServer() { RefreshAdminPlayerList(force: true); int num = 0; foreach (AdminPlayerEntry item in _adminPlayers.Where((AdminPlayerEntry p) => !p.HasBeetle)) { ForceClientIntoMatchOnServer(item, (TeamType)0); num++; } _nextAdminPlayerRefreshAt = 0f; return num; } private void SetSelectedPlayerFrozen(bool frozen) { AdminPlayerEntry selectedAdminPlayer = GetSelectedAdminPlayer(); if (selectedAdminPlayer == null) { return; } BeetleActor val = FindActorForClient(selectedAdminPlayer.ClientId); if ((Object)(object)val == (Object)null) { SetStatus(selectedAdminPlayer.Name + " has no beetle."); return; } NetworkManager singleton = NetworkManager.Singleton; HostAdminPlayerState obj = (((Object)(object)singleton != (Object)null && singleton.IsServer) ? GetOrCreateHostAdminState(selectedAdminPlayer.ClientId) : GetOrCreateJoinedClientVisualState(selectedAdminPlayer.ClientId)); obj.Frozen = frozen; obj.NextStunAt = 0f; TryDispatchPlayerStun(val, frozen ? 30f : 0.01f); if (!frozen) { val.UnStun(); } if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { SendServerAdminRequest(frozen ? ServerAdminAction.FreezePlayer : ServerAdminAction.ReleasePlayer, selectedAdminPlayer.ClientId); } SetStatus((frozen ? "Froze" : "Released") + " " + selectedAdminPlayer.Name); } private static bool TryDispatchPlayerStun(BeetleActor actor, float duration) { try { StunForDurationRpcDispatcher val = actor.stunDispatcher ?? ((Component)actor).GetComponent(); if ((Object)(object)val == (Object)null || !((NetworkBehaviour)val).IsSpawned) { return false; } ((SingleTargetParamRpcDispatcher)(object)val).DispatchRpcOrPerformLocal(Mathf.Max(0.01f, duration)); return true; } catch { return false; } } private void SetSelectedPlayerTeam(TeamType requestedTeam) { //IL_0037: 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) //IL_0035: Expected I4, but got Unknown //IL_003d: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_0083: Expected I4, but got Unknown AdminPlayerEntry selectedAdminPlayer = GetSelectedAdminPlayer(); if (selectedAdminPlayer == null) { return; } BeetleActor val = FindActorForClient(selectedAdminPlayer.ClientId); if ((Object)(object)val == (Object)null) { SendServerAdminRequest(ServerAdminAction.SetPlayerTeam, selectedAdminPlayer.ClientId, (int)requestedTeam); return; } TeamType val2 = (((int)requestedTeam == 0) ? MatchStateController.GetLeastRepresentedTeam() : requestedTeam); if ((int)val2 == 0) { val2 = (TeamType)1; } val.SetTeam_ServerRpc(val2); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { SendServerAdminRequest(ServerAdminAction.SetPlayerTeam, selectedAdminPlayer.ClientId, (int)val2); } SetStatus($"Set {selectedAdminPlayer.Name} to {val2}"); } private void SetSelectedPlayerScalePreset(float scale) { _selectedPlayerScale = Mathf.Max(0.05f, scale); SetSelectedPlayerScale(_selectedPlayerScale); } private void SetSelectedPlayerScale(float scale) { AdminPlayerEntry selectedAdminPlayer = GetSelectedAdminPlayer(); if (selectedAdminPlayer == null) { return; } scale = Mathf.Max(0.05f, scale); _selectedPlayerScale = scale; NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { SetStatus("Join or host a session first."); } else if (!singleton.IsServer) { BeetleActor val = FindActorForClient(selectedAdminPlayer.ClientId); if (selectedAdminPlayer.ClientId == singleton.LocalClientId) { _playerSize = scale; _playerTuning = true; if ((Object)(object)val != (Object)null) { RefreshPlayerSnapshot(val); ApplyPlayerTuning(val); } } else { GetOrCreateJoinedClientVisualState(selectedAdminPlayer.ClientId).Scale = scale; ApplyJoinedClientVisualPlayerStates(); } SetStatus($"Set {selectedAdminPlayer.Name} scale to {scale:0.##}x (local)"); } else { if (selectedAdminPlayer.ClientId == singleton.LocalClientId) { _playerSize = scale; _playerTuning = true; } else { GetOrCreateHostAdminState(selectedAdminPlayer.ClientId).Scale = scale; ApplyHostPlayerAdminStates(); } if (selectedAdminPlayer.IsModded) { SendAdminClientCommand(selectedAdminPlayer.ClientId, AdminClientAction.SetScale, 0, scale); SetStatus($"Sent {scale:0.##}x scale to modded owner {selectedAdminPlayer.Name}"); } else { SetStatus($"Tried {scale:0.##}x in host view; vanilla owner may overwrite it"); } } } private HostAdminPlayerState GetOrCreateJoinedClientVisualState(ulong clientId) { if (!_joinedClientVisualPlayerStates.TryGetValue(clientId, out HostAdminPlayerState value)) { value = new HostAdminPlayerState { ClientId = clientId }; _joinedClientVisualPlayerStates[clientId] = value; } return value; } private void ApplyJoinedClientVisualPlayerStates() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) if (_joinedClientVisualPlayerStates.Count == 0) { return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.IsServer) { RestoreAllJoinedClientVisualPlayerStates(); return; } _adminStateCleanup.Clear(); foreach (KeyValuePair joinedClientVisualPlayerState in _joinedClientVisualPlayerStates) { HostAdminPlayerState value = joinedClientVisualPlayerState.Value; BeetleActor val = FindActorForClient(value.ClientId); if ((Object)(object)val == (Object)null) { continue; } try { if (value.ActorPointer != ((Il2CppObjectBase)val).Pointer) { value.ActorPointer = ((Il2CppObjectBase)val).Pointer; value.Actor = val; value.BaseScale = ((Component)val).transform.localScale; value.LastAppliedScale = ((Component)val).transform.localScale; } if (Math.Abs(value.Scale - 1f) <= 0.0001f) { ((Component)val).transform.localScale = value.BaseScale; if (!value.Frozen) { _adminStateCleanup.Add(joinedClientVisualPlayerState.Key); } } else { Vector3 localScale = ((Component)val).transform.localScale; Vector3 val2 = localScale - value.LastAppliedScale; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { value.BaseScale = localScale; } Vector3 val3 = value.BaseScale * value.Scale; ((Component)val).transform.localScale = val3; value.LastAppliedScale = val3; } if (value.Frozen && (Object)(object)((NetworkActor)val).RB != (Object)null) { ((NetworkActor)val).RB.linearVelocity = Vector3.zero; ((NetworkActor)val).RB.angularVelocity = Vector3.zero; if (Time.unscaledTime >= value.NextStunAt) { TryDispatchPlayerStun(val, 30f); value.NextStunAt = Time.unscaledTime + 10f; } } } catch { } } foreach (ulong item in _adminStateCleanup) { _joinedClientVisualPlayerStates.Remove(item); } } private void RestoreAllJoinedClientVisualPlayerStates() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) foreach (HostAdminPlayerState value in _joinedClientVisualPlayerStates.Values) { try { if ((Object)(object)value.Actor != (Object)null) { ((Component)value.Actor).transform.localScale = value.BaseScale; if (value.Frozen) { TryDispatchPlayerStun(value.Actor, 0.01f); value.Actor.UnStun(); } } } catch { } } _joinedClientVisualPlayerStates.Clear(); _selectedPlayerScale = 1f; SetStatus("Restored local-view sizes."); } private HostAdminPlayerState GetOrCreateHostAdminState(ulong clientId) { if (!_hostAdminPlayerStates.TryGetValue(clientId, out HostAdminPlayerState value)) { value = new HostAdminPlayerState { ClientId = clientId }; _hostAdminPlayerStates[clientId] = value; } return value; } private void ApplyHostPlayerAdminStates() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) if (_hostAdminPlayerStates.Count == 0) { return; } if (!IsNetworkServerHost()) { RestoreAllHostAdminPlayerStates(); return; } _adminStateCleanup.Clear(); foreach (KeyValuePair hostAdminPlayerState in _hostAdminPlayerStates) { HostAdminPlayerState value = hostAdminPlayerState.Value; BeetleActor val = FindActorForClient(value.ClientId); if ((Object)(object)val == (Object)null) { continue; } try { if (value.ActorPointer != ((Il2CppObjectBase)val).Pointer) { value.ActorPointer = ((Il2CppObjectBase)val).Pointer; value.Actor = val; value.BaseScale = ((Component)val).transform.localScale; value.LastAppliedScale = ((Component)val).transform.localScale; } if (Math.Abs(value.Scale - 1f) > 0.0001f) { Vector3 localScale = ((Component)val).transform.localScale; Vector3 val2 = localScale - value.LastAppliedScale; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { value.BaseScale = localScale; } EnableNetworkScaleSync((Component)(object)val); Vector3 val3 = value.BaseScale * value.Scale; ((Component)val).transform.localScale = val3; value.LastAppliedScale = val3; } if (value.Frozen && (Object)(object)((NetworkActor)val).RB != (Object)null) { ((NetworkActor)val).RB.linearVelocity = Vector3.zero; ((NetworkActor)val).RB.angularVelocity = Vector3.zero; if (Time.unscaledTime >= value.NextStunAt) { val.Stun(30f); value.NextStunAt = Time.unscaledTime + 10f; } } if (!value.Frozen && Math.Abs(value.Scale - 1f) <= 0.0001f) { if ((Object)(object)value.Actor != (Object)null) { ((Component)value.Actor).transform.localScale = value.BaseScale; } _adminStateCleanup.Add(hostAdminPlayerState.Key); } } catch { } } foreach (ulong item in _adminStateCleanup) { _hostAdminPlayerStates.Remove(item); } } private void RestoreAllHostAdminPlayerStates() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) foreach (HostAdminPlayerState value in _hostAdminPlayerStates.Values) { try { if ((Object)(object)value.Actor != (Object)null) { ((Component)value.Actor).transform.localScale = value.BaseScale; if (value.Frozen) { value.Actor.Stun(0.01f); value.Actor.UnStun(); } } } catch { } } _hostAdminPlayerStates.Clear(); } private void ReleaseAllAdminFreezes() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { foreach (HostAdminPlayerState value in _joinedClientVisualPlayerStates.Values) { value.Frozen = false; BeetleActor val = FindActorForClient(value.ClientId); if ((Object)(object)val != (Object)null) { TryDispatchPlayerStun(val, 0.01f); val.UnStun(); } } ApplyJoinedClientVisualPlayerStates(); SendServerAdminRequest(ServerAdminAction.ReleaseAllFreezes, ulong.MaxValue); } else { ReleaseAllAdminFreezesOnServer(); SetStatus("Released all freezes."); } } private void ReleaseAllAdminFreezesOnServer() { foreach (HostAdminPlayerState value in _hostAdminPlayerStates.Values) { value.Frozen = false; BeetleActor val = FindActorForClient(value.ClientId); if ((Object)(object)val != (Object)null) { val.Stun(0.01f); val.UnStun(); } } } private void RestoreAllAdminPlayerSizes() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { foreach (HostAdminPlayerState value in _joinedClientVisualPlayerStates.Values) { value.Scale = 1f; } ApplyJoinedClientVisualPlayerStates(); _selectedPlayerScale = 1f; SendServerAdminRequest(ServerAdminAction.RestoreAllPlayerSizes, ulong.MaxValue); } else { RestoreAllAdminPlayerSizesOnServer(); SetStatus("Restored all player sizes."); } } private void RestoreAllAdminPlayerSizesOnServer() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) foreach (HostAdminPlayerState value in _hostAdminPlayerStates.Values) { value.Scale = 1f; if ((Object)(object)value.Actor != (Object)null) { try { ((Component)value.Actor).transform.localScale = value.BaseScale; } catch { } } if ((Object)(object)NetworkManager.Singleton != (Object)null && _moddedClientIds.Contains(value.ClientId)) { SendAdminClientCommand(value.ClientId, AdminClientAction.SetScale, 0, 1f); } } _selectedPlayerScale = 1f; } private void ResetHostedRound() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { SendServerAdminRequest(ServerAdminAction.ResetRound, ulong.MaxValue); return; } try { ResetRoundOnServer(); SetStatus("Reset scores and round."); } catch (Exception exception) { ReportException("resetting round", exception); } } private static void ResetRoundOnServer() { MatchStateController instance = MatchStateController.Instance; if ((Object)(object)instance == (Object)null) { throw new InvalidOperationException("MatchStateController unavailable."); } instance.ResetMatch(); instance.InitializeRound(); } private void RestartHostedMatch() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { SendServerAdminRequest(ServerAdminAction.RestartMatch, ulong.MaxValue); return; } try { RestartMatchOnServer(); _pendingForceSpectatorsAt = Time.unscaledTime + 1.25f; SetStatus("Restarted match; spectators will be added."); } catch (Exception exception) { ReportException("restarting match", exception); } } private static void RestartMatchOnServer() { MatchStateController instance = MatchStateController.Instance; if ((Object)(object)instance == (Object)null) { throw new InvalidOperationException("MatchStateController unavailable."); } instance.InitializeMatch(); } private void ClearAllDungAsHost() { try { NetworkManager singleton = NetworkManager.Singleton; Il2CppArrayBase obj = Object.FindObjectsOfType(); int num = 0; foreach (DungBall item in obj) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((NetworkBehaviour)item).NetworkObject == (Object)null) && ((NetworkBehaviour)item).NetworkObject.IsSpawned) { if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer) { item.Despawn_ServerRpc(); } else { ((NetworkBehaviour)item).NetworkObject.Despawn(true); } num++; } } SetStatus($"Cleared {num} dung balls."); } catch (Exception exception) { ReportException("clearing dung", exception); } } private void DrawRawGlobalCooldownControls() { RawSection("ALL-PLAYER COOLDOWNS"); bool flag = RawToggle("Enable global cooldown factor", _globalCooldownEnabled); if (flag != _globalCooldownEnabled) { _globalCooldownEnabled = flag; if (!flag) { RestoreGlobalCooldowns(); } SyncGlobalCooldownToModdedClients(flag); RequestGlobalCooldownFromServer(); SetStatus(flag ? $"Global cooldown at {_globalCooldownFactor:0.00}x" : "Global cooldown restored"); } float globalCooldownFactor = _globalCooldownFactor; _globalCooldownFactor = RawStepper("Cooldown factor (0=none)", _globalCooldownFactor, 0f, 2f, 0.05f, 1f); if (_globalCooldownEnabled && Math.Abs(globalCooldownFactor - _globalCooldownFactor) > 0.0001f) { SyncGlobalCooldownToModdedClients(enabled: true); RequestGlobalCooldownFromServer(); SetStatus($"Global cooldown set to {_globalCooldownFactor:0.00}x"); } } private void RequestGlobalCooldownFromServer() { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsListening && !singleton.IsServer) { SendServerAdminRequest(ServerAdminAction.SetGlobalCooldown, ulong.MaxValue, _globalCooldownEnabled ? 1 : 0, _globalCooldownFactor, quiet: true); } } private void ApplyGlobalCooldowns() { if (!_globalCooldownEnabled) { if (_globalCooldownSnapshots.Count > 0) { RestoreGlobalCooldowns(); } return; } try { float num = Mathf.Clamp(_globalCooldownFactor, 0f, 2f); Il2CppArrayBase obj = Object.FindObjectsOfType(); _globalCooldownSeen.Clear(); foreach (BeetleActor item in obj) { BeetleStatModifiersController val = ((item != null) ? item.StatModifiersController : null); if (!((Object)(object)item == (Object)null) && !((Object)(object)val == (Object)null)) { IntPtr pointer = ((Il2CppObjectBase)item).Pointer; _globalCooldownSeen.Add(pointer); if (!_globalCooldownSnapshots.TryGetValue(pointer, out GlobalCooldownSnapshot value)) { value = CaptureGlobalCooldownSnapshot(item, val); _globalCooldownSnapshots[pointer] = value; } BeetleStats stats = item.Stats; stats.GrabCooldownDuration = value.GrabCooldown * num; stats.HeadbuttCooldown = value.HeadbuttCooldown * num; stats.ShootBallRecoveryDuration = value.ShootRecovery * num; val.ModifiedStats = stats; item.jumpCooldown = value.JumpCooldown * num; item.ballJumpCooldown = value.BallJumpCooldown * num; SetLiveCooldownTimer(item.GrabCooldownTimer, value.GrabTimer, num); SetLiveCooldownTimer(item.JumpCooldownTimer, value.JumpTimer, num); SetLiveCooldownTimer(item.HeadbuttCooldownTimer, value.HeadbuttTimer, num); SetLiveCooldownTimer(item.BallJumpCooldownTimer, value.BallJumpTimer, num); SetLiveCooldownTimer(item.ShootBallRecoveryTimer, value.ShootRecoveryTimer, num); } } _globalCooldownCleanup.Clear(); foreach (KeyValuePair globalCooldownSnapshot in _globalCooldownSnapshots) { if (!_globalCooldownSeen.Contains(globalCooldownSnapshot.Key)) { _globalCooldownCleanup.Add(globalCooldownSnapshot.Key); } } foreach (IntPtr item2 in _globalCooldownCleanup) { _globalCooldownSnapshots.Remove(item2); } } catch (Exception exception) { ReportException("applying global cooldowns", exception); } } private GlobalCooldownSnapshot CaptureGlobalCooldownSnapshot(BeetleActor actor, BeetleStatModifiersController controller) { BeetleStats baselineStats = actor.Stats; try { if ((Object)(object)actor.BaseStats != (Object)null) { baselineStats = actor.BaseStats.Data; } } catch { } float jumpCooldown = actor.jumpCooldown; float ballJumpCooldown = actor.ballJumpCooldown; if (_playerSnapshot != null && _playerSnapshot.ActorPointer == ((Il2CppObjectBase)actor).Pointer) { jumpCooldown = _playerSnapshot.JumpCooldown; ballJumpCooldown = _playerSnapshot.BallJumpCooldown; } return new GlobalCooldownSnapshot(actor, controller, baselineStats, jumpCooldown, ballJumpCooldown); } private void RestoreGlobalCooldowns() { foreach (GlobalCooldownSnapshot value in _globalCooldownSnapshots.Values) { try { if (!((Object)(object)value.Actor == (Object)null) && !((Object)(object)value.Controller == (Object)null)) { BeetleStats stats = value.Actor.Stats; stats.GrabCooldownDuration = value.RestoreGrabCooldown; stats.HeadbuttCooldown = value.RestoreHeadbuttCooldown; stats.ShootBallRecoveryDuration = value.RestoreShootRecovery; value.Controller.ModifiedStats = stats; value.Actor.jumpCooldown = value.RestoreJumpCooldown; value.Actor.ballJumpCooldown = value.RestoreBallJumpCooldown; SetLiveCooldownTimer(value.Actor.GrabCooldownTimer, value.RestoreGrabTimer, 1f); SetLiveCooldownTimer(value.Actor.JumpCooldownTimer, value.RestoreJumpTimer, 1f); SetLiveCooldownTimer(value.Actor.HeadbuttCooldownTimer, value.RestoreHeadbuttTimer, 1f); SetLiveCooldownTimer(value.Actor.BallJumpCooldownTimer, value.RestoreBallJumpTimer, 1f); SetLiveCooldownTimer(value.Actor.ShootBallRecoveryTimer, value.RestoreShootRecoveryTimer, 1f); } } catch { } } _globalCooldownSnapshots.Clear(); } private void SyncGlobalCooldownToModdedClients(bool enabled) { try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } foreach (ulong moddedClientId in _moddedClientIds) { if (moddedClientId != singleton.LocalClientId) { SendAdminClientCommand(moddedClientId, AdminClientAction.SetGlobalCooldown, enabled ? 1 : 0, _globalCooldownFactor, quiet: true); } } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Sync cooldown failed: " + ex.Message); } } private void BeginExactLevelTyping() { _exactLevelTypingMode = 1; _exactLevelTypingText = string.Empty; SetStatus("Type level number; Enter applies, Escape cancels."); } private void CaptureExactLevelTyping() { if (_exactLevelTypingMode == 0 || !_menuOpen || _guiUnavailable || _menuPage != 0) { return; } try { if (Input.GetKeyDown((KeyCode)27)) { _exactLevelTypingMode = 0; _exactLevelTypingText = string.Empty; SetStatus("Cancelled."); return; } if (Input.GetKeyDown((KeyCode)127)) { _exactLevelTypingText = string.Empty; } if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { CommitExactLevelTyping(); return; } string inputString = Input.inputString; if (string.IsNullOrEmpty(inputString)) { return; } string text = inputString; for (int i = 0; i < text.Length; i++) { char c = text[i]; switch (c) { case '\b': if (_exactLevelTypingText.Length > 0) { _exactLevelTypingText = _exactLevelTypingText.Substring(0, _exactLevelTypingText.Length - 1); } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (_exactLevelTypingText.Length < 1000000.ToString().Length) { _exactLevelTypingText += c; } break; } } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Level typing error: " + ex.Message); } } private void CommitExactLevelTyping() { if (!int.TryParse(_exactLevelTypingText, out var result)) { SetStatus($"Enter a level from 1 to {1000000:N0}"); return; } result = Math.Clamp(result, 1, 1000000); _exactLevelTypingMode = 0; _exactLevelTypingText = string.Empty; _localTargetLevel = result; _localTargetLevelInitialized = true; ApplyExactLocalLevelFromStepper(); } private string BuildExactLevelTypingLabel() { return "Typing: " + ((_exactLevelTypingText.Length == 0) ? "(empty)" : _exactLevelTypingText) + "_"; } private void ApplyExactLocalLevelFromStepper() { _localTargetLevel = Math.Clamp(_localTargetLevel, 1, 1000000); _localTargetLevelInitialized = true; SetStatus(SetExactLocalLevel(_localTargetLevel)); } private void LoadCustomLocalLevelOverride() { try { int num = PlayerPrefs.GetInt("BeetleballSandbox.CustomLocalLevel.v1", 0); _customLocalLevelOverride = ((num >= 1 && num <= 1000000) ? num : 0); } catch { _customLocalLevelOverride = 0; } } private void SetCustomLocalLevelOverride(int level) { _customLocalLevelOverride = Math.Clamp(level, 1, 1000000); PlayerPrefs.SetInt("BeetleballSandbox.CustomLocalLevel.v1", _customLocalLevelOverride); PlayerPrefs.Save(); } private void ClearCustomLocalLevelOverride() { _customLocalLevelOverride = 0; PlayerPrefs.DeleteKey("BeetleballSandbox.CustomLocalLevel.v1"); PlayerPrefs.Save(); } internal static bool TryGetCustomLocalLevelOverride(out int level) { level = _activeInstance?._customLocalLevelOverride ?? 0; return level > 0; } private bool ExecuteServerAdminAction(ulong senderClientId, ServerAdminAction action, ulong targetClientId, int intValue, float floatValue, out string result) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { result = "Server authority unavailable."; return false; } switch (action) { case ServerAdminAction.ForceIntoMatch: { AdminPlayerEntry adminPlayerEntry = FindAdminPlayerEntry(targetClientId); if (adminPlayerEntry == null) { result = $"Client {targetClientId} not found."; return false; } TeamType val3 = ResolveRequestedSpawnTeam(adminPlayerEntry, (TeamType)intValue); ForceClientIntoMatchOnServer(adminPlayerEntry, val3); result = $"Spawned {adminPlayerEntry.Name} on {val3}."; break; } case ServerAdminAction.FreezePlayer: case ServerAdminAction.ReleasePlayer: { BeetleActor val = FindActorForClient(targetClientId); if ((Object)(object)val == (Object)null) { result = $"Client {targetClientId} has no beetle."; return false; } bool flag = action == ServerAdminAction.FreezePlayer; HostAdminPlayerState orCreateHostAdminState = GetOrCreateHostAdminState(targetClientId); orCreateHostAdminState.Frozen = flag; orCreateHostAdminState.NextStunAt = 0f; TryDispatchPlayerStun(val, flag ? 30f : 0.01f); if (!flag) { val.UnStun(); } result = (flag ? $"Froze client {targetClientId}." : $"Released client {targetClientId}."); break; } case ServerAdminAction.SetPlayerScale: { BeetleActor val = FindActorForClient(targetClientId); if ((Object)(object)val == (Object)null) { result = $"Client {targetClientId} has no beetle."; return false; } float num = SanitizeCreativeScale(floatValue); GetOrCreateHostAdminState(targetClientId).Scale = num; ApplyHostPlayerAdminStates(); result = $"Set client {targetClientId} scale to {num:0.##}x."; break; } case ServerAdminAction.ResetRound: ResetRoundOnServer(); result = "Reset round."; break; case ServerAdminAction.RestartMatch: RestartMatchOnServer(); _pendingForceSpectatorsAt = Time.unscaledTime + 1.25f; result = "Restarted match."; break; case ServerAdminAction.AddSpectators: { int num2 = ForceAllSpectatorsIntoMatchOnServer(); result = ((num2 == 0) ? "No spectators." : $"Spawned {num2} spectator(s)."); break; } case ServerAdminAction.ClearDung: result = $"Cleared {ClearAllDungOnServer()} dung balls."; break; case ServerAdminAction.ReleaseAllFreezes: ReleaseAllAdminFreezesOnServer(); result = "Released all freezes."; break; case ServerAdminAction.RestoreAllPlayerSizes: RestoreAllAdminPlayerSizesOnServer(); result = "Restored all player sizes."; break; case ServerAdminAction.SetGlobalCooldown: _globalCooldownEnabled = intValue != 0; _globalCooldownFactor = Mathf.Clamp(floatValue, 0f, 2f); if (!_globalCooldownEnabled) { RestoreGlobalCooldowns(); } SyncGlobalCooldownToModdedClients(_globalCooldownEnabled); result = (_globalCooldownEnabled ? $"Set global cooldown to {_globalCooldownFactor:0.00}x." : "Restored global cooldowns."); break; case ServerAdminAction.SetGlobalBallScale: _globalBallScaleEnabled = intValue != 0; _globalBallScale = SanitizeCreativeScale(floatValue); if (_globalBallScaleEnabled) { ApplyGlobalBallScale(); } else { RestoreGlobalBallScale(); } result = (_globalBallScaleEnabled ? $"Set global ball scale to {_globalBallScale:0.##}x." : "Restored global ball scale."); break; case ServerAdminAction.SetPlayerTeam: { BeetleActor val = FindActorForClient(targetClientId); if ((Object)(object)val == (Object)null) { result = $"Client {targetClientId} has no beetle."; return false; } TeamType val2 = (TeamType)(intValue switch { 1 => 1, 2 => 2, _ => (int)MatchStateController.GetLeastRepresentedTeam(), }); if ((int)val2 == 0) { val2 = (TeamType)1; } val.SetTeam_ServerRpc(val2); result = $"Moved client {targetClientId} to {val2}."; break; } default: result = "Unknown action."; return false; } return true; } catch (Exception ex) { result = ex.Message; return false; } } private AdminPlayerEntry? FindAdminPlayerEntry(ulong clientId) { RefreshAdminPlayerList(force: true); return _adminPlayers.FirstOrDefault((AdminPlayerEntry p) => p.ClientId == clientId); } private static float SanitizeCreativeScale(float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { return 1f; } return Mathf.Clamp(value, 0.05f, 1000000f); } private string ExecuteAdminClientAction(AdminClientAction action, int intValue, float floatValue) { switch (action) { case AdminClientAction.AddExperience: { int num2 = Math.Clamp(intValue, 1, 1000000); PlayerLevelManager instance = PlayerLevelManager.Instance; if ((Object)(object)instance == (Object)null) { return "Level manager unavailable."; } instance.AddExperience(num2); return $"Granted {num2:N0} XP."; } case AdminClientAction.NextLevel: { PlayerLevelManager instance = PlayerLevelManager.Instance; if ((Object)(object)instance == (Object)null) { return "Level manager unavailable."; } int num = Math.Max(1, instance.RequiredLevelUpExperience(instance.Level) - instance.Experience); instance.AddExperience(num); return $"Advanced to next level (+{num:N0} XP)."; } case AdminClientAction.SetLevel: return SetExactLocalLevel(Math.Clamp(intValue, 1, 1000000)); case AdminClientAction.UnlockSkins: return UnlockEveryLocalSkin(); case AdminClientAction.SetScale: _playerSize = Mathf.Max(0.05f, floatValue); _playerTuning = true; return $"Player scale set to {_playerSize:0.##}x."; case AdminClientAction.SetGlobalCooldown: return SetServerCooldownOverridePublic(intValue != 0, floatValue); default: return "Unknown action."; } } private static string SetExactLocalLevel(int level) { try { level = Math.Clamp(level, 1, 1000000); StatsManager instance = StatsManager.Instance; IStatsService val = ((instance != null) ? instance.Service : null); if (val == null) { return "Stats service unavailable."; } bool flag = val.SetInt("demo_level_new", level); bool flag2 = val.SetInt("demo_experience_new", 0); if (flag) { _activeInstance?.ClearCustomLocalLevelOverride(); } else { _activeInstance?.SetCustomLocalLevelOverride(level); } if (!(flag && flag2)) { return $"Requested level {level:N0} (save warning)."; } return $"Level set to {level:N0}."; } catch (Exception ex) { return "Level change failed: " + ex.Message; } } private static string UnlockEveryLocalSkin() { try { InventoryManager instance = InventoryManager.Instance; IInventoryService val = ((instance != null) ? instance.Service : null); if (val == null) { return "Inventory unavailable."; } Il2CppArrayBase obj = Resources.FindObjectsOfTypeAll(); int num = 0; int num2 = 0; foreach (BeetleSkinDataSO item in obj) { if (!((Object)(object)item == (Object)null) && !string.IsNullOrWhiteSpace(((ItemSO)item).Id)) { if (val.LocalPlayerHasItem(((ItemSO)item).Id)) { num2++; } else if (val.AddItem(((ItemSO)item).Id)) { num++; } } } CosmeticEvents.InvokeCosmeticRefreshRequested(); return $"Unlocked {num} skins; {num2} already owned."; } catch (Exception ex) { return "Skin unlock failed: " + ex.Message; } } private int ClearAllDungOnServer() { Il2CppArrayBase obj = Object.FindObjectsOfType(); int num = 0; foreach (DungBall item in obj) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((NetworkBehaviour)item).NetworkObject == (Object)null) && ((NetworkBehaviour)item).NetworkObject.IsSpawned) { ((NetworkBehaviour)item).NetworkObject.Despawn(true); num++; } } return num; } private void UpdateNetworkBridge() { //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) if (_serverCooldownOverrideActive && !_playerTuning) { _playerTuning = true; } NetworkManager val = null; CustomMessagingManager val2 = null; try { val = NetworkManager.Singleton; if ((Object)(object)val != (Object)null && val.IsListening) { val2 = val.CustomMessagingManager; } } catch { val = null; val2 = null; } if ((Object)(object)val == (Object)null || val2 == null) { if (_bridgeMessaging != null) { ResetNetworkBridge(); } return; } if (_bridgeMessaging == null || _bridgeMessagingPointer != ((Il2CppObjectBase)val2).Pointer) { ResetNetworkBridge(); _bridgeMessaging = val2; _bridgeMessagingPointer = ((Il2CppObjectBase)val2).Pointer; try { _relayResponseHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnRelayResponseReceived); _announcementBroadcastHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnAnnouncementBroadcastReceived); _adminCommandHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnAdminCommandReceived); _serverAdminResponseHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnServerAdminResponseReceived); val2.RegisterNamedMessageHandler("BeetleballSandbox.RelayResponse.v1", _relayResponseHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.AnnouncementBroadcast.v1", _announcementBroadcastHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.AdminCommand.v1", _adminCommandHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.ServerAdminResponse.v1", _serverAdminResponseHandler); if (val.IsServer) { _worldRequestHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnWorldRequestReceived); _announcementRequestHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnAnnouncementRequestReceived); _playerTuningRequestHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnPlayerTuningRequestReceived); _adminResultHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnAdminResultReceived); _serverAdminRequestHandler = HandleNamedMessageDelegate.op_Implicit((Action)OnServerAdminRequestReceived); val2.RegisterNamedMessageHandler("BeetleballSandbox.WorldRequest.v1", _worldRequestHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.AnnouncementRequest.v1", _announcementRequestHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.PlayerTuningRequest.v1", _playerTuningRequestHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.AdminResult.v1", _adminResultHandler); val2.RegisterNamedMessageHandler("BeetleballSandbox.ServerAdminRequest.v1", _serverAdminRequestHandler); } } catch (Exception exception) { ReportException("initializing the modded-server relay", exception); ResetNetworkBridge(); return; } _nextRelayHelloAt = 0f; } if (val.IsServer) { _hostRelayDetected = true; _hostRelayAllowed = _allowClientWorldRequests; _lastRelayAckAt = Time.unscaledTime; return; } if (_hostRelayDetected && Time.unscaledTime - _lastRelayAckAt > 12f) { _hostRelayDetected = false; _hostRelayAllowed = false; } if (val.IsConnectedClient && Time.unscaledTime >= _nextRelayHelloAt) { _nextRelayHelloAt = Time.unscaledTime + 3f; SendWorldRequest(WorldAction.Ping, null, 0, 0, 0f, 0f, default(Vector3), 0); } } private void ShutdownNetworkBridge() { ClearRelayedPlayerTuning(); ClearRelayedBallTuning(); RestoreAllRemotePlayerTunings(); RestoreAllRemoteBallTunings(); ResetNetworkBridge(); } private void ResetNetworkBridge() { ClearServerCooldownOverrideInternal(); if (_bridgeMessaging != null) { try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.WorldRequest.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.RelayResponse.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.AnnouncementRequest.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.AnnouncementBroadcast.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.PlayerTuningRequest.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.AdminCommand.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.AdminResult.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.ServerAdminRequest.v1"); } catch { } try { _bridgeMessaging.UnregisterNamedMessageHandler("BeetleballSandbox.ServerAdminResponse.v1"); } catch { } } _bridgeMessaging = null; _bridgeMessagingPointer = IntPtr.Zero; _worldRequestHandler = null; _relayResponseHandler = null; _announcementRequestHandler = null; _announcementBroadcastHandler = null; _playerTuningRequestHandler = null; _adminCommandHandler = null; _adminResultHandler = null; _serverAdminRequestHandler = null; _serverAdminResponseHandler = null; _hostRelayDetected = false; _hostRelayAllowed = false; _lastRelayedBallId = 0uL; _relayedPlayerTuningActive = false; RestoreAllRemotePlayerTunings(); RestoreAllRemoteBallTunings(); _lastAnnouncementTimes.Clear(); _moddedClientIds.Clear(); _lastLocalAnnouncementPopup = string.Empty; _lastLocalAnnouncementPopupAt = float.NegativeInfinity; _allowClientWorldRequests = false; } private bool IsNetworkServerHost() { try { NetworkManager singleton = NetworkManager.Singleton; return (Object)(object)singleton != (Object)null && singleton.IsListening && singleton.IsServer; } catch { return false; } } private bool HasReadyHostRelay() { if (_hostRelayDetected) { return _hostRelayAllowed; } return false; } private string BuildSharedWorldControlStatus() { try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return "Shared world controls: offline/direct authority."; } if (singleton.IsServer) { return _allowClientWorldRequests ? "Shared world controls: modded host relay ON; joining clients allowed." : "Shared world controls: host only; joining-client relay disabled."; } if (_hostRelayDetected) { return _hostRelayAllowed ? "Client direct controls ON; modded-host shared sync connected." : "Client direct controls ON; host relay has shared sync disabled."; } return "Client direct controls ON; no modded-host relay detected."; } catch { return "Shared world controls: relay state unavailable."; } } private string GetSharedWorldAuthorityTag() { try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return "offline authority"; } if (singleton.IsServer) { return "modded host authority"; } return (_hostRelayDetected && _hostRelayAllowed) ? "client direct + host sync" : "client direct mode"; } catch { return "relay unavailable"; } } private bool TryRelayWorldAction(WorldAction action, DungBall? ball = null, int intValue = 0, int secondaryIntValue = 0, float floatValue = 0f, float secondaryFloatValue = 0f, Vector3 vectorValue = default(Vector3), byte flags = 0) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (HasWorldAuthority()) { return false; } if (action == WorldAction.SpawnLooseDung || action == WorldAction.ChangeBallSize || action == WorldAction.SpawnBall) { return false; } if (SendWorldRequest(action, ball, intValue, secondaryIntValue, floatValue, secondaryFloatValue, vectorValue, flags)) { return HasReadyHostRelay(); } return false; } private bool SendWorldRequest(WorldAction action, DungBall? ball = null, int intValue = 0, int secondaryIntValue = 0, float floatValue = 0f, float secondaryFloatValue = 0f, Vector3 vectorValue = default(Vector3), byte flags = 0) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsListening || !singleton.IsClient) { return false; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(64, (Allocator)2, 64); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)action); WriteUInt64(val2, GetBallNetworkId(ball)); WriteInt32(val2, intValue); WriteInt32(val2, secondaryIntValue); WriteSingle(val2, floatValue); WriteSingle(val2, secondaryFloatValue); WriteVector3(val2, vectorValue); ((FastBufferWriter)(ref val2)).WriteByteSafe(flags); val.SendNamedMessage("BeetleballSandbox.WorldRequest.v1", NetworkManager.ServerClientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } if (action != WorldAction.Ping && action != WorldAction.ConfigureBall && action != WorldAction.ClearBallTuning) { SetStatus("Sent " + GetWorldActionName(action) + " request to the modded host"); } return true; } catch (Exception exception) { if (action != WorldAction.Ping && action != WorldAction.ConfigureBall) { ReportException("sending a world-control request", exception); } return false; } } private void OnWorldRequestReceived(ulong senderClientId, FastBufferReader reader) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) WorldAction worldAction = WorldAction.Ping; try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } byte b = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); worldAction = (WorldAction)b; bool flag = _moddedClientIds.Add(senderClientId); WorldRequest worldRequest = new WorldRequest { Action = worldAction, TargetBallId = ReadUInt64(reader), IntValue = ReadInt32(reader), SecondaryIntValue = ReadInt32(reader), FloatValue = ReadSingle(reader), SecondaryFloatValue = ReadSingle(reader), VectorValue = ReadVector3(reader) }; ((FastBufferReader)(ref reader)).ReadByteSafe(ref worldRequest.Flags); if (worldAction == WorldAction.Ping) { SendRelayResponse(senderClientId, worldAction, succeeded: true); if (flag && _globalCooldownEnabled) { SendAdminClientCommand(senderClientId, AdminClientAction.SetGlobalCooldown, 1, _globalCooldownFactor, quiet: true); } } else if (!_allowClientWorldRequests) { SendRelayResponse(senderClientId, worldAction, succeeded: false); } else { bool succeeded = ExecuteRemoteWorldAction(senderClientId, worldRequest); if (worldAction != WorldAction.ConfigureBall && worldAction != WorldAction.ClearBallTuning) { SendRelayResponse(senderClientId, worldAction, succeeded); } } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Rejected malformed {worldAction} request from client {senderClientId}: {ex.Message}"); if (worldAction != WorldAction.ConfigureBall) { SendRelayResponse(senderClientId, worldAction, succeeded: false); } } } private bool ExecuteRemoteWorldAction(ulong senderClientId, WorldRequest request) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) BeetleActor val = FindActorForClient(senderClientId); DungBall val2 = FindBallByNetworkId(request.TargetBallId); try { switch (request.Action) { case WorldAction.ChangeBallSize: if ((Object)(object)val2 == (Object)null) { return false; } val2.IncrementSize_ServerRpc(Math.Clamp(request.IntValue, -10, 10)); break; case WorldAction.SpawnLooseDung: if ((Object)(object)val == (Object)null) { return false; } if (!SpawnLooseDungOnServer(val, request.IntValue, request.SecondaryIntValue, request.VectorValue)) { return false; } break; case WorldAction.RecallBall: { if ((Object)(object)val == (Object)null || (Object)(object)((val2 != null) ? val2.RB : null) == (Object)null) { return false; } Vector3 position = ((Component)val).transform.position + ((Component)val).transform.forward * 3f + Vector3.up * 1.25f; val2.RB.position = position; ((Component)val2).transform.position = position; val2.RB.linearVelocity = Vector3.zero; val2.RB.angularVelocity = Vector3.zero; break; } case WorldAction.LaunchBall: { if ((Object)(object)((val2 != null) ? val2.RB : null) == (Object)null) { return false; } Vector3 val3 = ((!(((Vector3)(ref request.VectorValue)).sqrMagnitude < 0.01f)) ? ((Vector3)(ref request.VectorValue)).normalized : (((Object)(object)val == (Object)null) ? Vector3.forward : ((Component)val).transform.forward)); ApplyOwnerAwareBallForce(val2, val3 * Mathf.Clamp(request.FloatValue, 2f, 500f) + Vector3.up * 2f, resetVelocity: true); break; } case WorldAction.StopBall: if ((Object)(object)((val2 != null) ? val2.RB : null) == (Object)null) { return false; } ApplyOwnerAwareBallForce(val2, Vector3.zero, resetVelocity: true); val2.RB.angularVelocity = Vector3.zero; break; case WorldAction.SpinBall: if ((Object)(object)((val2 != null) ? val2.RB : null) == (Object)null) { return false; } val2.RB.angularVelocity = Vector3.up * Mathf.Clamp(request.FloatValue, 0f, 500f); break; case WorldAction.ExplodeBall: if ((Object)(object)val2 == (Object)null) { return false; } val2.Explode(true); break; case WorldAction.ConfigureBall: if ((Object)(object)((val2 != null) ? val2.RB : null) == (Object)null) { return false; } ConfigureRemoteBallTuning(senderClientId, val2, request); return true; case WorldAction.ClearBallTuning: RemoveRemoteBallTuning(senderClientId, restore: true); return true; case WorldAction.SpawnBall: if ((Object)(object)val == (Object)null) { return false; } if (!SpawnLooseDungOnServer(val, 1, Math.Clamp(request.IntValue, 1, 10), request.VectorValue)) { return false; } break; default: return false; } ((MelonBase)this).LoggerInstance.Msg($"Client {senderClientId} used {GetWorldActionName(request.Action)} through the host relay"); return true; } catch (Exception value) { ((MelonBase)this).LoggerInstance.Warning($"Host relay failed {request.Action} for client {senderClientId}: {value}"); return false; } } private void SendRelayResponse(ulong clientId, WorldAction action, bool succeeded) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if (val == null) { return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(8, (Allocator)2, 8); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)action); ((FastBufferWriter)(ref val2)).WriteByteSafe(succeeded ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val2)).WriteByteSafe(_allowClientWorldRequests ? ((byte)1) : ((byte)0)); val.SendNamedMessage("BeetleballSandbox.RelayResponse.v1", clientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Could not send relay response to client {clientId}: {ex.Message}"); } } private void OnRelayResponseReceived(ulong senderClientId, FastBufferReader reader) { try { byte b = 0; byte b2 = 0; byte b3 = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); ((FastBufferReader)(ref reader)).ReadByteSafe(ref b2); ((FastBufferReader)(ref reader)).ReadByteSafe(ref b3); WorldAction worldAction = (WorldAction)b; _hostRelayDetected = true; _hostRelayAllowed = b3 != 0; _lastRelayAckAt = Time.unscaledTime; if (worldAction != WorldAction.Ping && worldAction != WorldAction.ConfigureBall && worldAction != WorldAction.ClearBallTuning) { if (b2 != 0) { SetStatus("Host completed " + GetWorldActionName(worldAction)); } else if (!_hostRelayAllowed) { SetStatus("The host has disabled joining-client shared controls"); } else { SetStatus("Host could not complete " + GetWorldActionName(worldAction)); } } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Could not read host relay response from {senderClientId}: {ex.Message}"); } } private void UpdateRelayedBallTuning(DungBall ball) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < _nextBallTuningRelayAt) { return; } _nextBallTuningRelayAt = Time.unscaledTime + 0.25f; ulong ballNetworkId = GetBallNetworkId(ball); if (ballNetworkId != 0L) { if (_lastRelayedBallId != 0L && _lastRelayedBallId != ballNetworkId) { SendWorldRequest(WorldAction.ClearBallTuning, null, 0, 0, 0f, 0f, default(Vector3), 0); } byte b = 0; if (_ballUseGravity) { b |= 1; } if (_freezeBall) { b |= 2; } float ballMass = _ballMass; float ballScale = _ballScale; byte flags = b; if (SendWorldRequest(WorldAction.ConfigureBall, ball, 0, 0, ballMass, ballScale, default(Vector3), flags)) { _lastRelayedBallId = ballNetworkId; } } } private void ClearRelayedBallTuning() { //IL_0022: 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) if (_lastRelayedBallId != 0L) { if (!HasWorldAuthority()) { SendWorldRequest(WorldAction.ClearBallTuning, null, 0, 0, 0f, 0f, default(Vector3), 0); } _lastRelayedBallId = 0uL; } } private void UpdateRelayedPlayerTuning() { if (!(Time.unscaledTime < _nextPlayerTuningRelayAt)) { _nextPlayerTuningRelayAt = Time.unscaledTime + 0.25f; if (SendPlayerTuningRequest(enabled: true)) { _relayedPlayerTuningActive = true; } } } private void ClearRelayedPlayerTuning() { if (_relayedPlayerTuningActive) { SendPlayerTuningRequest(enabled: false); _relayedPlayerTuningActive = false; } } private bool SendPlayerTuningRequest(bool enabled) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsListening || !singleton.IsClient) { return false; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(64, (Allocator)2, 64); try { ((FastBufferWriter)(ref val2)).WriteByteSafe(enabled ? ((byte)1) : ((byte)0)); if (enabled) { WriteSingle(val2, _moveSpeed); WriteSingle(val2, _sprintSpeed); WriteSingle(val2, _jumpForce); WriteSingle(val2, _gravity); WriteSingle(val2, _playerSize); WriteSingle(val2, _ballRollSpeed); WriteSingle(val2, _throwForce); WriteSingle(val2, _headbuttForce); WriteSingle(val2, _cooldownFactor); ((FastBufferWriter)(ref val2)).WriteByteSafe(_noStun ? ((byte)1) : ((byte)0)); } val.SendNamedMessage("BeetleballSandbox.PlayerTuningRequest.v1", NetworkManager.ServerClientId, val2, (NetworkDelivery)1); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } return true; } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not send player tuning to the host: " + ex.Message); return false; } } private void OnPlayerTuningRequestReceived(ulong senderClientId, FastBufferReader reader) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } byte b = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); _moddedClientIds.Add(senderClientId); if (b == 0 || !_allowClientWorldRequests) { RemoveRemotePlayerTuning(senderClientId, restore: true); return; } BeetleActor val = FindActorForClient(senderClientId); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.StatModifiersController == (Object)null)) { ConfigureRemotePlayerTuning(senderClientId, val, Mathf.Clamp(ReadSingle(reader), 0.25f, 25f), Mathf.Clamp(ReadSingle(reader), 0.25f, 25f), Mathf.Clamp(ReadSingle(reader), 0.1f, 25f), Mathf.Clamp(ReadSingle(reader), 0.01f, 10f), SanitizeUnboundedMultiplier(ReadSingle(reader), 0.05f), Mathf.Clamp(ReadSingle(reader), 0.25f, 25f), Mathf.Clamp(ReadSingle(reader), 0.25f, 50f), Mathf.Clamp(ReadSingle(reader), 0.25f, 50f), Mathf.Clamp(ReadSingle(reader), 0f, 2f)); byte b2 = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b2); _remotePlayerTunings[senderClientId].NoStun = (b2 & 1) != 0; } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Rejected malformed player tuning from client {senderClientId}: {ex.Message}"); RemoveRemotePlayerTuning(senderClientId, restore: true); } } private void ConfigureRemotePlayerTuning(ulong clientId, BeetleActor actor, float moveSpeed, float sprintSpeed, float jumpForce, float gravity, float size, float ballRollSpeed, float throwForce, float headbuttForce, float cooldownFactor) { if (_remotePlayerTunings.TryGetValue(clientId, out RemotePlayerTuning value) && value.ActorPointer != ((Il2CppObjectBase)actor).Pointer) { RestoreRemotePlayerTuning(value); _remotePlayerTunings.Remove(clientId); value = null; } if (value == null) { value = new RemotePlayerTuning(actor); _remotePlayerTunings[clientId] = value; } value.MoveSpeed = moveSpeed; value.SprintSpeed = sprintSpeed; value.JumpForce = jumpForce; value.Gravity = gravity; value.Size = size; value.BallRollSpeed = ballRollSpeed; value.ThrowForce = throwForce; value.HeadbuttForce = headbuttForce; value.CooldownFactor = cooldownFactor; value.LastReceivedAt = Time.unscaledTime; } private void ApplyRemotePlayerTunings() { //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) if (!IsNetworkServerHost() || _remotePlayerTunings.Count == 0) { return; } _expiredRemotePlayerClients.Clear(); float unscaledTime = Time.unscaledTime; foreach (KeyValuePair remotePlayerTuning in _remotePlayerTunings) { RemotePlayerTuning value = remotePlayerTuning.Value; if (unscaledTime - value.LastReceivedAt > 1.5f || (Object)(object)value.Actor == (Object)null || (Object)(object)value.Controller == (Object)null) { _expiredRemotePlayerClients.Add(remotePlayerTuning.Key); continue; } try { BeetleStats stats = value.Actor.Stats; stats.MoveSpeed = value.BaseMoveSpeed * value.MoveSpeed; stats.SprintSpeedMult = value.BaseSprintSpeed * value.SprintSpeed; stats.JumpForce = value.BaseJumpForce * value.JumpForce; stats.GravityMult = value.BaseGravity * value.Gravity; stats.Size = value.BaseSize * value.Size; stats.BallMinSizeMaxSpeed = value.BaseBallMinSpeed * value.BallRollSpeed; stats.BallMaxSizeMaxSpeed = value.BaseBallMaxSpeed * value.BallRollSpeed; stats.ShootBallForceMinSize = value.BaseThrowMin * value.ThrowForce; stats.ShootBallForceMaxSize = value.BaseThrowMax * value.ThrowForce; stats.ShootBallForceChargedMult = value.BaseChargedMultiplier; stats.HeadbuttLaunchForce = value.BaseHeadbuttLaunch * value.HeadbuttForce; stats.HeadbuttLaunchForceForwardBonus = value.BaseHeadbuttForward * value.HeadbuttForce; stats.HeadbuttHitForce = value.BaseHeadbuttHit * value.HeadbuttForce; stats.GrabCooldownDuration = value.BaseGrabCooldown * value.CooldownFactor; stats.HeadbuttCooldown = value.BaseHeadbuttCooldown * value.CooldownFactor; stats.ShootBallRecoveryDuration = value.BaseShootRecovery * value.CooldownFactor; value.Controller.ModifiedStats = stats; value.Actor.jumpCooldown = value.BaseJumpCooldown * value.CooldownFactor; value.Actor.ballJumpCooldown = value.BaseBallJumpCooldown * value.CooldownFactor; SetLiveCooldownTimer(value.Actor.GrabCooldownTimer, value.BaseGrabCooldownTimer, value.CooldownFactor); SetLiveCooldownTimer(value.Actor.JumpCooldownTimer, value.BaseJumpCooldownTimer, value.CooldownFactor); SetLiveCooldownTimer(value.Actor.HeadbuttCooldownTimer, value.BaseHeadbuttCooldownTimer, value.CooldownFactor); SetLiveCooldownTimer(value.Actor.BallJumpCooldownTimer, value.BaseBallJumpCooldownTimer, value.CooldownFactor); SetLiveCooldownTimer(value.Actor.ShootBallRecoveryTimer, value.BaseShootRecoveryTimer, value.CooldownFactor); EnableNetworkScaleSync((Component)(object)value.Actor); ((Component)value.Actor).transform.localScale = value.BaseActorScale * value.Size; value.Actor.Unstunnable = value.NoStun || value.BaseUnstunnable; if (value.NoStun && value.Actor.IsStunned) { value.Actor.UnStun(); } } catch { _expiredRemotePlayerClients.Add(remotePlayerTuning.Key); } } for (int i = 0; i < _expiredRemotePlayerClients.Count; i++) { RemoveRemotePlayerTuning(_expiredRemotePlayerClients[i], restore: true); } } private void RemoveRemotePlayerTuning(ulong clientId, bool restore) { if (_remotePlayerTunings.TryGetValue(clientId, out RemotePlayerTuning value)) { if (restore) { RestoreRemotePlayerTuning(value); } _remotePlayerTunings.Remove(clientId); } } private static void RestoreRemotePlayerTuning(RemotePlayerTuning tuning) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)tuning.Actor == (Object)null) && !((Object)(object)tuning.Controller == (Object)null)) { BeetleStats stats = tuning.Actor.Stats; stats.MoveSpeed = tuning.BaseMoveSpeed; stats.SprintSpeedMult = tuning.BaseSprintSpeed; stats.JumpForce = tuning.BaseJumpForce; stats.GravityMult = tuning.BaseGravity; stats.Size = tuning.BaseSize; stats.BallMinSizeMaxSpeed = tuning.BaseBallMinSpeed; stats.BallMaxSizeMaxSpeed = tuning.BaseBallMaxSpeed; stats.ShootBallForceMinSize = tuning.BaseThrowMin; stats.ShootBallForceMaxSize = tuning.BaseThrowMax; stats.ShootBallForceChargedMult = tuning.BaseChargedMultiplier; stats.HeadbuttLaunchForce = tuning.BaseHeadbuttLaunch; stats.HeadbuttLaunchForceForwardBonus = tuning.BaseHeadbuttForward; stats.HeadbuttHitForce = tuning.BaseHeadbuttHit; stats.GrabCooldownDuration = tuning.BaseGrabCooldown; stats.HeadbuttCooldown = tuning.BaseHeadbuttCooldown; stats.ShootBallRecoveryDuration = tuning.BaseShootRecovery; tuning.Controller.ModifiedStats = stats; tuning.Actor.jumpCooldown = tuning.BaseJumpCooldown; tuning.Actor.ballJumpCooldown = tuning.BaseBallJumpCooldown; SetLiveCooldownTimer(tuning.Actor.GrabCooldownTimer, tuning.BaseGrabCooldownTimer, 1f); SetLiveCooldownTimer(tuning.Actor.JumpCooldownTimer, tuning.BaseJumpCooldownTimer, 1f); SetLiveCooldownTimer(tuning.Actor.HeadbuttCooldownTimer, tuning.BaseHeadbuttCooldownTimer, 1f); SetLiveCooldownTimer(tuning.Actor.BallJumpCooldownTimer, tuning.BaseBallJumpCooldownTimer, 1f); SetLiveCooldownTimer(tuning.Actor.ShootBallRecoveryTimer, tuning.BaseShootRecoveryTimer, 1f); ((Component)tuning.Actor).transform.localScale = tuning.BaseActorScale; tuning.Actor.Unstunnable = tuning.BaseUnstunnable; } } catch { } } private void RestoreAllRemotePlayerTunings() { foreach (RemotePlayerTuning value in _remotePlayerTunings.Values) { RestoreRemotePlayerTuning(value); } _remotePlayerTunings.Clear(); } private void ConfigureRemoteBallTuning(ulong senderClientId, DungBall ball, WorldRequest request) { ulong ballNetworkId = GetBallNetworkId(ball); if (_remoteBallTunings.TryGetValue(senderClientId, out RemoteBallTuning value) && value.BallId != ballNetworkId) { RestoreRemoteBallTuning(value); _remoteBallTunings.Remove(senderClientId); value = null; } if (value == null) { value = new RemoteBallTuning(ball); _remoteBallTunings[senderClientId] = value; } value.MassMultiplier = Mathf.Clamp(request.FloatValue, 0.1f, 50f); value.ScaleMultiplier = SanitizeUnboundedMultiplier(request.SecondaryFloatValue, 0.05f); value.UseGravity = (request.Flags & 1) != 0; value.Freeze = (request.Flags & 2) != 0; value.LastReceivedAt = Time.unscaledTime; } private void ApplyRemoteBallTunings() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) if (!IsNetworkServerHost() || _remoteBallTunings.Count == 0) { return; } _expiredRemoteTuningClients.Clear(); float unscaledTime = Time.unscaledTime; foreach (KeyValuePair remoteBallTuning in _remoteBallTunings) { RemoteBallTuning value = remoteBallTuning.Value; if (unscaledTime - value.LastReceivedAt > 1.5f) { _expiredRemoteTuningClients.Add(remoteBallTuning.Key); continue; } try { value.Rigidbody.mass = value.BaseMass * value.MassMultiplier; value.Rigidbody.useGravity = value.UseGravity; ((Component)value.Ball).transform.localScale = value.BaseScale * value.ScaleMultiplier; if (value.Freeze) { value.Rigidbody.linearVelocity = Vector3.zero; value.Rigidbody.angularVelocity = Vector3.zero; } } catch { _expiredRemoteTuningClients.Add(remoteBallTuning.Key); } } for (int i = 0; i < _expiredRemoteTuningClients.Count; i++) { RemoveRemoteBallTuning(_expiredRemoteTuningClients[i], restore: true); } } private void RemoveRemoteBallTuning(ulong clientId, bool restore) { if (_remoteBallTunings.TryGetValue(clientId, out RemoteBallTuning value)) { if (restore) { RestoreRemoteBallTuning(value); } _remoteBallTunings.Remove(clientId); } } private static void RestoreRemoteBallTuning(RemoteBallTuning tuning) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) try { tuning.Rigidbody.mass = tuning.BaseMass; tuning.Rigidbody.useGravity = tuning.BaseUseGravity; ((Component)tuning.Ball).transform.localScale = tuning.BaseScale; } catch { } } private void RestoreAllRemoteBallTunings() { foreach (RemoteBallTuning value in _remoteBallTunings.Values) { RestoreRemoteBallTuning(value); } _remoteBallTunings.Clear(); } private static BeetleActor? FindActorForClient(ulong clientId) { try { Il2CppArrayBase val = Object.FindObjectsOfType(); for (int i = 0; i < val.Length; i++) { BeetleActor val2 = val[i]; if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).OwnerClientId == clientId) { return val2; } } } catch { } return null; } private static DungBall? FindBallByNetworkId(ulong networkObjectId) { if (networkObjectId == 0L) { return null; } try { Il2CppArrayBase val = Object.FindObjectsOfType(); for (int i = 0; i < val.Length; i++) { DungBall val2 = val[i]; if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).NetworkObjectId == networkObjectId) { return val2; } } } catch { } return null; } private static ulong GetBallNetworkId(DungBall? ball) { try { return ((Object)(object)ball == (Object)null) ? 0 : ((NetworkBehaviour)ball).NetworkObjectId; } catch { return 0uL; } } private static bool SpawnLooseDungOnServer(BeetleActor actor, int count, int size, Vector3 requestedForward) { //IL_0027: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown NetworkPrefabSpawner instance = NetworkPrefabSpawner.Instance; if ((Object)(object)instance == (Object)null) { return false; } count = Math.Clamp(count, 1, 20); size = Math.Clamp(size, 1, 10); Vector3 val = requestedForward; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)actor).transform.forward; } val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val3 = ((Component)actor).transform.position + val * 2.5f + Vector3.up * 1.25f; for (int i = 0; i < count; i++) { float num = (float)i - (float)(count - 1) * 0.5f; Vector3 val4 = val3 + normalized * num * 0.65f + Vector3.up * (float)(i % 2) * 0.15f; Vector3 val5 = val * ((count == 1) ? 1.5f : 2.5f) + Vector3.up * ((count == 1) ? 0.75f : 1.5f); instance.SpawnDungBall_ServerRpc(val4, val5, size, 0.75f, new RpcParams()); } return true; } private bool SendServerAdminRequest(ServerAdminAction action, ulong targetClientId = ulong.MaxValue, int intValue = 0, float floatValue = 0f, bool quiet = false) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsListening) { return false; } if (singleton.IsServer) { string result; bool flag = ExecuteServerAdminAction(singleton.LocalClientId, action, targetClientId, intValue, floatValue, out result); if (!quiet) { SetStatus((flag ? "Completed: " : "Rejected: ") + result); } return flag; } if (!singleton.IsConnectedClient) { return false; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(32, (Allocator)2, 96); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)action); WriteUInt64(val2, targetClientId); WriteInt32(val2, intValue); WriteSingle(val2, floatValue); val.SendNamedMessage("BeetleballSandbox.ServerAdminRequest.v1", NetworkManager.ServerClientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } if (!quiet) { SetStatus("Requested " + GetServerAdminActionName(action) + " from the server; it may accept or ignore it"); } return true; } catch (Exception exception) { if (!quiet) { ReportException("requesting " + GetServerAdminActionName(action), exception); } return false; } } private void OnServerAdminRequestReceived(ulong senderClientId, FastBufferReader reader) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //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) ServerAdminAction serverAdminAction = (ServerAdminAction)0; try { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsServer) { byte b = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); serverAdminAction = (ServerAdminAction)b; ulong targetClientId = ReadUInt64(reader); int intValue = ReadInt32(reader); float floatValue = ReadSingle(reader); _moddedClientIds.Add(senderClientId); bool succeeded = false; string result; if (!_allowClientWorldRequests) { result = "this server has disabled joined-client creative requests"; } else { succeeded = ExecuteServerAdminAction(senderClientId, serverAdminAction, targetClientId, intValue, floatValue, out result); } SendServerAdminResponse(senderClientId, serverAdminAction, succeeded, result); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Rejected malformed {serverAdminAction} request from client {senderClientId}: {ex}"); SendServerAdminResponse(senderClientId, serverAdminAction, succeeded: false, ex.GetBaseException().Message); } } private void SendServerAdminResponse(ulong clientId, ServerAdminAction action, bool succeeded, string result) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsServer) { return; } if (result == null) { result = string.Empty; } if (result.Length > 180) { result = result.Substring(0, 180); } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(256, (Allocator)2, 512); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)action); ((FastBufferWriter)(ref val2)).WriteByteSafe(succeeded ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val2)).WriteValueSafe(result, true); val.SendNamedMessage("BeetleballSandbox.ServerAdminResponse.v1", clientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Could not return a server-action result to client {clientId}: {ex.Message}"); } } private void OnServerAdminResponseReceived(ulong senderClientId, FastBufferReader reader) { try { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsConnectedClient && !singleton.IsServer && senderClientId == NetworkManager.ServerClientId) { byte b = 0; byte b2 = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); ((FastBufferReader)(ref reader)).ReadByteSafe(ref b2); string text = string.Empty; ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, true); if (text.Length > 180) { text = text.Substring(0, 180); } ServerAdminAction action = (ServerAdminAction)b; SetStatus($"Server {((b2 != 0) ? "accepted" : "rejected")} {GetServerAdminActionName(action)}: {text}"); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not read the server-action response: " + ex.Message); } } private static string GetServerAdminActionName(ServerAdminAction action) { return action switch { ServerAdminAction.ForceIntoMatch => "spawn-player", ServerAdminAction.FreezePlayer => "freeze-player", ServerAdminAction.ReleasePlayer => "release-player", ServerAdminAction.SetPlayerScale => "player-scale", ServerAdminAction.ResetRound => "round-reset", ServerAdminAction.RestartMatch => "match-restart", ServerAdminAction.AddSpectators => "spectator-respawn", ServerAdminAction.ClearDung => "clear-dung", ServerAdminAction.ReleaseAllFreezes => "release-all-freezes", ServerAdminAction.RestoreAllPlayerSizes => "restore-all-sizes", ServerAdminAction.SetGlobalCooldown => "global-cooldown", ServerAdminAction.SetGlobalBallScale => "global-ball-scale", ServerAdminAction.SetPlayerTeam => "player-team", _ => "server action", }; } private bool SendAdminClientCommand(ulong clientId, AdminClientAction action, int intValue = 0, float floatValue = 0f, bool quiet = false) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsServer) { return false; } if (clientId == singleton.LocalClientId) { string status = ExecuteAdminClientAction(action, intValue, floatValue); if (!quiet) { SetStatus(status); } return true; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(32, (Allocator)2, 64); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)action); WriteInt32(val2, intValue); WriteSingle(val2, floatValue); val.SendNamedMessage("BeetleballSandbox.AdminCommand.v1", clientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } if (!quiet) { SetStatus($"Sent {GetAdminActionName(action)} to client {clientId}"); } return true; } catch (Exception exception) { ReportException("sending the player admin command", exception); return false; } } private void OnAdminCommandReceived(ulong senderClientId, FastBufferReader reader) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsConnectedClient && senderClientId == NetworkManager.ServerClientId) { byte b = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); int intValue = ReadInt32(reader); float floatValue = ReadSingle(reader); AdminClientAction action = (AdminClientAction)b; string text = ExecuteAdminClientAction(action, intValue, floatValue); SetStatus("Host admin: " + text); SendAdminResultToHost(text); } } catch (Exception value) { ((MelonBase)this).LoggerInstance.Warning($"Rejected host admin command: {value}"); } } private void SendAdminResultToHost(string result) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsConnectedClient || singleton.IsServer) { return; } if (result == null) { result = string.Empty; } if (result.Length > 160) { result = result.Substring(0, 160); } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(256, (Allocator)2, 384); try { ((FastBufferWriter)(ref val2)).WriteValueSafe(result, true); val.SendNamedMessage("BeetleballSandbox.AdminResult.v1", NetworkManager.ServerClientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } } catch { } } private void OnAdminResultReceived(ulong senderClientId, FastBufferReader reader) { try { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsServer) { string text = string.Empty; ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, true); if (text.Length > 160) { text = text.Substring(0, 160); } SetStatus($"Client {senderClientId}: {text}"); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Could not read admin result from client {senderClientId}: {ex.Message}"); } } private static string GetAdminActionName(AdminClientAction action) { return action switch { AdminClientAction.AddExperience => "XP grant", AdminClientAction.NextLevel => "next-level grant", AdminClientAction.SetLevel => "exact-level change", AdminClientAction.UnlockSkins => "skin unlock", AdminClientAction.SetScale => "player scale", AdminClientAction.SetGlobalCooldown => "all-player cooldown", _ => "admin command", }; } private void ClearServerCooldownOverrideInternal() { if (_serverCooldownOverrideActive) { bool serverCooldownForcedPlayerTuning = _serverCooldownForcedPlayerTuning; _serverCooldownOverrideActive = false; _serverCooldownOverrideFactor = 1f; _serverCooldownForcedPlayerTuning = false; if (serverCooldownForcedPlayerTuning) { _playerTuning = false; RestorePlayerTuning(); } } } public string SetServerCooldownOverridePublic(bool enabled, float factor) { return SetServerCooldownOverride(enabled, factor); } private string SetServerCooldownOverride(bool enabled, float factor) { if (float.IsNaN(factor) || float.IsInfinity(factor)) { factor = 1f; } factor = Mathf.Clamp(factor, 0f, 2f); if (enabled) { if (!_serverCooldownOverrideActive) { _serverCooldownForcedPlayerTuning = !_playerTuning; } _serverCooldownOverrideActive = true; _serverCooldownOverrideFactor = factor; _playerTuning = true; return $"server cooldown override set to {factor:0.00}x"; } bool num = _serverCooldownOverrideActive && _serverCooldownForcedPlayerTuning; _serverCooldownOverrideActive = false; _serverCooldownOverrideFactor = 1f; _serverCooldownForcedPlayerTuning = false; if (num) { _playerTuning = false; RestorePlayerTuning(); } return "server cooldown override restored"; } private void PreviewAnnouncement() { string text = SanitizeAnnouncement(_announcementText); if (string.IsNullOrWhiteSpace(text)) { SetStatus("Enter announcement text first"); return; } ShowAnnouncementLocal(text, _announcementDuration, _announcementPosition, _announcementColorPreset); SetStatus("Displayed local announcement preview"); } private void BroadcastAnnouncementFromMenu() { string text = SanitizeAnnouncement(_announcementText); if (string.IsNullOrWhiteSpace(text)) { SetStatus("Enter announcement text first"); return; } if (Time.unscaledTime < _nextAnnouncementSendAt) { SetStatus("Wait a moment before sending another connected-session message"); return; } _nextAnnouncementSendAt = Time.unscaledTime + 1f; try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { ShowAnnouncementLocal(text, _announcementDuration, _announcementPosition, _announcementColorPreset); SetStatus("Displayed offline announcement"); } else if (singleton.IsServer) { BroadcastAnnouncementAsHost(text, _announcementDuration, _announcementPosition, _announcementColorPreset); } else { bool flag = BroadcastAnnouncementThroughGameChat(text); bool flag2 = SendAnnouncementRequest(text, _announcementDuration, _announcementPosition, _announcementColorPreset, quiet: true); SetStatus((flag && flag2) ? "Attempted Beetleball all-chat plus a modded-host popup request" : (flag ? "Attempted Beetleball all-chat; no modded-host popup route was available" : (flag2 ? "All-chat was unavailable; sent the modded-host popup request" : "No connected-session message route was available"))); } } catch (Exception exception) { ReportException("broadcasting the announcement", exception); } } private bool SendAnnouncementRequest(string message, float duration, int position, int colorPreset, bool quiet = false) { //IL_0049: 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) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null || !singleton.IsConnectedClient) { return false; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(256, (Allocator)2, 512); try { ((FastBufferWriter)(ref val2)).WriteValueSafe(message, true); WriteSingle(val2, Mathf.Clamp(duration, 2f, 15f)); ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)Math.Clamp(position, 0, 2)); ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)Math.Clamp(colorPreset, 0, 3)); val.SendNamedMessage("BeetleballSandbox.AnnouncementRequest.v1", NetworkManager.ServerClientId, val2, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val2)).Dispose(); } if (!quiet) { SetStatus("Sent announcement request to the modded host"); } return true; } catch (Exception exception) { ReportException("sending the announcement request", exception); return false; } } private void OnAnnouncementRequestReceived(ulong senderClientId, FastBufferReader reader) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } if (!_allowClientWorldRequests) { SendRelayResponse(senderClientId, WorldAction.Announcement, succeeded: false); return; } if (_lastAnnouncementTimes.TryGetValue(senderClientId, out var value) && Time.unscaledTime - value < 1f) { SendRelayResponse(senderClientId, WorldAction.Announcement, succeeded: false); return; } string empty = string.Empty; ((FastBufferReader)(ref reader)).ReadValueSafe(ref empty, true); float num = ReadSingle(reader); byte value2 = 1; byte value3 = 1; ((FastBufferReader)(ref reader)).ReadByteSafe(ref value2); ((FastBufferReader)(ref reader)).ReadByteSafe(ref value3); empty = SanitizeAnnouncement(empty); if (string.IsNullOrWhiteSpace(empty)) { SendRelayResponse(senderClientId, WorldAction.Announcement, succeeded: false); return; } _lastAnnouncementTimes[senderClientId] = Time.unscaledTime; _moddedClientIds.Add(senderClientId); bool succeeded = BroadcastAnnouncementAsHost(empty, Mathf.Clamp(num, 2f, 15f), Math.Clamp((int)value2, 0, 2), Math.Clamp((int)value3, 0, 3), includeVanillaChat: false); SendRelayResponse(senderClientId, WorldAction.Announcement, succeeded); } catch (Exception value4) { ((MelonBase)this).LoggerInstance.Warning($"Rejected announcement from client {senderClientId}: {value4}"); SendRelayResponse(senderClientId, WorldAction.Announcement, succeeded: false); } } private bool BroadcastAnnouncementAsHost(string message, float duration, int position, int colorPreset, bool includeVanillaChat = true) { ShowAnnouncementLocal(message, duration, position, colorPreset); SendAnnouncementPopupToModdedClients(message, duration, position, colorPreset); bool flag = !includeVanillaChat || BroadcastAnnouncementThroughGameChat(message); SetStatus((!includeVanillaChat) ? "Accepted joined-client popup request; its all-chat RPC handles vanilla players" : (flag ? "Broadcast announcement to all players" : "Popup sent to modded players; built-in chat panel was unavailable")); return flag; } private void SendAnnouncementPopupToModdedClients(string message, float duration, int position, int colorPreset) { //IL_0083: 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) try { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = ((singleton != null) ? singleton.CustomMessagingManager : null); if ((Object)(object)singleton == (Object)null || val == null) { return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(256, (Allocator)2, 512); try { ((FastBufferWriter)(ref val2)).WriteValueSafe(message, true); WriteSingle(val2, duration); ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)position); ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)colorPreset); foreach (ulong moddedClientId in _moddedClientIds) { if (moddedClientId != singleton.LocalClientId) { try { val.SendNamedMessage("BeetleballSandbox.AnnouncementBroadcast.v1", moddedClientId, val2, (NetworkDelivery)3); } catch { } } } } finally { ((FastBufferWriter)(ref val2)).Dispose(); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not send announcement popup to modded clients: " + ex.Message); } } private void OnAnnouncementBroadcastReceived(ulong senderClientId, FastBufferReader reader) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) try { if (!IsNetworkServerHost()) { string empty = string.Empty; ((FastBufferReader)(ref reader)).ReadValueSafe(ref empty, true); float duration = ReadSingle(reader); byte position = 1; byte colorPreset = 1; ((FastBufferReader)(ref reader)).ReadByteSafe(ref position); ((FastBufferReader)(ref reader)).ReadByteSafe(ref colorPreset); ShowAnnouncementLocal(SanitizeAnnouncement(empty), duration, position, colorPreset); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning($"Could not display announcement from host {senderClientId}: {ex.Message}"); } } private bool BroadcastAnnouncementThroughGameChat(string message) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val == null || val.Length == 0) { return false; } string text = (IsNetworkServerHost() ? "[SERVER ANNOUNCEMENT]" : "[CUSTOM MESSAGE]") + " " + message.Replace('\n', ' '); while (Encoding.UTF8.GetByteCount(text) > 120 && text.Length > 1) { text = text.Substring(0, text.Length - 1); } FixedString128Bytes val2 = default(FixedString128Bytes); ((FixedString128Bytes)(ref val2))..ctor(text); for (int i = 0; i < val.Length; i++) { ChatPanel val3 = val[i]; if (!((Object)(object)val3 == (Object)null) && ((NetworkBehaviour)val3).IsSpawned) { val3.SendChatMessage_ServerRpc(val2, (MessageTarget)0, new RpcParams()); return true; } } return false; } catch (Exception value) { ((MelonBase)this).LoggerInstance.Warning($"Built-in vanilla announcement broadcast failed: {value}"); return false; } } internal static void TryMirrorAnnouncementChatToPopup(string? rawMessage, int messageTarget, ulong senderClientId) { SandboxMod activeInstance = _activeInstance; if (activeInstance == null || messageTarget != 0 || string.IsNullOrWhiteSpace(rawMessage)) { return; } string text = rawMessage.Trim(); string message; if (text.StartsWith("[SERVER ANNOUNCEMENT] ", StringComparison.Ordinal)) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && senderClientId != NetworkManager.ServerClientId) { return; } message = text.Substring("[SERVER ANNOUNCEMENT]".Length).TrimStart(); } else { if (!text.StartsWith("[CUSTOM MESSAGE] ", StringComparison.Ordinal)) { return; } message = text.Substring("[CUSTOM MESSAGE]".Length).TrimStart(); } message = SanitizeAnnouncement(message); if (!string.IsNullOrWhiteSpace(message) && (!string.Equals(activeInstance._lastLocalAnnouncementPopup, message, StringComparison.Ordinal) || !(Time.unscaledTime - activeInstance._lastLocalAnnouncementPopupAt < 2f))) { activeInstance.ShowAnnouncementLocal(message, 6f, 1, 1); } } private void ShowAnnouncementLocal(string message, float duration, int position, int colorPreset) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(message)) { return; } try { Nullable val = new Nullable(GetAnnouncementColor(colorPreset)); Nullable val2 = null; PopupManager.SimplePopup(message, (Position)Math.Clamp(position, 0, 2), Mathf.Clamp(duration, 2f, 15f), val, val2); _lastLocalAnnouncementPopup = message; _lastLocalAnnouncementPopupAt = Time.unscaledTime; } catch { } } private static Color GetAnnouncementColor(int colorPreset) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) return (Color)(colorPreset switch { 1 => new Color(1f, 0.85f, 0.2f, 1f), 2 => new Color(0.2f, 0.95f, 1f, 1f), 3 => new Color(1f, 0.25f, 0.25f, 1f), _ => Color.white, }); } private static string SanitizeAnnouncement(string? message) { if (string.IsNullOrWhiteSpace(message)) { return string.Empty; } string text = message.Replace("\r", string.Empty).Trim(); StringBuilder stringBuilder = new StringBuilder(Math.Min(text.Length, 96)); int num = 0; for (int i = 0; i < text.Length; i++) { if (stringBuilder.Length >= 96) { break; } char c = text[i]; if (c == '\n') { if (num >= 1) { c = ' '; } else { num++; } } else if (char.IsControl(c)) { c = ' '; } stringBuilder.Append(c); } return stringBuilder.ToString().Trim(); } private static string GetWorldActionName(WorldAction action) { return action switch { WorldAction.ChangeBallSize => "ball size", WorldAction.SpawnLooseDung => "dung spawn", WorldAction.RecallBall => "ball recall", WorldAction.LaunchBall => "ball launch", WorldAction.StopBall => "ball stop", WorldAction.SpinBall => "ball spin", WorldAction.ExplodeBall => "ball explosion", WorldAction.ConfigureBall => "ball tuning", WorldAction.ClearBallTuning => "ball reset", WorldAction.SpawnBall => "ball spawn", WorldAction.Announcement => "announcement", _ => "relay handshake", }; } private static void WriteUInt64(FastBufferWriter writer, ulong value) { for (int i = 0; i < 64; i += 8) { ((FastBufferWriter)(ref writer)).WriteByteSafe((byte)(value >> i)); } } private static ulong ReadUInt64(FastBufferReader reader) { ulong num = 0uL; for (int i = 0; i < 64; i += 8) { byte b = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); num |= (ulong)b << i; } return num; } private static void WriteInt32(FastBufferWriter writer, int value) { for (int i = 0; i < 32; i += 8) { ((FastBufferWriter)(ref writer)).WriteByteSafe((byte)((uint)value >> i)); } } private static int ReadInt32(FastBufferReader reader) { uint num = 0u; for (int i = 0; i < 32; i += 8) { byte b = 0; ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); num |= (uint)(b << i); } return (int)num; } private static void WriteSingle(FastBufferWriter writer, float value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) WriteInt32(writer, BitConverter.SingleToInt32Bits(value)); } private static float ReadSingle(FastBufferReader reader) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return BitConverter.Int32BitsToSingle(ReadInt32(reader)); } private static float SanitizeUnboundedMultiplier(float value, float minimum) { if (float.IsNaN(value) || float.IsInfinity(value)) { return 1f; } return Mathf.Max(minimum, value); } private static void WriteVector3(FastBufferWriter writer, Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) WriteSingle(writer, value.x); WriteSingle(writer, value.y); WriteSingle(writer, value.z); } private static Vector3 ReadVector3(FastBufferReader reader) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(ReadSingle(reader), ReadSingle(reader), ReadSingle(reader)); } public override void OnInitializeMelon() { _activeInstance = this; LoadCustomLocalLevelOverride(); LoadPrivacyDisplayPreferences(); ((MelonBase)this).LoggerInstance.Msg("Beetleball Sandbox loaded. Press F5 to toggle the menu."); SetMenuOpen(open: true); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { _sceneObjectAccessReadyAt = Time.unscaledTime + 0.85f; } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { _sceneObjectAccessReadyAt = Time.unscaledTime + 0.85f; ClearPendingLocalSpectatorSpawn(); } private bool SceneObjectAccessReady() { return Time.unscaledTime >= _sceneObjectAccessReadyAt; } public override void OnUpdate() { bool flag = SceneObjectAccessReady(); if (flag) { UpdateNetworkBridge(); UpdateAdminTools(); ApplyPrivacyDisplayControls(); } if (Input.GetKeyDown((KeyCode)286) || Input.GetKeyDown((KeyCode)277)) { if (_guiUnavailable) { _guiUnavailable = false; _menuPage = 0; SetMenuOpen(open: true); SetStatus("Menu recovered on the PLAYER tab"); } else { SetMenuOpen(!_menuOpen); } } CaptureAnnouncementTyping(); CaptureExactLevelTyping(); if (_menuOpen) { if (flag) { ApplyMenuInputLock(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (flag) { BeetleActor localBeetle = GetLocalBeetle(); if (_noStun && (Object)(object)localBeetle != (Object)null) { ApplyNoStunOverride(localBeetle); } else if (!_noStun) { RestoreNoStunOverride(); } if (_playerTuning && (Object)(object)localBeetle != (Object)null) { RefreshPlayerSnapshot(localBeetle); ApplyPlayerTuning(localBeetle); } else if (_playerApplied) { RestorePlayerTuning(); } ApplyGlobalCooldowns(); ApplyFov(); ApplyCameraDistance(); ApplyTimeScale(); } } public override void OnLateUpdate() { if (!SceneObjectAccessReady()) { return; } if (_playerTuning) { BeetleActor localBeetle = GetLocalBeetle(); if ((Object)(object)localBeetle != (Object)null) { if (_noStun) { ApplyNoStunOverride(localBeetle); } RefreshPlayerSnapshot(localBeetle); ApplyPlayerTuning(localBeetle); } } ApplyGlobalCooldowns(); MaintainFlightMomentum(GetLocalBeetle()); ApplyFov(); ApplyCameraDistance(); ApplyJoinedClientVisualPlayerStates(); ApplyPrivacyDisplayControls(); } public override void OnFixedUpdate() { if (!SceneObjectAccessReady()) { return; } BeetleActor localBeetle = GetLocalBeetle(); if (_noStun && (Object)(object)localBeetle != (Object)null) { ApplyNoStunOverride(localBeetle); } if (_playerTuning && (Object)(object)localBeetle != (Object)null) { RefreshPlayerSnapshot(localBeetle); ApplyPlayerTuning(localBeetle); } MaintainFlightMomentum(localBeetle); if (_playerTuning && (Object)(object)localBeetle != (Object)null && !HasWorldAuthority()) { UpdateRelayedPlayerTuning(); } else { ClearRelayedPlayerTuning(); } DungBall targetBall = GetTargetBall(localBeetle); if (_ballTuning && (Object)(object)targetBall != (Object)null) { RefreshBallSnapshot(targetBall); ApplyBallTuning(targetBall); if (!HasWorldAuthority()) { UpdateRelayedBallTuning(targetBall); } } else { if (_ballSnapshot != null) { RestoreBallTuning(); } ClearRelayedBallTuning(); } ApplyRemoteBallTunings(); ApplyRemotePlayerTunings(); ApplyGlobalBallScale(); ApplyHostPlayerAdminStates(); ApplyGlobalCooldowns(); } public override void OnGUI() { if (!_menuOpen || _guiUnavailable || !SceneObjectAccessReady()) { return; } try { DrawMenu(); } catch (Exception value) { _guiUnavailable = true; _menuOpen = false; RestoreMenuInputLock(); RestoreCursor(); ((MelonBase)this).LoggerInstance.Error($"Menu drawing was disabled after a Unity GUI error: {value}"); } } private void DrawMenu() { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min(620f, (float)Screen.width - 32f); float num2 = Mathf.Min(860f, (float)Screen.height - 32f); ((Rect)(ref _panelRect)).width = Mathf.Max(420f, num); ((Rect)(ref _panelRect)).height = Mathf.Max(420f, num2); ((Rect)(ref _panelRect)).x = Mathf.Clamp(((Rect)(ref _panelRect)).x, 8f, Mathf.Max(8f, (float)Screen.width - ((Rect)(ref _panelRect)).width - 8f)); ((Rect)(ref _panelRect)).y = Mathf.Clamp(((Rect)(ref _panelRect)).y, 8f, Mathf.Max(8f, (float)Screen.height - ((Rect)(ref _panelRect)).height - 8f)); GUI.Box(_panelRect, string.Empty); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref _panelRect)).x + 12f, ((Rect)(ref _panelRect)).y + 10f, ((Rect)(ref _panelRect)).width - 24f, ((Rect)(ref _panelRect)).height - 20f); GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width - 110f, 26f), "BEETLEBALL SANDBOX v0.3.5"); if (GUI.Button(new Rect(((Rect)(ref val)).x + ((Rect)(ref val)).width - 105f, ((Rect)(ref val)).y, 105f, 26f), "Close [F5]")) { SetMenuOpen(open: false); } BeetleActor localBeetle = GetLocalBeetle(); DungBall targetBall = GetTargetBall(localBeetle); GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 29f, ((Rect)(ref val)).width, 22f), BuildSessionStatus(localBeetle, targetBall)); string text = ((!string.IsNullOrEmpty(_status) && Time.unscaledTime <= _statusUntil) ? ("Status: " + _status) : string.Empty); GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 51f, ((Rect)(ref val)).width, 22f), text); float num3 = ((Rect)(ref val)).y + 76f; float num4 = 5f; float num5 = (((Rect)(ref val)).width - num4 * 5f) / 6f; if (GUI.Button(new Rect(((Rect)(ref val)).x, num3, num5, 28f), (_menuPage == 0) ? "[PLAYER]" : "PLAYER")) { _menuPage = 0; } if (GUI.Button(new Rect(((Rect)(ref val)).x + num5 + num4, num3, num5, 28f), (_menuPage == 1) ? "[BALL]" : "BALL")) { _menuPage = 1; } if (GUI.Button(new Rect(((Rect)(ref val)).x + (num5 + num4) * 2f, num3, num5, 28f), (_menuPage == 2) ? "[SERVER]" : "SERVER")) { _menuPage = 2; } if (GUI.Button(new Rect(((Rect)(ref val)).x + (num5 + num4) * 3f, num3, num5, 28f), (_menuPage == 3) ? "[PLAYERS]" : "PLAYERS")) { _menuPage = 3; } if (GUI.Button(new Rect(((Rect)(ref val)).x + (num5 + num4) * 4f, num3, num5, 28f), (_menuPage == 4) ? "[MESSAGE]" : "MESSAGE")) { _menuPage = 4; } if (GUI.Button(new Rect(((Rect)(ref val)).x + (num5 + num4) * 5f, num3, num5, 28f), (_menuPage == 5) ? "[EGGS]" : "EGGS")) { _menuPage = 5; } _uiX = ((Rect)(ref val)).x; _uiY = num3 + 36f; _uiWidth = ((Rect)(ref val)).width; if (_menuPage == 0) { DrawRawPlayerPage(localBeetle); } else if (_menuPage == 1) { DrawRawBallPage(localBeetle, targetBall); } else if (_menuPage == 2) { DrawRawWorldPage(); } else if (_menuPage == 3) { DrawRawPlayersPage(); } else if (_menuPage == 4) { DrawRawMessagePage(); } else { DrawRawEggPage(); } GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + ((Rect)(ref val)).height - 22f, ((Rect)(ref val)).width, 22f), "All connected controls are attempted; the server may accept, reject, or ignore each request."); } private void DrawRawPlayerPage(BeetleActor? actor) { RawSection("PROGRESSION - changes the local profile"); PlayerLevelManager val = null; try { val = PlayerLevelManager.Instance; } catch { } RawLabel(((Object)(object)val == (Object)null) ? "Level data is not available on this screen." : $"Level {val.Level} XP {val.Experience:N0}"); if (_customLocalLevelOverride > 0) { RawLabel($"Custom level override active: {_customLocalLevelOverride:N0} (Steam stat remains capped)."); } if (RawRowButton("+100 XP", 0, 4)) { GiveExperience(100); } if (RawRowButton("+1,000 XP", 1, 4)) { GiveExperience(1000); } if (RawRowButton("+10,000 XP", 2, 4)) { GiveExperience(10000); } if (RawRowButton("Next level", 3, 4)) { GiveNextLevel(); } RawNextRow(); if (!_localTargetLevelInitialized && (Object)(object)val != (Object)null) { _localTargetLevel = Math.Clamp(val.Level, 1, 1000000); _localTargetLevelInitialized = true; } _localTargetLevel = RawIntStepper("Exact local level", _localTargetLevel, 1, 1000000, 1, 10); if (RawRowButton("Type exact level", 0, 2)) { BeginExactLevelTyping(); } if (RawRowButton("Apply exact level", 1, 2)) { ApplyExactLocalLevelFromStepper(); } RawNextRow(); if (_exactLevelTypingMode == 1) { RawLabel(BuildExactLevelTypingLabel()); } RawSection("LOCAL BEETLE TUNING"); RawLabel(BuildPlayerLiveStatus(actor)); RawLabel("Client mode: local beetle tweaks are enabled; server correction may still apply."); bool flag = RawToggle("Enable player tuning", _playerTuning); if (flag != _playerTuning) { _playerTuning = flag; if (!flag) { RestorePlayerTuning(); } } _moveSpeed = RawStepper("Move speed", _moveSpeed, 0.25f, 25f, 0.25f, 1f); _sprintSpeed = RawStepper("Sprint multiplier", _sprintSpeed, 0.25f, 25f, 0.25f, 1f); _jumpForce = RawStepper("Jump force", _jumpForce, 0.1f, 25f, 0.25f, 1f); _gravity = RawStepper("Gravity", _gravity, 0.01f, 10f, 0.1f, 1f); _flySpeed = RawStepper("Fly / glide speed", _flySpeed, 0.25f, 25f, 0.25f, 1f); bool flag2 = RawToggle("Infinite flight / glide (no passive descent)", _holdFlightUntilGround); if (flag2 != _holdFlightUntilGround) { _holdFlightUntilGround = flag2; if (!flag2) { ResetFlightMomentum(); } } if (_holdFlightUntilGround) { RawLabel(_flightMomentumActive ? "Infinite flight active - steer normally; aim steeply down to descend and land." : "Arms when native flight, flutter, or glide starts; gravity resumes on landing."); } _playerSize = RawUnboundedStepper("Beetle scale (no upper cap)", _playerSize, 0.05f, 0.25f, 1f); if (RawRowButton("1x", 0, 4)) { _playerSize = 1f; } if (RawRowButton("5x", 1, 4)) { _playerSize = 5f; } if (RawRowButton("25x", 2, 4)) { _playerSize = 25f; } if (RawRowButton("Double size", 3, 4)) { _playerSize = SafeDouble(_playerSize); } RawNextRow(); _ballRollSpeed = RawStepper("Rolling-ball speed", _ballRollSpeed, 0.25f, 25f, 0.25f, 1f); _throwForce = RawStepper("Ball throw force", _throwForce, 0.25f, 50f, 0.5f, 1f); _headbuttForce = RawStepper("Headbutt force", _headbuttForce, 0.25f, 50f, 0.5f, 1f); _cooldownFactor = RawStepper("Cooldown duration (0 = none)", _cooldownFactor, 0f, 2f, 0.05f, 1f); bool flag3 = RawToggle("No stun (preempt and cancel dispatcher)", _noStun); if (flag3 != _noStun) { _noStun = flag3; if (!flag3) { RestoreNoStunOverride(); } } if (RawRowButton("Reset player", 0, 3)) { ResetPlayerOnly(); } if (RawRowButton("Pop upward", 1, 3)) { PopPlayer(actor); } if (RawRowButton("Charge ability", 2, 3)) { InvokeLocalCommand("ChargeAbilityCommand"); } RawNextRow(); } private void DrawRawBallPage(BeetleActor? actor, DungBall? ball) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) RawSection("TARGET BALL - held ball, otherwise nearest"); object text; if (!((Object)(object)ball == (Object)null)) { DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(26, 3); defaultInterpolatedStringHandler.AppendLiteral("Size "); defaultInterpolatedStringHandler.AppendFormatted(ball.Size); defaultInterpolatedStringHandler.AppendLiteral(" Radius "); defaultInterpolatedStringHandler.AppendFormatted(ball.Radius, "0.00"); defaultInterpolatedStringHandler.AppendLiteral(" Speed "); Vector3 velocity = ball.Velocity; defaultInterpolatedStringHandler.AppendFormatted(((Vector3)(ref velocity)).magnitude, "0.0"); text = defaultInterpolatedStringHandler.ToStringAndClear(); } else { text = "No dung ball found in the loaded scene."; } RawLabel((string)text); RawLabel(BuildSharedWorldControlStatus()); bool flag = RawToggle("Enable target-ball physics tuning", _ballTuning); if (flag != _ballTuning) { _ballTuning = flag; if (!flag) { RestoreBallTuning(); } } _freezeBall = RawToggle("Freeze target ball", _freezeBall); _ballUseGravity = RawToggle("Ball gravity", _ballUseGravity); _ballMass = RawStepper("Ball mass", _ballMass, 0.1f, 50f, 0.25f, 1f); _ballScale = RawUnboundedStepper("Target physical scale", _ballScale, 0.05f, 0.25f, 1f); _launchPower = RawStepper("Launch power", _launchPower, 2f, 500f, 5f, 30f, "0", string.Empty); _spinPower = RawStepper("Spin power", _spinPower, 0f, 500f, 5f, 20f, "0", string.Empty); DrawRawGlobalBallScaleControls(); _dungSpawnSize = RawIntStepper("Loose dung spawn size", _dungSpawnSize, 1, 10, 1, 1); if (RawRowButton("Spawn loose dung", 0, 2)) { SpawnLooseDung(actor, 1); } if (RawRowButton("Dung burst x5", 1, 2)) { SpawnLooseDung(actor, 5); } RawNextRow(); RawSection("BALL PRESETS"); if (RawRowButton("Beach ball", 0, 4)) { ApplyBallPreset("Beach ball", 0.15f, 2.5f, useGravity: true, 30f, 10f); } if (RawRowButton("Moon ball", 1, 4)) { ApplyBallPreset("Moon ball", 0.4f, 1.3f, useGravity: false, 35f, 15f); } if (RawRowButton("Cannonball", 2, 4)) { ApplyBallPreset("Cannonball", 6f, 0.8f, useGravity: true, 75f, 5f); } if (RawRowButton("Chaos ball", 3, 4)) { ApplyBallPreset("Chaos ball", 0.5f, 2f, useGravity: false, 90f, 80f); } RawNextRow(); if (RawRowButton("Grow +1", 0, 3)) { ChangeBallSize(ball, 1); } if (RawRowButton("Shrink -1", 1, 3)) { ChangeBallSize(ball, -1); } if (RawRowButton("Spawn ball", 2, 3)) { SpawnCommandBall(actor); } RawNextRow(); if (RawRowButton("Recall", 0, 4)) { RecallBall(actor, ball); } if (RawRowButton("Launch", 1, 4)) { LaunchBall(actor, ball); } if (RawRowButton("Stop", 2, 4)) { StopBall(ball); } if (RawRowButton("Spin", 3, 4)) { SpinBall(ball); } RawNextRow(); if (RawRowButton("Reset ball", 0, 2)) { ResetBallOnly(); } if (RawRowButton("Explode target", 1, 2)) { ExplodeBall(ball); } RawNextRow(); } private void DrawRawWorldPage() { RawSection("CONNECTED-SESSION CREATIVE TOOLS"); RawLabel(IsNetworkServerHost() ? "Direct server authority is active; vanilla players see synchronized world changes." : "Controls always attempt Beetleball RPCs or a modded-host request; a server may reject them."); RawLabel("Local fallbacks remain active where they are useful and safe."); RawLabel("Client-owned Steam profile data cannot be changed remotely by a game server."); if (IsNetworkServerHost()) { RawSection("HOST RELAY PERMISSION"); bool flag = RawToggle("Allow modded joined clients to request shared server changes", _allowClientWorldRequests); if (flag != _allowClientWorldRequests) { _allowClientWorldRequests = flag; _hostRelayAllowed = flag; if (!flag) { RestoreAllRemotePlayerTunings(); RestoreAllRemoteBallTunings(); } SetStatus(flag ? "Joined-client creative relay enabled for this hosted session" : "Joined-client creative relay disabled"); } RawLabel("Session-only and OFF by default; enable only for players you trust."); } DrawRawServerMatchControls(); RawSection("LOCAL CAMERA"); bool flag2 = RawToggle("Override camera FOV", _fovOverride); if (flag2 != _fovOverride) { _fovOverride = flag2; if (!flag2) { RestoreFov(); } } _fov = RawStepper("Field of view", _fov, 30f, 170f, 5f, 90f, "0", " deg"); RawLabel(BuildFovLiveStatus()); if (RawRowButton("FOV 75", 0, 4)) { SetFovPreset(75f); } if (RawRowButton("FOV 90", 1, 4)) { SetFovPreset(90f); } if (RawRowButton("FOV 110", 2, 4)) { SetFovPreset(110f); } if (RawRowButton("Disable FOV", 3, 4)) { _fovOverride = false; RestoreFov(); SetStatus("FOV override disabled"); } RawNextRow(); DrawRawCameraDistanceControls(); RawSection("LOCAL TIME - offline only"); bool flag3 = RawToggle("Override time scale", _timeScaleOverride); if (flag3 != _timeScaleOverride) { SetTimeScaleOverride(flag3); } _timeScale = RawStepper("Time scale", _timeScale, 0.1f, 3f, 0.1f, 1f); if (RawRowButton("0.25x", 0, 4)) { SetTimePreset(0.25f); } if (RawRowButton("0.5x", 1, 4)) { SetTimePreset(0.5f); } if (RawRowButton("Normal", 2, 4)) { SetTimePreset(1f); } if (RawRowButton("2x", 3, 4)) { SetTimePreset(2f); } RawNextRow(); RawSection("PLAYER PRESETS"); if (RawRowButton("Turbo", 0, 4)) { ApplyPlayerPreset("Turbo"); } if (RawRowButton("Tiny turbo", 1, 4)) { ApplyPlayerPreset("Tiny turbo"); } if (RawRowButton("Moon beetle", 2, 4)) { ApplyPlayerPreset("Moon beetle"); } if (RawRowButton("Heavy hitter", 3, 4)) { ApplyPlayerPreset("Heavy hitter"); } RawNextRow(); RawLabel("Presets enable player tuning; fine-tune them on the PLAYER tab."); RawSection("RESET"); if (RawRowButton("Reset player", 0, 3)) { ResetPlayerOnly(); } if (RawRowButton("Reset ball", 1, 3)) { ResetBallOnly(); } if (RawRowButton("Reset everything", 2, 3)) { ResetEverything(); } RawNextRow(); } private void DrawRawMessagePage() { RawSection("LOCAL PRIVACY / DISPLAY"); bool flag = RawToggle("Anonymous / quiet mode (hide local lobby notices)", _anonymousMode); if (flag != _anonymousMode) { _anonymousMode = flag; SavePrivacyDisplayPreference("BeetleballSandbox.AnonymousMode.v1", _anonymousMode); SetStatus(_anonymousMode ? "Quiet mode enabled: local lobby join/leave notices are suppressed" : "Quiet mode disabled: local lobby notices are visible"); } bool flag2 = RawToggle("Hide leaderboard locally", _hideLeaderboard); if (flag2 != _hideLeaderboard) { _hideLeaderboard = flag2; SavePrivacyDisplayPreference("BeetleballSandbox.HideLeaderboard.v1", _hideLeaderboard); if (!_hideLeaderboard) { RestoreHiddenUiObjects(_hiddenLeaderboardObjects); } SetStatus(_hideLeaderboard ? "Leaderboard hidden locally" : "Leaderboard restored"); } bool flag3 = RawToggle("Hide player list / player board locally", _hidePlayerBoard); if (flag3 != _hidePlayerBoard) { _hidePlayerBoard = flag3; SavePrivacyDisplayPreference("BeetleballSandbox.HidePlayerBoard.v1", _hidePlayerBoard); if (!_hidePlayerBoard) { RestoreHiddenUiObjects(_hiddenPlayerBoardObjects); } SetStatus(_hidePlayerBoard ? "Player board hidden locally" : "Player board restored"); } RawLabel("Quiet mode suppresses notices generated on this client; all three settings are saved."); RawLabel("Steam lobby membership/name still remain visible to the server and unmodded peers."); RawSection("CONNECTED-SESSION MESSAGE"); RawLabel(IsNetworkServerHost() ? "Broadcasts through Beetleball's built-in all-player chat RPC." : "Sends a labeled custom message through Beetleball all-chat; the server may reject it."); RawLabel("Sandbox v0.3.5 clients mirror labeled all-chat into Beetleball's on-screen popup UI."); RawLabel("Unmodified clients receive the built-in chat line because the game has no text-popup RPC."); RawLabel("Type while this tab is open; Backspace edits (maximum 96 characters)."); RawMessageBox(_announcementText, 66f); RawSection("QUICK TEXT"); if (RawRowButton("Welcome", 0, 4)) { _announcementText = "Welcome to the custom server!"; } if (RawRowButton("Starting", 1, 4)) { _announcementText = "Match starting soon - get ready!"; } if (RawRowButton("GG", 2, 4)) { _announcementText = "Good game, everyone!"; } if (RawRowButton("Clear", 3, 4)) { _announcementText = string.Empty; } RawNextRow(); if (RawRowButton("Preview locally", 0, 2)) { PreviewAnnouncement(); } if (RawRowButton("Broadcast to all", 1, 2)) { BroadcastAnnouncementFromMenu(); } RawNextRow(); } private void DrawRawEggPage() { RawSection("BEETLE EGG REWARD ROLLS"); RawLabel("Egg rewards are rolled by the local BeetleEggDataSO before the inventory grant."); bool flag = RawToggle("Override some egg rolls with Mythical rarity", _eggRarityBoost); if (flag != _eggRarityBoost) { _eggRarityBoost = flag; SavePrivacyDisplayPreference("BeetleballSandbox.EggRarityBoost.v1", _eggRarityBoost); SetStatus(flag ? "Mythical egg-roll override enabled" : "Normal egg rarity table restored"); } float eggMythicalChance = _eggMythicalChance; _eggMythicalChance = RawStepper("Forced Mythical chance", _eggMythicalChance, 0f, 100f, 5f, 100f, "0", "%"); if (Math.Abs(eggMythicalChance - _eggMythicalChance) > 0.001f) { SaveIntegerPreference("BeetleballSandbox.EggMythicalChance.v1", Mathf.RoundToInt(_eggMythicalChance)); } if (RawRowButton("25%", 0, 4)) { SetEggMythicalChancePreset(25f); } if (RawRowButton("50%", 1, 4)) { SetEggMythicalChancePreset(50f); } if (RawRowButton("100%", 2, 4)) { SetEggMythicalChancePreset(100f); } if (RawRowButton("Normal odds", 3, 4)) { _eggRarityBoost = false; SavePrivacyDisplayPreference("BeetleballSandbox.EggRarityBoost.v1", enabled: false); SetStatus("Normal egg rarity table restored"); } RawNextRow(); RawLabel("If every matching Mythical is owned, Beetleball's normal duplicate/refund logic still applies."); RawSection("EGG OPENING SPEED"); bool flag2 = RawToggle("Fast egg hatch (near-zero waits + 25x animation)", _fastEggHatch); if (flag2 != _fastEggHatch) { _fastEggHatch = flag2; SavePrivacyDisplayPreference("BeetleballSandbox.FastEggHatch.v1", _fastEggHatch); if (!flag2) { RestoreEggHatchTimings(); } SetStatus(flag2 ? "Fast egg hatch enabled" : "Normal egg hatch timing restored"); } if (RawRowButton("Open Beetle Egg screen", 0, 1)) { try { GameEvents.InvokeOpenEggScreenRequested(); SetStatus("Requested the Beetle Egg screen"); } catch (Exception exception) { ReportException("opening the Beetle Egg screen", exception); } } RawNextRow(); RawLabel("The override changes rewards only when an egg is actually consumed and opened."); } private void SetEggMythicalChancePreset(float chance) { _eggMythicalChance = Mathf.Clamp(chance, 0f, 100f); _eggRarityBoost = _eggMythicalChance > 0f; SaveIntegerPreference("BeetleballSandbox.EggMythicalChance.v1", Mathf.RoundToInt(_eggMythicalChance)); SavePrivacyDisplayPreference("BeetleballSandbox.EggRarityBoost.v1", _eggRarityBoost); SetStatus($"Forced Mythical egg chance set to {_eggMythicalChance:0}%"); } private void LoadPrivacyDisplayPreferences() { try { _anonymousMode = PlayerPrefs.GetInt("BeetleballSandbox.AnonymousMode.v1", 0) != 0; _hideLeaderboard = PlayerPrefs.GetInt("BeetleballSandbox.HideLeaderboard.v1", 0) != 0; _hidePlayerBoard = PlayerPrefs.GetInt("BeetleballSandbox.HidePlayerBoard.v1", 0) != 0; _eggRarityBoost = PlayerPrefs.GetInt("BeetleballSandbox.EggRarityBoost.v1", 0) != 0; _eggMythicalChance = Mathf.Clamp(PlayerPrefs.GetInt("BeetleballSandbox.EggMythicalChance.v1", 100), 0, 100); _fastEggHatch = PlayerPrefs.GetInt("BeetleballSandbox.FastEggHatch.v1", 1) != 0; } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not load privacy/display preferences: " + ex.Message); } } private void SavePrivacyDisplayPreference(string key, bool enabled) { try { PlayerPrefs.SetInt(key, enabled ? 1 : 0); PlayerPrefs.Save(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not save a privacy/display preference: " + ex.Message); } } private void SaveIntegerPreference(string key, int value) { try { PlayerPrefs.SetInt(key, value); PlayerPrefs.Save(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not save preference " + key + ": " + ex.Message); } } private void ApplyPrivacyDisplayControls() { if (_hideLeaderboard) { HideActiveLeaderboardObjects(); } else if (_hiddenLeaderboardObjects.Count > 0) { RestoreHiddenUiObjects(_hiddenLeaderboardObjects); } if (_hidePlayerBoard) { HideActivePlayerBoardObjects(); } else if (_hiddenPlayerBoardObjects.Count > 0) { RestoreHiddenUiObjects(_hiddenPlayerBoardObjects); } } private void HideActiveLeaderboardObjects() { try { Il2CppArrayBase val = Object.FindObjectsOfType(); for (int i = 0; i < val.Length; i++) { LeaderboardUI obj = val[i]; HideActiveUiObject((obj != null) ? ((Component)obj).gameObject : null, _hiddenLeaderboardObjects); } } catch { } } private void HideActivePlayerBoardObjects() { try { Il2CppArrayBase val = Object.FindObjectsOfType(); for (int i = 0; i < val.Length; i++) { PlayerListPanelUI obj = val[i]; HideActiveUiObject((obj != null) ? ((Component)obj).gameObject : null, _hiddenPlayerBoardObjects); } } catch { } } private static void HideActiveUiObject(GameObject? uiObject, Dictionary hiddenObjects) { if ((Object)(object)uiObject == (Object)null || !uiObject.activeInHierarchy) { return; } try { IntPtr pointer = ((Il2CppObjectBase)uiObject).Pointer; if (pointer == IntPtr.Zero) { return; } if (!hiddenObjects.TryGetValue(pointer, out HiddenUiSnapshot value) || (Object)(object)value.CanvasGroup == (Object)null) { CanvasGroup val = uiObject.GetComponent(); bool addedByMod = (Object)(object)val == (Object)null; if ((Object)(object)val == (Object)null) { val = uiObject.AddComponent(); } value = (hiddenObjects[pointer] = new HiddenUiSnapshot(val, addedByMod)); } value.CanvasGroup.alpha = 0f; value.CanvasGroup.interactable = false; value.CanvasGroup.blocksRaycasts = false; } catch { } } private static void RestoreHiddenUiObjects(Dictionary hiddenObjects) { foreach (HiddenUiSnapshot value in hiddenObjects.Values) { try { CanvasGroup canvasGroup = value.CanvasGroup; if (!((Object)(object)canvasGroup == (Object)null)) { canvasGroup.alpha = value.Alpha; canvasGroup.interactable = value.Interactable; canvasGroup.blocksRaycasts = value.BlocksRaycasts; if (value.AddedByMod) { Object.Destroy((Object)(object)canvasGroup); } } } catch { } } hiddenObjects.Clear(); } internal static bool ShouldSuppressLocalLobbyNotifications() { return _activeInstance?._anonymousMode ?? false; } internal static bool TryOverrideEggRarity(out Rarity rarity) { rarity = (Rarity)4; SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._eggRarityBoost) { return false; } float num = Mathf.Clamp(activeInstance._eggMythicalChance, 0f, 100f); if (!(num >= 100f)) { return Random.value * 100f < num; } return true; } internal static void PrepareFastEggHatch(EggScreen screen) { SandboxMod activeInstance = _activeInstance; if (activeInstance == null || (Object)(object)screen == (Object)null) { return; } try { IntPtr pointer = ((Il2CppObjectBase)screen).Pointer; if (!activeInstance._eggHatchTimingSnapshots.TryGetValue(pointer, out EggHatchTimingSnapshot value)) { value = new EggHatchTimingSnapshot(screen); activeInstance._eggHatchTimingSnapshots[pointer] = value; } if (!activeInstance._fastEggHatch) { value.Restore(); activeInstance._eggHatchTimingSnapshots.Remove(pointer); return; } screen.hatchDuration = 0.04f; screen.finalizeHatchDelay = 0.02f; Animator eggHatchAnimation = screen.eggHatchAnimation; if ((Object)(object)eggHatchAnimation != (Object)null) { eggHatchAnimation.speed = 25f; } } catch (Exception ex) { ((MelonBase)activeInstance).LoggerInstance.Warning("Could not apply fast egg timing: " + ex.Message); } } private void RestoreEggHatchTimings() { foreach (EggHatchTimingSnapshot value in _eggHatchTimingSnapshots.Values) { try { value.Restore(); } catch { } } _eggHatchTimingSnapshots.Clear(); } private void CaptureAnnouncementTyping() { if (!_menuOpen || _guiUnavailable || _menuPage != 4) { return; } try { if (Input.GetKeyDown((KeyCode)127)) { _announcementText = string.Empty; } string inputString = Input.inputString; if (string.IsNullOrEmpty(inputString)) { return; } for (int i = 0; i < inputString.Length; i++) { char c = inputString[i]; switch (c) { case '\b': if (_announcementText.Length > 0) { _announcementText = _announcementText.Substring(0, _announcementText.Length - 1); } continue; case '\n': case '\r': c = ' '; break; default: if (char.IsControl(c)) { continue; } break; } if (_announcementText.Length < 96) { _announcementText += c; } } } catch { } } private void RawSection(string title) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) GUI.Box(new Rect(_uiX, _uiY, _uiWidth, 26f), title); _uiY += 32f; } private void RawLabel(string text) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(_uiX, _uiY, _uiWidth, 22f), text); _uiY += 22f; } private void RawMessageBox(string text, float height) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(_uiX, _uiY, _uiWidth, height); GUI.Box(val, string.Empty); string text2 = text ?? string.Empty; int num = Math.Min(58, text2.Length); if (text2.Length > num) { int num2 = text2.LastIndexOf(' ', num - 1, num); if (num2 >= 24) { num = num2; } } string text3 = text2.Substring(0, num); string text4 = ((text2.Length > num) ? text2.Substring(num).TrimStart() : string.Empty); GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 7f, ((Rect)(ref val)).width - 16f, 24f), text3); GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 33f, ((Rect)(ref val)).width - 16f, 24f), text4 + "_"); _uiY += height + 6f; } private bool RawToggle(string text, bool value) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) bool result = GUI.Toggle(new Rect(_uiX, _uiY, _uiWidth, 24f), value, text); _uiY += 26f; return result; } private bool RawRowButton(string text, int column, int columns) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) float num = (_uiWidth - 5f * (float)(columns - 1)) / (float)columns; return GUI.Button(new Rect(_uiX + (float)column * (num + 5f), _uiY, num, 28f), text); } private void RawNextRow() { _uiY += 34f; } private float RawStepper(string label, float value, float minimum, float maximum, float step, float reset, string format = "0.00", string suffix = "x") { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) float num = _uiWidth - 84f - 58f - 12f; GUI.Label(new Rect(_uiX, _uiY, num, 26f), label + ": " + value.ToString(format) + suffix); float num2 = _uiX + num + 4f; if (GUI.Button(new Rect(num2, _uiY, 42f, 26f), "-")) { value -= step; } float num3 = num2 + 46f; if (GUI.Button(new Rect(num3, _uiY, 58f, 26f), "Reset")) { value = reset; } if (GUI.Button(new Rect(num3 + 62f, _uiY, 42f, 26f), "+")) { value += step; } _uiY += 30f; return Mathf.Clamp(value, minimum, maximum); } private float RawUnboundedStepper(string label, float value, float minimum, float step, float reset, string format = "0.00", string suffix = "x") { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) float num = _uiWidth - 84f - 58f - 12f; GUI.Label(new Rect(_uiX, _uiY, num, 26f), label + ": " + value.ToString(format) + suffix); float num2 = _uiX + num + 4f; if (GUI.Button(new Rect(num2, _uiY, 42f, 26f), "-")) { value -= step; } float num3 = num2 + 46f; if (GUI.Button(new Rect(num3, _uiY, 58f, 26f), "Reset")) { value = reset; } if (GUI.Button(new Rect(num3 + 62f, _uiY, 42f, 26f), "+")) { value += step; } _uiY += 30f; if (float.IsNaN(value) || float.IsInfinity(value)) { value = reset; } return Mathf.Max(minimum, value); } private static float SafeDouble(float value) { if (float.IsNaN(value) || float.IsInfinity(value) || value <= 0f) { return 1f; } if (!(value >= 1.7014117E+38f)) { return value * 2f; } return float.MaxValue; } private int RawIntStepper(string label, int value, int minimum, int maximum, int step, int reset) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) float num = _uiWidth - 84f - 58f - 12f; GUI.Label(new Rect(_uiX, _uiY, num, 26f), $"{label}: {value}"); float num2 = _uiX + num + 4f; if (GUI.Button(new Rect(num2, _uiY, 42f, 26f), "-")) { value -= step; } float num3 = num2 + 46f; if (GUI.Button(new Rect(num3, _uiY, 58f, 26f), "Reset")) { value = reset; } if (GUI.Button(new Rect(num3 + 62f, _uiY, 42f, 26f), "+")) { value += step; } _uiY += 30f; return Math.Clamp(value, minimum, maximum); } private void ApplyPlayerPreset(string preset) { ResetPlayerSliders(); _playerTuning = true; switch (preset) { case "Turbo": _moveSpeed = 2.5f; _sprintSpeed = 2.5f; _jumpForce = 1.4f; _gravity = 0.85f; _ballRollSpeed = 2.5f; _cooldownFactor = 0.5f; break; case "Tiny turbo": _moveSpeed = 4f; _sprintSpeed = 2f; _jumpForce = 1.6f; _gravity = 0.7f; _playerSize = 0.45f; _ballRollSpeed = 3f; _cooldownFactor = 0.4f; break; case "Moon beetle": _moveSpeed = 1.4f; _sprintSpeed = 1.5f; _jumpForce = 2.8f; _gravity = 0.2f; _playerSize = 0.8f; break; case "Heavy hitter": _moveSpeed = 1.2f; _sprintSpeed = 1.3f; _jumpForce = 0.8f; _gravity = 1.4f; _playerSize = 1.8f; _throwForce = 4f; _headbuttForce = 5f; _noStun = true; break; } SetStatus(preset + " preset enabled"); } private void ApplyBallPreset(string name, float mass, float scale, bool useGravity, float launch, float spin) { _ballTuning = true; _freezeBall = false; _ballMass = mass; _ballScale = scale; _ballUseGravity = useGravity; _launchPower = launch; _spinPower = spin; SetStatus(name + " preset enabled"); } private void SetFovPreset(float value) { _fov = value; _fovOverride = true; SetStatus($"FOV set to {value:0}"); } private void SetTimePreset(float value) { _timeScale = value; if (Math.Abs(value - 1f) < 0.001f) { SetTimeScaleOverride(enabled: false); } else { SetTimeScaleOverride(enabled: true); } SetStatus((Math.Abs(value - 1f) < 0.001f) ? "Time scale restored" : $"Time scale set to {value:0.00}x"); } private void ResetPlayerOnly() { ClearRelayedPlayerTuning(); _playerTuning = false; RestorePlayerTuning(); ResetPlayerSliders(); SetStatus("Player tweaks disabled and reset"); } private void ResetBallOnly() { ClearRelayedBallTuning(); _ballTuning = false; ResetBallTuning(); ResetGlobalBallScale(); SetStatus("Ball tweaks disabled and reset"); } private void ResetEverything() { ResetPlayerOnly(); ResetBallOnly(); _fovOverride = false; RestoreFov(); ResetCameraDistance(); _timeScale = 1f; SetTimeScaleOverride(enabled: false); SetStatus("All sandbox tweaks reset"); } public override void OnDeinitializeMelon() { ShutdownNetworkBridge(); ShutdownAdminTools(); RestoreHiddenUiObjects(_hiddenLeaderboardObjects); RestoreHiddenUiObjects(_hiddenPlayerBoardObjects); RestoreEggHatchTimings(); _noStun = false; RestoreNoStunOverride(); RestorePlayerTuning(); RestoreBallTuning(); RestoreFov(); RestoreTimeScale(); RestoreMenuInputLock(); RestoreCursor(); _activeInstance = null; } private string BuildSessionStatus(BeetleActor? actor, DungBall? ball) { string value = (((Object)(object)actor == (Object)null) ? "no local beetle" : "local beetle ready"); string value2 = (((Object)(object)ball == (Object)null) ? "no ball" : "ball ready"); string sharedWorldAuthorityTag = GetSharedWorldAuthorityTag(); return $"{value} | {value2} | {sharedWorldAuthorityTag}"; } private static string BuildPlayerLiveStatus(BeetleActor? actor) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)actor == (Object)null) { return "Waiting for the local beetle to spawn."; } try { BeetleStats stats = actor.Stats; Transform beetleVisualRoot = GetBeetleVisualRoot(actor); float value = (((Object)(object)beetleVisualRoot == (Object)null) ? 1f : beetleVisualRoot.localScale.x); return $"Live: speed {stats.MoveSpeed:0.00} | throw {stats.ShootBallForceMinSize:0.0} | scale {value:0.00}"; } catch { return "Local beetle found; waiting for its stats and model."; } } private string BuildFovLiveStatus() { try { PlayerCamera instance = PlayerCamera.Instance; Camera val = (((Object)(object)instance == (Object)null) ? Camera.main : (instance.Cam ?? Camera.main)); return ((Object)(object)val == (Object)null) ? "Live camera is not available on this screen." : $"Live camera FOV {val.fieldOfView:0.0} | requested {_fov:0.0}"; } catch { return "Live camera is not available on this screen."; } } private static BeetleActor? GetLocalBeetle() { try { NetworkActor localActor = NetworkActor.LocalActor; BeetleActor val = (((Object)(object)localActor == (Object)null) ? null : ((Il2CppObjectBase)localActor).TryCast()); if ((Object)(object)val != (Object)null) { return val; } } catch { } try { NetworkManager singleton = NetworkManager.Singleton; object obj2; if (singleton == null) { obj2 = null; } else { NetworkClient localClient = singleton.LocalClient; obj2 = ((localClient != null) ? localClient.PlayerObject : null); } BeetleActor val2 = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { return val2; } } catch { } try { Il2CppArrayBase val3 = Object.FindObjectsOfType(); for (int i = 0; i < val3.Length; i++) { BeetleActor val4 = val3[i]; if ((Object)(object)val4 != (Object)null && ((NetworkBehaviour)val4).IsOwner) { return val4; } } } catch { } return null; } private static Transform? GetBeetleVisualRoot(BeetleActor actor) { try { return ((Component)actor).transform; } catch { return null; } } private static void EnableNetworkScaleSync(Component component) { try { NetworkTransform component2 = component.GetComponent(); if (!((Object)(object)component2 == (Object)null)) { component2.SyncScaleX = true; component2.SyncScaleY = true; component2.SyncScaleZ = true; } } catch { } } private static DungBall? GetTargetBall(BeetleActor? actor) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) try { object obj; if (actor == null) { obj = null; } else { BallHandling ballHandling = actor.BallHandling; obj = ((ballHandling != null) ? ballHandling.HeldBall : null); } DungBall val = (DungBall)obj; if ((Object)(object)val != (Object)null) { return val; } Il2CppArrayBase val2 = Object.FindObjectsOfType(); if (val2 == null || val2.Length == 0) { return null; } if ((Object)(object)actor == (Object)null) { return val2[0]; } DungBall result = null; float num = float.MaxValue; for (int i = 0; i < val2.Length; i++) { DungBall val3 = val2[i]; if (!((Object)(object)val3 == (Object)null)) { Vector3 val4 = ((Component)val3).transform.position - ((Component)actor).transform.position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; result = val3; } } } return result; } catch { return null; } } private static bool HasWorldAuthority() { try { NetworkManager singleton = NetworkManager.Singleton; return (Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.IsHost || singleton.IsServer; } catch { return true; } } private static bool IsNetworkSessionActive() { try { NetworkManager singleton = NetworkManager.Singleton; return (Object)(object)singleton != (Object)null && singleton.IsListening; } catch { return false; } } private void RefreshPlayerSnapshot(BeetleActor? actor) { if ((Object)(object)actor == (Object)null) { return; } try { BeetleStatModifiersController statModifiersController = actor.StatModifiersController; BeetleStats stats = actor.Stats; if (!((Object)(object)statModifiersController == (Object)null) && stats != null) { Transform beetleVisualRoot = GetBeetleVisualRoot(actor); IntPtr intPtr = ((beetleVisualRoot != null) ? ((Il2CppObjectBase)beetleVisualRoot).Pointer : IntPtr.Zero); if (_playerSnapshot == null || !(_playerSnapshot.ActorPointer == ((Il2CppObjectBase)actor).Pointer) || !(_playerSnapshot.ControllerPointer == ((Il2CppObjectBase)statModifiersController).Pointer) || !(_playerSnapshot.VisualPointer == intPtr)) { RestorePlayerTuning(); _playerSnapshot = new PlayerSnapshot(actor, statModifiersController, stats, beetleVisualRoot); } } } catch { } } private bool IsLocalFlightActor(BeetleActor actor) { try { BeetleActor localBeetle = GetLocalBeetle(); if ((Object)(object)localBeetle != (Object)null) { return ((Il2CppObjectBase)localBeetle).Pointer == ((Il2CppObjectBase)actor).Pointer; } } catch { } try { return ((NetworkBehaviour)actor).IsOwner; } catch { return false; } } private static bool IsFlightGrounded(BeetleActor actor) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) try { GroundRaycaster groundChecker = actor.GroundChecker; if ((Object)(object)groundChecker != (Object)null && !groundChecker.IsDisabled) { return groundChecker.IsGrounded; } } catch { } try { return actor.TimeInAir <= 0.02f && (Object)(object)((NetworkActor)actor).RB != (Object)null && ((NetworkActor)actor).RB.linearVelocity.y <= 0.25f; } catch { return false; } } private float GetFlySpeedMultiplier() { if (!float.IsNaN(_flySpeed) && !float.IsInfinity(_flySpeed)) { return Mathf.Clamp(_flySpeed, 0.25f, 25f); } return 1f; } private void ArmFlightMomentum(BeetleActor actor) { //IL_0035: 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) float unscaledTime = Time.unscaledTime; if (!_flightMomentumActive || _flightMomentumActorPointer != ((Il2CppObjectBase)actor).Pointer) { _flightMomentumActive = true; _flightMomentumActorPointer = ((Il2CppObjectBase)actor).Pointer; _flightMomentumVelocity = Vector3.zero; _flightBaseSpeed = 0f; _flightGroundGraceUntil = unscaledTime + 0.35f; } _flightStateUpdatedAt = unscaledTime; } private void ResetFlightMomentum() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) _flightMomentumActive = false; _flightMomentumActorPointer = IntPtr.Zero; _flightMomentumVelocity = Vector3.zero; _flightBaseSpeed = 0f; _flightStateUpdatedAt = float.NegativeInfinity; _flightGroundGraceUntil = 0f; } private void MaintainFlightMomentum(BeetleActor? actor) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (!_playerTuning || !_holdFlightUntilGround) { ResetFlightMomentum(); } else { if (!_flightMomentumActive) { return; } if ((Object)(object)((actor != null) ? ((NetworkActor)actor).RB : null) == (Object)null || ((Il2CppObjectBase)actor).Pointer != _flightMomentumActorPointer) { ResetFlightMomentum(); return; } float unscaledTime = Time.unscaledTime; if (!(unscaledTime >= _flightGroundGraceUntil) || !IsFlightGrounded(actor)) { if (unscaledTime - _flightStateUpdatedAt <= 0.12f) { try { Vector3 val = StabilizeHeldFlightVelocity(actor, ((NetworkActor)actor).RB.linearVelocity); if (_flightMomentumActive) { actor.SetLinearVelocity(val); _flightMomentumVelocity = val; if (_flightBaseSpeed <= 0.1f && ((Vector3)(ref val)).sqrMagnitude > 0.0001f) { _flightBaseSpeed = ((Vector3)(ref val)).magnitude / GetFlySpeedMultiplier(); } } return; } catch { ResetFlightMomentum(); return; } } try { Vector3 val2 = ((((Vector3)(ref _flightMomentumVelocity)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref _flightMomentumVelocity)).normalized : ((Component)actor).transform.forward); Camera main = Camera.main; if ((Object)(object)main != (Object)null) { Vector3 val3 = ((Component)main).transform.forward; if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { val3 = ((Component)main).transform.forward; Vector3 normalized = ((Vector3)(ref val3)).normalized; if (!WantsIntentionalFlightDescent() && normalized.y < 0f) { normalized.y = 0f; if (((Vector3)(ref normalized)).sqrMagnitude > 0.0001f) { ((Vector3)(ref normalized)).Normalize(); } } float num = Mathf.Clamp01(Time.deltaTime * 6f); val3 = Vector3.Slerp(val2, normalized, num); val2 = ((Vector3)(ref val3)).normalized; } } float num2 = Mathf.Max(0.1f, _flightBaseSpeed * GetFlySpeedMultiplier()); _flightMomentumVelocity = StabilizeHeldFlightVelocity(actor, val2 * num2); if (_flightMomentumActive) { actor.SetLinearVelocity(_flightMomentumVelocity); } return; } catch { ResetFlightMomentum(); return; } } ResetFlightMomentum(); } } private bool WantsIntentionalFlightDescent() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) try { Camera main = Camera.main; return (Object)(object)main != (Object)null && ((Component)main).transform.forward.y <= -0.65f; } catch { return false; } } private Vector3 StabilizeHeldFlightVelocity(BeetleActor actor, Vector3 velocity) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!_holdFlightUntilGround || !_flightMomentumActive) { return velocity; } if (Time.unscaledTime >= _flightGroundGraceUntil && IsFlightGrounded(actor)) { ResetFlightMomentum(); return velocity; } if (!WantsIntentionalFlightDescent() && velocity.y < 0f) { velocity.y = 0f; } return velocity; } internal static bool ShouldSuppressHeldFlightGravity(BeetleActor actor) { SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._playerTuning || !activeInstance._holdFlightUntilGround || !activeInstance._flightMomentumActive || !activeInstance.IsLocalFlightActor(actor) || ((Il2CppObjectBase)actor).Pointer != activeInstance._flightMomentumActorPointer) { return false; } if (Time.unscaledTime >= activeInstance._flightGroundGraceUntil && IsFlightGrounded(actor)) { activeInstance.ResetFlightMomentum(); return false; } return !activeInstance.WantsIntentionalFlightDescent(); } internal static bool BeginPatchedFlightFrame(BeetleActor actor) { SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._playerTuning || !activeInstance._holdFlightUntilGround || !activeInstance.IsLocalFlightActor(actor)) { return false; } activeInstance.ArmFlightMomentum(actor); if (Time.unscaledTime >= activeInstance._flightGroundGraceUntil && IsFlightGrounded(actor)) { activeInstance.ResetFlightMomentum(); return false; } _flightChargeDrainSuppressionDepth++; return true; } internal static void EndPatchedFlightFrame(bool suppressionApplied) { if (suppressionApplied) { _flightChargeDrainSuppressionDepth = Math.Max(0, _flightChargeDrainSuppressionDepth - 1); } } internal static bool ShouldSuppressFlightChargeDrain() { return _flightChargeDrainSuppressionDepth > 0; } internal static void ApplyPatchedFlightVelocity(BeetleActor actor) { //IL_0030: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._playerTuning || !activeInstance.IsLocalFlightActor(actor) || (Object)(object)((NetworkActor)actor).RB == (Object)null) { return; } try { Vector3 linearVelocity = ((NetworkActor)actor).RB.linearVelocity; if (((Vector3)(ref linearVelocity)).sqrMagnitude <= 0.0001f) { return; } Vector3 val = linearVelocity * activeInstance.GetFlySpeedMultiplier(); if (activeInstance._holdFlightUntilGround) { activeInstance.ArmFlightMomentum(actor); val = activeInstance.StabilizeHeldFlightVelocity(actor, val); if (!activeInstance._flightMomentumActive) { return; } activeInstance._flightBaseSpeed = ((Vector3)(ref linearVelocity)).magnitude; activeInstance._flightMomentumVelocity = val; } actor.SetLinearVelocity(val); } catch { } } internal static void ApplyPatchedGlideVelocity(BeetleActor actor) { //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_0047: 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) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._playerTuning || !activeInstance._holdFlightUntilGround || !activeInstance.IsLocalFlightActor(actor) || (Object)(object)((NetworkActor)actor).RB == (Object)null) { return; } try { activeInstance.ArmFlightMomentum(actor); Vector3 linearVelocity = ((NetworkActor)actor).RB.linearVelocity; Vector3 val = activeInstance.StabilizeHeldFlightVelocity(actor, linearVelocity); if (activeInstance._flightMomentumActive) { actor.SetLinearVelocity(val); activeInstance._flightMomentumVelocity = val; if (((Vector3)(ref linearVelocity)).sqrMagnitude > 0.0001f) { activeInstance._flightBaseSpeed = ((Vector3)(ref linearVelocity)).magnitude / activeInstance.GetFlySpeedMultiplier(); } } } catch { } } internal static void CapturePatchedFlightExit(BeetleActor actor) { //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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._playerTuning || !activeInstance._holdFlightUntilGround || !activeInstance.IsLocalFlightActor(actor) || (Object)(object)((NetworkActor)actor).RB == (Object)null) { return; } try { activeInstance.ArmFlightMomentum(actor); Vector3 velocity = ((NetworkActor)actor).RB.linearVelocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.0001f) { velocity = (activeInstance._flightMomentumVelocity = activeInstance.StabilizeHeldFlightVelocity(actor, velocity)); if (activeInstance._flightBaseSpeed <= 0.1f) { activeInstance._flightBaseSpeed = ((Vector3)(ref velocity)).magnitude / activeInstance.GetFlySpeedMultiplier(); } } } catch { } } internal static void RestorePatchedFlightExitVelocity(BeetleActor actor) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._flightMomentumActive || (Object)(object)((NetworkActor)actor).RB == (Object)null || ((Il2CppObjectBase)actor).Pointer != activeInstance._flightMomentumActorPointer) { return; } if (Time.unscaledTime >= activeInstance._flightGroundGraceUntil && IsFlightGrounded(actor)) { activeInstance.ResetFlightMomentum(); return; } try { if (((Vector3)(ref activeInstance._flightMomentumVelocity)).sqrMagnitude > 0.0001f) { activeInstance._flightMomentumVelocity = activeInstance.StabilizeHeldFlightVelocity(actor, activeInstance._flightMomentumVelocity); if (activeInstance._flightMomentumActive) { actor.SetLinearVelocity(activeInstance._flightMomentumVelocity); } } activeInstance._flightStateUpdatedAt = float.NegativeInfinity; } catch { activeInstance.ResetFlightMomentum(); } } private void ApplyPlayerTuning(BeetleActor actor) { //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) PlayerSnapshot playerSnapshot = _playerSnapshot; if (playerSnapshot == null || actor.Stats == null) { return; } try { BeetleStats stats = actor.Stats; float num = (_serverCooldownOverrideActive ? Mathf.Clamp(_serverCooldownOverrideFactor, 0f, 2f) : _cooldownFactor); stats.MoveSpeed = playerSnapshot.MoveSpeed * _moveSpeed; stats.SprintSpeedMult = playerSnapshot.SprintSpeedMult * _sprintSpeed; stats.JumpForce = playerSnapshot.JumpForce * _jumpForce; stats.GravityMult = playerSnapshot.GravityMult * _gravity; stats.FlutterSpeed = playerSnapshot.FlutterSpeed * _flySpeed; stats.GlideSpeed = playerSnapshot.GlideSpeed * _flySpeed; stats.Size = playerSnapshot.Size * _playerSize; stats.BallMinSizeMaxSpeed = playerSnapshot.BallMinSizeMaxSpeed * _ballRollSpeed; stats.BallMaxSizeMaxSpeed = playerSnapshot.BallMaxSizeMaxSpeed * _ballRollSpeed; stats.ShootBallForceMinSize = playerSnapshot.ShootBallForceMinSize * _throwForce; stats.ShootBallForceMaxSize = playerSnapshot.ShootBallForceMaxSize * _throwForce; stats.ShootBallForceChargedMult = playerSnapshot.ShootBallForceChargedMult; stats.HeadbuttLaunchForce = playerSnapshot.HeadbuttLaunchForce * _headbuttForce; stats.HeadbuttLaunchForceForwardBonus = playerSnapshot.HeadbuttLaunchForceForwardBonus * _headbuttForce; stats.HeadbuttHitForce = playerSnapshot.HeadbuttHitForce * _headbuttForce; stats.GrabCooldownDuration = playerSnapshot.GrabCooldownDuration * num; stats.HeadbuttCooldown = playerSnapshot.HeadbuttCooldown * num; stats.ShootBallRecoveryDuration = playerSnapshot.ShootBallRecoveryDuration * num; playerSnapshot.Controller.ModifiedStats = stats; ApplyLiveCooldowns(actor, playerSnapshot, num); if ((Object)(object)playerSnapshot.VisualRoot != (Object)null) { EnableNetworkScaleSync((Component)(object)actor); playerSnapshot.VisualRoot.localScale = playerSnapshot.VisualScale * _playerSize; } actor.Unstunnable = _noStun || playerSnapshot.Unstunnable; if (_noStun) { ApplyNoStunOverride(actor); } _playerApplied = true; } catch (Exception exception) { ReportException("applying player tuning", exception); } } private void RestorePlayerTuning() { //IL_0139: Unknown result type (might be due to invalid IL or missing references) ResetFlightMomentum(); PlayerSnapshot playerSnapshot = _playerSnapshot; if (playerSnapshot == null || !_playerApplied) { _playerApplied = false; _playerSnapshot = null; return; } try { BeetleStats stats = playerSnapshot.Actor.Stats; stats.MoveSpeed = playerSnapshot.MoveSpeed; stats.SprintSpeedMult = playerSnapshot.SprintSpeedMult; stats.JumpForce = playerSnapshot.JumpForce; stats.GravityMult = playerSnapshot.GravityMult; stats.FlutterSpeed = playerSnapshot.FlutterSpeed; stats.GlideSpeed = playerSnapshot.GlideSpeed; stats.Size = playerSnapshot.Size; stats.BallMinSizeMaxSpeed = playerSnapshot.BallMinSizeMaxSpeed; stats.BallMaxSizeMaxSpeed = playerSnapshot.BallMaxSizeMaxSpeed; stats.ShootBallForceMinSize = playerSnapshot.ShootBallForceMinSize; stats.ShootBallForceMaxSize = playerSnapshot.ShootBallForceMaxSize; stats.ShootBallForceChargedMult = playerSnapshot.ShootBallForceChargedMult; stats.HeadbuttLaunchForce = playerSnapshot.HeadbuttLaunchForce; stats.HeadbuttLaunchForceForwardBonus = playerSnapshot.HeadbuttLaunchForceForwardBonus; stats.HeadbuttHitForce = playerSnapshot.HeadbuttHitForce; stats.GrabCooldownDuration = playerSnapshot.GrabCooldownDuration; stats.HeadbuttCooldown = playerSnapshot.HeadbuttCooldown; stats.ShootBallRecoveryDuration = playerSnapshot.ShootBallRecoveryDuration; playerSnapshot.Controller.ModifiedStats = stats; RestoreLiveCooldowns(playerSnapshot.Actor, playerSnapshot); if ((Object)(object)playerSnapshot.VisualRoot != (Object)null) { playerSnapshot.VisualRoot.localScale = playerSnapshot.VisualScale; } playerSnapshot.Actor.Unstunnable = _noStun || playerSnapshot.Unstunnable; } catch { } _playerApplied = false; _playerSnapshot = null; } private static void ApplyLiveCooldowns(BeetleActor actor, PlayerSnapshot snapshot, float factor) { factor = Mathf.Clamp(factor, 0f, 2f); actor.jumpCooldown = snapshot.JumpCooldown * factor; actor.ballJumpCooldown = snapshot.BallJumpCooldown * factor; SetLiveCooldownTimer(actor.GrabCooldownTimer, snapshot.GrabCooldownTimerDuration, factor); SetLiveCooldownTimer(actor.JumpCooldownTimer, snapshot.JumpCooldownTimerDuration, factor); SetLiveCooldownTimer(actor.HeadbuttCooldownTimer, snapshot.HeadbuttCooldownTimerDuration, factor); SetLiveCooldownTimer(actor.BallJumpCooldownTimer, snapshot.BallJumpCooldownTimerDuration, factor); SetLiveCooldownTimer(actor.ShootBallRecoveryTimer, snapshot.ShootBallRecoveryTimerDuration, factor); } private static void RestoreLiveCooldowns(BeetleActor actor, PlayerSnapshot snapshot) { actor.jumpCooldown = snapshot.JumpCooldown; actor.ballJumpCooldown = snapshot.BallJumpCooldown; SetLiveCooldownTimer(actor.GrabCooldownTimer, snapshot.GrabCooldownTimerDuration, 1f); SetLiveCooldownTimer(actor.JumpCooldownTimer, snapshot.JumpCooldownTimerDuration, 1f); SetLiveCooldownTimer(actor.HeadbuttCooldownTimer, snapshot.HeadbuttCooldownTimerDuration, 1f); SetLiveCooldownTimer(actor.BallJumpCooldownTimer, snapshot.BallJumpCooldownTimerDuration, 1f); SetLiveCooldownTimer(actor.ShootBallRecoveryTimer, snapshot.ShootBallRecoveryTimerDuration, 1f); } private static void SetLiveCooldownTimer(Timer? timer, float baseDuration, float factor) { if (timer != null) { float duration = Mathf.Max(0f, baseDuration * factor); ((TimerBase)timer).Duration = duration; if (factor <= 0.0001f) { ((TimerBase)timer).CompleteTimer(); } } } private static float ReadLiveCooldownDuration(Timer? timer, float fallback) { try { if (timer != null && !float.IsNaN(((TimerBase)timer).Duration) && !float.IsInfinity(((TimerBase)timer).Duration)) { return Mathf.Max(0f, ((TimerBase)timer).Duration); } } catch { } return Mathf.Max(0f, fallback); } private void ResetPlayerSliders() { _moveSpeed = 1f; _sprintSpeed = 1f; _jumpForce = 1f; _gravity = 1f; _flySpeed = 1f; _holdFlightUntilGround = true; ResetFlightMomentum(); _playerSize = 1f; _ballRollSpeed = 1f; _throwForce = 1f; _headbuttForce = 1f; _cooldownFactor = 1f; _noStun = false; RestoreNoStunOverride(); SetStatus("Player sliders reset"); } private void ApplyNoStunOverride(BeetleActor actor) { try { if (!_noStunOverrideApplied || (Object)(object)_noStunActor == (Object)null || ((Il2CppObjectBase)_noStunActor).Pointer != ((Il2CppObjectBase)actor).Pointer) { RestoreNoStunOverride(); _noStunActor = actor; _noStunOriginalUnstunnable = actor.Unstunnable; _noStunOverrideApplied = true; } actor.Unstunnable = true; actor.IsStunned = false; actor.UnStun(); StunForDurationRpcDispatcher component = ((Component)actor).GetComponent(); if ((Object)(object)component != (Object)null) { component.UnStun(); } } catch { } } private void RestoreNoStunOverride() { if (_noStunOverrideApplied && (Object)(object)_noStunActor != (Object)null) { try { _noStunActor.Unstunnable = _noStunOriginalUnstunnable; } catch { } } _noStunActor = null; _noStunOverrideApplied = false; } internal static bool ShouldSuppressLocalStun(StunForDurationRpcDispatcher dispatcher) { SandboxMod activeInstance = _activeInstance; if (activeInstance == null || !activeInstance._noStun || (Object)(object)dispatcher == (Object)null) { return false; } try { BeetleActor component = ((Component)dispatcher).GetComponent(); BeetleActor localBeetle = GetLocalBeetle(); return (Object)(object)component != (Object)null && (Object)(object)localBeetle != (Object)null && ((Il2CppObjectBase)component).Pointer == ((Il2CppObjectBase)localBeetle).Pointer; } catch { return false; } } private void GiveExperience(int amount) { try { if (_customLocalLevelOverride > 0) { SetStatus("Custom level override is active; use Exact local level to change it"); return; } PlayerLevelManager instance = PlayerLevelManager.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("PlayerLevelManager is not available"); return; } instance.AddExperience(amount); SetStatus($"Added {amount:N0} XP"); } catch (Exception exception) { ReportException("adding XP", exception); } } private void GiveNextLevel() { try { if (_customLocalLevelOverride > 0) { _localTargetLevel = Math.Min(1000000, _customLocalLevelOverride + 1); SetStatus(SetExactLocalLevel(_localTargetLevel)); return; } PlayerLevelManager instance = PlayerLevelManager.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("PlayerLevelManager is not available"); return; } int num = instance.RequiredLevelUpExperience(instance.Level); int num2 = Math.Max(1, num - instance.Experience); instance.AddExperience(num2); SetStatus($"Added {num2:N0} XP toward the next level"); } catch (Exception exception) { ReportException("leveling up", exception); } } private void PopPlayer(BeetleActor? actor) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((actor != null) ? ((NetworkActor)actor).RB : null) == (Object)null) { SetStatus("The local beetle is not available"); return; } try { ((NetworkActor)actor).RB.AddForce(Vector3.up * 14f, (ForceMode)2); SetStatus("Popped the local beetle upward"); } catch (Exception exception) { ReportException("popping the player", exception); } } private void RefreshBallSnapshot(DungBall? ball) { if (!((Object)(object)ball == (Object)null) && !((Object)(object)ball.RB == (Object)null) && (_ballSnapshot == null || !(_ballSnapshot.BallPointer == ((Il2CppObjectBase)ball).Pointer))) { RestoreBallTuning(); _ballSnapshot = new BallSnapshot(ball); } } private void ApplyBallTuning(DungBall ball) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) BallSnapshot ballSnapshot = _ballSnapshot; if (ballSnapshot == null || (Object)(object)ball.RB == (Object)null) { return; } try { ball.RB.mass = ballSnapshot.Mass * _ballMass; ball.RB.useGravity = _ballUseGravity; if (!_globalBallScaleEnabled) { ((Component)ball).transform.localScale = ballSnapshot.LocalScale * _ballScale; } if (_freezeBall) { ball.RB.linearVelocity = Vector3.zero; ball.RB.angularVelocity = Vector3.zero; } } catch (Exception exception) { ReportException("applying ball tuning", exception); } } private void RestoreBallTuning() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) BallSnapshot ballSnapshot = _ballSnapshot; if (ballSnapshot == null) { return; } try { ballSnapshot.Rigidbody.mass = ballSnapshot.Mass; ballSnapshot.Rigidbody.useGravity = ballSnapshot.UseGravity; if (!_globalBallScaleEnabled) { ((Component)ballSnapshot.Ball).transform.localScale = ballSnapshot.LocalScale; } } catch { } _ballSnapshot = null; } private void ResetBallTuning() { _freezeBall = false; _ballUseGravity = true; _ballMass = 1f; _ballScale = 1f; RestoreBallTuning(); SetStatus("Ball tweaks reset"); } private void ChangeBallSize(DungBall? ball, int change) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ball == (Object)null) { SetStatus("No target ball is available"); } else if (!TryRelayWorldAction(WorldAction.ChangeBallSize, ball, change, 0, 0f, 0f, default(Vector3), 0)) { try { ball.IncrementSize_ServerRpc(change); SetStatus((change > 0) ? "Requested one ball growth step" : "Requested one ball shrink step"); } catch (Exception exception) { ReportException("changing ball size", exception); } } } private void SpawnLooseDung(BeetleActor? actor, int count) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown try { Camera main = Camera.main; if ((Object)(object)actor == (Object)null && (Object)(object)main == (Object)null) { SetStatus("Enter a match before spawning loose dung"); return; } Vector3 val = (((Object)(object)main != (Object)null) ? ((Component)main).transform.forward : ((Component)actor).transform.forward); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); count = Math.Clamp(count, 1, 20); if (TryRelayWorldAction(WorldAction.SpawnLooseDung, null, count, _dungSpawnSize, 0f, 0f, val, 0)) { return; } NetworkPrefabSpawner instance = NetworkPrefabSpawner.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("The network dung spawner is not available on this screen"); return; } Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val3 = (((Object)(object)actor != (Object)null) ? (((Component)actor).transform.position + val * 2.5f + Vector3.up * 1.25f) : (((Component)main).transform.position + val * 3f)); for (int i = 0; i < count; i++) { float num = (float)i - (float)(count - 1) * 0.5f; Vector3 val4 = val3 + normalized * num * 0.65f + Vector3.up * (float)(i % 2) * 0.15f; Vector3 val5 = val * ((count == 1) ? 1.5f : 2.5f) + Vector3.up * ((count == 1) ? 0.75f : 1.5f); instance.SpawnDungBall_ServerRpc(val4, val5, _dungSpawnSize, 0.75f, new RpcParams()); } SetStatus((count == 1) ? $"Spawned loose dung (size {_dungSpawnSize})" : $"Spawned {count} loose dung pieces (size {_dungSpawnSize})"); } catch (Exception exception) { ReportException("spawning loose dung", exception); } } private void RecallBall(BeetleActor? actor, DungBall? ball) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) if ((Object)(object)actor == (Object)null || (Object)(object)((ball != null) ? ball.RB : null) == (Object)null) { SetStatus("The local beetle or target ball is not available"); } else if (!TryRelayWorldAction(WorldAction.RecallBall, ball, 0, 0, 0f, 0f, default(Vector3), 0)) { try { Vector3 position = ((Component)actor).transform.position + ((Component)actor).transform.forward * 3f + Vector3.up * 1.25f; ball.RB.position = position; ((Component)ball).transform.position = position; ball.RB.linearVelocity = Vector3.zero; ball.RB.angularVelocity = Vector3.zero; SetStatus("Recalled target ball"); } catch (Exception exception) { ReportException("recalling the ball", exception); } } } private void LaunchBall(BeetleActor? actor, DungBall? ball) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((ball != null) ? ball.RB : null) == (Object)null) { SetStatus("No target ball is available"); return; } try { Camera main = Camera.main; Vector3 val = (((Object)(object)main != (Object)null) ? ((Component)main).transform.forward : (((Object)(object)actor != (Object)null) ? ((Component)actor).transform.forward : Vector3.forward)); if (!TryRelayWorldAction(WorldAction.LaunchBall, ball, 0, 0, _launchPower, 0f, ((Vector3)(ref val)).normalized, 0)) { ApplyOwnerAwareBallForce(ball, ((Vector3)(ref val)).normalized * _launchPower + Vector3.up * 2f, resetVelocity: true); SetStatus("Launched target ball"); } } catch (Exception exception) { ReportException("launching the ball", exception); } } private static void ApplyOwnerAwareBallForce(DungBall ball, Vector3 force, bool resetVelocity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) try { ForceParams val = new ForceParams(); val.force = force; val.resetVelocity = resetVelocity; val.ignoreMass = true; val.additive = !resetVelocity; val.disableGroundCheck = true; ball.AddForce(val); return; } catch { } if (!((Object)(object)ball.RB == (Object)null)) { if (resetVelocity) { ball.RB.linearVelocity = force; } else { ball.RB.AddForce(force, (ForceMode)2); } } } private void StopBall(DungBall? ball) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((ball != null) ? ball.RB : null) == (Object)null) { SetStatus("No target ball is available"); } else if (!TryRelayWorldAction(WorldAction.StopBall, ball, 0, 0, 0f, 0f, default(Vector3), 0)) { try { ApplyOwnerAwareBallForce(ball, Vector3.zero, resetVelocity: true); ball.RB.angularVelocity = Vector3.zero; SetStatus("Stopped target ball"); } catch (Exception exception) { ReportException("stopping the ball", exception); } } } private void SpinBall(DungBall? ball) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((ball != null) ? ball.RB : null) == (Object)null) { SetStatus("No target ball is available"); } else if (!TryRelayWorldAction(WorldAction.SpinBall, ball, 0, 0, _spinPower, 0f, default(Vector3), 0)) { try { ball.RB.angularVelocity = Vector3.up * _spinPower; SetStatus("Spun target ball"); } catch (Exception exception) { ReportException("spinning the ball", exception); } } } private void ExplodeBall(DungBall? ball) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ball == (Object)null) { SetStatus("No target ball is available"); } else if (!TryRelayWorldAction(WorldAction.ExplodeBall, ball, 0, 0, 0f, 0f, default(Vector3), 0)) { try { ball.Explode(true); SetStatus("Exploded target ball"); } catch (Exception exception) { ReportException("exploding the ball", exception); } } } private void SpawnCommandBall(BeetleActor? actor) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!TryRelayWorldAction(WorldAction.SpawnBall, null, 1, 0, 0f, 0f, ((Object)(object)actor == (Object)null) ? Vector3.forward : ((Component)actor).transform.forward, 0)) { InvokeInternalCommandCore("SpawnBallCommand", new object[1] { 1 }); } } private void InvokeLocalCommand(string methodName, params object[] arguments) { InvokeInternalCommandCore(methodName, arguments); } private void InvokeInternalCommandCore(string methodName, object[] arguments) { try { MethodInfo method = typeof(BeetleBallCommands).GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { SetStatus("Internal command " + methodName + " was not found"); return; } method.Invoke(null, arguments); SetStatus("Ran " + methodName); } catch (Exception exception) { ReportException("running " + methodName, exception); } } private void ApplyFov() { if (!_fovOverride) { return; } try { PlayerCamera instance = PlayerCamera.Instance; Camera val = (((Object)(object)instance == (Object)null) ? Camera.main : (instance.Cam ?? Camera.main)); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)_cameraSnapshot == (Object)null || ((Il2CppObjectBase)_cameraSnapshot).Pointer != ((Il2CppObjectBase)val).Pointer) { RestoreFov(); _cameraSnapshot = val; _originalFov = val.fieldOfView; } if ((Object)(object)instance != (Object)null) { instance.SetFOV(_fov); } val.fieldOfView = _fov; } } catch { _cameraSnapshot = null; } } private void RestoreFov() { try { PlayerCamera instance = PlayerCamera.Instance; if ((Object)(object)instance != (Object)null) { instance.ResetFOV(); } } catch { } if ((Object)(object)_cameraSnapshot != (Object)null) { try { _cameraSnapshot.fieldOfView = _originalFov; } catch { } } _cameraSnapshot = null; } private void SetTimeScaleOverride(bool enabled) { if (enabled && IsNetworkSessionActive()) { _timeScaleOverride = false; SetStatus("Time scale is restricted to offline play"); return; } if (enabled && !_timeScaleOverride) { _originalTimeScale = Time.timeScale; _timeScaleCaptured = true; } _timeScaleOverride = enabled; if (!enabled) { RestoreTimeScale(); } } private void ApplyTimeScale() { if (_timeScaleOverride) { if (IsNetworkSessionActive()) { SetTimeScaleOverride(enabled: false); } else { Time.timeScale = _timeScale; } } } private void RestoreTimeScale() { if (_timeScaleCaptured) { try { Time.timeScale = _originalTimeScale; } catch { } } _timeScaleCaptured = false; _timeScaleOverride = false; } private void SetMenuOpen(bool open) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) _menuOpen = open; if (open) { if (!_cursorCaptured) { _savedCursorLock = Cursor.lockState; _savedCursorVisible = Cursor.visible; _cursorCaptured = true; } ApplyMenuInputLock(); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else { RestoreMenuInputLock(); RestoreCursor(); } } private void ApplyMenuInputLock() { if (_menuInputLockApplied) { return; } try { PlayerControls controls = PlayerInputManager.Controls; if (controls != null) { PlayerInputManager.AddKeyedGroupInputLock("beetleballSandboxMenu", controls.Actions.Get()); _menuInputLockApplied = true; _menuInputLockWarningLogged = false; } } catch (Exception ex) { if (!_menuInputLockWarningLogged) { _menuInputLockWarningLogged = true; ((MelonBase)this).LoggerInstance.Warning("Could not pause gameplay input for the sandbox menu yet: " + ex.Message); } } } private void RestoreMenuInputLock() { if (!_menuInputLockApplied) { return; } try { PlayerControls controls = PlayerInputManager.Controls; if (controls != null) { PlayerInputManager.RemoveKeyedGroupInputLock("beetleballSandboxMenu", controls.Actions.Get()); } PlayerInputManager.FlushKeyedInputStates("beetleballSandboxMenu"); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Could not fully restore gameplay input after closing the sandbox menu: " + ex.Message); } finally { _menuInputLockApplied = false; } } private void RestoreCursor() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (_cursorCaptured) { try { Cursor.lockState = _savedCursorLock; Cursor.visible = _savedCursorVisible; } catch { } _cursorCaptured = false; } } private void SetStatus(string message) { _status = message; _statusUntil = Time.unscaledTime + 5f; ((MelonBase)this).LoggerInstance.Msg(message); } private void ReportException(string operation, Exception exception) { _status = "Error " + operation + ": " + exception.GetBaseException().Message; _statusUntil = Time.unscaledTime + 8f; ((MelonBase)this).LoggerInstance.Error($"Error {operation}: {exception}"); } } [HarmonyPatch(typeof(StunForDurationRpcDispatcher), "PerformLocal")] internal static class LocalNoStunPatch { private static bool Prefix(StunForDurationRpcDispatcher __instance) { return !SandboxMod.ShouldSuppressLocalStun(__instance); } } [HarmonyPatch(typeof(ChatPanel), "OnMemberJoin")] internal static class LocalLobbyJoinNoticePatch { private static bool Prefix() { return !SandboxMod.ShouldSuppressLocalLobbyNotifications(); } } [HarmonyPatch(typeof(ChatPanel), "OnMemberLeave")] internal static class LocalLobbyLeaveNoticePatch { private static bool Prefix() { return !SandboxMod.ShouldSuppressLocalLobbyNotifications(); } } [HarmonyPatch(typeof(ChatPanel), "SendChatMessage_ClientRpc")] internal static class AnnouncementChatPopupPatch { private unsafe static void Postfix(FixedString128Bytes __0, MessageTarget __1, ulong __2) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected I4, but got Unknown try { SandboxMod.TryMirrorAnnouncementChatToPopup(((object)(*(FixedString128Bytes*)(&__0))/*cast due to .constrained prefix*/).ToString(), (int)__1, __2); } catch { } } } [HarmonyPatch(typeof(PlayerLevelManager), "get_Level")] internal static class CustomLocalLevelPatch { private static void Postfix(ref int __result) { if (SandboxMod.TryGetCustomLocalLevelOverride(out var level)) { __result = level; } } } [HarmonyPatch(typeof(BeetleEggDataSO), "GetRandomizedRarity")] internal static class BeetleEggRarityPatch { private static bool Prefix(ref Rarity __result) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected I4, but got Unknown if (!SandboxMod.TryOverrideEggRarity(out var rarity)) { return true; } __result = (Rarity)(int)rarity; return false; } } [HarmonyPatch(typeof(EggScreen), "StockEgg")] internal static class FastEggStockPatch { private static void Prefix(EggScreen __instance) { SandboxMod.PrepareFastEggHatch(__instance); } } [HarmonyPatch(typeof(EggScreen), "HatchEgg")] internal static class FastEggHatchPatch { private static void Prefix(EggScreen __instance) { SandboxMod.PrepareFastEggHatch(__instance); } } [HarmonyPatch(typeof(AbilityCharging), "DecreaseChargeRelativeToDrainDuration")] internal static class FlightChargeDrainPatch { private static bool Prefix() { return !SandboxMod.ShouldSuppressFlightChargeDrain(); } } [HarmonyPatch(typeof(BeetleActor), "ApplyGravity")] internal static class HeldFlightGravityPatch { private static bool Prefix(BeetleActor __instance) { return !SandboxMod.ShouldSuppressHeldFlightGravity(__instance); } } [HarmonyPatch(typeof(LadybugBeetleAbilityState_Fly), "FrameUpdate")] internal static class LadybugFlightFramePatch { private static void Prefix(BeetleActor __0, out bool __state) { __state = SandboxMod.BeginPatchedFlightFrame(__0); } private static void Postfix(bool __state) { SandboxMod.EndPatchedFlightFrame(__state); } } [HarmonyPatch(typeof(FireflyBeetleAbilityState_Normal), "FrameUpdate")] internal static class FireflyFlightFramePatch { private static void Prefix(BeetleActor __0, out bool __state) { __state = SandboxMod.BeginPatchedFlightFrame(__0); } private static void Postfix(bool __state) { SandboxMod.EndPatchedFlightFrame(__state); } } [HarmonyPatch(typeof(LadybugBeetleAbilityState_FlyBall), "FrameUpdate")] internal static class LadybugBallFlightFramePatch { private static void Prefix(BeetleActor __0, out bool __state) { __state = SandboxMod.BeginPatchedFlightFrame(__0); } private static void Postfix(bool __state) { SandboxMod.EndPatchedFlightFrame(__state); } } [HarmonyPatch(typeof(LadybugBeetleAbilityState_Fly), "PhysicsUpdate")] internal static class LadybugFlightVelocityPatch { private static void Postfix(BeetleActor __0) { SandboxMod.ApplyPatchedFlightVelocity(__0); } } [HarmonyPatch(typeof(FireflyBeetleAbilityState_Normal), "PhysicsUpdate")] internal static class FireflyFlightVelocityPatch { private static void Postfix(BeetleActor __0) { SandboxMod.ApplyPatchedFlightVelocity(__0); } } [HarmonyPatch(typeof(LadybugBeetleAbilityState_FlyBall), "PhysicsUpdate")] internal static class LadybugBallFlightVelocityPatch { private static void Postfix(BeetleActor __0) { SandboxMod.ApplyPatchedFlightVelocity(__0); } } [HarmonyPatch(typeof(BeetleGliding), "Glide")] internal static class GeneralGlideVelocityPatch { private static void Postfix(BeetleActor __0) { SandboxMod.ApplyPatchedGlideVelocity(__0); } } [HarmonyPatch(typeof(BeetleGeneralState_Fluttering), "PhysicsUpdate")] internal static class GeneralFlutterVelocityPatch { private static void Postfix(BeetleActor __0) { SandboxMod.ApplyPatchedGlideVelocity(__0); } } [HarmonyPatch(typeof(LonghornBeetleAbilityState_Parasailing), "PhysicsUpdate")] internal static class LonghornParasailVelocityPatch { private static void Postfix(BeetleActor __0) { SandboxMod.ApplyPatchedGlideVelocity(__0); } } [HarmonyPatch(typeof(LadybugBeetleAbilityState_Fly), "Exit")] internal static class LadybugFlightExitPatch { private static void Prefix(BeetleActor __0) { SandboxMod.CapturePatchedFlightExit(__0); } private static void Postfix(BeetleActor __0) { SandboxMod.RestorePatchedFlightExitVelocity(__0); } } [HarmonyPatch(typeof(FireflyBeetleAbilityState_Normal), "Exit")] internal static class FireflyFlightExitPatch { private static void Prefix(BeetleActor __0) { SandboxMod.CapturePatchedFlightExit(__0); } private static void Postfix(BeetleActor __0) { SandboxMod.RestorePatchedFlightExitVelocity(__0); } } [HarmonyPatch(typeof(LadybugBeetleAbilityState_FlyBall), "Exit")] internal static class LadybugBallFlightExitPatch { private static void Prefix(BeetleActor __0) { SandboxMod.CapturePatchedFlightExit(__0); } private static void Postfix(BeetleActor __0) { SandboxMod.RestorePatchedFlightExitVelocity(__0); } } }