Exemplo n.º 1
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 0)
            {
                throw new CommandWrongUsageException(Context);
            }

            UnturnedUser uPlayer        = (UnturnedUser)Context.Actor;
            var          currentVehicle = uPlayer.Player.Player.movement.getVehicle();

            if (currentVehicle != null)
            {
                await UniTask.SwitchToMainThread();

                RepairVehicle(currentVehicle);
                await uPlayer.PrintMessageAsync(m_StringLocalizer["repair:vehicle:current"]);
            }
            else
            {
                PlayerLook  look    = uPlayer.Player.Player.look;
                RaycastInfo raycast = DamageTool.raycast(new Ray(look.aim.position, look.aim.forward),
                                                         100f, RayMasks.VEHICLE);

                if (raycast.vehicle == null)
                {
                    throw new UserFriendlyException(m_StringLocalizer["repair:vehicle:none"]);
                }

                await UniTask.SwitchToMainThread();

                RepairVehicle(raycast.vehicle);
                await uPlayer.PrintMessageAsync(m_StringLocalizer["repair:vehicle:looking"]);
            }
        }
Exemplo n.º 2
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            var player = src.ToPlayer();

            float       dist = 2048f;
            RaycastInfo veh  = TraceRay(player, dist, RayMasks.VEHICLE);

            if (veh.vehicle != null)
            {
                if (veh.vehicle.isLocked)
                {
                    VehicleManager.unlockVehicle(veh.vehicle, player.UnturnedPlayer);
                    EssLang.Send(src, "VEHICLE_UNLOCK");
                    return(CommandResult.Success());
                }
                else
                {
                    return(CommandResult.LangError("VEHICLE_NOT_LOCKED"));
                }
            }
            else
            {
                return(CommandResult.LangError("NO_OBJECT"));
            }
        }
Exemplo n.º 3
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player      = (UnturnedPlayer)caller;
            Ray            ray         = new Ray(player.Player.look.aim.position, player.Player.look.aim.forward);
            RaycastInfo    raycastInfo = DamageTool.raycast(ray, 10f, RayMasks.VEHICLE);

            if (raycastInfo.vehicle != null)
            {
                bool getPInfo = false;
                if (WreckingBall.Instance.Configuration.Instance.EnablePlayerInfo && WreckingBall.isPlayerInfoLibPresent && WreckingBall.isPlayerInfoLibLoaded)
                {
                    getPInfo = true;
                }
                if (!raycastInfo.vehicle.isDead)
                {
                    bool showSignOwner = false;
                    showSignOwner = DestructionProcessing.HasFlaggedElement(raycastInfo.transform, out ulong signOwner);
                    string signmsg   = getPInfo ? WreckingBall.Instance.PInfoGenerateMessage(signOwner) : signOwner.ToString();
                    string lockedmsg = raycastInfo.vehicle.isLocked ? (!getPInfo || raycastInfo.vehicle.lockedOwner == CSteamID.Nil ? raycastInfo.vehicle.lockedOwner.ToString() : WreckingBall.Instance.PInfoGenerateMessage((ulong)raycastInfo.vehicle.lockedOwner)) : "N/A";
                    string msg       = string.Format("Dropping elements off of vehicle: {0}({1}), InstanceID: {2}, Locked Owner: {3}, SignOwner {4}.", raycastInfo.vehicle.asset.name, raycastInfo.vehicle.id, raycastInfo.vehicle.instanceID,
                                                     lockedmsg,
                                                     showSignOwner ? signmsg : "N/A");
                    UnturnedChat.Say(caller, msg);
                    Logger.Log(msg);
                    WreckingBall.Instance.VehicleElementDrop(raycastInfo.vehicle, true, raycastInfo.transform);
                }
            }
            else
            {
                UnturnedChat.Say(caller, "Couldn't find a vehicle in the direction you're looking, or too far away, within 10 units.");
            }
        }
