Beispiel #1
0
        protected override void OnLateInitialize()
        {
            base.OnInitialize();

            CachedBody = this.GetComponent <UnityLSBody>().InternalBody;

            if (this.BlockPathfinding)
            {
                //const long gridSpacing = FixedMath.One;
                bufferCoordinates.FastClear();
                CachedBody.GetCoveredNodePositions(FixedMath.One / 8, bufferCoordinates);


                foreach (Vector2d vec in bufferCoordinates)
                {
                    GridNode node = GridManager.GetNode(vec.x, vec.y);
                    int      gridX, gridY;
                    GridManager.GetCoordinates(vec.x, vec.y, out gridX, out gridY);
                    if (node == null)
                    {
                        continue;
                    }

                    node.AddObstacle();
                }
            }
        }
        private void UpdateCoordinates()
        {
            const long gridSpacing = FixedMath.One;

            bufferCoordinates.FastClear();
            CachedBody.GetCoveredSnappedPositions(gridSpacing, bufferCoordinates);
            foreach (Vector2d vec in bufferCoordinates)
            {
                GridNode node = GridManager.GetNode(vec.x, vec.y);

                if (node == null)
                {
                    continue;
                }

                node.AddObstacle();
                LastCoordinates.Add(node);
            }
        }