示例#1
0
        public void Should_BeEqual()
        {
            var d1 = new IntRange(10, 50);
            var d2 = new IntRange(10, 50);
            var d3 = new IntRange(20, 50);

            d1.Equals(d2).Should().BeTrue();
            d1.Equals(d3).Should().BeFalse();
        }
示例#2
0
        public void Comparison()
        {
            IntRange rangeA = new IntRange(1, 1);
            IntRange rangeB = new IntRange(1, 1);
            IntRange rangeC = new IntRange(2, 2);

            Assert.IsTrue(rangeA.Equals(rangeB));
            Assert.IsFalse(rangeA.Equals(rangeC));
            Assert.IsFalse(rangeB.Equals(rangeC));
            Assert.AreEqual(rangeA, rangeB);
            Assert.AreNotEqual(rangeA, rangeC);
            Assert.AreNotEqual(rangeB, rangeC);
        }
示例#3
0
        public void EqualityOperatorTest( int min1, int max1, int min2, int max2, bool areEqual )
        {
            IntRange range1 = new IntRange( min1, max1 );
            IntRange range2 = new IntRange( min2, max2 );

            Assert.AreEqual( range1.Equals( range2 ), areEqual );
            Assert.AreEqual( range1 == range2, areEqual );
            Assert.AreEqual( range1 != range2, !areEqual );
        }
示例#4
0
        public void EqualityOperatorTest(int min1, int max1, int min2, int max2, bool areEqual)
        {
            IntRange range1 = new IntRange(min1, max1);
            IntRange range2 = new IntRange(min2, max2);

            Assert.AreEqual(range1.Equals(range2), areEqual);
            Assert.AreEqual(range1 == range2, areEqual);
            Assert.AreEqual(range1 != range2, !areEqual);
        }
        public static IntVec3 TryFindWatchBuildingPosition(Pawn pawn, Building building, IntRange standDistanceRange, bool desireToSit, out Thing chair)
        {
            chair = null;

            if (standDistanceRange.Equals(IntRange.zero))
            {
                return(building.Position);
            }

            List <IntVec3> foundCells = FindAllWatchBuildingCells(building, standDistanceRange);

            for (int j = 0; j < foundCells.Count; j++)
            {
                IntVec3 intVec = foundCells[j];

                bool flag = false;
                if (desireToSit)
                {
                    chair = intVec.GetEdifice(pawn.Map);
                    if (chair != null && chair.def.building.isSittable && pawn.CanReserve(chair, 1))
                    {
                        flag = true;
                    }
                    else
                    {
                        // Not sittable or reservable => null
                        chair = null;
                    }
                }
                else if (intVec.InBounds(pawn.Map) && intVec.Standable(pawn.Map) && !intVec.IsForbidden(pawn) && pawn.CanReserve(intVec, 1) && pawn.Map.pawnDestinationReservationManager.CanReserve(intVec, pawn))
                {
                    flag = true;
                }

                if (flag && GenSight.LineOfSight(intVec, building.Position, pawn.Map, false))
                {
                    return(intVec);
                }
            }

            return(IntVec3.Invalid);
        }