protected void Page_Load(object sender, EventArgs e)
 {
     BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
     {
         new BreadCrumb(NavUtil.GetHomePageUrl(), "Home", IsActive: true)
     });
 }
Beispiel #2
0
        protected override void OnUpdate()
        {
            var commandBuffer = barrier.CreateCommandBuffer().AsParallelWriter();
            var randomArray   = World.GetExistingSystem <RandomSystem>().RandomArray;
            var surfaceAABB   = surfaceAabb;

            Entities
            .WithAll <PathAgent>()
            .WithNone <PathProblem, PathDestination, PathBufferElement>()
            .WithNativeDisableParallelForRestriction(randomArray)
            .ForEach((Entity entity, int entityInQueryIndex, int nativeThreadIndex) =>
            {
                var random = randomArray[nativeThreadIndex];

                var pos = NavUtil.GetRandomPointInBounds(
                    ref random,
                    surfaceAABB,
                    1,
                    float3.zero
                    );

                commandBuffer.AddComponent(entityInQueryIndex, entity, new PathDestination
                {
                    WorldPoint = pos
                });

                randomArray[nativeThreadIndex] = random;
            })
            .WithName("PathDestinationJob")
            .ScheduleParallel();

            barrier.AddJobHandleForProducer(Dependency);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectUtil.RedirectUnauthenticatedUserToLoginPage();
            RedirectUtil.RedirectNonAdminUserToHomePage();

            BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
            {
                new BreadCrumb(NavUtil.GetHomePageUrl(), "Home"),
                new BreadCrumb(NavUtil.GetUsersPageUrl(), "Users", IsActive: true),
            });

            var items = new List <HyperlinkListPanelItem>();

            var divisionService = ServiceFactory.DivisionService;

            var accountUtil = new AccountUtil(Context);

            foreach (var user in new AccountUtil(Context).GetAllUsers().OrderBy(u => u.UserName))
            {
                string role = (accountUtil.IsUserAnAdmin(user.Id) ? "Administrator" : "");
                role = (accountUtil.IsUserASuperuser(user.Id) ? "Superuser" : role);

                items.Add(new HyperlinkListPanelItem(
                              URL: NavUtil.GetUpdateUserPageUrl(user.Id),
                              Heading: user.UserName + (!String.IsNullOrWhiteSpace(role) ? " (" + role + ")" : ""),
                              Text: user.Email));
            }

            HyperlinkListPanelRenderer.Render(usersList, new HyperlinkListPanelConfig("Users", items));
        }
Beispiel #4
0
        void Start()
        {
            var prefabEntity = entityManager.CreateEntityQuery(typeof(NavAgentPrefab)).GetSingleton <NavAgentPrefab>().Value;

            SpawnSystem.Enqueue(new Spawn()
                                .WithPrefab(prefabEntity)
                                .WithComponentList(
                                    new NavAgent
            {
                JumpDegrees          = 45,
                JumpGravity          = 100,
                JumpSpeedMultiplierX = 1.5f,
                JumpSpeedMultiplierY = 2,
                TranslationSpeed     = 20,
                TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID),
                Offset = new float3(0, 1, 0)
            },
                                    new NavNeedsSurface {
            },
                                    new Parent {
            },
                                    new LocalToParent {
            },
                                    new Translation
            {
                Value = new float3(0, 1, 0)
            }
                                    ),
                                50
                                );
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectUtil.RedirectUnauthenticatedUserToLoginPage();
            RedirectUtil.RedirectNonAdminUserToHomePage();

            BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
            {
                new BreadCrumb(NavUtil.GetHomePageUrl(), "Home"),
                new BreadCrumb(NavUtil.GetShowsPageUrl(), "Shows"),
                new BreadCrumb(NavUtil.GetShowPageUrl(GetShowId()), "Show"),
                new BreadCrumb(NavUtil.GetShowReportPageUrl(GetShowId()), "Judge Sheet Report", IsActive: true),
            });

            var showId = GetShowId();
            var show   = ServiceFactory.ShowService.Get(showId);

            labelPageTitle.Text       = show.Name;
            labelPageDescription.Text = show.Description;

            int contestId = Convert.ToInt32(Request.QueryString["contestId"]);

            if (contestId > 0)
            {
                contests = ServiceFactory.ContestService.GetShowContests(showId).Where(c => c.Id == contestId);
            }
            else
            {
                contests = ServiceFactory.ContestService.GetShowContests(showId);
            }
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectUtil.RedirectUnauthenticatedUserToLoginPage();

            BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
            {
                new BreadCrumb(NavUtil.GetHomePageUrl(), "Home"),
                new BreadCrumb(NavUtil.GetShowsPageUrl(), "Shows"),
                new BreadCrumb(NavUtil.GetShowPageUrl(GetShowId()), "Show", IsActive: true),
            });

            var items  = new List <HyperlinkListPanelItem>();
            var showId = GetShowId();
            var show   = ServiceFactory.ShowService.Get(showId);

            labelPageTitle.Text       = show.Name;
            labelPageDescription.Text = show.Description;

            this.contests = ServiceFactory.ContestService.GetShowContests(showId);

            if (!IsUserAnAdmin())
            {
                var currentUserId = Context.User.Identity.GetUserId();
                contests = contests.Where(c => (c.Judges.Any(j => j.UserId == currentUserId) || c.TimeKeeperId == currentUserId) && c.Status == "In Progress").ToList();
            }

            foreach (var contest in contests)
            {
                items.Add(new HyperlinkListPanelItem(URL: NavUtil.GetContestPageUrl(showId, contest.Id), Heading: contest.Name + " (" + contest.Status + ")", Text: contest.Description));
            }

            HyperlinkListPanelRenderer.Render(contestsList, new HyperlinkListPanelConfig("Contests", items, ButtonAddContestClick));
        }
