public static RaycastInfo OriginalRaycast(Ray ray, float range, int mask)
        {
            RaycastHit hit;

            PhysicsUtility.raycast(ray, out hit, range, mask, QueryTriggerInteraction.UseGlobal);
            RaycastInfo raycastInfo = new RaycastInfo(hit);

            raycastInfo.direction = ray.direction;
            if (raycastInfo.transform != null)
            {
                if (raycastInfo.transform.CompareTag("Barricade"))
                {
                    raycastInfo.transform = DamageTool.getBarricadeRootTransform(raycastInfo.transform);
                }

                else if (raycastInfo.transform.CompareTag("Structure"))
                {
                    raycastInfo.transform = DamageTool.getStructureRootTransform(raycastInfo.transform);
                }

                if (raycastInfo.transform.CompareTag("Enemy"))
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                }

                if (raycastInfo.transform.CompareTag("Zombie"))
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }

                if (raycastInfo.transform.CompareTag("Animal"))
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }

                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);

                if (raycastInfo.transform.CompareTag("Vehicle"))
                {
                    raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
                }

                if (raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive)
                {
                    raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                }
                else
                {
                    raycastInfo.material = DamageTool.getMaterial(hit.point, raycastInfo.transform, raycastInfo.collider);
                }
            }
            return(raycastInfo);
        }
 public RaycastResult(RaycastHit Info, bool hit)
 {
     RaycastHit = hit;
     if (hit)
     {
         Raycast = Info;
         Vehicle = TryGetEntity <InteractableVehicle>();
         Transform target = Raycast.collider?.transform;
         if (target != null)
         {
             if (target.CompareTag("Barricade"))
             {
                 target = DamageTool.getBarricadeRootTransform(target);
                 BarricadeRootTransform = target;
                 if (BarricadeManager.tryGetInfo(target, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion Region, out BarricadeDrop Drop))
                 {
                     BarricadeRegion = Region;
                     BarricadeX      = x;
                     BarricadeY      = y;
                     BarricadePlant  = plant;
                     BarricadeIndex  = index;
                     BarricadeData B = Region.barricades.FirstOrDefault(D => D.instanceID == Drop.instanceID);
                     if (B != null)
                     {
                         Barricade = B;
                     }
                 }
             }
             else if (target.CompareTag("Structure"))
             {
                 target = DamageTool.getStructureRootTransform(target);
                 StructureRootTransform = target;
                 if (StructureManager.tryGetInfo(target, out byte x, out byte y, out ushort index, out StructureRegion Region))
                 {
                     StructureX      = x;
                     StructureY      = y;
                     StructureIndex  = index;
                     StructureRegion = Region;
                     StructureData B = Region.structures[index];
                     if (B != null)
                     {
                         Structure = B;
                     }
                 }
             }
         }
     }
 }