Exemplo n.º 4
0
        public void Update()
        {
            foreach (SteamPlayer player in Provider.clients)
            {
                RaycastInfo thingLocated = TraceRay(player, 10f, RayMasks.PLAYER | RayMasks.PLAYER_INTERACT);

                if (thingLocated.player != null)
                {
                    if (thingLocated.player.name == player.player.name)
                    {
                        return;
                    }

                    if (thingLocated.player.clothing.mask != 0)
                    {
                        if (player.player.isPluginWidgetFlagActive(EPluginWidgetFlags.ShowInteractWithEnemy))
                        {
                            if (player.isAdmin && Main.Config.adminOverride == true)
                            {
                                return;
                            }

                            player.player.disablePluginWidgetFlag(EPluginWidgetFlags.ShowInteractWithEnemy);
                        }
                    }
                    else
                    {
                        if (!player.player.isPluginWidgetFlagActive(EPluginWidgetFlags.ShowInteractWithEnemy))
                        {
                            player.player.enablePluginWidgetFlag(EPluginWidgetFlags.ShowInteractWithEnemy);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void Update()
        {
            foreach (SteamPlayer player in Provider.clients)
            {
                RaycastInfo thingLocated = TraceRay(player, 10f, RayMasks.PLAYER | RayMasks.PLAYER_INTERACT);

                if (thingLocated.player != null)
                {
                    if (thingLocated.player.name == player.player.name)
                    {
                        return;
                    }

                    if (enabledNameplatesList.Contains(thingLocated.player.channel.owner.playerID.steamID) && !player.player.isPluginWidgetFlagActive(EPluginWidgetFlags.ShowInteractWithEnemy))
                    {
                        player.player.enablePluginWidgetFlag(EPluginWidgetFlags.ShowInteractWithEnemy);
                    }
                    else if (disabledNameplatesList.Contains(thingLocated.player.channel.owner.playerID.steamID) && player.player.isPluginWidgetFlagActive(EPluginWidgetFlags.ShowInteractWithEnemy))
                    {
                        if (player.isAdmin && Main.Config.adminOverride)
                        {
                            return;
                        }

                        player.player.disablePluginWidgetFlag(EPluginWidgetFlags.ShowInteractWithEnemy);
                    }
                }
            }
        }
Exemplo n.º 6
0
    // Performs multiple raycasts in specified direction
    private bool CheckRaycast(Vector3 origin, Vector3 direction, RaycastInfo info)
    {
        // Determine direction for offset to be applied between raycasts
        Vector3 offset = Vector3.zero;

        // Vertical collisions
        if (direction == Vector3.up || direction == Vector3.down)
        {
            offset = Vector3.right;
        }
        // Horizontal collisions
        else if (direction == Vector3.left || direction == Vector3.right)
        {
            offset = Vector3.up;
        }
        // Error checking
        if (offset == Vector3.zero)
        {
            Debug.LogError("Invalid raycast direction specified in call to CheckRaycast()");
        }

        // Multiple raycasts in specified direction
        for (int i = 0; i < info.count; i++)
        {
            if (Physics.Raycast(origin + offset * info.spacing * i, direction, info.distance, mask))
            {
                return(true);
            }
            Debug.DrawRay(origin + offset * info.spacing * i, direction * info.distance, Color.yellow);
        }
        // If no raycast hits, return false
        return(false);
    }
Exemplo n.º 7
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            var player = src.ToPlayer();

            float       dist = 2048f;
            RaycastInfo veh  = TraceRay(player, dist, RayMasks.VEHICLE);

            if (veh.vehicle != null)
            {
                if (!veh.vehicle.isLocked)
                {
                    VehicleManager.instance.channel.send("tellVehicleLock", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, veh.vehicle.instanceID, player.CSteamId, player.UnturnedPlayer.channel.owner.playerID.group, player.CSteamId != CSteamID.Nil);
                    EssLang.Send(src, "VEHICLE_LOCK");
                    return(CommandResult.Success());
                }
                else
                {
                    return(CommandResult.LangError("VEHICLE_ALREADY_LOCKED"));
                }
            }
            else
            {
                return(CommandResult.LangError("NO_OBJECT"));
            }
        }
Exemplo n.º 8
0
    private void OnTriggerEnter(Collider other)
    {
        if (!cursorObject.activeSelf)
        {
            return;
        }
        if (other.CompareTag("Ground"))
        {
            if (selectedObject != null)
            {
                UnSelectObject();
            }
            return;
        }

        if (selectedObject != other.transform)
        {
            RaycastInfo raycast = MouseRaycast();
            if (raycast.hit)
            {
                if (raycast.rayHit.collider.GetComponent <SelectionTarget>() != null)
                {
                    if (MouseRaycast().rayHit.collider.transform == other.transform)
                    {
                        SelectObject(other.transform);
                        return;
                    }
                }
            }
            SelectObject(other.transform);
        }
    }
Exemplo n.º 9
0
    EdgeInfo FindEdge(RaycastInfo minimumViewRaycast, RaycastInfo maximumViewRaycast) //edge information method that takes in raycast information
    {
        float   minimumAngle = minimumViewRaycast.angle;                              //the angle of the passed in minimum raycast
        float   maximumAngle = maximumViewRaycast.angle;                              //the angle of the passed in maximum raycast
        Vector3 minimumPoint = Vector3.zero;                                          //minimum raycast point, defaulted at 0,0,0
        Vector3 maximumPoint = Vector3.zero;                                          //maximum raycast point, defaulted at 0,0,0

        for (int i = 0; i < edgeResolveIterations; i++)                               //for each iteration of the edge resolution
        {
            float       angle          = (minimumAngle + maximumAngle) / 2;           //gets our new angle, halfway between our minumum and maximum
            RaycastInfo newViewRaycast = ViewRaycast(angle);                          //raycast with our new angle

            bool edgeDistanceThresholdExceeded = Mathf.Abs(minimumViewRaycast.length - newViewRaycast.length) > edgeDistanceThreshold;
            //bool that check whether the distance between our old and new raycasts exceeds our set threshold
            if (newViewRaycast.hit == minimumViewRaycast.hit && !edgeDistanceThresholdExceeded)              // if the hit result of our raycast is equal to that
            //of our minimum hit and the distance threshold has not been exceeded
            {
                minimumAngle = angle;                 //set the minimum angle to our new angle
                minimumPoint = newViewRaycast.point;  //set the minimum point to our new raycast point
            }
            else
            {
                maximumAngle = angle;                 //set the maximum angle to our new angle
                maximumPoint = newViewRaycast.point;  //set the maximum point to our new raycast point
            }
        }

        return(new EdgeInfo(minimumPoint, maximumPoint));        //returns edge info containing our new minimum and maximum points
    }
Exemplo n.º 10
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length == 0)
            {
                RaycastInfo rayinfo = DamageTool.raycast(new Ray(player.Player.look.aim.position, player.Player.look.aim.forward), 3f, RayMasks.PLAYER_INTERACT, player.Player);

                if (rayinfo.player == null)
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.ray.player.not.found")}", Color.red);
                    return;
                }
                UnturnedPlayer toPlayer = UnturnedPlayer.FromPlayer(rayinfo.player);

                if (toPlayer.HasPermission(Permissions[0]))
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.immune")}");
                    return;
                }

                // одеть наручники на игрока
                JailTimePlugin.Instance.Prison.HandcuffToPlayer(toPlayer.CSteamID);

                UnturnedChat.Say(toPlayer, $"{JailTimePlugin.Instance.Translate("handcuff.successful.to.player")}");
                UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.successful", toPlayer.CharacterName)}");
            }

            UnturnedPlayer playerFromName = UnturnedPlayer.FromName(command[0]);

            if (command.Length == 1)
            {
                if (playerFromName == null)
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.player.not.found", command[0])}", Color.red);
                    return;
                }

                if (playerFromName.CSteamID == player.CSteamID)
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.self")}", Color.red);
                    return;
                }

                if (playerFromName.HasPermission(Permissions[0]))
                {
                    UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.immune")}", Color.red);
                    return;
                }

                // одеть наручники на игрока
                JailTimePlugin.Instance.Prison.HandcuffToPlayer(playerFromName.CSteamID);

                UnturnedChat.Say(player, $"{JailTimePlugin.Instance.Translate("handcuff.successful", playerFromName.CharacterName)}", Color.yellow);
                UnturnedChat.Say(playerFromName, $"{JailTimePlugin.Instance.Translate("handcuff.successful.to.player", playerFromName.CharacterName)}", Color.red);
            }
        }
