using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ReplaySystem.Patches;
using Reptile;
using Reptile.Phone;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ReplaySystem")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cf31c7b08a85d4d847ec8a8bbbd20af54c75c550")]
[assembly: AssemblyProduct("ReplaySystem")]
[assembly: AssemblyTitle("ReplaySystem")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ReplaySystem
{
[BepInPlugin("com.LazyDuchess.BRC.ReplaySystem", "ReplaySystem", "0.0.1")]
internal class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
private const string GUID = "com.LazyDuchess.BRC.ReplaySystem";
private const string Name = "ReplaySystem";
private const string Version = "0.0.1";
public ManualLogSource Log => ((BaseUnityPlugin)this).Logger;
private void Awake()
{
//IL_000b: 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)
//IL_0036: Expected O, but got Unknown
Instance = this;
new Harmony("com.LazyDuchess.BRC.ReplaySystem").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"ReplaySystem 0.0.1 loaded!");
StageManager.OnStagePostInitialization += new OnStageInitializedDelegate(StageManager_OnStagePostInitialization);
}
private void StageManager_OnStagePostInitialization()
{
ReplayManager.Create();
}
}
public class Replay
{
private Player _player;
private float _fps;
private List<ReplayFrame> _frames = new List<ReplayFrame>();
public float FPS => _fps;
public Player Player => _player;
public int FrameCount => _frames.Count;
public float Length => (float)(FrameCount - 1) * FPS;
public List<ReplayFrame> Frames => _frames;
public Replay(float fps)
{
_fps = fps;
}
public void Init()
{
_player = WorldHandler.instance.GetCurrentPlayer();
}
public int GetFrameForTime(float time)
{
return Mathf.FloorToInt(time / _fps);
}
}
public class ReplayFrame
{
public int Frame;
public bool Valid;
public Vector3 PlayerPosition;
public Quaternion PlayerRotation;
public Vector2 MoveInputPlain;
public Vector3 MoveInput;
public bool JumpButtonNew;
public bool JumpButtonHeld;
public bool SprayButtonHeld;
public bool SprayButtonNew;
public bool Trick1ButtonHeld;
public bool Trick1ButtonNew;
public bool Trick2ButtonHeld;
public bool Trick2ButtonNew;
public bool Trick3ButtonHeld;
public bool Trick3ButtonNew;
public bool SlideButtonHeld;
public bool SlideButtonNew;
public bool DanceButtonHeld;
public bool DanceButtonNew;
public bool BoostButtonNew;
public bool BoostButtonHeld;
public bool SwitchStyleButtonNew;
public bool SwitchStyleButtonHeld;
public bool WalkButtonNew;
public bool WalkButtonHeld;
public bool PhoneButtonNew;
public bool Jump;
public bool JumpRequested;
public Vector3 Velocity;
public float BoostCharge;
public float HP;
public PhoneState PhoneState;
public bool UsingEquippedMoveStyle;
public int Animation;
public float AnimationTime;
private Replay _replay;
public ReplayFrame(Replay replay)
{
_replay = replay;
}
}
public class ReplayManager : MonoBehaviour
{
private static ReplayManager _instance;
private ReplayState _currentReplayState;
private ReplayRecorder _replayRecorder = new ReplayRecorder();
private ReplayPlayer _replayPlayer = new ReplayPlayer();
public static ReplayManager Instance => _instance;
public ReplayState CurrentReplayState => _currentReplayState;
public ReplayRecorder ReplayRecorder => _replayRecorder;
public ReplayPlayer ReplayPlayer => _replayPlayer;
public static ReplayManager Create()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return new GameObject("Replay Manager").AddComponent<ReplayManager>();
}
private void Awake()
{
_instance = this;
}
private void Update()
{
if (Core.instance.IsCorePaused)
{
return;
}
if (_currentReplayState != null)
{
_currentReplayState.OnUpdate();
}
if (Input.GetKeyDown((KeyCode)284))
{
if (_currentReplayState == null)
{
_currentReplayState?.End();
_currentReplayState = _replayRecorder;
_replayRecorder.Start();
}
else if (_currentReplayState == _replayRecorder)
{
_replayRecorder.End();
_currentReplayState = _replayPlayer;
_replayPlayer.Replay = _replayRecorder.Replay;
_replayPlayer.Start();
}
else if (_currentReplayState == _replayPlayer)
{
_replayPlayer.End();
_currentReplayState = null;
}
}
}
public void OnFixedUpdate()
{
if (!Core.instance.IsCorePaused)
{
_currentReplayState?.OnFixedUpdate();
}
}
private void OnDestroy()
{
_instance = null;
}
}
public class ReplayPlaybackCamera : MonoBehaviour
{
private enum CameraType
{
Gameplay,
LookAt,
Orbit,
FreeCam
}
private const float MedFOV = 40f;
private const float CameraMinTopDownDistance = 3f;
private const float CameraMaxDistance = 30f;
private const float CameraRadius = 0.25f;
private const float MinPrevCameraDistance = 1f;
private ReplayPlayer _replayPlayer;
private Player _player;
private float _currentCameraTypeEndTime;
private CameraType _currentCameraType;
private bool _manualCam;
private GameplayCamera _gameplayCamera;
private Camera _camera;
private float _originalFOV;
private float _freeCamX;
private float _freeCamY;
private float _freeCamRoll;
private float _freeCamFOV = 65f;
private float _freeCamDistance = 2.5f;
private float _freeCamSensitivity = 1.5f;
private float _freeCamSpeed = 12f;
public static ReplayPlaybackCamera Create()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return new GameObject("Replay Camera Controller").AddComponent<ReplayPlaybackCamera>();
}
private void Awake()
{
_gameplayCamera = GameplayCamera.instance;
_camera = _gameplayCamera.cam;
_originalFOV = _camera.fieldOfView;
((Behaviour)_gameplayCamera).enabled = false;
_player = WorldHandler.instance.GetCurrentPlayer();
_replayPlayer = ReplayManager.Instance.ReplayPlayer;
ReplayPlayer replayPlayer = _replayPlayer;
replayPlayer.OnFrameSkip = (Action)Delegate.Combine(replayPlayer.OnFrameSkip, new Action(OnSkip));
}
private void Update()
{
//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_0098: 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_00d8: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_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)
if (Input.GetKeyDown((KeyCode)99))
{
if (_currentCameraType == CameraType.Gameplay)
{
EndGameplayCamera();
}
switch (_currentCameraType)
{
case CameraType.Orbit:
DoFreeCamera();
break;
case CameraType.Gameplay:
DoOrbitCamera();
break;
case CameraType.FreeCam:
DoNewCamera();
break;
default:
DoManualGameplayCamera();
break;
}
}
if (_manualCam)
{
UpdateManualCameras();
return;
}
if (_replayPlayer.CurrentTime >= _currentCameraTypeEndTime)
{
DoNewCamera();
}
if (_currentCameraType == CameraType.LookAt)
{
Vector3 lookTarget = GetLookTarget();
if (Vector3.Distance(lookTarget, ((Component)_camera).transform.position) >= 30f)
{
DoNewCamera();
}
if (!CheckSpotForCameraLookAt(((Component)_camera).transform.position))
{
DoNewCamera();
}
Vector3 val = lookTarget - ((Component)_camera).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
((Component)_camera).transform.rotation = Quaternion.LookRotation(normalized, Vector3.up);
}
}
private void UpdateManualCameras()
{
if (_currentCameraType == CameraType.Gameplay)
{
return;
}
_camera.fieldOfView = _freeCamFOV;
if (Input.GetKey((KeyCode)116))
{
_freeCamRoll = 0f;
}
else
{
if (Input.GetKey((KeyCode)101))
{
_freeCamRoll += _freeCamSpeed * Time.unscaledDeltaTime;
}
if (Input.GetKey((KeyCode)113))
{
_freeCamRoll -= _freeCamSpeed * Time.unscaledDeltaTime;
}
}
if (Input.GetKey((KeyCode)323) || (_currentCameraType == CameraType.FreeCam && !Input.GetKey((KeyCode)325) && !Input.GetKey((KeyCode)324)))
{
_freeCamX += Input.GetAxisRaw("Mouse X") * _freeCamSensitivity;
_freeCamY -= Input.GetAxisRaw("Mouse Y") * _freeCamSensitivity;
}
if (Input.GetKey((KeyCode)324))
{
if (_currentCameraType == CameraType.Orbit)
{
_freeCamDistance -= Input.GetAxisRaw("Mouse Y") * _freeCamSensitivity;
if (_freeCamDistance < 0f)
{
_freeCamDistance = 0f;
}
}
else
{
_freeCamSpeed += Input.GetAxisRaw("Mouse Y") * _freeCamSensitivity;
if (_freeCamSpeed < 0f)
{
_freeCamSpeed = 0f;
}
}
}
if (Input.GetKey((KeyCode)325))
{
_freeCamFOV -= Input.GetAxisRaw("Mouse Y") * _freeCamSensitivity;
if (_freeCamFOV < 1f)
{
_freeCamFOV = 1f;
}
}
if (_currentCameraType == CameraType.Orbit)
{
UpdateOrbitCamera();
}
if (_currentCameraType == CameraType.FreeCam)
{
UpdateFreeCamera();
}
}
private void UpdateFreeCamera()
{
//IL_0058: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_0090: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: 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_011f: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
float num = (Input.GetKey((KeyCode)119) ? 1f : 0f);
float num2 = (Input.GetKey((KeyCode)115) ? 1f : 0f);
float num3 = (Input.GetKey((KeyCode)100) ? 1f : 0f);
float num4 = (Input.GetKey((KeyCode)97) ? 1f : 0f);
Vector3 val = Vector3.zero;
val += ((Component)_camera).transform.forward * num;
val += -((Component)_camera).transform.forward * num2;
val += ((Component)_camera).transform.right * num3;
val += -((Component)_camera).transform.right * num4;
((Vector3)(ref val)).Normalize();
float num5 = _freeCamSpeed;
if (Input.GetKey((KeyCode)304))
{
num5 *= 2f;
}
Transform transform = ((Component)_camera).transform;
transform.position += val * num5 * Time.unscaledDeltaTime;
Quaternion rotation = Quaternion.Euler(_freeCamY, _freeCamX, _freeCamRoll);
((Component)_camera).transform.rotation = rotation;
}
private void UpdateOrbitCamera()
{
//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_0024: 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_002a: 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)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0058: Unknown result type (might be due to invalid IL or missing references)
Vector3 lookTarget = GetLookTarget();
Quaternion val = Quaternion.Euler(_freeCamY, _freeCamX, _freeCamRoll);
Vector3 val2 = val * Vector3.forward;
Vector3 position = lookTarget - val2 * _freeCamDistance;
((Component)_camera).transform.position = position;
((Component)_camera).transform.rotation = val;
}
private void DoFreeCamera()
{
_camera.fieldOfView = _freeCamFOV;
_manualCam = true;
_currentCameraType = CameraType.FreeCam;
}
private void DoOrbitCamera()
{
_camera.fieldOfView = _freeCamFOV;
_manualCam = true;
_currentCameraType = CameraType.Orbit;
}
private void DoManualGameplayCamera()
{
_manualCam = true;
DoGameplayCamera(0f);
}
private void OnSkip()
{
if (!_manualCam)
{
DoNewCamera();
}
}
private bool TryDoCamera(int attempts, float duration)
{
//IL_0008: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < attempts; i++)
{
float height = GetLookTarget().y + Random.Range(0f, 1f);
bool flag = true;
bool flag2 = true;
float time = Random.Range(1f, 3f);
Vector3 spot = Vector3.zero;
Vector3 spot2 = Vector3.zero;
if (!FindSpotForMedCameraLookAt(out spot, height, time))
{
flag2 = FindSpotForMedCameraLookAt(out spot, height, 0f);
}
if (!FindSpotForMedCameraLookAt(out spot2, height, time, onGround: true))
{
flag = FindSpotForMedCameraLookAt(out spot2, height, 0f, onGround: true);
}
bool flag3 = false;
if (flag)
{
flag3 = ((!_player.IsGrounded() && !_player.IsGrinding()) ? (Random.Range(0, 3) == 0) : (Random.Range(0, 4) != 0));
if (!flag2)
{
flag3 = true;
}
}
if (flag3)
{
DoLookAtCamera(spot2, duration);
return true;
}
if (flag2)
{
DoLookAtCamera(spot, duration);
return true;
}
}
return false;
}
private void DoNewCamera()
{
_manualCam = false;
if (_currentCameraType == CameraType.Gameplay)
{
EndGameplayCamera();
}
float duration = Random.Range(3f, 5f);
if (!TryDoCamera(3, duration))
{
DoGameplayCamera(duration);
}
}
private void DoLookAtCamera(Vector3 from, float duration)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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)
//IL_0032: 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)
Vector3 lookTarget = GetLookTarget();
((Component)_camera).transform.position = from;
Vector3 val = lookTarget - from;
Vector3 normalized = ((Vector3)(ref val)).normalized;
((Component)_camera).transform.rotation = Quaternion.LookRotation(normalized, Vector3.up);
_currentCameraType = CameraType.LookAt;
_currentCameraTypeEndTime = _replayPlayer.CurrentTime + duration;
_camera.fieldOfView = 40f;
}
private void DoGameplayCamera(float duration)
{
_currentCameraType = CameraType.Gameplay;
_currentCameraTypeEndTime = _replayPlayer.CurrentTime + duration;
((Behaviour)_gameplayCamera).enabled = true;
_camera.fieldOfView = _originalFOV;
}
private void EndGameplayCamera()
{
((Behaviour)_gameplayCamera).enabled = false;
}
private bool FindSpotForMedCameraLookAt(out Vector3 spot, float height, float time, bool onGround = false)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0067: 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_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: 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_0094: 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_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_00a7: 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_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_00c1: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: 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_013e: 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_012c: 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_0100: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
Replay replay = _replayPlayer.Replay;
float time2 = _replayPlayer.CurrentTime + time;
int num = replay.GetFrameForTime(time2);
if (num >= replay.FrameCount)
{
num = replay.FrameCount - 1;
}
ReplayFrame replayFrame = replay.Frames[num];
Vector3 val = GetLookTarget(replayFrame.PlayerPosition);
Vector3 lookTarget = GetLookTarget();
if (Vector3.Distance(val, lookTarget) >= 30f)
{
val = lookTarget;
}
float num2 = 1f;
float num3 = 8f;
List<Vector3> list = new List<Vector3>();
RaycastHit val3 = default(RaycastHit);
for (float num4 = 0f - num3; num4 <= num3; num4 += num2)
{
for (float num5 = 0f - num3; num5 <= num3; num5 += num2)
{
Vector3 val2 = val + new Vector3(num4, height, num5);
if (!(Vector2.Distance(new Vector2(val2.x, val2.z), new Vector2(val.x, val.z)) < 3f))
{
if (onGround && Physics.Raycast(val2, -Vector3.up, ref val3, 10f, 1, (QueryTriggerInteraction)1))
{
val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 1f;
}
if ((_currentCameraType != CameraType.LookAt || !(Vector3.Distance(val2, ((Component)_camera).transform.position) < 1f)) && CheckSpotForCameraLookAt(val2))
{
list.Add(val2);
}
}
}
}
spot = Vector3.zero;
if (list.Count <= 0)
{
return false;
}
spot = list[Random.Range(0, list.Count)];
return true;
}
private bool CheckSpotForCameraLookAt(Vector3 spot)
{
//IL_000d: 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)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_002c: 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)
//IL_0034: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
bool queriesHitBackfaces = Physics.queriesHitBackfaces;
Physics.queriesHitBackfaces = true;
Vector3 lookTarget = GetLookTarget();
if (Physics.CheckSphere(spot, 0.25f, 1, (QueryTriggerInteraction)1))
{
Physics.queriesHitBackfaces = queriesHitBackfaces;
return false;
}
Vector3 val = lookTarget - spot;
Vector3 normalized = ((Vector3)(ref val)).normalized;
float num = ((Vector3)(ref val)).magnitude - 1f;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(spot, normalized, ref val2, num, 1, (QueryTriggerInteraction)1))
{
Physics.queriesHitBackfaces = queriesHitBackfaces;
return false;
}
Physics.queriesHitBackfaces = queriesHitBackfaces;
return true;
}
private Vector3 GetLookTarget()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return GetLookTarget(((Component)_player).transform.position);
}
private Vector3 GetLookTarget(Vector3 playerPosition)
{
//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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return playerPosition + Vector3.up * 1f;
}
private void OnDestroy()
{
_camera.fieldOfView = _originalFOV;
((Behaviour)_gameplayCamera).enabled = true;
ReplayPlayer replayPlayer = _replayPlayer;
replayPlayer.OnFrameSkip = (Action)Delegate.Remove(replayPlayer.OnFrameSkip, new Action(OnSkip));
}
public void Destroy()
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public class ReplayPlayer : ReplayState
{
public Replay Replay;
public Action OnFrameSkip;
private bool _paused;
private float _playbackSpeed = 1f;
private ReplayPlaybackCamera _replayCamera;
private float _currentTime;
public static GameplayUI ui;
public float CurrentTime => _currentTime;
public override void Start()
{
Core.Instance.GameInput.DisableControllerMap(0, 0);
Core.Instance.GameInput.DisableControllerMap(1, 0);
Core.Instance.GameInput.DisableControllerMap(2, 0);
Core.Instance.GameInput.DisableControllerMap(3, 0);
Core.Instance.GameInput.DisableControllerMap(4, 0);
Core.Instance.GameInput.DisableControllerMap(5, 0);
_currentTime = 0f;
_replayCamera = ReplayPlaybackCamera.Create();
_paused = false;
_playbackSpeed = 1f;
UI.Instance.ShowNotification("C : toggle camera mode\r\nR : reset settings\r\nspace : pause\r\n0 to 4 : timeline \r\n(0,25,50,75,100%)\r\nMouse wheel up/down:\r\n -speed up/slow down clip\r\nQ and E : camera pan\r\nH : toggle UI\r\nG : toggle tooltip");
}
public void SkipTo(float time)
{
int num = Replay.GetFrameForTime(time);
if (num >= Replay.FrameCount)
{
num = Replay.FrameCount - 1;
}
if (num < 0)
{
num = 0;
}
ApplyFrameToWorld(Replay.Frames[num], skip: true);
_currentTime = (float)num * Replay.FPS;
}
public override void OnFixedUpdate()
{
bool skip = false;
if (_currentTime == 0f)
{
skip = true;
}
List<ReplayFrame> frames = Replay.Frames;
int frameForTime = Replay.GetFrameForTime(_currentTime);
if (frameForTime >= frames.Count)
{
_currentTime = 0f;
skip = true;
frameForTime = Replay.GetFrameForTime(_currentTime);
}
else
{
_currentTime += Time.fixedDeltaTime;
}
ApplyFrameToWorld(frames[frameForTime], skip);
}
private void ApplyFrameToWorld(ReplayFrame frame, bool skip)
{
//IL_004f: 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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_019a: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
if (frame.Valid)
{
Player player = Replay.Player;
if (skip)
{
WorldHandler.instance.PlacePlayerAt(player, frame.PlayerPosition, frame.PlayerRotation, true);
player.motor._rigidbody.rotation = frame.PlayerRotation;
}
else
{
((Component)player).transform.position = frame.PlayerPosition;
}
((Component)player).transform.rotation = frame.PlayerRotation;
player.SetVelocity(frame.Velocity);
player.moveInput = frame.MoveInput;
player.jumpButtonHeld = frame.JumpButtonHeld;
player.jumpButtonNew = frame.JumpButtonNew;
player.sprayButtonHeld = frame.SprayButtonHeld;
player.sprayButtonNew = frame.SprayButtonNew;
player.trick1ButtonHeld = frame.Trick1ButtonHeld;
player.trick1ButtonNew = frame.Trick1ButtonNew;
player.trick2ButtonHeld = frame.Trick2ButtonHeld;
player.trick2ButtonNew = frame.Trick2ButtonNew;
player.trick3ButtonHeld = frame.Trick3ButtonHeld;
player.trick3ButtonNew = frame.Trick3ButtonNew;
player.slideButtonHeld = frame.SlideButtonHeld;
player.slideButtonNew = frame.SlideButtonNew;
player.danceButtonHeld = frame.DanceButtonHeld;
player.danceButtonNew = frame.DanceButtonNew;
player.boostButtonHeld = frame.BoostButtonHeld;
player.boostButtonNew = frame.BoostButtonNew;
player.switchStyleButtonHeld = frame.SwitchStyleButtonHeld;
player.switchStyleButtonNew = frame.SwitchStyleButtonNew;
player.walkButtonHeld = frame.WalkButtonHeld;
player.walkButtonNew = frame.WalkButtonNew;
player.phoneButtonNew = frame.PhoneButtonNew;
if (frame.Jump)
{
player.Jump();
}
player.jumpRequested = frame.JumpRequested;
player.moveInputPlain = frame.MoveInputPlain;
player.boostCharge = frame.BoostCharge;
player.HP = frame.HP;
player.phone.state = frame.PhoneState;
if (skip)
{
player.DropCombo();
player.SwitchToEquippedMovestyle(frame.UsingEquippedMoveStyle, false, true, false);
OnFrameSkip?.Invoke();
player.PlayAnim(frame.Animation, true, true, frame.AnimationTime);
player.StopCurrentAbility();
}
}
}
public override void End()
{
ReplayFrame frame = Replay.Frames[Replay.Frames.Count - 1];
UI.Instance.HideNotification();
ApplyFrameToWorld(frame, skip: true);
Core.Instance.GameInput.EnableControllerMap(0, 0);
Core.Instance.GameInput.EnableControllerMap(1, 0);
Core.Instance.GameInput.EnableControllerMap(2, 0);
Core.Instance.GameInput.EnableControllerMap(3, 0);
Core.Instance.GameInput.EnableControllerMap(4, 0);
Core.Instance.GameInput.EnableControllerMap(5, 0);
((Component)Core.instance.UIManager).gameObject.SetActive(true);
_replayCamera.Destroy();
Time.timeScale = 1f;
}
private void RefreshTimeScale()
{
if (_paused)
{
Time.timeScale = 0f;
}
else
{
Time.timeScale = _playbackSpeed;
}
}
public override void OnUpdate()
{
UpdatePlaybackInput();
RefreshTimeScale();
}
private void UpdatePlaybackInput()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown((KeyCode)32))
{
_paused = !_paused;
}
_playbackSpeed += Input.mouseScrollDelta.y * 0.05f;
if (_playbackSpeed <= 0f)
{
_playbackSpeed = 0f;
}
if (Input.GetKeyDown((KeyCode)114))
{
_playbackSpeed = 1f;
_paused = false;
}
if (Input.GetKeyDown((KeyCode)8))
{
_currentTime = 0f;
}
if (Input.GetKeyDown((KeyCode)104))
{
((Component)Core.instance.UIManager).gameObject.SetActive(!((Component)Core.instance.UIManager).gameObject.activeSelf);
}
if (Input.GetKeyDown((KeyCode)103))
{
((Component)UI.m_label1).gameObject.SetActive(!((Component)UI.m_label1).gameObject.activeSelf);
}
if (Input.GetKeyDown((KeyCode)48))
{
SkipTo(0f);
}
if (Input.GetKeyDown((KeyCode)49))
{
SkipTo(Replay.Length * 0.25f);
}
if (Input.GetKeyDown((KeyCode)50))
{
SkipTo(Replay.Length * 0.5f);
}
if (Input.GetKeyDown((KeyCode)51))
{
SkipTo(Replay.Length * 0.75f);
}
if (Input.GetKeyDown((KeyCode)52))
{
SkipTo(Replay.Length);
}
}
}
public class ReplayRecorder : ReplayState
{
public InputBuffer CurrentInput;
private Replay _currentReplay;
public Replay Replay => _currentReplay;
public ReplayFrame LastFrame => _currentReplay.Frames[_currentReplay.Frames.Count - 1];
public override void Start()
{
_currentReplay = new Replay(Time.fixedDeltaTime);
_currentReplay.Init();
}
public void OnPlayerInput(Player player)
{
//IL_0015: 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)
if (!((Object)(object)WorldHandler.instance.GetCurrentPlayer() != (Object)(object)player))
{
CurrentInput = player.inputBuffer;
}
}
public override void OnFixedUpdate()
{
RecordCurrentFrame();
}
private void RecordCurrentFrame()
{
//IL_0061: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_0186: 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_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: 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)
ReplayFrame replayFrame = new ReplayFrame(Replay);
replayFrame.Frame = Replay.Frames.Count;
Replay.Frames.Add(replayFrame);
if (!((Object)(object)Replay.Player == (Object)null))
{
Player player = Replay.Player;
replayFrame.Valid = true;
replayFrame.PlayerPosition = ((Component)player).transform.position;
replayFrame.PlayerRotation = ((Component)player).transform.rotation;
replayFrame.MoveInput = player.moveInput;
replayFrame.JumpButtonNew = player.jumpButtonNew;
replayFrame.JumpButtonHeld = player.jumpButtonHeld;
replayFrame.SprayButtonHeld = player.sprayButtonHeld;
replayFrame.SprayButtonNew = player.sprayButtonNew;
replayFrame.Trick1ButtonHeld = player.trick1ButtonHeld;
replayFrame.Trick1ButtonNew = player.trick1ButtonNew;
replayFrame.Trick2ButtonHeld = player.trick2ButtonHeld;
replayFrame.Trick2ButtonNew = player.trick2ButtonNew;
replayFrame.Trick3ButtonHeld = player.trick3ButtonHeld;
replayFrame.Trick3ButtonNew = player.trick3ButtonNew;
replayFrame.SlideButtonHeld = player.slideButtonHeld;
replayFrame.SlideButtonNew = player.slideButtonNew;
replayFrame.DanceButtonHeld = player.danceButtonHeld;
replayFrame.DanceButtonNew = player.danceButtonNew;
replayFrame.BoostButtonNew = player.boostButtonNew;
replayFrame.BoostButtonHeld = player.boostButtonHeld;
replayFrame.SwitchStyleButtonNew = player.switchStyleButtonNew;
replayFrame.SwitchStyleButtonHeld = player.switchStyleButtonHeld;
replayFrame.WalkButtonNew = player.walkButtonNew;
replayFrame.WalkButtonHeld = player.walkButtonHeld;
replayFrame.PhoneButtonNew = player.phoneButtonNew;
replayFrame.Velocity = player.GetVelocity();
replayFrame.JumpRequested = player.jumpRequested;
replayFrame.MoveInputPlain = player.moveInputPlain;
replayFrame.BoostCharge = player.boostCharge;
replayFrame.HP = player.HP;
replayFrame.PhoneState = player.phone.state;
replayFrame.UsingEquippedMoveStyle = player.usingEquippedMovestyle;
replayFrame.Animation = player.curAnim;
replayFrame.AnimationTime = player.anim.playbackTime;
}
}
}
public abstract class ReplayState
{
public virtual void Start()
{
}
public virtual void OnFixedUpdate()
{
}
public virtual void End()
{
}
public virtual void OnUpdate()
{
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ReplaySystem";
public const string PLUGIN_NAME = "ReplaySystem";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace ReplaySystem.Patches
{
[HarmonyPatch(typeof(GameplayUI))]
public class GameplayUIPatch
{
[HarmonyPostfix]
[HarmonyPatch("Init")]
public static void Init(GameplayUI __instance)
{
ReplayPlayer.ui = __instance;
((Component)__instance.gameplayScreen).gameObject.AddComponent<UI>();
}
}
[HarmonyPatch(typeof(Player))]
internal class PlayerPatch
{
[HarmonyPrefix]
[HarmonyPatch("UpdateRotation")]
private static void UpdateRotation_Prefix(Player __instance)
{
ReplayManager instance = ReplayManager.Instance;
if (!((Object)(object)instance == (Object)null) && !((Object)(object)WorldHandler.instance.GetCurrentPlayer() != (Object)(object)__instance))
{
instance.OnFixedUpdate();
}
}
[HarmonyPrefix]
[HarmonyPatch("Jump")]
private static void Jump_Prefix(Player __instance)
{
ReplayManager instance = ReplayManager.Instance;
if (!((Object)(object)instance == (Object)null) && !((Object)(object)WorldHandler.instance.GetCurrentPlayer() != (Object)(object)__instance) && instance.CurrentReplayState is ReplayRecorder replayRecorder)
{
ReplayFrame lastFrame = replayRecorder.LastFrame;
if (lastFrame != null)
{
lastFrame.Jump = true;
lastFrame.JumpRequested = false;
lastFrame.JumpButtonHeld = false;
lastFrame.JumpButtonNew = false;
}
}
}
}
public class UI : MonoBehaviour
{
public static UI Instance;
public static TextMeshProUGUI m_label1;
private float m_notificationTimer = 5f;
private bool m_active;
private void Awake()
{
Instance = this;
SetupLabel();
SetupLabelPause();
}
public void ShowNotification(string textbef)
{
((TMP_Text)m_label1).text = textbef;
m_notificationTimer = 5f;
((Component)m_label1).gameObject.SetActive(true);
}
public void HideNotification()
{
((Component)m_label1).gameObject.SetActive(false);
}
private void SetupLabel()
{
//IL_0005: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: 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)
m_label1 = new GameObject("EmotePrev").AddComponent<TextMeshProUGUI>();
GameplayUI value = Traverse.Create((object)Core.Instance.UIManager).Field<GameplayUI>("gameplay").Value;
TextMeshProUGUI contextLabel = value.contextLabel;
((TMP_Text)m_label1).font = ((TMP_Text)contextLabel).font;
((TMP_Text)m_label1).fontSize = 32f;
((TMP_Text)m_label1).fontMaterial = ((TMP_Text)contextLabel).fontMaterial;
((TMP_Text)m_label1).alignment = (TextAlignmentOptions)260;
RectTransform rectTransform = ((TMP_Text)m_label1).rectTransform;
rectTransform.anchorMin = new Vector2(0.1f, 0.5f);
rectTransform.anchorMax = new Vector2(0.88f, 0.97f);
rectTransform.pivot = new Vector2(0f, 1f);
rectTransform.anchoredPosition = new Vector2(1f, 0.2f);
((Transform)((TMP_Text)m_label1).rectTransform).SetParent((Transform)(object)((Component)value.gameplayScreen).GetComponent<RectTransform>(), false);
}
private void SetupLabelPause()
{
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}