Beispiel #7
0
        /// <summary>
        /// Builds a straight path and gets the point farthest along the path that does not exceed
        /// the specified maximum number of polygons.
        /// </summary>
        /// <remarks>
        /// <para>Limits:</para>
        /// <ul>
        /// <li>The path must exist and both the start and goal points must be within the path.</li>
        /// <li>
        /// The goal's polygon reference must be in or after the start points polygon reference.
        /// </li>
        /// </ul>
        /// <para>
        /// <b>Special Case:</b>The result will exceed <paramref name="maxLength"/> if the
        /// first straight path point is greater than <paramref name="maxLength"/> from the start
        /// point.
        /// </para>
        /// </remarks>
        /// <param name="start">The start point within the current path.</param>
        /// <param name="goal">The end point located in or after the start point polygon.</param>
        /// <param name="maxLength">
        /// The maximum allowed number of polygons between the start and target. [Limit: >= 1]
        /// </param>
        /// <param name="target">The resulting target point.</param>
        /// <returns>The straight path index of the target point, or -1 on error.</returns>
        public int GetLocalTarget(NavmeshPoint start, NavmeshPoint goal, int maxLength
                                  , NavmeshQuery query
                                  , out NavmeshPoint target)
        {
            if (NavUtil.Failed(BuildStraightPath(start, goal, query)))
            {
                target = new NavmeshPoint();
                return(-1);
            }

            int targetIndex = straightCount;  // Will be decremented.
            int iStart      = FindPolyRef(0, start.polyRef);

            // Start at the end of the straight path and search back toward
            // the start until the number of polygons is less than
            // maxLength.
            uint targetRef = 0;

            do
            {
                targetIndex--;

                targetRef = (straightPath[targetIndex] == 0 ?
                             goal.polyRef : straightPath[targetIndex]);
            }while (FindPolyRefReverse(iStart, targetRef) - iStart + 1
                    > maxLength &&
                    targetIndex > 0);

            target = new NavmeshPoint(targetRef, straightPoints[targetIndex]);

            return(targetIndex);
        }
        void Spawn()
        {
            var outputEntities = new NativeArray <Entity>(spawnCount, Allocator.Temp);

            entityManager.Instantiate(currentPrefab, outputEntities);

            for (var i = 0; i < outputEntities.Length; ++i)
            {
                entityManager.AddComponentData(outputEntities[i], new NavAgent
                {
                    TranslationSpeed = 20,
                    RotationSpeed    = 0.3f,
                    TypeID           = NavUtil.GetAgentType(NavConstants.HUMANOID),
                    Offset           = new float3(0, 1, 0)
                });

                entityManager.AddComponentData <LocalToWorld>(outputEntities[i], new LocalToWorld
                {
                    Value = float4x4.TRS(
                        new float3(0, 1, 0),
                        quaternion.identity,
                        1
                        )
                });

                entityManager.AddComponent <Parent>(outputEntities[i]);
                entityManager.AddComponent <LocalToParent>(outputEntities[i]);
                entityManager.AddComponent <NavNeedsSurface>(outputEntities[i]);
            }

            outputEntities.Dispose();
        }
        void Enqueue()
        {
            var entities = new NativeArray <Entity>(enqueueCount, Allocator.Temp);

            entityManager.Instantiate(currentPrefab, entities);

            for (var i = 0; i < entities.Length; ++i)
            {
                entityManager.AddComponentData(entities[i], new NavAgent
                {
                    TranslationSpeed = 20,
                    RotationSpeed    = 0.3f,
                    TypeID           = NavUtil.GetAgentType(NavConstants.HUMANOID),
                    Offset           = new float3(0, 1, 0)
                });

                entityManager.AddComponentData(entities[i], new Translation
                {
                    Value = SpawnOffset
                });

                entityManager.AddComponent <LocalToWorld>(entities[i]);
                entityManager.AddComponent <Parent>(entities[i]);
                entityManager.AddComponent <LocalToParent>(entities[i]);
                entityManager.AddComponent <NavNeedsSurface>(entities[i]);
                entityManager.AddComponent <NavTerrainCapable>(entities[i]);
            }

            entities.Dispose();
        }