Exemplo n.º 11
0
 public void Insert(DebugTag tag, RaycastInfo info)
 {
     info.index = index;
     if (!castInfo.ContainsKey(tag))
     {
         castInfo.Add(tag, new List <RaycastInfo>());
     }
     castInfo[tag].Add(info);
 }
Exemplo n.º 12
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player       = (UnturnedPlayer)caller;
            RaycastInfo    thingLocated = TraceRay(player, 2048f, RayMasks.VEHICLE | RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.BARRICADE_INTERACT | RayMasks.STRUCTURE_INTERACT);

            if (thingLocated.vehicle != null)
            {
                InteractableVehicle vehicle = thingLocated.vehicle;

                if (vehicle.lockedOwner != CSteamID.Nil)
                {
                    Utils.TellInfo(caller, vehicle.lockedOwner, vehicle.lockedGroup);
                    return;
                }
                UnturnedChat.Say(caller, "Vehicle does not have an owner.");
                return;
            }
            else
            {
                if (!(thingLocated.transform != null))
                {
                    return;
                }
                byte          x;
                byte          y;
                Interactable2 component = thingLocated.transform.GetComponent <Interactable2>();
                if (!(component.transform != null))
                {
                    return;
                }
                CSteamID val2 = (CSteamID)component.owner;
                CSteamID val3 = (CSteamID)component.group;
                Interactable2SalvageBarricade interactable2SalvageBarricade = component as Interactable2SalvageBarricade;
                if (interactable2SalvageBarricade != null)
                {
                    if (!BarricadeManager.tryGetInfo(interactable2SalvageBarricade.root, out x, out y, out ushort _, out ushort index, out BarricadeRegion region))
                    {
                        return;
                    }
                    ItemBarricadeAsset asset = region.barricades[index].barricade.asset;
                    Utils.TellInfo(caller, val2, val3);
                }
                else
                {
                    if (!(component is Interactable2SalvageStructure))
                    {
                        return;
                    }
                    if (!StructureManager.tryGetInfo(thingLocated.transform, out y, out x, out ushort index2, out StructureRegion region2))
                    {
                        return;
                    }
                    ItemStructureAsset asset = region2.structures[index2].structure.asset;
                    Utils.TellInfo(caller, val2, val3);
                }
            }
        }
