Exemple #1
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        public void Awake()
        {
            On.RoR2.PickupPickerController.CreatePickup_PickupIndex += delegate(On.RoR2.PickupPickerController.orig_CreatePickup_PickupIndex orig, RoR2.PickupPickerController self, RoR2.PickupIndex PickupIndex)
            {
                orig.Invoke(self, PickupIndex);
                Time.timeScale = 1f;
            };
            On.RoR2.UI.PickupPickerPanel.Awake += delegate(On.RoR2.UI.PickupPickerPanel.orig_Awake orig, RoR2.UI.PickupPickerPanel self)
            {
                MethodInfo methodCached = Reflection.GetMethodCached(typeof(RoR2.CharacterMaster), "ToggleGod");
                bool       flag         = true;
                foreach (RoR2.PlayerCharacterMasterController playerCharacterMasterController in RoR2.PlayerCharacterMasterController.instances)
                {
                    methodCached.Invoke(playerCharacterMasterController.master, null);
                    bool flag2 = flag;
                    if (flag2)
                    {
                        flag = false;
                    }
                }

                //RoR2.CharacterBody.AddBuff(RoR2.LocalUserManager.GetFirstLocalUser ,RoR2.RoR2Content.Buffs.Cloak);
                RoR2.LocalUser     user = RoR2.LocalUserManager.GetFirstLocalUser();
                RoR2.CharacterBody body = user.cachedBody;
                body.AddBuff(RoR2.RoR2Content.Buffs.Cloak);
                orig.Invoke(self);
            };
            On.RoR2.PickupPickerController.OnDisplayEnd += delegate(On.RoR2.PickupPickerController.orig_OnDisplayEnd orig, RoR2.PickupPickerController self, RoR2.NetworkUIPromptController NetworkUIPromptController, RoR2.LocalUser LocalUser, RoR2.CameraRigController CameraRigController)
            {
                orig.Invoke(self, NetworkUIPromptController, LocalUser, CameraRigController);
                new WaitForSeconds(5);
                MethodInfo methodCached = Reflection.GetMethodCached(typeof(RoR2.CharacterMaster), "ToggleGod");
                bool       flag         = false;
                foreach (RoR2.PlayerCharacterMasterController playerCharacterMasterController in RoR2.PlayerCharacterMasterController.instances)
                {
                    methodCached.Invoke(playerCharacterMasterController.master, null);
                    bool flag2 = flag;
                    if (flag2)
                    {
                        flag = false;
                    }
                }
                //base.characterBody.RemoveBuff(RoR2.RoR2Content.Buffs.CloakSpeed);
                RoR2.LocalUser     user = RoR2.LocalUserManager.GetFirstLocalUser();
                RoR2.CharacterBody body = user.cachedBody;
                body.RemoveBuff(RoR2.RoR2Content.Buffs.Cloak);
            };
        }
