Esempio n. 1
0
        // Token: 0x060012D6 RID: 4822 RVA: 0x0005C5E0 File Offset: 0x0005A7E0
        public void AttemptPing(Ray aimRay, GameObject bodyObject)
        {
            if (this.pingStock <= 0)
            {
                Chat.AddMessage(Language.GetString("PLAYER_PING_COOLDOWN"));
                return;
            }
            PingerController.PingInfo pingInfo = new PingerController.PingInfo
            {
                active = true
            };
            this.pingStock--;
            BullseyeSearch bullseyeSearch = new BullseyeSearch();

            bullseyeSearch.filterByLoS       = true;
            bullseyeSearch.maxDistanceFilter = 1000f;
            bullseyeSearch.maxAngleFilter    = 10f;
            bullseyeSearch.teamMaskFilter    = TeamMask.allButNeutral;
            bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Distance;
            bullseyeSearch.searchOrigin      = aimRay.origin;
            bullseyeSearch.searchDirection   = aimRay.direction;
            bullseyeSearch.RefreshCandidates();
            bullseyeSearch.FilterOutGameObject(bodyObject);
            HurtBox    hurtBox = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();
            RaycastHit raycastHit;

            if (hurtBox && hurtBox.healthComponent)
            {
                Transform transform = hurtBox.healthComponent.transform;
                pingInfo.origin = transform.position;
                pingInfo.targetNetworkIdentity = hurtBox.healthComponent.GetComponent <NetworkIdentity>();
            }
            else if (Util.CharacterRaycast(base.gameObject, aimRay, out raycastHit, 1000f, LayerIndex.world.mask | LayerIndex.defaultLayer.mask, QueryTriggerInteraction.Collide))
            {
                GameObject      gameObject      = raycastHit.collider.gameObject;
                NetworkIdentity networkIdentity = gameObject.GetComponentInParent <NetworkIdentity>();
                if (!networkIdentity)
                {
                    EntityLocator entityLocator = gameObject.transform.parent ? gameObject.transform.parent.GetComponentInChildren <EntityLocator>() : gameObject.GetComponent <EntityLocator>();
                    if (entityLocator)
                    {
                        gameObject      = entityLocator.entity;
                        networkIdentity = gameObject.GetComponent <NetworkIdentity>();
                    }
                }
                pingInfo.origin = raycastHit.point;
                pingInfo.normal = raycastHit.normal;
                pingInfo.targetNetworkIdentity = networkIdentity;
            }
            if (pingInfo.targetNetworkIdentity != null && pingInfo.targetNetworkIdentity == this.currentPing.targetNetworkIdentity)
            {
                pingInfo = PingerController.emptyPing;
                this.pingStock++;
            }
            this.SetCurrentPing(pingInfo);
        }