Example #3
0
        public static RaycastInfo GenerateOriginalRaycast(Ray ray, float range, int mask)
        {
            PhysicsUtility.raycast(ray, out RaycastHit hit, range, mask, QueryTriggerInteraction.UseGlobal);
            RaycastInfo raycastInfo = new RaycastInfo(hit)
            {
                direction = ray.direction
            };

            if (hit.transform == null)
            {
                return(raycastInfo);
            }

            if (raycastInfo.transform.CompareTag("Barricade"))
            {
                raycastInfo.transform = DamageTool.getBarricadeRootTransform(raycastInfo.transform);
            }

            else if (raycastInfo.transform.CompareTag("Structure"))
            {
                raycastInfo.transform = DamageTool.getStructureRootTransform(raycastInfo.transform);
            }

            if (raycastInfo.transform.CompareTag("Enemy"))
            {
                raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
            }

            if (raycastInfo.transform.CompareTag("Zombie"))
            {
                raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
            }

            if (raycastInfo.transform.CompareTag("Animal"))
            {
                raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
            }

            raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);

            if (RaycastOptions.UseCustomLimb)
            {
                raycastInfo.limb = RaycastOptions.TargetLimb;
            }

            else if (RaycastOptions.UseRandomLimb)
            {
                ELimb[] Limbs = (ELimb[])Enum.GetValues(typeof(ELimb));
                raycastInfo.limb = Limbs[MathUtilities.Random.Next(0, Limbs.Length)];
            }

            if (raycastInfo.transform.CompareTag("Vehicle"))
            {
                raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
            }

            if (raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive)
            {
                raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
            }
            else
            {
                raycastInfo.material = DamageTool.getMaterial(hit.point, raycastInfo.transform, raycastInfo.collider);
            }

            return(raycastInfo);
        }
        // Token: 0x06000094 RID: 148 RVA: 0x000068DC File Offset: 0x00004ADC
        public static RaycastInfo GenerateOriginalRaycast(Ray ray, float range, int mask)
        {
            RaycastHit hit;

            PhysicsUtility.raycast(ray, out hit, range, mask, QueryTriggerInteraction.UseGlobal);
            RaycastInfo raycastInfo = new RaycastInfo(hit);

            raycastInfo.direction = ray.direction;
            bool        flag = !(raycastInfo.transform == null);
            RaycastInfo result;

            if (flag)
            {
                bool flag2 = raycastInfo.transform.CompareTag("Barricade");
                if (flag2)
                {
                    raycastInfo.transform = DamageTool.getBarricadeRootTransform(raycastInfo.transform);
                }
                else
                {
                    bool flag3 = raycastInfo.transform.CompareTag("Structure");
                    if (flag3)
                    {
                        raycastInfo.transform = DamageTool.getStructureRootTransform(raycastInfo.transform);
                    }
                }
                bool flag4 = raycastInfo.transform.CompareTag("Enemy");
                if (flag4)
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                }
                bool flag5 = raycastInfo.transform.CompareTag("Zombie");
                if (flag5)
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }
                bool flag6 = raycastInfo.transform.CompareTag("Animal");
                if (flag6)
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }
                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);
                bool flag7 = !RaycastOptions.UseRandomLimb;
                if (flag7)
                {
                    bool useCustomLimb = RaycastOptions.UseCustomLimb;
                    if (useCustomLimb)
                    {
                        raycastInfo.limb = RaycastOptions.TargetLimb;
                    }
                }
                else
                {
                    ELimb[] array = (ELimb[])Enum.GetValues(typeof(ELimb));
                    raycastInfo.limb = array[MathUtilities.Random.Next(0, array.Length)];
                }
                bool flag8 = raycastInfo.transform.CompareTag("Vehicle");
                if (flag8)
                {
                    raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
                }
                else
                {
                    bool flag9 = raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive;
                    if (flag9)
                    {
                        raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                    }
                    else
                    {
                        raycastInfo.material = DamageTool.getMaterial(hit.point, raycastInfo.transform, raycastInfo.collider);
                    }
                }
                bool alwaysHitHead = RaycastOptions.AlwaysHitHead;
                if (alwaysHitHead)
                {
                    raycastInfo.limb = ELimb.SKULL;
                }
                result = raycastInfo;
            }
            else
            {
                result = raycastInfo;
            }
            return(result);
        }
Example #5
0
        // Token: 0x06000237 RID: 567 RVA: 0x000152E4 File Offset: 0x000134E4
        public static RaycastInfo GenerateOriginalRaycast(Ray ray, float range, int mask, Player ignorePlayer = null)
        {
            RaycastHit hit;

            PhysicsUtility.raycast(ray, out hit, range, mask, QueryTriggerInteraction.UseGlobal);
            RaycastInfo raycastInfo = new RaycastInfo(hit)
            {
                direction = ray.direction
            };

            if (!(raycastInfo.transform == null))
            {
                if (!raycastInfo.transform.CompareTag("Barricade"))
                {
                    if (raycastInfo.transform.CompareTag("Structure"))
                    {
                        raycastInfo.transform = DamageTool.getStructureRootTransform(raycastInfo.transform);
                    }
                }
                else
                {
                    raycastInfo.transform = DamageTool.getBarricadeRootTransform(raycastInfo.transform);
                }
                if (raycastInfo.transform.CompareTag("Enemy"))
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                    if (raycastInfo.player == ignorePlayer)
                    {
                        raycastInfo.player = null;
                    }
                }
                if (raycastInfo.transform.CompareTag("Zombie"))
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }
                if (raycastInfo.transform.CompareTag("Animal"))
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }
                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);
                if (!RaycastOptions.UseRandomLimb)
                {
                    if (RaycastOptions.UseCustomLimb)
                    {
                        raycastInfo.limb = RaycastOptions.TargetLimb;
                    }
                }
                else
                {
                    raycastInfo.limb = MathUtilities.RandomEnumValue <ELimb>();
                }
                if (raycastInfo.transform.CompareTag("Vehicle"))
                {
                    raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
                }
                if (raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive)
                {
                    raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                }
                else
                {
                    raycastInfo.material = DamageTool.getMaterial(hit.point, raycastInfo.transform, raycastInfo.collider);
                }
                return(raycastInfo);
            }
            return(raycastInfo);
        }