Пример #1
0
 public NativeArray <GeometryDataModels.Target> GetTargetsAsNativeArray(Vector3 rayLocation, Vector3 rayDirection, GeometryVision geometryVision, TargetingInstruction targetingInstruction)
 {
     throw new System.NotImplementedException();
 }
        List <GeometryDataModels.Target> IGeoTargeting.GetTargets(Vector3 rayLocation, Vector3 rayDirection,
                                                                  GeometryVision geometryVision, TargetingInstruction targetingInstruction)
        {
            geoVision                  = geometryVision;
            this.rayLocation           = rayLocation;
            this.rayDirectionWS        = rayDirection;
            this.entityFilterComponent = targetingInstruction.GetCurrentEntityFilterType();
            Update();

            return(this.targets.ToList());
        }
Пример #3
0
        List <GeometryDataModels.Target> IGeoTargeting.GetTargets(Vector3 rayLocation, Vector3 rayDirectionWS,
                                                                  GeometryVision geoVision, TargetingInstruction targetingInstruction)
        {
            GeometryDataModels.Target        targetInfo        = new GeometryDataModels.Target();
            List <GeometryDataModels.Target> gameObjectTargets = new List <GeometryDataModels.Target>();

            if (targetingInstruction.TargetTag.Length > 0)
            {
                foreach (var geoInfoAsTarget in geoVision.GetEye <GeometryVisionEye>().SeenGeoInfos)
                {
                    if (geoInfoAsTarget.gameObject.CompareTag(targetingInstruction.TargetTag))
                    {
                        gameObjectTargets.Add(GetDataForTarget(geoInfoAsTarget));
                    }
                }
            }
            else
            {
                foreach (var geoInfoAsTarget in geoVision.GetEye <GeometryVisionEye>().SeenGeoInfos)
                {
                    gameObjectTargets.Add(GetDataForTarget(geoInfoAsTarget));
                }
            }


            return(gameObjectTargets);

            //Local functions

            GeometryDataModels.Target GetDataForTarget(GeometryDataModels.GeoInfo geoInfoAsTarget)
            {
                float3 point = geoInfoAsTarget.transform.position;
                float3 rayDirectionEndPoint = rayDirectionWS;

                point = pointToRaySpace(rayLocation, point);
                rayDirectionEndPoint = pointToRaySpace(rayLocation, rayDirectionWS);
                targetInfo.projectedTargetPosition = Vector3.Project(point, rayDirectionEndPoint) + rayLocation;
                targetInfo.position      = pointFromRaySpaceToObjectSpace(point, rayLocation);
                targetInfo.distanceToRay =
                    Vector3.Distance(targetInfo.position, targetInfo.projectedTargetPosition);
                targetInfo.distanceToCastOrigin =
                    Vector3.Distance(rayLocation, targetInfo.projectedTargetPosition);
                targetInfo.GeoInfoHashCode = geoInfoAsTarget.GetHashCode();

                return(targetInfo);
            }
        }
        public NativeArray <GeometryDataModels.Target> GetTargetsAsNativeArray(Vector3 rayLocation, Vector3 rayDirection, GeometryVision geometryVision, TargetingInstruction targetingInstruction)
        {
            geoVision                  = geometryVision;
            this.rayLocation           = rayLocation;
            this.rayDirectionWS        = rayDirection;
            this.entityFilterComponent = targetingInstruction.GetCurrentEntityFilterType();
            Update();

            return(this.targets);
        }