Esempio n. 1
0
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     return(ChunkPos.Equals(((ChunkAwarenessInfo)obj).ChunkPos));
 }
Esempio n. 2
0
        private static void Vector3iInequality(params int[] a)
        {
            var p = new Vector3i(2, 3, 5);
            var q = new Vector3i(a[0], a[1], a[2]);

            Assert.IsFalse(p.Equals(q));
            Assert.IsFalse(p == q);
            Assert.IsTrue(p != q);
        }
Esempio n. 3
0
        public void Vector3iEquality()
        {
            Vector3i
                p = new Vector3i(1, 2, 3),
                q = new Vector3i(1, 2, 3);

            Assert.IsTrue(p.Equals(q));
            Assert.IsTrue(p == q);
            Assert.IsFalse(p != q);
        }
Esempio n. 4
0
        public void Vector3iCtorCopy()
        {
            Vector3i
                p = new Vector3i(1, 2, 3),
                q = new Vector3i(p);

            Assert.IsTrue(p.Equals(q));
            Assert.IsTrue(p == q);
            Assert.IsFalse(p != q);
            Assert.IsFalse(ReferenceEquals(p, q));
        }
Esempio n. 5
0
        private static void RemoveLight(ELinkedList <Block> removedBlocksList, Block block, Vector3i source)
        {
            var light = block.BlockLight;

            if (!source.Equals(light.SunlightSource))
            {
                return;
            }

            var oldLight = Equals(block.Position, source) ? Block.MaxBlockLight : light.Sunlight;

            light.Sunlight       = light.LinearSunlight;
            light.SunlightSource = block.Position;
            removedBlocksList.Add(block);

            for (var i = 0; i < Faces; i++)
            {
                var face      = (BlockFace)i;
                var opposite  = BlockFaceMethods.GetOpposite(face);
                var neighbour = block.GetNeighbour((BlockFace)i);
                if (neighbour == null)
                {
                    continue;
                }

                if (!block.CanLightPassThrough(face) || !neighbour.CanLightBePassedFrom(opposite, block))
                {
                    continue;
                }
                if (oldLight <= neighbour.BlockLight.Sunlight)
                {
                    continue;
                }
                RemoveLight(removedBlocksList, neighbour, source);
            }
        }
    public override bool Equals(object obj)
    {
        PathingNode objNode = (PathingNode)obj;

        return(obj != null && objNode != null && loc.Equals(objNode.loc));
    }
    //Quick implementation of A* pathing
    private Vector3[] AStar(Vector3 start, Vector3 goal)
    {
        List <PathingNode> closedSet = new List <PathingNode> ();
        List <PathingNode> openSet   = new List <PathingNode> ();

        Vector3i goalI  = new Vector3i(goal.x, goal.y, goal.z);
        Vector3i startI = new Vector3i(start.x, start.y - midPointHeight, start.z);

        PathingNode currNode = new PathingNode(startI, goalI);

        openSet.Add(currNode);

        int count = 0;

        //Brief check to stop if we're already at the goal; or if our current position is not viable
        if (startI.Equals(goalI) || !IsViablePosition(startI))
        {
            return(null);
        }

        //Actual A* pathing
        while (openSet.Count != 0 && count < maxChecksPerFrame)
        {
            count++;
            currNode = openSet[0];

            //get best next node
            foreach (PathingNode node in openSet)
            {
                if (node.GetFScore() < currNode.GetFScore())
                {
                    currNode = node;
                }
            }

            //Did we make it
            if (currNode.loc.DistanceSquared(goalI) < 3 || count == maxChecksPerFrame)
            {
                return(GetPathFromNode(currNode));
            }
            else
            {
                openSet.Remove(currNode);
                closedSet.Add(currNode);

                //Get next allowable moves
                List <Vector3i> moves = GetPossibleNextMovesFromPosition(currNode.loc);

                foreach (Vector3i move in moves)
                {
                    PathingNode potentialNode = new PathingNode(move, goalI, currNode);

                    if (closedSet.Contains(potentialNode))
                    {
                    }
                    else if (openSet.Contains(potentialNode))                     //See if we need to update the node
                    {
                        int index = openSet.IndexOf(potentialNode);
                        if (openSet[index].g_score > potentialNode.g_score)
                        {
                            //Update the node if this version is better
                            openSet[index] = potentialNode;
                        }
                    }
                    else
                    {
                        //Add the node to the openSet if its new
                        openSet.Add(potentialNode);
                    }
                }
            }
        }
        return(null);
    }