Beispiel #10
0
        /// <summary>
        /// Provides a standard way detecting where the current
        /// <see cref="hitPosition"/> is on the navigation mesh.
        /// </summary>
        public static SearchResult HandleStandardPolySearch(NavGroup helper
                                                            , out Vector3 geomPoint
                                                            , out NavmeshPoint navPoint
                                                            , out string message)
        {
            if (!hasHit)
            {
                message   = "Outside source geometry.";
                navPoint  = new NavmeshPoint();
                geomPoint = Vector3.zero;
                return(SearchResult.Failed);
            }

            geomPoint = hitPosition;

            NavStatus status =
                helper.query.GetNearestPoint(geomPoint, helper.extents, helper.filter, out navPoint);

            message = "GetNearestPoint: " + status.ToString();

            if (NavUtil.Failed(status))
            {
                return(SearchResult.HitGeometry);
            }

            if (navPoint.polyRef == 0)
            {
                message = "Too far from navmesh: GetNearestPoint: " + status.ToString();
                return(SearchResult.HitGeometry);
            }

            return(SearchResult.HitNavmesh);
        }
        void Start()
        {
            var prefabEntity = entityManager.CreateEntityQuery(typeof(DinosaurPrefab)).GetSingleton <DinosaurPrefab>().Value;
            var entity       = entityManager.Instantiate(prefabEntity);

            entityManager.AddComponentData(entity, new NavAgent
            {
                JumpDegrees          = 45,
                JumpGravity          = 100,
                JumpSpeedMultiplierX = 2,
                JumpSpeedMultiplierY = 4,
                TranslationSpeed     = 40,
                RotationSpeed        = 0.3f,
                TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID),
                Offset = new float3(0, 1, 0)
            });

            entityManager.AddComponentData <LocalToWorld>(entity, new LocalToWorld
            {
                Value = float4x4.TRS(
                    new float3(0, 1, 0),
                    quaternion.identity,
                    1
                    )
            });

            entityManager.AddComponent <Parent>(entity);
            entityManager.AddComponent <LocalToParent>(entity);
            entityManager.AddComponent <NavNeedsSurface>(entity);
        }
Beispiel #12
0
        public static bool GetNavmeshPoint(Vector3 source, Vector3 extends, out NavmeshPoint point, NavmeshQueryFilter filter = null)
        {
            point = new NavmeshPoint();
            if (m_Map == null)
            {
                return(false);
            }
            var query = m_Map.Query;

            if (query == null)
            {
                return(false);
            }
            if (filter == null)
            {
                filter = m_Map.DefaultQueryFilter;
            }
            var status = query.GetNearestPoint(source, extends, filter, out point);

            if (NavUtil.Failed(status))
            {
                return(false);
            }
            return(true);
        }