Exemplo n.º 13
0
 public static void OV_sendRaycast(PlayerInput instance, RaycastInfo info)
 {
     if (Packets.Count > 0)
     {
         Packets.Last().clientsideInputs.Add(info);
     }
     else
     {
         DebugUtilities.Log("f**k");
     }
 }
        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);
        }
Exemplo n.º 15
0
    private IEnumerator Rotate(Direction direction)
    {
        Vector3  position = transform.position;
        Rotation rotation = _rotations[direction];
        Vector3  anchor   = _localAnchors[rotation.anchor];
        float    angle    = 90f;

        RaycastInfo raycastHits = CheckForObstacle(direction);

        if (raycastHits.forward)
        {
            CheckObstacleUp(direction, ref raycastHits);

            if (raycastHits.up)
            {
                yield break;
            }
            else
            {
                anchor = _localAnchors[rotation.anchor + 4];
                angle  = 180f;
            }
        }
        else
        {
            CheckObstacleDown(direction, ref raycastHits);

            if (!raycastHits.down && !raycastHits.bottomDown)
            {
                yield break;
            }
            else if (!raycastHits.down && raycastHits.bottomDown)
            {
                angle = 180f;
            }
        }

        _isRotating = true;

        float elapsed = 0f;

        while (elapsed < _rotationDuration)
        {
            elapsed += Time.deltaTime;
            transform.RotateAround(position + anchor, rotation.axis, (angle / _rotationDuration) * Time.deltaTime);
            yield return(null);
        }

        SnapPosition();

        _isRotating = false;
    }
        // Token: 0x06000095 RID: 149 RVA: 0x00006AF4 File Offset: 0x00004CF4
        public static bool GenerateRaycast(out RaycastInfo info)
        {
            ItemGunAsset itemGunAsset = OptimizationVariables.MainPlayer.equipment.asset as ItemGunAsset;
            float        num          = (itemGunAsset != null) ? itemGunAsset.range : 15.5f;

            info = RaycastUtilities.GenerateOriginalRaycast(new Ray(OptimizationVariables.MainPlayer.look.aim.position, OptimizationVariables.MainPlayer.look.aim.forward), num, RayMasks.DAMAGE_CLIENT);
            bool flag = RaycastOptions.EnablePlayerSelection && RaycastUtilities.TargetedPlayer != null;

            if (flag)
            {
                GameObject gameObject = RaycastUtilities.TargetedPlayer.gameObject;
                bool       flag2      = true;
                Vector3    position   = OptimizationVariables.MainPlayer.look.aim.position;
                bool       flag3      = Vector3.Distance(position, gameObject.transform.position) > num;
                if (flag3)
                {
                    flag2 = false;
                }
                Vector3 point;
                bool    flag4 = !SphereUtilities.GetRaycast(gameObject, position, out point);
                if (flag4)
                {
                    flag2 = false;
                }
                bool flag5 = flag2;
                if (flag5)
                {
                    info = RaycastUtilities.GenerateRaycast(gameObject, point, info.collider);
                    return(true);
                }
                bool onlyShootAtSelectedPlayer = RaycastOptions.OnlyShootAtSelectedPlayer;
                if (onlyShootAtSelectedPlayer)
                {
                    return(false);
                }
            }
            GameObject @object;
            Vector3    point2;
            bool       targetObject = RaycastUtilities.GetTargetObject(RaycastUtilities.Objects, out @object, out point2, (double)num);
            bool       result;

            if (targetObject)
            {
                info   = RaycastUtilities.GenerateRaycast(@object, point2, info.collider);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 17
0
 public static void AddTracer(RaycastInfo ri)
 {
     if (G.Settings.WeaponOptions.TracerLines && ri.point != new Vector3(0, 0, 0))
     {
         TracerObject tracer = new TracerObject
         {
             HitPos    = ri.point,
             PlayerPos = Player.player.look.aim.transform.position,
             ShotTime  = DateTime.Now
         };
         TracerLines.Add(tracer);
     }
 }
Exemplo n.º 18
0
    private void CheckObstacleDown(Direction direction, ref RaycastInfo info)
    {
        /// Down
        Ray ray = new Ray(transform.position + _rotations[direction].direction, Vector3.down);

        Debug.DrawRay(ray.origin, Vector3.down * _obstacleCheckDistance, Color.red, 1);
        info.down = Physics.Raycast(ray, _obstacleCheckDistance, _obstacleLayers);

        /// Bottom
        ray.origin     += Vector3.down;
        info.bottomDown = info.down | Physics.Raycast(ray, _obstacleCheckDistance, _obstacleLayers);
        Debug.DrawRay(ray.origin, Vector3.down * _obstacleCheckDistance, Color.red, 1);
    }
Exemplo n.º 19
0
    private RaycastInfo CheckForObstacle(Direction direction)
    {
        RaycastInfo info   = new RaycastInfo();
        Vector3     rayDir = _rotations[direction].direction;

        /// Forward
        Ray ray = new Ray(transform.position, rayDir);

        Debug.DrawLine(ray.origin, ray.origin + (rayDir * _obstacleCheckDistance), Color.red, 1);
        info.forward = Physics.Raycast(ray, _obstacleCheckDistance, _obstacleLayers);

        return(info);
    }
Exemplo n.º 20
0
        internal bool Sell(decimal curBallance, UnturnedPlayer player, RaycastInfo raycastInfo, out decimal totalCost, out short actualCount)
        {
            bool sufficientAmount = false;

            totalCost   = 0;
            actualCount = 0;
            InteractableVehicle vehicle = null;

            if (RestrictBuySell == RestrictBuySell.BuyOnly)
            {
                actualCount = -1;
                return(false);
            }
            VehicleInfo vInfo = DShop.Instance.Database.GetVehicleInfo((ulong)player.CSteamID, ItemID);

            if (vInfo == null)
            {
                // The car the player's looking at hasn't been bought before from them, from the shop.
                actualCount = -2;
                return(false);
            }
            else
            {
                vehicle          = raycastInfo.vehicle;
                sufficientAmount = true;
                actualCount      = 1;
                if (DShop.Instance.Configuration.Instance.VehicleSellDropElements)
                {
                    BarricadeRegion vregion = null;
                    byte            x;
                    byte            y;
                    ushort          plant;
                    if (BarricadeManager.tryGetPlant(vehicle.transform, out x, out y, out plant, out vregion))
                    {
                        for (int j = 0; j < vregion.drops.Count; j++)
                        {
                            if (j < vregion.drops.Count && vregion.barricades[j].barricade.id > 0)
                            {
                                Item item = new Item(vregion.barricades[j].barricade.id, true);
                                ItemManager.dropItem(item, vregion.drops[j].model.position, false, true, true);
                            }
                        }
                    }
                }
                DShop.Instance.Database.DeleteVehicleInfo(vInfo);
                vehicle.askDamage(ushort.MaxValue, false);
                totalCost = decimal.Multiply(BuyCost, SellMultiplier);
                DShop.Instance._OnShopSell(decimal.Add(curBallance, totalCost), player, 1, this, ItemType.Vehicle, BuyCost, totalCost, actualCount, 0);
            }
            return(sufficientAmount);
        }
Exemplo n.º 21
0
        public static bool Prefix(ref RaycastInfo info, ref ERaycastInfoUsage usage)
        {
            if (Global.AllOff)
            {
                return(true);
            }

            if ((info.zombie != null || info.player != null) && (Global.AimSettings.ForceHit || Global.AimSettings.RageBot))
            {
                info.limb = ELimb.SKULL;
            }

            return(true);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Transform ray cast info by a transformation
        /// </summary>
        /// <param name="m"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public static RaycastInfo TransformRayCastInfo(this Matrix4x4 m, RaycastInfo r)
        {
            float dist = r.Distance;
            var   sc   = m.GetScale();

            if (sc.sqrMagnitude != 1.0f)
            {
                var v = r.Direction * r.Distance;
                v    = Matrix4x4.Scale(sc).MultiplyPoint(v);
                dist = v.magnitude;
            }

            return(new RaycastInfo(m.MultiplyPoint(r.Origin), m.MultiplyVector(r.Direction), dist));
        }
Exemplo n.º 23
0
        public static RaycastInfo TransformRayCastInfo(this Transform t, RaycastInfo r)
        {
            float dist = r.Distance;
            var   sc   = t.localToWorldMatrix.GetScale();

            if (sc.sqrMagnitude != 1.0f)
            {
                var v = r.Direction * r.Distance;
                v    = Matrix4x4.Scale(sc).MultiplyPoint(v);
                dist = v.magnitude;
            }

            return(new RaycastInfo(t.TransformPoint(r.Origin), t.TransformDirection(r.Direction), dist));
        }
Exemplo n.º 24
0
        // Token: 0x06000238 RID: 568 RVA: 0x00015488 File Offset: 0x00013688
        public static bool GenerateRaycast(out RaycastInfo info)
        {
            ItemWeaponAsset itemWeaponAsset = Player.player.equipment.asset as ItemWeaponAsset;
            float           range           = (itemWeaponAsset != null) ? Mathf.Max(itemWeaponAsset.range, 20f) : 20f;
            GameObject      @object;
            Vector3         point;

            if (!RaycastUtilities.GetTargetObject(out @object, out point, range))
            {
                info = RaycastUtilities.GenerateOriginalRaycast(new Ray(Player.player.look.aim.position, Player.player.look.aim.forward), range, RayMasks.DAMAGE_CLIENT, null);
                return(false);
            }
            info = RaycastUtilities.GenerateRaycast(@object, point);
            return(true);
        }
Exemplo n.º 25
0
 // Gets ItemID out of buy/cost/shop command.
 public static bool GetItemID(IRocketPlayer caller, string[] command, ItemType type, int start, out ushort itemID, bool checkValidAsset = true)
 {
     if (!ushort.TryParse(type == ItemType.Item ? command[start] : command[start + 1], out itemID))
     {
         if (!(caller is ConsolePlayer) && (type == ItemType.Item ? command[start].ToLower() == "h" : command[start + 1].ToLower() == "h"))
         {
             UnturnedPlayer player = (UnturnedPlayer)caller;
             if (type == ItemType.Item)
             {
                 itemID = player.Player.equipment.itemID;
             }
             else if (player.IsInVehicle)
             {
                 itemID = player.CurrentVehicle.id;
             }
             else if (type == ItemType.Vehicle && !player.IsInVehicle)
             {
                 RaycastInfo raycastInfo = RaycastInfoVehicle(player, 10);
                 if (raycastInfo.vehicle != null)
                 {
                     itemID = raycastInfo.vehicle.id;
                 }
             }
             if (itemID == 0)
             {
                 if (type == ItemType.Item)
                 {
                     UnturnedChat.Say(caller, Instance.Translate("no_item_held"));
                 }
                 else
                 {
                     UnturnedChat.Say(caller, Instance.Translate("no_item_held_vehicle2"));
                 }
                 return(false);
             }
         }
         else
         {
             itemID = type == ItemType.Item ? command[start].AssetIDFromName(type) : command[start + 1].AssetIDFromName(type);
         }
     }
     if (checkValidAsset && itemID.AssetFromID(type) == null)
     {
         UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
         return(false);
     }
     return(true);
 }
Exemplo n.º 26
0
        public static bool GenerateRaycast(out RaycastInfo info)
        {
            ItemGunAsset currentGun = OptimizationVariables.MainPlayer.equipment.asset as ItemGunAsset;

            float Range = currentGun?.range ?? 15.5f;

            info = GenerateOriginalRaycast(new Ray(OptimizationVariables.MainPlayer.look.aim.position, OptimizationVariables.MainPlayer.look.aim.forward), Range,
                                           RayMasks.DAMAGE_CLIENT);

            if (RaycastOptions.EnablePlayerSelection && TargetedPlayer != null)
            {
                GameObject p          = TargetedPlayer.gameObject;
                bool       shouldFire = true;

                Vector3 aimPos = OptimizationVariables.MainPlayer.look.aim.position;

                if (Vector3.Distance(aimPos, p.transform.position) > Range)
                {
                    shouldFire = false;
                }

                if (!SphereUtilities.GetRaycast(p, aimPos, out Vector3 point))
                {
                    shouldFire = false;
                }

                if (shouldFire)
                {
                    info = GenerateRaycast(p, point, info.collider);
                    return(true);
                }

                if (RaycastOptions.OnlyShootAtSelectedPlayer)
                {
                    return(false);
                }
            }

            if (!GetTargetObject(Objects, out GameObject Object, out Vector3 Point, Range))
            {
                return(false);
            }

            info = GenerateRaycast(Object, Point, info.collider);
            return(true);
        }
    public static void OV_FixedUpdate()
    {
        Player mainPlayer = OptimizationVariables.MainPlayer;

        bool punchSilentAim = MiscOptions.PunchSilentAim;

        if (punchSilentAim)
        {
            OV_DamageTool.OVType = OverrideType.PlayerHit;
        }
        RaycastInfo raycastInfo = DamageTool.raycast(new Ray(mainPlayer.look.aim.position, mainPlayer.look.aim.forward), 6f, RayMasks.DAMAGE_SERVER);

        OverrideUtilities.CallOriginal(null, new object[0]);
        List <PlayerInputPacket> clientsidePackets = ClientsidePackets;

        LastPacket = ((clientsidePackets != null) ? clientsidePackets.Last <PlayerInputPacket>() : null);
    }
Exemplo n.º 28
0
 public static void AddDamage(RaycastInfo ri)
 {
     if (G.Settings.WeaponOptions.DamageIndicators && ri.point != new Vector3(0, 0, 0))
     {
         ItemGunAsset currentGun = Player.player.equipment.asset as ItemGunAsset;
         if (currentGun != null && ri.player != null)
         {
             IndicatorObject dmgi = new IndicatorObject
             {
                 HitPos   = ri.point,
                 Damage   = Mathf.FloorToInt(DamageTool.getPlayerArmor(ri.limb, ri.player) * currentGun.playerDamageMultiplier.multiply(ri.limb)), // big maths
                 ShotTime = DateTime.Now
             };
             DamageIndicators.Add(dmgi);
         }
     }
 }
Exemplo n.º 29
0
        public static RaycastInfo raycast(Ray ray, float range, int mask)
        {
            RaycastHit hit;
            int        msk = RayMasks.ENEMY | RayMasks.ENTITY | RayMasks.VEHICLE;

            if (ComponentManager.hack_Weapons.meleeThroughWalls)
            {
                Physics.Raycast(ray, out hit, range, msk);
            }
            else
            {
                Physics.Raycast(ray, out hit, range, mask);
            }
            RaycastInfo raycastInfo = new RaycastInfo(hit);

            raycastInfo.direction = ray.direction;
            if (hit.transform != null)
            {
                if (hit.transform.CompareTag("Enemy"))
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                }
                if (hit.transform.CompareTag("Zombie"))
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }
                if (hit.transform.CompareTag("Animal"))
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }
                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);
                if (hit.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, hit.transform, hit.collider);
                }
            }
            return(raycastInfo);
        }
Exemplo n.º 30
0
        public override void Update()
        {
            base.Update();

            if (Input.Mouse.JustClicked())
            {
                //FIXME
                var raycastInfo = new RaycastInfo[0];
                if (scene.RaycastAll(camera.GetRay(Input.Mouse.Position), 250, out raycastInfo))
                {
                    _hit = raycastInfo[0].Collider.GameObject.Name;
                }
                else
                {
                    _hit = "Nothing";
                }
            }
        }
Exemplo n.º 31
0
		void updateWheel( btRigidBody chassis, RaycastInfo& raycastInfo);