示例#1
0
 private bool CanHitFromCellIgnoringRange(IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest)
 {
     if (targ.Thing != null)
     {
         if (targ.Thing.Map != this.caster.Map)
         {
             goodDest = IntVec3.Invalid;
             return(false);
         }
         ShootLeanUtility.CalcShootableCellsOf(Verb.tempDestList, targ.Thing);
         for (int i = 0; i < Verb.tempDestList.Count; i++)
         {
             if (this.CanHitCellFromCellIgnoringRange(sourceCell, Verb.tempDestList[i], targ.Thing.def.Fillage == FillCategory.Full))
             {
                 goodDest = Verb.tempDestList[i];
                 return(true);
             }
         }
     }
     else if (this.CanHitCellFromCellIgnoringRange(sourceCell, targ.Cell, false))
     {
         goodDest = targ.Cell;
         return(true);
     }
     goodDest = IntVec3.Invalid;
     return(false);
 }
示例#2
0
        public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine)
        {
            if (targ.HasThing && targ.Thing.Map != caster.Map)
            {
                resultingLine = default(ShootLine);
                return(false);
            }
            if (verbProps.IsMeleeAttack || verbProps.range <= 1.42f)
            {
                resultingLine = new ShootLine(root, targ.Cell);
                return(ReachabilityImmediate.CanReachImmediate(root, targ, caster.Map, PathEndMode.Touch, null));
            }
            CellRect cellRect = targ.HasThing ? targ.Thing.OccupiedRect() : CellRect.SingleCell(targ.Cell);
            float    num      = verbProps.EffectiveMinRange(targ, caster);
            float    num2     = cellRect.ClosestDistSquaredTo(root);

            if (num2 > verbProps.range * verbProps.range || num2 < num * num)
            {
                resultingLine = new ShootLine(root, targ.Cell);
                return(false);
            }
            if (!verbProps.requireLineOfSight)
            {
                resultingLine = new ShootLine(root, targ.Cell);
                return(true);
            }
            IntVec3 goodDest;

            if (CasterIsPawn)
            {
                if (CanHitFromCellIgnoringRange(root, targ, out goodDest))
                {
                    resultingLine = new ShootLine(root, goodDest);
                    return(true);
                }
                ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), caster.Map, tempLeanShootSources);
                for (int i = 0; i < tempLeanShootSources.Count; i++)
                {
                    IntVec3 intVec = tempLeanShootSources[i];
                    if (CanHitFromCellIgnoringRange(intVec, targ, out goodDest))
                    {
                        resultingLine = new ShootLine(intVec, goodDest);
                        return(true);
                    }
                }
            }
            else
            {
                foreach (IntVec3 item in caster.OccupiedRect())
                {
                    if (CanHitFromCellIgnoringRange(item, targ, out goodDest))
                    {
                        resultingLine = new ShootLine(item, goodDest);
                        return(true);
                    }
                }
            }
            resultingLine = new ShootLine(root, targ.Cell);
            return(false);
        }