Beispiel #13
0
        void Start()
        {
            var prefabEntity = entityManager.CreateEntityQuery(typeof(DinosaurPrefab)).GetSingleton <DinosaurPrefab>().Value;

            SpawnSystem.Enqueue(new Spawn()
                                .WithPrefab(prefabEntity)
                                .WithComponentList(
                                    new NavAgent
            {
                JumpDegrees          = 45,
                JumpGravity          = 100,
                JumpSpeedMultiplierX = 2,
                JumpSpeedMultiplierY = 4,
                TranslationSpeed     = 40,
                TypeID = NavUtil.GetAgentType(NavConstants.HUMANOID),
                Offset = new float3(0, 1, 0)
            },
                                    new Parent {
            },
                                    new LocalToParent {
            },
                                    new LocalToWorld
            {
                Value = float4x4.TRS(
                    new float3(0, 1, 0),
                    quaternion.identity,
                    1
                    )
            },
                                    new NavNeedsSurface {
            }
                                    )
                                );
        }
 void Enqueue()
 {
     SpawnSystem.Enqueue(new Spawn()
                         .WithPrefab(currentPrefab)
                         .WithComponentList(
                             new NavAgent
     {
         JumpDegrees      = 45,
         JumpGravity      = 200,
         TranslationSpeed = 20,
         TypeID           = NavUtil.GetAgentType(NavConstants.HUMANOID),
         Offset           = new float3(0, 1, 0)
     },
                             new Parent {
     },
                             new LocalToParent {
     },
                             new LocalToWorld
     {
         Value = float4x4.TRS(
             new float3(0, 1, 0),
             quaternion.identity,
             1
             )
     },
                             new NavNeedsSurface {
     }
                             ),
                         enqueueCount
                         );
 }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            if (
                !SceneManager.GetActiveScene().name.Equals("NavPerformanceDemo") &&
                !SceneManager.GetActiveScene().name.Equals("NavMovingJumpDemo")
                )
            {
                return(inputDeps);
            }

            var commandBuffer            = barrier.CreateCommandBuffer().ToConcurrent();
            var jumpableBufferFromEntity = GetBufferFromEntity <NavJumpableBufferElement>(true);
            var renderBoundsFromEntity   = GetComponentDataFromEntity <RenderBounds>(true);
            var randomArray = World.GetExistingSystem <RandomSystem>().RandomArray;

            var job = Entities
                      .WithNone <NavLerping>()
                      .WithReadOnly(jumpableBufferFromEntity)
                      .WithReadOnly(renderBoundsFromEntity)
                      .WithNativeDisableParallelForRestriction(randomArray)
                      .ForEach((Entity entity, int entityInQueryIndex, int nativeThreadIndex, ref NavAgent agent) =>
            {
                if (
                    agent.Surface.Equals(Entity.Null) ||
                    !jumpableBufferFromEntity.Exists(agent.Surface)
                    )
                {
                    return;
                }

                var jumpableSurfaces = jumpableBufferFromEntity[agent.Surface];
                var random           = randomArray[nativeThreadIndex];

                if (jumpableSurfaces.Length == 0)
                {     // For the NavPerformanceDemo scene.
                    var bounds             = renderBoundsFromEntity[agent.Surface].Value;
                    agent.WorldDestination = NavUtil.GetRandomPointInBounds(ref random, bounds, agent.Offset, 99);
                }
                else
                {     // For the NavMovingJumpDemo scene.
                    agent.DestinationSurface = jumpableSurfaces[random.NextInt(0, jumpableSurfaces.Length)];
                    var bounds             = renderBoundsFromEntity[agent.DestinationSurface].Value;
                    agent.LocalDestination = NavUtil.GetRandomPointInBounds(ref random, bounds, agent.Offset, 0.7f);     // Agents should not try to jump too close to an edge, hence the scale.
                }

                commandBuffer.AddComponent <NavPlanning>(entityInQueryIndex, entity);

                randomArray[nativeThreadIndex] = random;
            })
                      .WithName("NavDestinationJob")
                      .Schedule(inputDeps);

            barrier.AddJobHandleForProducer(job);

            return(job);
        }
Beispiel #16
0
        /*
         * public float GetPathDistance(Vector3 start, Vector3 end)
         * {
         *  List<Vector3> path = GeneratePath(start, end).;
         *  float distance = 0;
         *
         *  for (int i = 0; i < path.Count - 1; i++)
         *  {
         *      distance += path[i].DistanceFrom(path[i + 1]);
         *  }
         *
         *  return distance;
         * }
         */

        private oVector3[] StraightenPath(oVector3 start, oVector3 end, uint[] path, int pathCount)
        {
            oVector3[] straightPath = new oVector3[200];
            int        count        = 0;

            if (NavUtil.Failed(_query.GetStraightPath(start, end, path, 0, pathCount, straightPath, null, null, out count)))
            {
                throw new Exception("Failed to straighten path.");
            }
            return(straightPath.Take(count).ToArray());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectUtil.RedirectUnauthenticatedUserToLoginPage();
            RedirectUtil.RedirectNonAdminUserToHomePage();

            BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
            {
                new BreadCrumb(NavUtil.GetHomePageUrl(), "Home"),
                new BreadCrumb(NavUtil.GetUsersPageUrl(), "System Info", IsActive: true),
            });
        }