Exemple #2
0
            void SubmitChoice(On.RoR2.PickupPickerController.orig_SubmitChoice orig, RoR2.PickupPickerController pickupPickerController, int integer)
            {
                if (Data.modEnabled)
                {
                    if (Data.mode == DataShop.mode)
                    {
                        System.Type type = typeof(RoR2.PickupPickerController);
                        System.Reflection.FieldInfo info = type.GetField("options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                        ICollection collection           = info.GetValue(pickupPickerController) as ICollection;
                        int         index = 0;
                        foreach (object item in collection)
                        {
                            if (index == integer)
                            {
                                RoR2.PickupPickerController.Option option = (RoR2.PickupPickerController.Option)item;
                                ItemIndex itemIndex = RoR2.PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex;

                                RoR2.NetworkUIPromptController promptController = pickupPickerController.GetComponent <RoR2.NetworkUIPromptController>();
                                type = typeof(RoR2.NetworkUIPromptController);
                                info = type.GetField("_currentLocalParticipant", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                                RoR2.LocalUser localUser = (RoR2.LocalUser)info.GetValue(promptController);
                                foreach (NetworkUser networkUser in RoR2.NetworkUser.readOnlyInstancesList)
                                {
                                    if (localUser.currentNetworkUser.netId == networkUser.netId)
                                    {
                                        if (networkUser.isLocalPlayer)
                                        {
                                            DataShop.RemoveScrap(Data.GetItemTier(Data.allItemsIndexes[itemIndex]), Mathf.Min(DataShop.purchaseCost, networkUser.GetCurrentBody().inventory.GetItemCount(itemIndex)));
                                        }
                                        break;
                                    }
                                }
                                break;
                            }
                            index += 1;
                        }
                    }
                    orig(pickupPickerController, integer);
                }
                ;
            }
Exemple #3
0
        private static void HandlePickupMessage(NetworkMessage netMsg)
        {
            Debug.Log("GenericPickupController.HandlePickupMessage: Received pickup message.");
            ReadOnlyCollection <NotificationQueue> readOnlyInstancesList = NotificationQueue.readOnlyInstancesList;

            GenericPickupController.PickupMessage pickupMessage = GenericPickupController.pickupMessageInstance;
            netMsg.ReadMessage <GenericPickupController.PickupMessage>(pickupMessage);
            GameObject  masterGameObject = pickupMessage.masterGameObject;
            PickupIndex pickupIndex      = pickupMessage.pickupIndex;
            uint        pickupQuantity   = pickupMessage.pickupQuantity;

            pickupMessage.Reset();
            if (!masterGameObject)
            {
                Debug.Log("GenericPickupController.HandlePickupMessage: failed! masterObject is not valid.");
                return;
            }
            CharacterMaster component = masterGameObject.GetComponent <CharacterMaster>();

            if (!component)
            {
                Debug.Log("GenericPickupController.HandlePickupMessage: failed! master component is not valid.");
                return;
            }
            PlayerCharacterMasterController component2 = component.GetComponent <PlayerCharacterMasterController>();

            if (component2)
            {
                NetworkUser networkUser = component2.networkUser;
                if (networkUser)
                {
                    LocalUser localUser = networkUser.localUser;
                    if (localUser != null)
                    {
                        localUser.userProfile.DiscoverPickup(pickupIndex);
                    }
                }
            }
            for (int i = 0; i < readOnlyInstancesList.Count; i++)
            {
                readOnlyInstancesList[i].OnPickup(component, pickupIndex);
            }
            CharacterBody body = component.GetBody();

            if (!body)
            {
                Debug.Log("GenericPickupController.HandlePickupMessage: failed! characterBody is not valid.");
            }
            ItemDef itemDef = ItemCatalog.GetItemDef(pickupIndex.itemIndex);

            if (itemDef != null && itemDef.hidden)
            {
                Debug.LogFormat("GenericPickupController.HandlePickupMessage: skipped item {0}, marked hidden.", new object[]
                {
                    itemDef.nameToken
                });
                return;
            }
            Chat.AddPickupMessage(body, pickupIndex.GetPickupNameToken(), pickupIndex.GetPickupColor(), pickupQuantity);
            if (body)
            {
                Util.PlaySound("Play_UI_item_pickup", body.gameObject);
            }
        }
        // Token: 0x060006EB RID: 1771 RVA: 0x0001C2F0 File Offset: 0x0001A4F0
        private void Update()
        {
            if (Time.deltaTime == 0f)
            {
                return;
            }
            if (this.target != this.previousTarget)
            {
                this.previousTarget = this.target;
                Action <CameraRigController, GameObject> action = CameraRigController.onCameraTargetChanged;
                if (action != null)
                {
                    action(this, this.target);
                }
            }
            this.lerpCameraTime   += Time.deltaTime * this.lerpCameraTimeScale;
            this.firstPersonTarget = null;
            float num = this.baseFov;

            this.sceneCam.rect = this.viewport;
            Player      player      = null;
            UserProfile userProfile = null;
            bool        flag        = false;

            if (this.viewer && this.viewer.localUser != null)
            {
                player      = this.viewer.localUser.inputPlayer;
                userProfile = this.viewer.localUser.userProfile;
                flag        = this.viewer.localUser.isUIFocused;
            }
            if (this.cameraMode == CameraRigController.CameraMode.SpectateUser && player != null)
            {
                if (player.GetButtonDown("PrimarySkill"))
                {
                    this.target = CameraRigController.GetNextSpectateGameObject(this.viewer, this.target);
                }
                if (player.GetButtonDown("SecondarySkill"))
                {
                    this.target = CameraRigController.GetPreviousSpectateGameObject(this.viewer, this.target);
                }
            }
            LocalUser     localUserViewer = this.localUserViewer;
            MPEventSystem mpeventSystem   = (localUserViewer != null) ? localUserViewer.eventSystem : null;
            float         num14;
            float         num15;

            if ((!mpeventSystem || !mpeventSystem.isCursorVisible) && player != null && userProfile != null && !flag && (!(UnityEngine.Object) this.overrideCam || this.overrideCam.AllowUserLook(this)))
            {
                float   mouseLookSensitivity = userProfile.mouseLookSensitivity;
                float   num2 = userProfile.stickLookSensitivity * CameraRigController.aimStickGlobalScale.value * 45f;
                Vector2 vector = new Vector2(player.GetAxisRaw(2), player.GetAxisRaw(3));
                Vector2 vector2 = new Vector2(player.GetAxisRaw(16), player.GetAxisRaw(17));
                CameraRigController.< Update > g__ConditionalNegate | 70_0 (ref vector.x, userProfile.mouseLookInvertX);
                CameraRigController.< Update > g__ConditionalNegate | 70_0 (ref vector.y, userProfile.mouseLookInvertY);
                CameraRigController.< Update > g__ConditionalNegate | 70_0 (ref vector2.x, userProfile.stickLookInvertX);
                CameraRigController.< Update > g__ConditionalNegate | 70_0 (ref vector2.y, userProfile.stickLookInvertY);
                float magnitude = vector2.magnitude;
                float num3      = magnitude;
                this.aimStickPostSmoothing = Vector2.zero;
                this.aimStickPostDualZone  = Vector2.zero;
                this.aimStickPostExponent  = Vector2.zero;
                if (CameraRigController.aimStickDualZoneSmoothing.value != 0f)
                {
                    float maxDelta = Time.deltaTime / CameraRigController.aimStickDualZoneSmoothing.value;
                    num3 = Mathf.Min(Mathf.MoveTowards(this.stickAimPreviousAcceleratedMagnitude, magnitude, maxDelta), magnitude);
                    this.stickAimPreviousAcceleratedMagnitude = num3;
                    this.aimStickPostSmoothing = ((magnitude != 0f) ? (vector2 * (num3 / magnitude)) : Vector2.zero);
                }
                float num4  = num3;
                float value = CameraRigController.aimStickDualZoneSlope.value;
                float num5;
                if (num4 <= CameraRigController.aimStickDualZoneThreshold.value)
                {
                    num5 = 0f;
                }
                else
                {
                    num5 = 1f - value;
                }
                num3 = value * num4 + num5;
                this.aimStickPostDualZone = ((magnitude != 0f) ? (vector2 * (num3 / magnitude)) : Vector2.zero);
                num3 = Mathf.Pow(num3, CameraRigController.aimStickExponent.value);
                this.aimStickPostExponent = ((magnitude != 0f) ? (vector2 * (num3 / magnitude)) : Vector2.zero);
                if (magnitude != 0f)
                {
                    vector2 *= num3 / magnitude;
                }
                if (this.cameraMode == CameraRigController.CameraMode.PlayerBasic && this.targetBody && !this.targetBody.isSprinting)
                {
                    AimAssistTarget exists     = null;
                    AimAssistTarget exists2    = null;
                    float           value2     = CameraRigController.aimStickAssistMinSize.value;
                    float           num6       = value2 * CameraRigController.aimStickAssistMaxSize.value;
                    float           value3     = CameraRigController.aimStickAssistMaxSlowdownScale.value;
                    float           value4     = CameraRigController.aimStickAssistMinSlowdownScale.value;
                    float           num7       = 0f;
                    float           value5     = 0f;
                    float           num8       = 0f;
                    Vector2         v          = Vector2.zero;
                    Vector2         zero       = Vector2.zero;
                    Vector2         normalized = vector2.normalized;
                    Vector2         vector3    = new Vector2(0.5f, 0.5f);
                    for (int i = 0; i < AimAssistTarget.instancesList.Count; i++)
                    {
                        AimAssistTarget aimAssistTarget = AimAssistTarget.instancesList[i];
                        if (aimAssistTarget.teamComponent.teamIndex != this.targetTeamIndex)
                        {
                            Vector3 vector4 = this.sceneCam.WorldToViewportPoint(aimAssistTarget.point0.position);
                            Vector3 vector5 = this.sceneCam.WorldToViewportPoint(aimAssistTarget.point1.position);
                            float   num9    = Mathf.Lerp(vector4.z, vector5.z, 0.5f);
                            if (num9 > 3f)
                            {
                                float   num10   = 1f / num9;
                                Vector2 vector6 = Util.ClosestPointOnLine(vector4, vector5, vector3) - vector3;
                                float   num11   = Mathf.Clamp01(Util.Remap(vector6.magnitude, value2 * aimAssistTarget.assistScale * num10, num6 * aimAssistTarget.assistScale * num10, 1f, 0f));
                                float   num12   = Mathf.Clamp01(Vector3.Dot(vector6, vector2.normalized));
                                float   num13   = num12 * num11;
                                if (num7 < num11)
                                {
                                    num7    = num11;
                                    exists2 = aimAssistTarget;
                                }
                                if (num13 > num8)
                                {
                                    num7   = num11;
                                    value5 = num12;
                                    exists = aimAssistTarget;
                                    v      = vector6;
                                }
                            }
                        }
                    }
                    Vector2 vector7 = vector2;
                    if (exists2)
                    {
                        float magnitude2 = vector2.magnitude;
                        float d          = Mathf.Clamp01(Util.Remap(1f - num7, 0f, 1f, value3, value4));
                        vector7 *= d;
                    }
                    if (exists)
                    {
                        vector7 = Vector3.RotateTowards(vector7, v, Util.Remap(value5, 1f, 0f, CameraRigController.aimStickAssistMaxDelta.value, CameraRigController.aimStickAssistMinDelta.value), 0f);
                    }
                    vector2 = vector7;
                }
                num14 = vector.x * mouseLookSensitivity * userProfile.mouseLookScaleX + vector2.x * num2 * userProfile.stickLookScaleX * Time.deltaTime;
                num15 = vector.y * mouseLookSensitivity * userProfile.mouseLookScaleY + vector2.y * num2 * userProfile.stickLookScaleY * Time.deltaTime;
            }
            else
            {
                num14 = 0f;
                num15 = 0f;
            }
            NetworkUser         networkUser         = Util.LookUpBodyNetworkUser(this.target);
            NetworkedViewAngles networkedViewAngles = null;

            if (networkUser)
            {
                networkedViewAngles = networkUser.GetComponent <NetworkedViewAngles>();
            }
            this.targetTeamIndex = TeamIndex.None;
            bool flag2 = false;

            this.targetParams = null;
            if (this.target)
            {
                this.targetBody = this.target.GetComponent <CharacterBody>();
                if (this.targetBody)
                {
                    flag2 = this.targetBody.isSprinting;
                    if (this.targetBody.currentVehicle)
                    {
                        this.targetParams = this.targetBody.currentVehicle.GetComponent <CameraTargetParams>();
                    }
                }
                if (!this.targetParams)
                {
                    this.targetParams = this.target.GetComponent <CameraTargetParams>();
                }
                TeamComponent component = this.target.GetComponent <TeamComponent>();
                if (component)
                {
                    this.targetTeamIndex = component.teamIndex;
                }
            }
            Vector3 vector8 = this.desiredCameraState.position;

            if (this.targetParams)
            {
                Vector3 position            = this.target.transform.position;
                Vector3 cameraPivotPosition = this.targetParams.cameraPivotPosition;
                if (this.targetParams.dontRaycastToPivot)
                {
                    vector8 = cameraPivotPosition;
                }
                else
                {
                    Vector3 direction = cameraPivotPosition - position;
                    Ray     ray       = new Ray(position, direction);
                    float   distance  = this.Raycast(ray, direction.magnitude, this.targetParams.cameraParams.wallCushion);
                    vector8 = ray.GetPoint(distance);
                }
            }
            if (this.cameraMode == CameraRigController.CameraMode.PlayerBasic || this.cameraMode == CameraRigController.CameraMode.SpectateUser)
            {
                float   min = -89.9f;
                float   max = 89.9f;
                Vector3 idealLocalCameraPos = new Vector3(0f, 0f, 0f);
                float   wallCushion         = 0.1f;
                Vector2 vector9             = Vector2.zero;
                if (this.targetParams)
                {
                    min = this.targetParams.cameraParams.minPitch;
                    max = this.targetParams.cameraParams.maxPitch;
                    idealLocalCameraPos = this.targetParams.idealLocalCameraPos;
                    wallCushion         = this.targetParams.cameraParams.wallCushion;
                    vector9             = this.targetParams.recoil;
                    if (this.targetParams.aimMode == CameraTargetParams.AimType.FirstPerson)
                    {
                        this.firstPersonTarget = this.target;
                    }
                    if (this.targetParams.fovOverride >= 0f)
                    {
                        num    = this.targetParams.fovOverride;
                        num14 *= num / this.baseFov;
                        num15 *= num / this.baseFov;
                    }
                    if (this.targetBody && flag2 && CameraRigController.enableSprintSensitivitySlowdown.value)
                    {
                        num14 *= 0.5f;
                        num15 *= 0.5f;
                    }
                }
                if (this.sprintingParticleSystem)
                {
                    ParticleSystem.MainModule main = this.sprintingParticleSystem.main;
                    if (flag2)
                    {
                        main.loop = true;
                        if (!this.sprintingParticleSystem.isPlaying)
                        {
                            this.sprintingParticleSystem.Play();
                        }
                    }
                    else
                    {
                        main.loop = false;
                    }
                }
                if (this.cameraMode == CameraRigController.CameraMode.PlayerBasic)
                {
                    float num16 = this.pitch - num15;
                    float num17 = this.yaw + num14;
                    num16     += vector9.y;
                    num17     += vector9.x;
                    this.pitch = Mathf.Clamp(num16, min, max);
                    this.yaw   = Mathf.Repeat(num17, 360f);
                }
                else if (this.cameraMode == CameraRigController.CameraMode.SpectateUser && this.target)
                {
                    if (networkedViewAngles)
                    {
                        this.SetPitchYaw(networkedViewAngles.viewAngles);
                    }
                    else
                    {
                        InputBankTest component2 = this.target.GetComponent <InputBankTest>();
                        if (component2)
                        {
                            this.SetPitchYawFromLookVector(component2.aimDirection);
                        }
                    }
                }
                this.desiredCameraState.rotation = Quaternion.Euler(this.pitch, this.yaw, 0f);
                Vector3 direction2 = vector8 + this.desiredCameraState.rotation * idealLocalCameraPos - vector8;
                float   num18      = direction2.magnitude;
                float   num19      = (1f + this.pitch / -90f) * 0.5f;
                num18 *= Mathf.Sqrt(1f - num19);
                if (num18 < 0.25f)
                {
                    num18 = 0.25f;
                }
                float a = this.Raycast(new Ray(vector8, direction2), num18, wallCushion);
                this.currentCameraDistance       = Mathf.Min(a, Mathf.SmoothDamp(this.currentCameraDistance, a, ref this.cameraDistanceVelocity, 0.5f));
                this.desiredCameraState.position = vector8 + direction2.normalized * this.currentCameraDistance;
                this.pitch -= vector9.y;
                this.yaw   -= vector9.x;
                if (networkedViewAngles && networkedViewAngles.hasEffectiveAuthority)
                {
                    networkedViewAngles.viewAngles = new PitchYawPair(this.pitch, this.yaw);
                }
            }
            if (this.targetBody)
            {
                num *= (this.targetBody.isSprinting ? 1.3f : 1f);
            }
            this.desiredCameraState.fov = Mathf.SmoothDamp(this.desiredCameraState.fov, num, ref this.fovVelocity, 0.2f, float.PositiveInfinity, Time.deltaTime);
            if (this.hud)
            {
                CharacterMaster targetMaster = this.targetBody ? this.targetBody.master : null;
                this.hud.targetMaster = targetMaster;
            }
            this.UpdateCrosshair(vector8);
            CameraState cameraState = this.desiredCameraState;

            if (this.overrideCam != null)
            {
                if ((UnityEngine.Object) this.overrideCam)
                {
                    this.overrideCam.GetCameraState(this, ref cameraState);
                }
                this.overrideCam = null;
            }
            if (this.lerpCameraTime >= 1f)
            {
                this.currentCameraState = cameraState;
            }
            else
            {
                this.currentCameraState = CameraState.Lerp(ref this.lerpCameraState, ref cameraState, CameraRigController.RemapLerpTime(this.lerpCameraTime));
            }
            this.SetCameraState(this.currentCameraState);
        }