示例#3
0
        public static void LeanShootingSourcesFromTo(IntVec3 shooterLoc, IntVec3 targetPos, Map map, List <IntVec3> listToFill)
        {
            listToFill.Clear();
            float angleFlat = (targetPos - shooterLoc).AngleFlat;
            bool  flag      = angleFlat > 270f || angleFlat < 90f;
            bool  flag2     = angleFlat > 90f && angleFlat < 270f;
            bool  flag3     = angleFlat > 180f;
            bool  flag4     = angleFlat < 180f;

            bool[] workingBlockedArray = ShootLeanUtility.GetWorkingBlockedArray();
            for (int i = 0; i < 8; i++)
            {
                workingBlockedArray[i] = !(shooterLoc + GenAdj.AdjacentCells[i]).CanBeSeenOver(map);
            }
            if (!workingBlockedArray[1] && ((workingBlockedArray[0] && !workingBlockedArray[5] && flag) || (workingBlockedArray[2] && !workingBlockedArray[4] && flag2)))
            {
                listToFill.Add(shooterLoc + new IntVec3(1, 0, 0));
            }
            if (!workingBlockedArray[3] && ((workingBlockedArray[0] && !workingBlockedArray[6] && flag) || (workingBlockedArray[2] && !workingBlockedArray[7] && flag2)))
            {
                listToFill.Add(shooterLoc + new IntVec3(-1, 0, 0));
            }
            if (!workingBlockedArray[2] && ((workingBlockedArray[3] && !workingBlockedArray[7] && flag3) || (workingBlockedArray[1] && !workingBlockedArray[4] && flag4)))
            {
                listToFill.Add(shooterLoc + new IntVec3(0, 0, -1));
            }
            if (!workingBlockedArray[0] && ((workingBlockedArray[3] && !workingBlockedArray[6] && flag3) || (workingBlockedArray[1] && !workingBlockedArray[5] && flag4)))
            {
                listToFill.Add(shooterLoc + new IntVec3(0, 0, 1));
            }
            for (int j = 0; j < 4; j++)
            {
                if (!workingBlockedArray[j])
                {
                    if (j != 0 || flag)
                    {
                        if (j != 1 || flag4)
                        {
                            if (j != 2 || flag2)
                            {
                                if (j != 3 || flag3)
                                {
                                    if ((shooterLoc + GenAdj.AdjacentCells[j]).GetCover(map) != null)
                                    {
                                        listToFill.Add(shooterLoc + GenAdj.AdjacentCells[j]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ShootLeanUtility.ReturnWorkingBlockedArray(workingBlockedArray);
        }
示例#4
0
        public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine)
        {
            if (targ.HasThing && targ.Thing.Map != this.caster.Map)
            {
                resultingLine = default(ShootLine);
                return(false);
            }
            if (this.verbProps.IsMeleeAttack || this.verbProps.range <= 1.42f)
            {
                resultingLine = new ShootLine(root, targ.Cell);
                return(ReachabilityImmediate.CanReachImmediate(root, targ, this.caster.Map, PathEndMode.Touch, null));
            }
            CellRect cellRect = (!targ.HasThing) ? CellRect.SingleCell(targ.Cell) : targ.Thing.OccupiedRect();
            float    num      = this.verbProps.EffectiveMinRange(targ, this.caster);
            float    num2     = cellRect.ClosestDistSquaredTo(root);

            if (num2 > this.verbProps.range * this.verbProps.range || num2 < num * num)
            {
                resultingLine = new ShootLine(root, targ.Cell);
                return(false);
            }
            if (!this.verbProps.requireLineOfSight)
            {
                resultingLine = new ShootLine(root, targ.Cell);
                return(true);
            }
            if (this.CasterIsPawn)
            {
                IntVec3 dest;
                if (this.CanHitFromCellIgnoringRange(root, targ, out dest))
                {
                    resultingLine = new ShootLine(root, dest);
                    return(true);
                }
                ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), this.caster.Map, Verb.tempLeanShootSources);
                for (int i = 0; i < Verb.tempLeanShootSources.Count; i++)
                {
                    IntVec3 intVec = Verb.tempLeanShootSources[i];
                    if (this.CanHitFromCellIgnoringRange(intVec, targ, out dest))
                    {
                        resultingLine = new ShootLine(intVec, dest);
                        return(true);
                    }
                }
            }
            else
            {
                CellRect.CellRectIterator iterator = this.caster.OccupiedRect().GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 intVec2 = iterator.Current;
                    IntVec3 dest;
                    if (this.CanHitFromCellIgnoringRange(intVec2, targ, out dest))
                    {
                        resultingLine = new ShootLine(intVec2, dest);
                        return(true);
                    }
                    iterator.MoveNext();
                }
            }
            resultingLine = new ShootLine(root, targ.Cell);
            return(false);
        }
        public static void LeanShootingSourcesFromTo(IntVec3 shooterLoc, IntVec3 targetPos, Map map, List <IntVec3> listToFill)
        {
            listToFill.Clear();
            float angleFlat = (targetPos - shooterLoc).AngleFlat;
            bool  flag      = angleFlat > 270.0 || angleFlat < 90.0;
            bool  flag2     = angleFlat > 90.0 && angleFlat < 270.0;
            bool  flag3     = angleFlat > 180.0;
            bool  flag4     = angleFlat < 180.0;

            bool[] workingBlockedArray = ShootLeanUtility.GetWorkingBlockedArray();
            for (int i = 0; i < 8; i++)
            {
                workingBlockedArray[i] = !(shooterLoc + GenAdj.AdjacentCells[i]).CanBeSeenOver(map);
            }
            if (!workingBlockedArray[1])
            {
                if (workingBlockedArray[0] && !workingBlockedArray[5] && flag)
                {
                    goto IL_00d3;
                }
                if (workingBlockedArray[2] && !workingBlockedArray[4] && flag2)
                {
                    goto IL_00d3;
                }
            }
            goto IL_00e7;
IL_0134:
            if (!workingBlockedArray[2])
            {
                if (workingBlockedArray[3] && !workingBlockedArray[7] && flag3)
                {
                    goto IL_016f;
                }
                if (workingBlockedArray[1] && !workingBlockedArray[4] && flag4)
                {
                    goto IL_016f;
                }
            }
            goto IL_0183;
IL_016f:
            listToFill.Add(shooterLoc + new IntVec3(0, 0, -1));
            goto IL_0183;
IL_0120:
            listToFill.Add(shooterLoc + new IntVec3(-1, 0, 0));
            goto IL_0134;
IL_01be:
            listToFill.Add(shooterLoc + new IntVec3(0, 0, 1));
            goto IL_01d2;
IL_0183:
            if (!workingBlockedArray[0])
            {
                if (workingBlockedArray[3] && !workingBlockedArray[6] && flag3)
                {
                    goto IL_01be;
                }
                if (workingBlockedArray[1] && !workingBlockedArray[5] && flag4)
                {
                    goto IL_01be;
                }
            }
            goto IL_01d2;
IL_01d2:
            for (int j = 0; j < 4; j++)
            {
                if (!workingBlockedArray[j] && (j != 0 || flag) && (j != 1 || flag4) && (j != 2 || flag2) && (j != 3 || flag3) && (shooterLoc + GenAdj.AdjacentCells[j]).GetCover(map) != null)
                {
                    listToFill.Add(shooterLoc + GenAdj.AdjacentCells[j]);
                }
            }
            ShootLeanUtility.ReturnWorkingBlockedArray(workingBlockedArray);
            return;

IL_00d3:
            listToFill.Add(shooterLoc + new IntVec3(1, 0, 0));
            goto IL_00e7;
IL_00e7:
            if (!workingBlockedArray[3])
            {
                if (workingBlockedArray[0] && !workingBlockedArray[6] && flag)
                {
                    goto IL_0120;
                }
                if (workingBlockedArray[2] && !workingBlockedArray[7] && flag2)
                {
                    goto IL_0120;
                }
            }
            goto IL_0134;
        }