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.Security;
using System.Security.Permissions;
using BepInEx;
using Cinemachine;
using Colossal.Entities;
using Colossal.Mathematics;
using Colossal.Serialization.Entities;
using FirstPersonCamera.MonoBehaviours;
using FirstPersonCamera.Patches;
using FirstPersonCamera.Systems;
using FirstPersonCamera.Transformer;
using FirstPersonCamera.Transformer.FinalTransforms;
using FirstPersonCamera.Transformer.Transforms;
using FirstPersonCamera.Transforms;
using Game;
using Game.Audio;
using Game.Citizens;
using Game.Common;
using Game.Creatures;
using Game.Events;
using Game.Objects;
using Game.Prefabs;
using Game.Rendering;
using Game.Simulation;
using Game.Tools;
using Game.Vehicles;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FirstPersonCamera")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+90f48069dc81b162ba12d7edebef2c74b28748ba")]
[assembly: AssemblyProduct("FirstPersonCamera")]
[assembly: AssemblyTitle("FirstPersonCamera")]
[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]
internal sealed class IsUnmanagedAttribute : Attribute
{
}
[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 FirstPersonCamera
{
internal class CameraDataModel
{
public CameraMode Mode { get; set; } = CameraMode.Disabled;
public Entity LastFollowEntity { get; set; }
public Entity FollowEntity { get; set; } = Entity.Null;
public bool IsSprinting { get; set; }
public float2 Look { get; set; }
public float2 Movement { get; set; }
public float3 Position { get; set; }
public quaternion Rotation { get; set; }
public quaternion ChildRotation { get; set; }
public float Yaw { get; set; }
public float Pitch { get; set; }
public CameraScope Scope { get; set; } = CameraScope.Default;
public VehicleType ScopeVehicle { get; set; } = VehicleType.Unknown;
public CitizenAge ScopeCitizen { get; set; }
public bool DisableEffects { get; set; }
public bool IsTransitioningIn { get; set; }
public bool IsTransitioningOut { get; set; }
public float TransitionStart { get; set; }
}
internal class CameraInput
{
private readonly CameraDataModel _model;
private List<InputAction> TemporaryActions { get; set; } = new List<InputAction>();
public Action OnToggle { get; set; }
public Action OnFollow { get; set; }
public Action OnUnfollow { get; set; }
public Action<bool> OnToggleSelectionMode { get; set; }
internal CameraInput(CameraDataModel model)
{
_model = model;
Configure();
}
private void Configure()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0019: 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_002d: 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_0041: 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)
//IL_0075: Expected O, but got Unknown
//IL_007d: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: 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_0121: Expected O, but got Unknown
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Expected O, but got Unknown
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Expected O, but got Unknown
InputAction val = new InputAction("ToggleFPSController", (InputActionType)0, (string)null, (string)null, (string)null, (string)null);
CompositeSyntax val2 = InputActionSetupExtensions.AddCompositeBinding(val, "ButtonWithOneModifier", (string)null, (string)null);
val2 = ((CompositeSyntax)(ref val2)).With("Modifier", "<Keyboard>/alt", (string)null, (string)null);
((CompositeSyntax)(ref val2)).With("Button", "<Keyboard>/f", (string)null, (string)null);
val.performed += delegate
{
Toggle();
};
val.Enable();
val = new InputAction("FPSController_Movement", (InputActionType)0, "<Gamepad>/leftStick", (string)null, (string)null, (string)null);
val2 = InputActionSetupExtensions.AddCompositeBinding(val, "Dpad", (string)null, (string)null);
val2 = ((CompositeSyntax)(ref val2)).With("Up", "<Keyboard>/w", (string)null, (string)null);
val2 = ((CompositeSyntax)(ref val2)).With("Down", "<Keyboard>/s", (string)null, (string)null);
val2 = ((CompositeSyntax)(ref val2)).With("Left", "<Keyboard>/a", (string)null, (string)null);
((CompositeSyntax)(ref val2)).With("Right", "<Keyboard>/d", (string)null, (string)null);
val.performed += delegate(CallbackContext ctx)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
_model.Movement = float2.op_Implicit(((CallbackContext)(ref ctx)).ReadValue<Vector2>());
if (_model.Mode == CameraMode.Follow)
{
OnUnfollow?.Invoke();
}
};
val.canceled += delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
_model.Movement = float2.zero;
};
val.Disable();
TemporaryActions.Add(val);
val = new InputAction("FPSController_MousePosition", (InputActionType)0, "<Mouse>/delta", (string)null, (string)null, (string)null);
val.performed += delegate(CallbackContext ctx)
{
//IL_0008: 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)
_model.Look = float2.op_Implicit(((CallbackContext)(ref ctx)).ReadValue<Vector2>());
};
val.canceled += delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
_model.Look = float2.zero;
};
val.Disable();
TemporaryActions.Add(val);
val = new InputAction("FPSController_Sprint", (InputActionType)0, (string)null, (string)null, (string)null, (string)null);
InputActionSetupExtensions.AddBinding(val, "<Keyboard>/leftShift", (string)null, (string)null, (string)null);
val.performed += delegate
{
_model.IsSprinting = true;
};
val.canceled += delegate
{
_model.IsSprinting = false;
};
val.Disable();
TemporaryActions.Add(val);
val = new InputAction("FPSController_RightClick", (InputActionType)0, "<Mouse>/rightButton", (string)null, (string)null, (string)null);
val.performed += delegate
{
RightClick(isDown: true);
};
val.canceled += delegate
{
RightClick(isDown: false);
};
val.Disable();
TemporaryActions.Add(val);
val = new InputAction("FPSController_Escape", (InputActionType)0, "<Keyboard>/escape", (string)null, (string)null, (string)null);
val.performed += delegate
{
Disable();
OnToggle?.Invoke();
};
val.Disable();
TemporaryActions.Add(val);
}
private void Enable()
{
//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)
_model.Mode = ((!(_model.FollowEntity != Entity.Null)) ? CameraMode.Manual : CameraMode.Follow);
foreach (InputAction temporaryAction in TemporaryActions)
{
temporaryAction.Enable();
}
}
private void Disable()
{
foreach (InputAction temporaryAction in TemporaryActions)
{
temporaryAction.Disable();
}
}
private void Toggle()
{
if (!_model.IsTransitioningIn && !_model.IsTransitioningOut)
{
if (_model.Mode != 0)
{
Disable();
}
else
{
Enable();
}
OnToggle?.Invoke();
}
}
private void RightClick(bool isDown)
{
if (!isDown && _model.Mode != 0)
{
OnFollow?.Invoke();
}
OnToggleSelectionMode?.Invoke(isDown);
}
}
internal enum CameraMode
{
Disabled,
Manual,
Follow
}
internal class CameraRaycaster
{
private readonly EntityManager _entityManager;
private readonly ToolRaycastSystem _raycastSystem;
internal CameraRaycaster()
{
//IL_0010: 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)
World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
_entityManager = defaultGameObjectInjectionWorld.EntityManager;
_raycastSystem = defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<ToolRaycastSystem>();
}
public bool TryRaycast(out RaycastResult hitInfo)
{
//IL_0010: 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_0019: Unknown result type (might be due to invalid IL or missing references)
int result;
if (_raycastSystem.GetRaycastResult(ref hitInfo))
{
EntityManager entityManager = _entityManager;
result = ((!((EntityManager)(ref entityManager)).HasComponent<Deleted>(hitInfo.m_Owner)) ? 1 : 0);
}
else
{
result = 0;
}
return (byte)result != 0;
}
}
internal enum CameraScope
{
Default,
Citizen,
Pet,
UnknownVehicle,
Car,
Truck,
Van,
Train,
Airplane,
Helicopter,
Building
}
internal class EntityFollower
{
private readonly CameraDataModel _model;
private readonly EntityManager _entityManager;
internal EntityFollower(CameraDataModel model)
{
//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)
_model = model;
_entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
}
private void Filter()
{
//IL_0002: 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_0037: 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_005b: 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_008d: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00c8: 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_00e3: 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_0101: Unknown result type (might be due to invalid IL or missing references)
DynamicBuffer<TargetElement> val = default(DynamicBuffer<TargetElement>);
if (EntitiesExtensions.TryGetBuffer<TargetElement>(_entityManager, _model.FollowEntity, true, ref val) && val.Length > 0)
{
_model.FollowEntity = val[0].m_Entity;
}
if (TryGetComponent<CurrentTransport>(out CurrentTransport component))
{
_model.FollowEntity = component.m_CurrentTransport;
}
if (HasComponent<Unspawned>())
{
Resident component3;
CurrentBuilding component4;
Pet component5;
CurrentBuilding component6;
if (TryGetComponent<CurrentVehicle>(out CurrentVehicle component2))
{
_model.FollowEntity = component2.m_Vehicle;
}
else if (TryGetComponent<Resident>(out component3) && TryGetComponent<CurrentBuilding>(component3.m_Citizen, out component4))
{
_model.FollowEntity = component4.m_CurrentBuilding;
}
else if (TryGetComponent<Pet>(out component5) && TryGetComponent<CurrentBuilding>(component5.m_HouseholdPet, out component6))
{
_model.FollowEntity = component6.m_CurrentBuilding;
}
}
}
private bool HasComponent<T>() where T : unmanaged, IComponentData
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = _entityManager;
return ((EntityManager)(ref entityManager)).HasComponent<T>(_model.FollowEntity);
}
private bool TryGetComponent<T>(out T component) where T : unmanaged, IComponentData
{
//IL_0002: 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)
return EntitiesExtensions.TryGetComponent<T>(_entityManager, _model.FollowEntity, ref component);
}
private bool TryGetComponent<T>(Entity entity, out T component) where T : unmanaged, IComponentData
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return EntitiesExtensions.TryGetComponent<T>(_entityManager, entity, ref component);
}
private Transform GetObjectPosition(Entity entity, Transform transform, out Bounds3 bounds)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_005a: 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_0043: 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_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)
//IL_004f: 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_005e: Unknown result type (might be due to invalid IL or missing references)
bounds = new Bounds3(transform.m_Position, transform.m_Position);
PrefabRef val = default(PrefabRef);
ObjectGeometryData val2 = default(ObjectGeometryData);
if (EntitiesExtensions.TryGetComponent<PrefabRef>(_entityManager, entity, ref val) && EntitiesExtensions.TryGetComponent<ObjectGeometryData>(_entityManager, val.m_Prefab, ref val2))
{
bounds = ObjectUtils.CalculateBounds(transform.m_Position, transform.m_Rotation, val2);
}
return transform;
}
private Transform GetInterpolatedPosition(Entity entity, DynamicBuffer<TransformFrame> transformFrames, out Bounds3 bounds)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_0021: 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_0033: 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_0050: 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_005c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = _entityManager;
RenderingSystem orCreateSystemManaged = ((EntityManager)(ref entityManager)).World.GetOrCreateSystemManaged<RenderingSystem>();
entityManager = _entityManager;
UpdateFrame sharedComponent = ((EntityManager)(ref entityManager)).GetSharedComponent<UpdateFrame>(entity);
uint num = default(uint);
uint num2 = default(uint);
float num3 = default(float);
ObjectInterpolateSystem.CalculateUpdateFrames(orCreateSystemManaged.frameIndex, orCreateSystemManaged.frameTime, sharedComponent.m_Index, ref num, ref num2, ref num3);
InterpolatedTransform val = ObjectInterpolateSystem.CalculateTransform(transformFrames[(int)num], transformFrames[(int)num2], num3);
return GetObjectPosition(entity, ((InterpolatedTransform)(ref val)).ToTransform(), out bounds);
}
private Transform GetRelativePosition(Entity entity, Relative relative, out Bounds3 bounds)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_0011: 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_0017: 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)
//IL_0034: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0044: 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_004c: 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_007d: 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_0063: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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)
//IL_0099: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = _entityManager;
Transform transform = ((EntityManager)(ref entityManager)).GetComponentData<Transform>(entity);
Entity val = Entity.Null;
Owner component2;
if (TryGetComponent<CurrentVehicle>(entity, out CurrentVehicle component))
{
val = component.m_Vehicle;
}
else if (TryGetComponent<Owner>(entity, out component2))
{
val = component2.m_Owner;
}
DynamicBuffer<TransformFrame> transformFrames = default(DynamicBuffer<TransformFrame>);
Transform component3;
if (EntitiesExtensions.TryGetBuffer<TransformFrame>(_entityManager, val, true, ref transformFrames))
{
transform = ObjectUtils.LocalToWorld(GetInterpolatedPosition(val, transformFrames, out var _), ((Relative)(ref relative)).ToTransform());
}
else if (TryGetComponent<Transform>(val, out component3))
{
transform = ObjectUtils.LocalToWorld(component3, ((Relative)(ref relative)).ToTransform());
}
return GetObjectPosition(entity, transform, out bounds);
}
public bool TryGetPosition(out float3 position, out Bounds3 bounds, out quaternion rotation)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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)
//IL_001e: 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_006f: 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_0042: 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_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_0050: 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_0056: 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_005d: 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_00c1: 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_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_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_00a3: 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_00aa: 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_00b2: 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_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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: 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)
position = default(float3);
bounds = default(Bounds3);
rotation = default(quaternion);
Filter();
DynamicBuffer<TransformFrame> transformFrames = default(DynamicBuffer<TransformFrame>);
Relative relative = default(Relative);
Transform transform = default(Transform);
if (EntitiesExtensions.TryGetBuffer<TransformFrame>(_entityManager, _model.FollowEntity, true, ref transformFrames))
{
Transform interpolatedPosition = GetInterpolatedPosition(_model.FollowEntity, transformFrames, out bounds);
position = interpolatedPosition.m_Position;
rotation = interpolatedPosition.m_Rotation;
}
else if (EntitiesExtensions.TryGetComponent<Relative>(_entityManager, _model.FollowEntity, ref relative))
{
Transform relativePosition = GetRelativePosition(_model.FollowEntity, relative, out bounds);
position = relativePosition.m_Position;
rotation = relativePosition.m_Rotation;
}
else if (EntitiesExtensions.TryGetComponent<Transform>(_entityManager, _model.FollowEntity, ref transform))
{
Transform objectPosition = GetObjectPosition(_model.FollowEntity, transform, out bounds);
position = objectPosition.m_Position;
rotation = objectPosition.m_Rotation;
}
return true;
}
public bool TryGetPosition(out float3 position)
{
//IL_0002: 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)
//IL_001b: 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_0061: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_0044: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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_0080: 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_0089: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00c7: 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_00d0: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
position = default(float3);
Filter();
DynamicBuffer<TransformFrame> transformFrames = default(DynamicBuffer<TransformFrame>);
Bounds3 bounds;
Relative relative = default(Relative);
Transform transform = default(Transform);
if (EntitiesExtensions.TryGetBuffer<TransformFrame>(_entityManager, _model.FollowEntity, true, ref transformFrames))
{
Transform interpolatedPosition = GetInterpolatedPosition(_model.FollowEntity, transformFrames, out bounds);
position = interpolatedPosition.m_Position;
}
else if (EntitiesExtensions.TryGetComponent<Relative>(_entityManager, _model.FollowEntity, ref relative))
{
Transform relativePosition = GetRelativePosition(_model.FollowEntity, relative, out bounds);
position = relativePosition.m_Position;
}
else if (EntitiesExtensions.TryGetComponent<Transform>(_entityManager, _model.FollowEntity, ref transform))
{
Transform objectPosition = GetObjectPosition(_model.FollowEntity, transform, out bounds);
position = objectPosition.m_Position;
}
return true;
}
public bool TryGetRotation(out quaternion rotation, Entity entity = default(Entity))
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_003b: 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_0064: 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_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)
//IL_0093: 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_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_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_0082: 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_0089: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: 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_00b2: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00e0: 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_00e8: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
rotation = default(quaternion);
Entity val = ((entity != default(Entity)) ? entity : _model.FollowEntity);
Filter();
InterpolatedTransform val2 = default(InterpolatedTransform);
DynamicBuffer<TransformFrame> transformFrames = default(DynamicBuffer<TransformFrame>);
Bounds3 bounds;
Relative relative = default(Relative);
Transform transform = default(Transform);
if (EntitiesExtensions.TryGetComponent<InterpolatedTransform>(_entityManager, _model.FollowEntity, ref val2))
{
rotation = val2.m_Rotation;
}
else if (EntitiesExtensions.TryGetBuffer<TransformFrame>(_entityManager, val, true, ref transformFrames))
{
Transform interpolatedPosition = GetInterpolatedPosition(val, transformFrames, out bounds);
rotation = interpolatedPosition.m_Rotation;
}
else if (EntitiesExtensions.TryGetComponent<Relative>(_entityManager, val, ref relative))
{
Transform relativePosition = GetRelativePosition(val, relative, out bounds);
rotation = relativePosition.m_Rotation;
}
else if (EntitiesExtensions.TryGetComponent<Transform>(_entityManager, val, ref transform))
{
Transform objectPosition = GetObjectPosition(val, transform, out bounds);
rotation = objectPosition.m_Rotation;
}
return true;
}
}
[BepInPlugin("FirstPersonCamera", "FirstPersonCamera", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
Harmony val = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "FirstPersonCamera_Cities2Harmony");
MethodBase[] array = val.GetPatchedMethods().ToArray();
((BaseUnityPlugin)this).Logger.LogInfo((object)"=================================================================");
((BaseUnityPlugin)this).Logger.LogInfo((object)"FirstPersonCamera by Cities2Modding community.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"=================================================================");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Reddit link: https://www.reddit.com/r/cities2modding/");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Discord link: https://discord.gg/KGRNBbm5Fh");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Our mods are officially distributed via Thunderstore.io and https://github.com/Cities2Modding");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Example mod repository and modding info: https://github.com/optimus-code/Cities2Modding");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Thanks to Captain_Of_Coit, 89pleasure, Rebecca, optimus-code and the Cites2Modding community!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"=================================================================");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin FirstPersonCamera is loaded! Patched methods: " + array.Length));
MethodBase[] array2 = array;
foreach (MethodBase methodBase in array2)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched method: " + methodBase.Module.Name + ":" + methodBase.Name));
}
}
}
[Flags]
internal enum VehicleType : long
{
Unknown = 0L,
PersonalCar = 1L,
PostVan = 2L,
PoliceVan = 4L,
PoliceCar = 8L,
MaintenanceVehicle = 0x10L,
Ambulance = 0x20L,
GarbageTruck = 0x40L,
FireEngine = 0x80L,
DeliveryTruck = 0x100L,
Hearse = 0x200L,
CargoTransport = 0x400L,
Taxi = 0x800L,
CarTrailer = 0x1000L,
Helicopter = 0x2000L,
Cars = 0xA09L,
Vans = 0x36L,
Trucks = 0x5C0L
}
internal class VirtualCameraRig
{
private const float TRANSITION_DAMPEN = 3.5f;
public Action<bool> OnTransitionComplete;
private readonly CameraDataModel _model;
private readonly Transform _target;
private readonly CinemachineVirtualCamera _virtualCamera;
private readonly CameraUpdateSystem _cameraUpdateSystem;
private quaternion startRotation;
private float3 startPosition;
private float startFOV;
public Transform Parent => _target;
public Transform CameraTransform { get; private set; }
public Transform RigTransform { get; private set; }
public VirtualCameraRig(CameraDataModel model, Transform target)
{
//IL_002e: 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_0063: Unknown result type (might be due to invalid IL or missing references)
_model = model;
World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
_cameraUpdateSystem = defaultGameObjectInjectionWorld.GetExistingSystemManaged<CameraUpdateSystem>();
_target = target;
RigTransform = new GameObject("FirstPersonCamera_SubObject").transform;
RigTransform.parent = target;
RigTransform.position = target.position;
CameraTransform = new GameObject("FirstPersonCamera_VCam").transform;
_virtualCamera = ((Component)CameraTransform).gameObject.AddComponent<CinemachineVirtualCamera>();
((CinemachineVirtualCameraBase)_virtualCamera).Follow = target;
Configure();
}
private void Configure()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_009e: 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_00d1: 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_00ed: 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)
CinemachineVirtualCamera val = (CinemachineVirtualCamera)_cameraUpdateSystem.orbitCameraController.virtualCamera;
_virtualCamera.m_Lens = val.m_Lens;
((CinemachineVirtualCameraBase)_virtualCamera).Priority = 0;
_virtualCamera.m_Lens.NearClipPlane = 0.03f;
startFOV = val.m_Lens.FieldOfView;
_virtualCamera.m_Lens.FieldOfView = startFOV;
CameraTransform.position = ((Component)_cameraUpdateSystem.activeCamera).transform.position;
Parent.position = CameraTransform.position;
_model.Position = float3.op_Implicit(Parent.position);
_model.Rotation = quaternion.op_Implicit(Parent.rotation);
_model.ChildRotation = quaternion.op_Implicit(RigTransform.localRotation);
}
public void Update(bool noLerp = false)
{
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: 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_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)
//IL_0063: 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_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_009a: 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_00bc: 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_00d1: 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_0109: 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_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: 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_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: 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)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
if (_model.IsTransitioningIn || _model.IsTransitioningOut)
{
if (_model.IsTransitioningIn)
{
Parent.position = Vector3.Lerp(Parent.position, float3.op_Implicit(_model.Position), 3.5f * Time.deltaTime);
Parent.rotation = Quaternion.Lerp(Parent.rotation, quaternion.op_Implicit(_model.Rotation), 3.5f * Time.deltaTime);
RigTransform.localRotation = Quaternion.Lerp(RigTransform.localRotation, quaternion.op_Implicit(_model.ChildRotation), 3.5f * Time.deltaTime);
((Component)CameraTransform).transform.position = RigTransform.position;
((Component)CameraTransform).transform.rotation = RigTransform.rotation;
_virtualCamera.m_Lens.FieldOfView = math.lerp(_virtualCamera.m_Lens.FieldOfView, 70f, 3.5f * Time.deltaTime);
if (Vector3.Distance(Parent.position, float3.op_Implicit(_model.Position)) <= 0.125f)
{
_model.IsTransitioningIn = false;
OnTransitionComplete?.Invoke(obj: false);
}
}
else if (_model.IsTransitioningOut)
{
Parent.position = Vector3.Lerp(Parent.position, float3.op_Implicit(startPosition), 3.5f * Time.deltaTime);
Parent.rotation = Quaternion.Lerp(Parent.rotation, quaternion.op_Implicit(startRotation), 3.5f * Time.deltaTime);
RigTransform.localRotation = Quaternion.Lerp(RigTransform.localRotation, Quaternion.identity, 3.5f * Time.deltaTime);
((Component)CameraTransform).transform.position = RigTransform.position;
((Component)CameraTransform).transform.rotation = RigTransform.rotation;
_virtualCamera.m_Lens.FieldOfView = math.lerp(_virtualCamera.m_Lens.FieldOfView, startFOV, 3.5f * Time.deltaTime);
if (Vector3.Distance(Parent.position, float3.op_Implicit(startPosition)) <= 0.125f)
{
_model.IsTransitioningOut = false;
((CinemachineVirtualCameraBase)_virtualCamera).Priority = 0;
OnTransitionComplete?.Invoke(obj: true);
}
}
}
else
{
if (!noLerp)
{
Parent.position = Vector3.Lerp(Parent.position, float3.op_Implicit(_model.Position), 10f * Time.deltaTime);
}
else
{
Parent.position = float3.op_Implicit(_model.Position);
}
Parent.rotation = Quaternion.Lerp(Parent.rotation, quaternion.op_Implicit(_model.Rotation), 12f * Time.deltaTime);
RigTransform.localRotation = Quaternion.Lerp(RigTransform.localRotation, quaternion.op_Implicit(_model.ChildRotation), 12f * Time.deltaTime);
((Component)CameraTransform).transform.position = RigTransform.position;
((Component)CameraTransform).transform.rotation = RigTransform.rotation;
}
}
public void SetActive(bool isActive)
{
//IL_003a: 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_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_005a: 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_007d: Unknown result type (might be due to invalid IL or missing references)
if (_model.IsTransitioningIn)
{
((CinemachineVirtualCameraBase)_virtualCamera).Priority = 99999;
}
if (isActive)
{
Camera activeCamera = _cameraUpdateSystem.activeCamera;
startRotation = quaternion.op_Implicit(((Component)activeCamera).transform.rotation);
startPosition = float3.op_Implicit(((Component)activeCamera).transform.position);
Parent.position = float3.op_Implicit(startPosition);
_model.Position = startPosition;
}
}
public void UpdateNearClipPlane(float nearClipPlane = 0.03f)
{
_virtualCamera.m_Lens.NearClipPlane = nearClipPlane;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "FirstPersonCamera";
public const string PLUGIN_NAME = "FirstPersonCamera";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace FirstPersonCamera.Transformer
{
internal interface IFinalCameraTransform
{
void Apply(VirtualCameraRig rig, CameraDataModel model);
}
}
namespace FirstPersonCamera.Transformer.Transforms
{
internal class Breathing : ICameraTransform
{
public float breathingFrequency = 0.5f;
public float breathingAmplitude = 0.001f;
private float breathingTimer = 0f;
public void Apply(CameraDataModel model)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0083: 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)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if (!model.IsTransitioningIn && !model.IsTransitioningOut)
{
if (model.Movement.x == 0f && model.Movement.y == 0f)
{
breathingTimer += Time.deltaTime;
float num = Mathf.Sin(breathingTimer * breathingFrequency) * breathingAmplitude;
float3 position = model.Position;
quaternion childRotation = model.ChildRotation;
position.y += num;
model.Position = position;
float num2 = Mathf.Sin(breathingTimer * breathingFrequency) * breathingAmplitude;
Quaternion val = quaternion.op_Implicit(childRotation);
Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles;
eulerAngles.x += num2;
model.ChildRotation = quaternion.op_Implicit(Quaternion.Euler(eulerAngles));
}
else
{
breathingTimer = 0f;
}
}
}
}
internal class HeadBob : ICameraTransform
{
public float bobFrequency = 1.3f;
public float bobVerticalAmplitude = 0.02f;
public float bobbingSpeed = 10f;
private float bobTimer = 0f;
public void Apply(CameraDataModel model)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0091: Unknown result type (might be due to invalid IL or missing references)
if (!model.IsTransitioningIn && !model.IsTransitioningOut)
{
if (model.Movement.x != 0f || model.Movement.y != 0f)
{
bobTimer += Time.deltaTime * bobbingSpeed;
float num = Mathf.Sin(bobTimer * bobFrequency) * bobVerticalAmplitude;
float3 position = model.Position;
position.y += num;
model.Position = position;
}
else
{
bobTimer = 0f;
}
}
}
}
internal class MouseLook : ICameraTransform
{
public float sensitivity = 0.005f;
public void Apply(CameraDataModel model)
{
//IL_0017: 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_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_0098: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
bool flag = model.IsTransitioningIn || model.IsTransitioningOut;
float num = (flag ? 0f : (model.Look.x * sensitivity));
float num2 = (flag ? 0f : (model.Look.y * sensitivity));
model.Yaw += num;
model.Pitch -= num2;
model.Pitch = math.clamp(model.Pitch, -MathF.PI / 2f, MathF.PI / 2f);
model.Rotation = quaternion.AxisAngle(float3.op_Implicit(Vector3.up), model.Yaw);
model.ChildRotation = quaternion.AxisAngle(float3.op_Implicit(Vector3.right), model.Pitch);
}
}
internal class Sway : ICameraTransform
{
public float swayFrequency = 0.05f;
public float swayAmplitude = 0.0005f;
private float swayTimer = 0f;
public void Apply(CameraDataModel model)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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)
if (!model.IsTransitioningIn && !model.IsTransitioningOut)
{
if (model.Movement.x == 0f && model.Movement.y == 0f)
{
swayTimer += Time.deltaTime;
float num = Mathf.Cos(swayTimer * swayFrequency) * swayAmplitude;
float num2 = Mathf.Sin(swayTimer * swayFrequency) * swayAmplitude;
float3 position = model.Position;
position.x += num;
position.y += num2;
model.Position = position;
}
else
{
swayTimer = 0f;
}
}
}
}
}
namespace FirstPersonCamera.Transformer.FinalTransforms
{
internal class FollowEntityFinalTransform : IFinalCameraTransform
{
private float3 offset;
private Entity lastFollow;
private readonly EntityFollower _entityFollower;
public FollowEntityFinalTransform(EntityFollower entityFollower)
{
_entityFollower = entityFollower;
}
public void Apply(VirtualCameraRig rig, CameraDataModel model)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_005a: 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_0065: 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_0070: 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)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: 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_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)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: 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_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_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: 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_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_0122: 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_003f: Unknown result type (might be due to invalid IL or missing references)
if (_entityFollower.TryGetPosition(out var position, out var bounds, out var rotation))
{
if (lastFollow != model.FollowEntity)
{
lastFollow = model.FollowEntity;
GrabOffset(model);
}
quaternion val = default(quaternion);
((quaternion)(ref val))..ctor(rotation.value.x, rotation.value.y, rotation.value.z, rotation.value.w);
float3 val2 = math.mul(val, new float3(0f, 0f, 1f));
float3 val3 = default(float3);
((float3)(ref val3))..ctor(0f, (((Bounds3)(ref bounds)).y.max - ((Bounds3)(ref bounds)).y.min) / 2f + offset.y, 0f);
val3 += val2 * ((bounds.max.z - bounds.min.z) * offset.z);
model.Position = position + val3;
model.Rotation = math.mul(val, model.Rotation);
}
}
private void GrabOffset(CameraDataModel model)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
offset = GetOffset(model);
}
private float3 GetOffset(CameraDataModel model)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_0027: 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_002b: 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)
//IL_0044: Expected I4, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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)
float num = 0.25f;
float num2 = 0.5f;
CameraScope scope = model.Scope;
switch (scope)
{
case CameraScope.Citizen:
{
CitizenAge scopeCitizen = model.ScopeCitizen;
CitizenAge val = scopeCitizen;
CitizenAge val2 = val;
switch ((int)val2)
{
case 0:
num2 = 0.25f;
break;
case 1:
num2 = 0.4f;
break;
case 2:
case 3:
num2 = 0.75f;
break;
}
break;
}
case CameraScope.Truck:
num = 0.53f;
num2 = 0.52f;
break;
case CameraScope.Van:
num = 0.385f;
num2 = 0.5f;
break;
case CameraScope.Car:
num = 0.3f;
num2 = 0.475f;
break;
case CameraScope.UnknownVehicle:
num = 0.25f;
num2 = 0.5f;
break;
case CameraScope.Pet:
num2 = 0.35f;
break;
default:
if (scope == CameraScope.UnknownVehicle && model.ScopeVehicle == VehicleType.Helicopter)
{
num2 = 0f;
num = 0.01f;
}
break;
}
return new float3(0f, num2, num);
}
}
internal class ManualFinalTransform : IFinalCameraTransform
{
public float movementSpeed = 0.1f;
public float runSpeed = 0.35f;
private TerrainSystem _terrainSystem;
public void Apply(VirtualCameraRig rig, CameraDataModel model)
{
//IL_0011: 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_003d: 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_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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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_012e: 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_011e: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: 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_009f: 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_00c8: 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_00c0: 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_00c6: 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_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_015a: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: 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_0108: Unknown result type (might be due to invalid IL or missing references)
float yOffset = GetYOffset(rig);
float3 val = default(float3);
((float3)(ref val))..ctor(rig.RigTransform.right.x, 0f, rig.RigTransform.right.z);
float3 val2 = default(float3);
((float3)(ref val2))..ctor(rig.RigTransform.forward.x, 0f, rig.RigTransform.forward.z);
float3 val3 = float3.zero;
if (!model.IsTransitioningIn && !model.IsTransitioningOut)
{
if (model.Movement.x > 0f)
{
val3 += val;
}
else if (model.Movement.x < 0f)
{
val3 -= val;
}
if (model.Movement.y > 0f)
{
val3 += val2;
}
else if (model.Movement.y < 0f)
{
val3 -= val2;
}
}
if (math.length(val3) > 0f)
{
val3 = math.normalize(val3);
}
float3 position = model.Position;
position += val3 * (model.IsSprinting ? runSpeed : movementSpeed);
position.y = yOffset;
model.Position = position;
}
private float GetYOffset(VirtualCameraRig rig)
{
//IL_0021: 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_002f: 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)
try
{
if (_terrainSystem == null)
{
_terrainSystem = World.DefaultGameObjectInjectionWorld.GetExistingSystemManaged<TerrainSystem>();
}
TerrainHeightData heightData = _terrainSystem.GetHeightData(true);
return TerrainUtils.SampleHeight(ref heightData, float3.op_Implicit(rig.Parent.position)) + 1.7f;
}
catch (NullReferenceException)
{
return 0f;
}
}
}
}
namespace FirstPersonCamera.Transforms
{
internal class CameraTransformer
{
public Action OnScopeChanged;
private readonly VirtualCameraRig _rig;
private readonly CameraDataModel _model;
private readonly ManualFinalTransform _manualFinalTransform;
private readonly FollowEntityFinalTransform _followEntityFinalTransform;
private readonly EntityFollower _entityFollower;
private readonly EntityManager _entityManager;
private List<ICameraTransform> Transforms { get; set; } = new List<ICameraTransform>();
private ICameraTransform CoreTransform { get; set; }
private IFinalCameraTransform FinalTransform { get; set; }
internal CameraTransformer(VirtualCameraRig rig, CameraDataModel model)
{
//IL_0054: 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)
_rig = rig;
_model = model;
_manualFinalTransform = new ManualFinalTransform();
_entityFollower = new EntityFollower(_model);
_followEntityFinalTransform = new FollowEntityFinalTransform(_entityFollower);
_entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
FinalTransform = _manualFinalTransform;
AddTransforms();
UpdateEffectToggle();
OrbitCameraController_FollowedEntityPatch.OnFollowChanged = delegate(Entity entity)
{
//IL_0007: 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_002f: 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_0051: 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_0080: 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)
//IL_0097: 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_0128: 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_0157: 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)
//IL_013a: 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_00d8: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
_model.FollowEntity = entity;
_model.Mode = ((_model.Mode != 0) ? ((_model.FollowEntity == Entity.Null) ? CameraMode.Manual : CameraMode.Follow) : CameraMode.Disabled);
IFinalCameraTransform finalTransform;
if (!(_model.FollowEntity == Entity.Null))
{
IFinalCameraTransform followEntityFinalTransform = _followEntityFinalTransform;
finalTransform = followEntityFinalTransform;
}
else
{
IFinalCameraTransform followEntityFinalTransform = _manualFinalTransform;
finalTransform = followEntityFinalTransform;
}
FinalTransform = finalTransform;
quaternion rotation2;
if (_model.LastFollowEntity != Entity.Null && _model.FollowEntity == Entity.Null && _model.Mode == CameraMode.Manual)
{
if (_entityFollower.TryGetRotation(out var rotation, _model.LastFollowEntity))
{
float3x3 val = default(float3x3);
((float3x3)(ref val))..ctor(rotation);
float num = math.atan2(((float3)(ref ((float3x3)(ref val))[0]))[2], ((float3)(ref ((float3x3)(ref val))[2]))[2]);
_model.Yaw -= num;
}
}
else if ((_model.LastFollowEntity == Entity.Null || _model.LastFollowEntity != _model.FollowEntity) && _model.FollowEntity != Entity.Null && _model.Mode == CameraMode.Follow && _entityFollower.TryGetRotation(out rotation2, _model.FollowEntity))
{
_model.Yaw = 0f;
}
_model.Scope = DetermineScope();
UpdateEffectToggle();
OnScopeChanged?.Invoke();
_model.LastFollowEntity = _model.FollowEntity;
};
}
private void AddTransforms()
{
Transforms.Add(new HeadBob());
Transforms.Add(new Breathing());
Transforms.Add(new Sway());
CoreTransform = new MouseLook();
}
public void Apply()
{
if (!_model.DisableEffects)
{
foreach (ICameraTransform transform in Transforms)
{
transform.Apply(_model);
}
}
CoreTransform.Apply(_model);
FinalTransform?.Apply(_rig, _model);
}
private void UpdateEffectToggle()
{
_model.DisableEffects = _model.Mode == CameraMode.Disabled || _model.Scope != CameraScope.Citizen;
}
private CameraScope DetermineScope()
{
//IL_0007: 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_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_0052: 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)
if (_model.FollowEntity == Entity.Null)
{
return CameraScope.Default;
}
if (CheckForCitizenScope(out var citizenAge))
{
_model.ScopeCitizen = citizenAge;
return CameraScope.Citizen;
}
EntityManager entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<Pet>(_model.FollowEntity))
{
return CameraScope.Pet;
}
if (CheckForVehicleScope(out var vehicleType))
{
bool flag = (vehicleType & VehicleType.Cars) != 0;
bool flag2 = (vehicleType & VehicleType.Vans) != 0;
bool flag3 = (vehicleType & VehicleType.Trucks) != 0;
_model.ScopeVehicle = vehicleType;
return flag3 ? CameraScope.Truck : (flag2 ? CameraScope.Van : (flag ? CameraScope.Car : CameraScope.UnknownVehicle));
}
return CameraScope.Default;
}
private bool CheckForCitizenScope(out CitizenAge citizenAge)
{
//IL_0005: 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)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_003a: 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_0057: Expected I4, but got Unknown
citizenAge = (CitizenAge)1;
Resident val = default(Resident);
Citizen val2 = default(Citizen);
if (EntitiesExtensions.TryGetComponent<Resident>(_entityManager, _model.FollowEntity, ref val) && val.m_Citizen != Entity.Null && EntitiesExtensions.TryGetComponent<Citizen>(_entityManager, val.m_Citizen, ref val2))
{
citizenAge = (CitizenAge)(int)((Citizen)(ref val2)).GetAge();
return true;
}
return false;
}
private bool CheckForVehicleScope(out VehicleType vehicleType)
{
//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)
//IL_0014: 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)
//IL_001c: 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)
//IL_0038: 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_0054: 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_005c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_009b: 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_00bd: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: 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_0102: 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_0125: 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_0145: 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_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: 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_0189: 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_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: 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_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_01d7: Unknown result type (might be due to invalid IL or missing references)
vehicleType = VehicleType.Unknown;
Entity followEntity = _model.FollowEntity;
bool result = false;
EntityManager entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<Helicopter>(followEntity))
{
vehicleType = VehicleType.Helicopter;
result = true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<CarTrailer>(followEntity))
{
vehicleType = VehicleType.CarTrailer;
result = true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<Vehicle>(followEntity))
{
vehicleType = VehicleType.Unknown;
result = true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<PersonalCar>(followEntity))
{
vehicleType = VehicleType.PersonalCar;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<PostVan>(followEntity))
{
vehicleType = VehicleType.PersonalCar;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<PoliceCar>(followEntity))
{
vehicleType = VehicleType.PoliceCar;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<MaintenanceVehicle>(followEntity))
{
vehicleType = VehicleType.MaintenanceVehicle;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<Ambulance>(followEntity))
{
vehicleType = VehicleType.Ambulance;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<GarbageTruck>(followEntity))
{
vehicleType = VehicleType.GarbageTruck;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<FireEngine>(followEntity))
{
vehicleType = VehicleType.FireEngine;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<DeliveryTruck>(followEntity))
{
vehicleType = VehicleType.DeliveryTruck;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<Hearse>(followEntity))
{
vehicleType = VehicleType.Hearse;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<CargoTransport>(followEntity))
{
vehicleType = VehicleType.CargoTransport;
return true;
}
entityManager = _entityManager;
if (((EntityManager)(ref entityManager)).HasComponent<Taxi>(followEntity))
{
vehicleType = VehicleType.Taxi;
return true;
}
return result;
}
}
internal interface ICameraTransform
{
void Apply(CameraDataModel model);
}
}
namespace FirstPersonCamera.Systems
{
public class FirstPersonCameraSystem : GameSystemBase
{
private RenderingSystem _renderingSystem;
private ToolRaycastSystem _toolRaycastSystem;
private ToolSystem _toolSystem;
private FirstPersonCameraController Controller { get; set; }
private bool IsRaycastingOverridden { get; set; }
protected override void OnCreate()
{
((GameSystemBase)this).OnCreate();
Debug.Log((object)"FirstPersonCamera loaded!");
_renderingSystem = ((ComponentSystemBase)this).World.GetExistingSystemManaged<RenderingSystem>();
_toolSystem = ((ComponentSystemBase)this).World.GetExistingSystemManaged<ToolSystem>();
_toolRaycastSystem = ((ComponentSystemBase)this).World.GetExistingSystemManaged<ToolRaycastSystem>();
CreateOrGetController();
}
protected override void OnUpdate()
{
}
public void UpdateCamera()
{
Controller.UpdateCamera();
}
private void CreateOrGetController()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("FirstPersonCameraController");
if ((Object)(object)val != (Object)null)
{
Controller = val.GetComponent<FirstPersonCameraController>();
}
else
{
Controller = new GameObject("FirstPersonCameraController").AddComponent<FirstPersonCameraController>();
}
}
public void ToggleUI(bool hidden)
{
//IL_0049: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
_renderingSystem.hideOverlay = hidden;
if (hidden)
{
ToolRaycastSystem toolRaycastSystem = _toolRaycastSystem;
toolRaycastSystem.raycastFlags = (RaycastFlags)(toolRaycastSystem.raycastFlags | 8);
_toolSystem.activeTool = (ToolBaseSystem)(object)((ComponentSystemBase)this).World.GetExistingSystemManaged<DefaultToolSystem>();
}
else
{
ToolRaycastSystem toolRaycastSystem2 = _toolRaycastSystem;
toolRaycastSystem2.raycastFlags = (RaycastFlags)(toolRaycastSystem2.raycastFlags & -9);
}
}
public void ToggleRaycasting(bool isEnabled)
{
//IL_002f: 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_0018: 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)
IsRaycastingOverridden = !isEnabled;
if (isEnabled)
{
ToolRaycastSystem toolRaycastSystem = _toolRaycastSystem;
toolRaycastSystem.raycastFlags = (RaycastFlags)(toolRaycastSystem.raycastFlags & -9);
}
else
{
ToolRaycastSystem toolRaycastSystem2 = _toolRaycastSystem;
toolRaycastSystem2.raycastFlags = (RaycastFlags)(toolRaycastSystem2.raycastFlags | 8);
}
}
protected override void OnDestroy()
{
((GameSystemBase)this).OnDestroy();
if ((Object)(object)Controller != (Object)null)
{
Object.Destroy((Object)(object)((Component)Controller).gameObject);
Controller = null;
}
}
}
}
namespace FirstPersonCamera.Patches
{
[HarmonyPatch(typeof(CameraUpdateSystem), "OnUpdate")]
internal class CameraUpdateSystem_Patch
{
private static void Prefix(CameraUpdateSystem __instance)
{
((ComponentSystemBase)__instance).World.GetExistingSystemManaged<FirstPersonCameraSystem>()?.UpdateCamera();
}
}
[HarmonyPatch(typeof(AudioManager), "OnGameLoadingComplete")]
internal class EntryPoint_Patch
{
private static void Postfix(AudioManager __instance, Purpose purpose, GameMode mode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (GameModeExtensions.IsGame(mode) && !GameModeExtensions.IsEditor(mode))
{
((ComponentSystemBase)__instance).World.GetOrCreateSystemManaged<FirstPersonCameraSystem>();
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class OrbitCameraController_FollowedEntityPatch
{
public static Action<Entity> OnFollowChanged;
public static void Postfix(Entity value)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
OnFollowChanged?.Invoke(value);
}
}
[HarmonyPatch(typeof(OrbitCameraController), "UpdateCamera")]
internal class OrbitCameraController_UpdateCameraPatch
{
public static bool overrideUpdate;
public static bool Prefix()
{
return !overrideUpdate;
}
}
}
namespace FirstPersonCamera.MonoBehaviours
{
public class FirstPersonCameraController : MonoBehaviour
{
private FirstPersonCameraSystem _firstPersonCameraSystem;
private TerrainSystem terrainSystem;
private RenderingSystem renderingSystem;
private float storedLODScale;
private float storedAmbienceVolume;
private readonly CameraDataModel _model;
private readonly CameraInput _input;
private readonly CameraTransformer _transformer;
private readonly VirtualCameraRig _rig;
private readonly CameraRaycaster _raycaster;
private readonly CameraUpdateSystem _cameraUpdateSystem;
private bool IsActive { get; set; }
public FirstPersonCameraController()
{
_model = new CameraDataModel();
_input = new CameraInput(_model);
_rig = new VirtualCameraRig(_model, ((Component)this).transform);
_transformer = new CameraTransformer(_rig, _model);
_raycaster = new CameraRaycaster();
World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
_cameraUpdateSystem = defaultGameObjectInjectionWorld.GetExistingSystemManaged<CameraUpdateSystem>();
terrainSystem = defaultGameObjectInjectionWorld.GetExistingSystemManaged<TerrainSystem>();
renderingSystem = defaultGameObjectInjectionWorld.GetOrCreateSystemManaged<RenderingSystem>();
_firstPersonCameraSystem = defaultGameObjectInjectionWorld.GetExistingSystemManaged<FirstPersonCameraSystem>();
SetupEvents();
}
private void SetupEvents()
{
_input.OnToggle = Toggle;
_input.OnFollow = delegate
{
FollowTrigger(follow: true);
};
_input.OnUnfollow = delegate
{
FollowTrigger(follow: false);
};
_input.OnToggleSelectionMode = _firstPersonCameraSystem.ToggleRaycasting;
_rig.OnTransitionComplete = OnTransitionComplete;
_transformer.OnScopeChanged = OnScopeChanged;
}
private void Start()
{
Object.DontDestroyOnLoad((Object)(object)this);
}
public void UpdateCamera()
{
if (terrainSystem != null && IsActive)
{
InternalUpdate();
}
}
private void InternalUpdate()
{
//IL_0038: 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)
_transformer.Apply();
_rig.Update(_model.Mode == CameraMode.Follow);
AudioManager instance = AudioManager.instance;
if (instance != null)
{
instance.UpdateAudioListener(((Component)this).transform.position, _rig.RigTransform.rotation);
}
}
private void Toggle()
{
if (_model.IsTransitioningIn)
{
OnTransitionComplete(isTransitionOut: false);
}
else if (_model.IsTransitioningOut)
{
OnTransitionComplete(isTransitionOut: true);
}
bool flag = !IsActive;
_model.IsTransitioningIn = flag;
_model.IsTransitioningOut = !flag;
if (_model.IsTransitioningIn)
{
IsActive = true;
}
if (_model.IsTransitioningIn)
{
Debug.Log((object)"IsTransitioningIn");
}
else if (_model.IsTransitioningOut)
{
Debug.Log((object)"IsTransitioningOut");
}
_rig.SetActive(flag);
if (flag)
{
Cursor.lockState = (CursorLockMode)1;
storedLODScale = renderingSystem.levelOfDetail;
renderingSystem.levelOfDetail = storedLODScale * 0.85f;
storedAmbienceVolume = AudioManager.instance.ambienceVolume;
AudioManager.instance.ambienceVolume = storedAmbienceVolume * 0.35f;
_cameraUpdateSystem.orbitCameraController.inputEnabled = false;
OrbitCameraController_UpdateCameraPatch.overrideUpdate = true;
_firstPersonCameraSystem.ToggleUI(IsActive);
}
else
{
OrbitCameraController_UpdateCameraPatch.overrideUpdate = false;
}
}
private void FollowTrigger(bool follow)
{
//IL_0023: 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_0054: Unknown result type (might be due to invalid IL or missing references)
if (follow && _raycaster.TryRaycast(out var hitInfo))
{
_cameraUpdateSystem.orbitCameraController.followedEntity = hitInfo.m_Owner;
}
else if (!follow && _model.Mode == CameraMode.Follow)
{
_cameraUpdateSystem.orbitCameraController.followedEntity = Entity.Null;
}
}
private void OnScopeChanged()
{
CameraScope scope = _model.Scope;
CameraScope cameraScope = scope;
if (cameraScope == CameraScope.Citizen)
{
_rig.UpdateNearClipPlane(0.3f);
}
else
{
_rig.UpdateNearClipPlane();
}
}
private void OnTransitionComplete(bool isTransitionOut)
{
if (isTransitionOut)
{
Cursor.lockState = (CursorLockMode)0;
renderingSystem.levelOfDetail = storedLODScale;
_cameraUpdateSystem.orbitCameraController.inputEnabled = true;
_firstPersonCameraSystem.ToggleUI(hidden: false);
IsActive = false;
_model.Mode = CameraMode.Disabled;
}
}
}
}