Пример #1
0
        private static void CreateTransportHookFrontBackMode(HookPair transHook)
        {
            Vehicle playerVehicle    = Util.GetVehiclePlayerIsIn();
            Vector3 entityDimensions = transHook.entity2.Model.GetDimensions();

            HookPair hook1 = new HookPair(transHook);
            HookPair hook2 = new HookPair(transHook);

            Vector3 playerHookOffset = playerVehicle.ForwardVector * 1.9f;

            hook1.hookOffset1 = -playerHookOffset;
            hook2.hookOffset1 = playerHookOffset;


            Vector3 hookOffsetFront = (-transHook.entity2.ForwardVector * (entityDimensions.X / 1.9f))
                                      + (transHook.entity2.UpVector * (entityDimensions.Z * 0.6f));

            Vector3 hookOffsetBack = (transHook.entity2.ForwardVector * (entityDimensions.X / 1.9f))
                                     + (transHook.entity2.UpVector * (entityDimensions.Z * 0.6f));

            hook1.hookOffset2 = hookOffsetFront;
            hook2.hookOffset2 = hookOffsetBack;

            float rope1Length = (hook1.entity1.Position + hook1.hookOffset1).DistanceTo(hook1.entity2.Position + hook1.hookOffset2);
            float rope2Length = (hook2.entity1.Position + hook1.hookOffset1).DistanceTo(hook2.entity2.Position + hook1.hookOffset2);

            float greatestRopeLength = Math.Max(rope1Length, rope2Length);


            RopeModule.CreateHook(hook1, false, MinTransportRopeLength, greatestRopeLength);
            RopeModule.CreateHook(hook2, false, MinTransportRopeLength, greatestRopeLength);
        }
Пример #2
0
        private static void CreateTransportHookCenterMode(HookPair transHook, bool copyHook = true)
        {
            float minRopeLength = (!Util.IsPed(transHook.entity2) ? MinTransportRopeLength : MinTransportPedRopeLength);

            Vector3 entityDimensions = transHook.entity2.Model.GetDimensions();

            if (!Util.IsPed(transHook.entity2))
            {
                transHook.hookOffset2 += transHook.entity2.UpVector * entityDimensions.Z * 0.5f;
            }

            RopeModule.CreateHook(transHook, copyHook, minRopeLength);
        }
Пример #3
0
        private static void CreateTransportHookLeftRightMode(HookPair transHook)
        {
            Vehicle playerVehicle    = Util.GetVehiclePlayerIsIn();
            Vector3 entityDimensions = transHook.entity2.Model.GetDimensions();

            HookPair hook1 = new HookPair(transHook);
            HookPair hook2 = new HookPair(transHook);

            Vector3 playerHookOffset = playerVehicle.RightVector * 1.2f;

            hook1.hookOffset1 = -playerHookOffset;
            hook2.hookOffset1 = playerHookOffset;

            Vector3 raySourceLeft = transHook.entity2.Position +
                                    (-transHook.entity2.RightVector * (entityDimensions.Y / 5.0f));

            Vector3 raySourceRight = transHook.entity2.Position +
                                     (transHook.entity2.RightVector * (entityDimensions.Y / 5.0f));

            RaycastResult rayLeft  = World.Raycast(raySourceLeft, transHook.entity2.RightVector, 7.0f, IntersectOptions.Everything, playerVehicle);
            RaycastResult rayRight = World.Raycast(raySourceRight, -transHook.entity2.RightVector, 7.0f, IntersectOptions.Everything, playerVehicle);

            Vector3 heightOffset = (transHook.entity2.UpVector * entityDimensions.Z * 0.5f);

            if (rayLeft.DitHitEntity && rayLeft.HitEntity == transHook.entity2 &&
                rayRight.DitHitEntity && rayRight.HitEntity == transHook.entity2)
            {
                hook1.hookOffset2 = rayLeft.HitCoords - transHook.entity2.Position + heightOffset;
                hook2.hookOffset2 = rayRight.HitCoords - transHook.entity2.Position + heightOffset;
            }
            else
            {
                if (DebugMode)
                {
                    UI.Notify("Failed L/R Raycast Hook");
                }

                hook1.hookOffset2 = (-transHook.entity2.RightVector * (entityDimensions.Y / 5.0f)) + heightOffset;
                hook2.hookOffset2 = (transHook.entity2.RightVector * (entityDimensions.Y / 5.0f)) + heightOffset;
            }

            float rope1Length = (hook1.entity1.Position + hook1.hookOffset1).DistanceTo(hook1.entity2.Position + hook1.hookOffset2);
            float rope2Length = (hook2.entity1.Position + hook1.hookOffset1).DistanceTo(hook2.entity2.Position + hook1.hookOffset2);

            float greatestRopeLength = Math.Max(rope1Length, rope2Length);


            RopeModule.CreateHook(hook1, false, MinTransportRopeLength, greatestRopeLength);
            RopeModule.CreateHook(hook2, false, MinTransportRopeLength, greatestRopeLength);
        }
Пример #4
0
        private static bool CheckTransportHookPermission(Entity entity)
        {
            //if (DebugMode)
            //{
            //    UI.Notify(
            //            "E.Null/!Exist:" + (entity == null || !entity.Exists()).ToString() +
            //            "\nE.PlayerVeh:" + (entity == Util.GetVehiclePlayerIsIn()).ToString() +
            //            "\nE.Player:" + Util.IsPlayer(entity).ToString() +
            //            "\nE.matchesFilter:" + HookFilter.DefaultFilters[CurrentTransportHookFilterIndex].matches(entity).ToString() +
            //            "\nE.PedInVehicle:" + (Util.IsPed(entity) && ((Ped)entity).IsSittingInVehicle()).ToString() +
            //            "\nE.hookedToPlayer:" + RopeModule.IsEntityHookedToPlayer(entity).ToString() +
            //            "\nE.hookedToPlayerVeh:" + RopeModule.IsEntityHookedToPlayersVehicle(entity).ToString()
            //            );
            //}

            if (entity == null || !entity.Exists())
            {
                return(false);
            }

            if (Hooks.Count >= MAX_HOOK_COUNT)
            {
                return(false);
            }

            if (entity == Util.GetVehiclePlayerIsIn() ||

                Util.IsPlayer(entity) ||

                !HookFilter.DefaultFilters[CurrentTransportHookFilterIndex].matches(entity) ||

                Util.IsPed(entity) &&
                (
                    HookedPedCount >= MAX_HOOKED_PEDS ||
                    ((Ped)entity).IsDead ||
                    ((Ped)entity).IsSittingInVehicle()
                ) ||

                RopeModule.IsEntityHookedToPlayer(entity) ||

                RopeModule.IsEntityHookedToPlayersVehicle(entity))
            {
                return(false);
            }

            return(true);
        }