Beispiel #18
0
    private void FindPath()
    {
        NavStatus status = mGroup.query.FindPath(
            mPathStart, mPathEnd, mGroup.filter, mPath.buffer, out mPathCount);

        mCorridor.Reset(mPathStart);
        if (NavUtil.Succeeded(status) && mPathCount > 0)
        {
            mCorridor.SetCorridor(mPathEnd.point, mPath.buffer, mPathCount);
        }
    }
Beispiel #19
0
        public static bool GetConnectionEndpoints(uint startRef, uint endRef, out Vector3 startPos, out Vector3 endPos)
        {
            if (m_Map == null || m_Map.m_NavMesh == null)
            {
                startPos = Vector3.zero;
                endPos   = Vector3.zero;
                return(false);
            }
            var status = m_Map.m_NavMesh.GetConnectionEndpoints(startRef, endRef, out startPos, out endPos);

            return(NavUtil.Succeeded(status));
        }
Beispiel #20
0
        public Pathfinder(Navmesh navMesh)
        {
            _navMesh = navMesh;
            _filter  = new NavmeshQueryFilter();

            if (NavUtil.Failed(NavmeshQuery.Create(_navMesh, 1000, out _query)))
            {
                throw new Exception("NavQuery failed");
            }

            _pathCorridor = new PathCorridor(1000, 1000, _query, _filter);
        }
