Exemplo n.º 1
0
        public override void DoExecute(BaseContext c)
        {
            Vector3 best = base.GetBest(c, c.sampledPositions);

            if (best.sqrMagnitude == 0f)
            {
                return;
            }
            NPCHumanContext nPCHumanContext = c as NPCHumanContext;

            if (nPCHumanContext != null && nPCHumanContext.CurrentCoverVolume != null)
            {
                int num = 0;
                while (num < nPCHumanContext.sampledCoverPoints.Count)
                {
                    CoverPoint           item      = nPCHumanContext.sampledCoverPoints[num];
                    CoverPoint.CoverType coverType = nPCHumanContext.sampledCoverPointTypes[num];
                    if (Vector3Ex.Distance2D(item.Position, best) >= 1f)
                    {
                        num++;
                    }
                    else
                    {
                        nPCHumanContext.CoverSet.Update(item, item, item);
                        break;
                    }
                }
            }
            c.AIAgent.UpdateDestination(best);
            c.lastSampledPosition = best;
        }
        internal static CoverPoint GetClosestCover(
            NPCHumanContext c,
            Vector3 point,
            float MaxDistance,
            ProximityToCover.CoverType _coverType,
            out float bestDistance)
        {
            bestDistance = MaxDistance;
            CoverPoint coverPoint = (CoverPoint)null;

            for (int index = 0; index < c.sampledCoverPoints.Count; ++index)
            {
                CoverPoint           sampledCoverPoint     = c.sampledCoverPoints[index];
                CoverPoint.CoverType sampledCoverPointType = c.sampledCoverPointTypes[index];
                if ((_coverType != ProximityToCover.CoverType.Full || sampledCoverPointType == CoverPoint.CoverType.Full) && (_coverType != ProximityToCover.CoverType.Partial || sampledCoverPointType == CoverPoint.CoverType.Partial))
                {
                    float num = Vector3.Distance(sampledCoverPoint.Position, point);
                    if ((double)num < (double)bestDistance)
                    {
                        bestDistance = num;
                        coverPoint   = sampledCoverPoint;
                    }
                }
            }
            return(coverPoint);
        }
Exemplo n.º 3
0
        internal static CoverPoint GetClosestCover(NPCHumanContext c, Vector3 point, float MaxDistance, ProximityToCover.CoverType _coverType, out float bestDistance)
        {
            bestDistance = MaxDistance;
            CoverPoint coverPoint = null;

            for (int i = 0; i < c.sampledCoverPoints.Count; i++)
            {
                CoverPoint           item      = c.sampledCoverPoints[i];
                CoverPoint.CoverType coverType = c.sampledCoverPointTypes[i];
                if ((_coverType != ProximityToCover.CoverType.Full || coverType == CoverPoint.CoverType.Full) && (_coverType != ProximityToCover.CoverType.Partial || coverType == CoverPoint.CoverType.Partial))
                {
                    float single = Vector3.Distance(item.Position, point);
                    if (single < bestDistance)
                    {
                        bestDistance = single;
                        coverPoint   = item;
                    }
                }
            }
            return(coverPoint);
        }