Esempio n. 2
0
        // Token: 0x06000FE2 RID: 4066 RVA: 0x00045CF4 File Offset: 0x00043EF4
        public void AttemptPing(Ray aimRay, GameObject bodyObject)
        {
            if (this.pingStock <= 0)
            {
                Chat.AddMessage(Language.GetString("PLAYER_PING_COOLDOWN"));
                return;
            }
            PingerController.PingInfo pingInfo = new PingerController.PingInfo
            {
                active = true
            };
            if (!RoR2Application.isInSinglePlayer)
            {
                this.pingStock--;
            }
            HurtBox    hurtBox = null;
            RaycastHit raycastHit;

            if (Util.CharacterRaycast(bodyObject, aimRay, out raycastHit, 1000f, LayerIndex.entityPrecise.mask | LayerIndex.world.mask, QueryTriggerInteraction.UseGlobal))
            {
                hurtBox = raycastHit.collider.GetComponent <HurtBox>();
            }
            if (hurtBox && hurtBox.healthComponent)
            {
                Transform transform = hurtBox.healthComponent.transform;
                pingInfo.origin = transform.position;
                pingInfo.targetNetworkIdentity = hurtBox.healthComponent.GetComponent <NetworkIdentity>();
            }
            else if (Util.CharacterRaycast(base.gameObject, aimRay, out raycastHit, 1000f, LayerIndex.world.mask | LayerIndex.defaultLayer.mask, QueryTriggerInteraction.Collide))
            {
                GameObject      gameObject      = raycastHit.collider.gameObject;
                NetworkIdentity networkIdentity = gameObject.GetComponentInParent <NetworkIdentity>();
                if (!networkIdentity)
                {
                    EntityLocator entityLocator = gameObject.transform.parent ? gameObject.transform.parent.GetComponentInChildren <EntityLocator>() : gameObject.GetComponent <EntityLocator>();
                    if (entityLocator)
                    {
                        gameObject      = entityLocator.entity;
                        networkIdentity = gameObject.GetComponent <NetworkIdentity>();
                    }
                }
                pingInfo.origin = raycastHit.point;
                pingInfo.normal = raycastHit.normal;
                pingInfo.targetNetworkIdentity = networkIdentity;
            }
            if (pingInfo.targetNetworkIdentity != null && pingInfo.targetNetworkIdentity == this.currentPing.targetNetworkIdentity)
            {
                pingInfo = PingerController.emptyPing;
                this.pingStock++;
            }
            this.SetCurrentPing(pingInfo);
        }
        // Token: 0x06000A6A RID: 2666 RVA: 0x0002DB1C File Offset: 0x0002BD1C
        public static GameObject GetEntity(GameObject gameObject)
        {
            if (gameObject == null)
            {
                return(null);
            }
            EntityLocator component = gameObject.GetComponent <EntityLocator>();

            if (!component)
            {
                return(null);
            }
            return(component.entity);
        }
        // Token: 0x06000D41 RID: 3393 RVA: 0x0003B944 File Offset: 0x00039B44
        public GameObject FindBestInteractableObject(Ray raycastRay, float maxRaycastDistance, Vector3 overlapPosition, float overlapRadius)
        {
            LayerMask  mask = LayerIndex.defaultLayer.mask | LayerIndex.world.mask | LayerIndex.pickups.mask;
            RaycastHit raycastHit;

            if (Physics.Raycast(raycastRay, out raycastHit, maxRaycastDistance, mask, QueryTriggerInteraction.Collide))
            {
                GameObject entity = EntityLocator.GetEntity(raycastHit.collider.gameObject);
                if (entity)
                {
                    IInteractable component = entity.GetComponent <IInteractable>();
                    if (component != null && ((MonoBehaviour)component).isActiveAndEnabled && component.GetInteractability(this) != Interactability.Disabled)
                    {
                        return(entity);
                    }
                }
            }
            Collider[] array  = Physics.OverlapSphere(overlapPosition, overlapRadius, mask, QueryTriggerInteraction.Collide);
            int        num    = array.Length;
            GameObject result = null;
            float      num2   = 0f;

            for (int i = 0; i < num; i++)
            {
                Collider   collider = array[i];
                GameObject entity2  = EntityLocator.GetEntity(collider.gameObject);
                if (entity2)
                {
                    IInteractable component2 = entity2.GetComponent <IInteractable>();
                    if (component2 != null && ((MonoBehaviour)component2).isActiveAndEnabled && component2.GetInteractability(this) != Interactability.Disabled && !component2.ShouldIgnoreSpherecastForInteractibility(this))
                    {
                        float num3 = Vector3.Dot((collider.transform.position - overlapPosition).normalized, raycastRay.direction);
                        if (num3 > num2)
                        {
                            num2   = num3;
                            result = entity2.gameObject;
                        }
                    }
                }
            }
            return(result);
        }
        // Token: 0x060006F2 RID: 1778 RVA: 0x0001D0F4 File Offset: 0x0001B2F4
        private void UpdateCrosshair(Vector3 raycastStartPlanePoint)
        {
            this.lastAimAssist = this.aimAssist;
            Vector2 zero = Vector2.zero;
            Ray     crosshairRaycastRay = this.GetCrosshairRaycastRay(zero, raycastStartPlanePoint);
            bool    flag = false;

            this.lastCrosshairHurtBox = null;
            RaycastHit raycastHit = default(RaycastHit);

            RaycastHit[] array = Physics.RaycastAll(crosshairRaycastRay, this.maxAimRaycastDistance, LayerIndex.world.mask | LayerIndex.entityPrecise.mask, QueryTriggerInteraction.Ignore);
            float        num   = float.PositiveInfinity;
            int          num2  = -1;

            for (int i = 0; i < array.Length; i++)
            {
                RaycastHit    raycastHit2 = array[i];
                HurtBox       hurtBox     = raycastHit2.collider.GetComponent <HurtBox>();
                EntityLocator component   = raycastHit2.collider.GetComponent <EntityLocator>();
                float         distance    = raycastHit2.distance;
                if (distance > 3f && num > distance)
                {
                    if (hurtBox)
                    {
                        if (hurtBox.teamIndex == this.targetTeamIndex)
                        {
                            goto IL_145;
                        }
                        if (hurtBox.healthComponent && hurtBox.healthComponent.dontShowHealthbar)
                        {
                            hurtBox = null;
                        }
                    }
                    if (component)
                    {
                        VehicleSeat vehicleSeat = component.entity ? component.entity.GetComponent <VehicleSeat>() : null;
                        if (vehicleSeat && vehicleSeat.currentPassengerBody == this.targetBody)
                        {
                            goto IL_145;
                        }
                    }
                    num  = distance;
                    num2 = i;
                    this.lastCrosshairHurtBox = hurtBox;
                }
                IL_145 :;
            }
            if (num2 != -1)
            {
                flag       = true;
                raycastHit = array[num2];
            }
            this.aimAssist.aimAssistHurtbox = null;
            if (flag)
            {
                this.crosshairWorldPosition = raycastHit.point;
                float num3 = 1000f;
                if (raycastHit.distance < num3)
                {
                    HurtBox component2 = raycastHit.collider.GetComponent <HurtBox>();
                    if (component2)
                    {
                        HealthComponent healthComponent = component2.healthComponent;
                        if (healthComponent)
                        {
                            TeamComponent component3 = healthComponent.GetComponent <TeamComponent>();
                            if (component3 && component3.teamIndex != this.targetTeamIndex && component3.teamIndex != TeamIndex.None)
                            {
                                CharacterBody body     = healthComponent.body;
                                HurtBox       hurtBox2 = (body != null) ? body.mainHurtBox : null;
                                if (hurtBox2)
                                {
                                    this.aimAssist.aimAssistHurtbox       = hurtBox2;
                                    this.aimAssist.worldPosition          = raycastHit.point;
                                    this.aimAssist.localPositionOnHurtbox = hurtBox2.transform.InverseTransformPoint(raycastHit.point);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                this.crosshairWorldPosition = crosshairRaycastRay.GetPoint(this.maxAimRaycastDistance);
            }
        }