Beispiel #21
0
        protected override void OnUpdate()
        {
            var physicsWorld             = buildPhysicsWorld.PhysicsWorld;
            var settings                 = navSystem.Settings;
            var commandBuffer            = barrier.CreateCommandBuffer().AsParallelWriter();
            var jumpableBufferFromEntity = GetBufferFromEntity <NavJumpableBufferElement>(true);
            var renderBoundsFromEntity   = GetComponentDataFromEntity <RenderBounds>(true);
            var randomArray              = World.GetExistingSystem <RandomSystem>().RandomArray;

            Dependency = JobHandle.CombineDependencies(Dependency, buildPhysicsWorld.GetOutputDependency());

            Entities
            .WithNone <NavProblem, NavDestination, NavPlanning>()
            .WithReadOnly(jumpableBufferFromEntity)
            .WithReadOnly(renderBoundsFromEntity)
            .WithReadOnly(physicsWorld)
            .WithNativeDisableParallelForRestriction(randomArray)
            .ForEach((Entity entity, int entityInQueryIndex, int nativeThreadIndex, ref NavAgent agent, in Parent surface, in LocalToWorld localToWorld) =>
            {
                if (
                    surface.Value.Equals(Entity.Null) ||
                    !jumpableBufferFromEntity.HasComponent(surface.Value)
                    )
                {
                    return;
                }

                var jumpableSurfaces = jumpableBufferFromEntity[surface.Value];
                var random           = randomArray[nativeThreadIndex];

                if (
                    physicsWorld.GetPointOnSurfaceLayer(
                        localToWorld,
                        NavUtil.GetRandomPointInBounds(
                            ref random,
                            renderBoundsFromEntity[surface.Value].Value,
                            99
                            ),
                        out var validDestination,
                        settings.ObstacleRaycastDistanceMax,
                        settings.ColliderLayer,
                        settings.SurfaceLayer
                        )
                    )
                {
                    commandBuffer.AddComponent(entityInQueryIndex, entity, new NavDestination
                    {
                        WorldPoint = validDestination
                    });
                }

                randomArray[nativeThreadIndex] = random;
            })
        protected override void OnUpdate()
        {
            var commandBuffer            = barrier.CreateCommandBuffer().ToConcurrent();
            var jumpableBufferFromEntity = GetBufferFromEntity <NavJumpableBufferElement>(true);
            var renderBoundsFromEntity   = GetComponentDataFromEntity <RenderBounds>(true);
            var localToWorldFromEntity   = GetComponentDataFromEntity <LocalToWorld>(true);
            var randomArray = World.GetExistingSystem <RandomSystem>().RandomArray;

            Entities
            .WithNone <NavHasProblem, NavNeedsDestination>()
            .WithReadOnly(jumpableBufferFromEntity)
            .WithReadOnly(renderBoundsFromEntity)
            .WithReadOnly(localToWorldFromEntity)
            .WithNativeDisableParallelForRestriction(randomArray)
            .ForEach((Entity entity, int entityInQueryIndex, int nativeThreadIndex, ref NavAgent agent, in Parent surface) =>
            {
                if (
                    surface.Value.Equals(Entity.Null) ||
                    !jumpableBufferFromEntity.Exists(surface.Value)
                    )
                {
                    return;
                }

                var jumpableSurfaces = jumpableBufferFromEntity[surface.Value];
                var random           = randomArray[nativeThreadIndex];

                var destinationSurface = jumpableSurfaces[random.NextInt(0, jumpableSurfaces.Length)];

                var localPoint = NavUtil.GetRandomPointInBounds(
                    ref random,
                    renderBoundsFromEntity[destinationSurface].Value,
                    3
                    );

                var worldPoint = NavUtil.MultiplyPoint3x4(
                    localToWorldFromEntity[destinationSurface.Value].Value,
                    localPoint
                    );

                commandBuffer.AddComponent(entityInQueryIndex, entity, new NavNeedsDestination
                {
                    Destination = worldPoint
                });

                randomArray[nativeThreadIndex] = random;
            })
            .WithName("NavMovingJumpDestinationJob")
            .ScheduleParallel();

            barrier.AddJobHandleForProducer(Dependency);
        }
Beispiel #23
0
        void Enqueue()
        {
            if (!IsForAgents)
            {
                var random = new Unity.Mathematics.Random((uint)new System.Random().Next());

                for (int i = 0; i < enqueueCount; ++i)
                {
                    SpawnSystem.Enqueue(new Spawn()
                                        .WithPrefab(prefabEntity)
                                        .WithComponentList(
                                            new Translation
                    {
                        Value = new float3(
                            random.NextInt(-25, 25),
                            2,
                            random.NextInt(-25, 25)
                            )
                    }
                                            )
                                        );
                }

                return;
            }

            SpawnSystem.Enqueue(new Spawn()
                                .WithPrefab(prefabEntity)
                                .WithComponentList(
                                    new NavAgent
            {
                JumpDegrees      = 45,
                JumpGravity      = 200,
                TranslationSpeed = 20,
                TypeID           = NavUtil.GetAgentType(NavConstants.HUMANOID),
                Offset           = new float3(0, 1, 0)
            },
                                    new NavNeedsSurface {
            },
                                    new Parent {
            },
                                    new LocalToParent {
            },
                                    new Translation
            {
                Value = new float3(0, 1, 0)
            }
                                    ),
                                enqueueCount
                                );
        }
Beispiel #24
0
        public PathBuffer _FindPath(Vector3 start, Vector3 end, Vector3 extends, NavmeshQueryFilter filter = null)
        {
            var query = this.Query;

            if (query == null)
            {
                return(null);
            }
            if (filter == null)
            {
                filter = this.DefaultQueryFilter;
            }
            NavmeshPoint startPoint;
            var          status = query.GetNearestPoint(start, extends, filter, out startPoint);

            if (NavUtil.Failed(status))
            {
                return(null);
            }
            NavmeshPoint endPoint;

            status = query.GetNearestPoint(end, extends, filter, out endPoint);
            if (NavUtil.Failed(status))
            {
                return(null);
            }

            PathBuffer pathBuf = GetPathBuffer();

            if (pathBuf == null || pathBuf.Buffer == null)
            {
                return(null);
            }
            try
            {
                int dataCount;
                status = query.FindPath(ref startPoint, ref endPoint, extends, filter, pathBuf.Buffer, out dataCount);
                if (NavUtil.Failed(status))
                {
                    return(null);
                }

                pathBuf.SetDataCount(dataCount);

                return(pathBuf);
            } catch
            {
                StorePathBuffer(pathBuf);
            }
            return(null);
        }
Beispiel #25
0
 static int NavMeshRaycast(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
         UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 2);
         bool o = NavUtil.NavMeshRaycast(arg0, arg1);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #26
0
    /// <summary>
    /// Creates a new <see cref="Navmesh"/> object from the mesh data
    /// </summary>
    /// <returns>A new <see cref="Navmesh"/> object. Or null if the mesh is not available.</returns>
    public Navmesh GetNavmesh()
    {
        if (!HasNavmesh)
        {
            return(null);
        }

        Navmesh result;

        if (NavUtil.Failed(Navmesh.Create(mDataPack, out result)))
        {
            return(null);
        }

        return(result);
    }
Beispiel #27
0
        public List <Waypoint> GenerateWaypointsBetweenTwoPoints(Navmesh navmesh, Vector3 startPos, Vector3 endPos)
        {
            List <Waypoint> waypoints = new List <Waypoint>();

            NavmeshQuery query;
            var          status = NavmeshQuery.Create(navmesh, 1024, out query);

            if (!NavUtil.Failed(status))
            {
                org.critterai.Vector3 navStartPointVect;
                org.critterai.Vector3 navEndPointVect;
                var navStartPointStatus = query.GetNearestPoint(1, new org.critterai.Vector3(startPos.x, startPos.y, startPos.z), out navStartPointVect);
                var navEndPointStatus   = query.GetNearestPoint(1, new org.critterai.Vector3(startPos.x, startPos.y, startPos.z), out navEndPointVect);
                if (navStartPointStatus == NavStatus.Sucess && navEndPointStatus == NavStatus.Sucess)
                {
                    NavmeshPoint navStartPoint = new NavmeshPoint(1, new org.critterai.Vector3(startPos.x, startPos.y, startPos.z));
                    NavmeshPoint navEndPoint   = new NavmeshPoint(1, new org.critterai.Vector3(endPos.x, endPos.y, endPos.z));

                    uint[] path = new uint[1024];
                    int    pathCount;
                    status = query.FindPath(navStartPoint, navEndPoint, new NavmeshQueryFilter(), path, out pathCount);
                    if (!NavUtil.Failed(status))
                    {
                        const int MaxStraightPath = 4;
                        int       wpCount;
                        org.critterai.Vector3[] wpPoints = new org.critterai.Vector3[MaxStraightPath];
                        uint[] wpPath = new uint[MaxStraightPath];

                        WaypointFlag[] wpFlags = new WaypointFlag[MaxStraightPath];
                        status = query.GetStraightPath(navStartPoint.point, navEndPoint.point
                                                       , path, 0, pathCount, wpPoints, wpFlags, wpPath
                                                       , out wpCount);
                        if (!NavUtil.Failed(status) && wpCount > 0)
                        {
                            foreach (var wp in wpPoints)
                            {
                                Mogre.Vector3 wayPointPos = new Vector3(wp.x, wp.y, wp.z);
                                waypoints.Add(new Waypoint(wayPointPos, new Vector3()));
                            }
                        }
                    }
                }
            }

            return(waypoints);
        }
Beispiel #28
0
 static int PositionValidate(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
         UnityEngine.Vector3 arg1;
         bool o = NavUtil.PositionValidate(arg0, out arg1);
         LuaDLL.lua_pushboolean(L, o);
         ToLua.Push(L, arg1);
         return(2);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        public override void Execute()
        {
            #line 1 "..\..\Views\Shared\_Menu.cshtml"
            Write(NavUtil.WriteMenuLink(Html, "overview", "Index", "Overview", null, "Overview"));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 2 "..\..\Views\Shared\_Menu.cshtml"
            Write(NavUtil.WriteMenuLink(Html, "skills & tech", "Index", "SkillsAndTech", null, "SkillsAndTech"));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 3 "..\..\Views\Shared\_Menu.cshtml"
            Write(NavUtil.WriteMenuLink(Html, "work history", "Index", "WorkHistory", null, "WorkHistory"));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 4 "..\..\Views\Shared\_Menu.cshtml"
            Write(NavUtil.WriteMenuLink(Html, "education", "Index", "Education", null, "Education"));


            #line default
            #line hidden
            WriteLiteral("\r\n");


            #line 5 "..\..\Views\Shared\_Menu.cshtml"
            Write(NavUtil.WriteMenuLink(Html, "contact me", "Index", "ContactMe", null, "ContactMe"));


            #line default
            #line hidden
        }
Beispiel #30
0
 static int DetectLineInNavRange(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
         UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 2);
         UnityEngine.Vector3 arg2;
         bool o = NavUtil.DetectLineInNavRange(arg0, arg1, out arg2);
         LuaDLL.lua_pushboolean(L, o);
         ToLua.Push(L, arg2);
         return(2);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }