Ejemplo n.º 1
0
 /// <summary>
 /// Remove a finder from the finder list
 /// </summary>
 /// <param name="value">the finder you want to remove</param>
 public static void RemoveFinder(BaseAOIFinder value)
 {
     if (finders.Contains(value))
     {
         finders.Remove(value);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Add a finder to the finder list
 /// </summary>
 /// <param name="value">the finder you want to add</param>
 public static void AddFinder(BaseAOIFinder value)
 {
     if (!finders.Contains(value))
     {
         finders.Add(value);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Handle AOI Change
 /// </summary>
 /// <param name="finder">The finder that we got in range/ out of range of.</param>
 /// <param name="_inRange">Are we in range of the finder or out of range of the finder?</param>
 public virtual void HandleAOI(BaseAOIFinder finder, bool _inRange)
 {
     //add your code when inheriting...
     if (!calculateDuplicates || inRange == _inRange)
     {
         return;                                              // make sure we arent receiving same data.
     }
     this.inRange = _inRange;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the AOI of the finder.
        /// </summary>
        /// <param name="finder">the finder you want to update the AOI zone of.</param>
        public static void UpdateAOI(BaseAOIFinder finder)
        {
            ThreadTask <BaseAOIFinder> task = new ThreadTask <BaseAOIFinder>(ComputeAOI, finder);

            UpdatePositions();

            #if !UNITY_WEBGL
            ThreadManager.RunOnUConstructThread(task);
            #else
            ThreadManager.RunOnUnityThread(task);
            #endif
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handle the AOI results
        /// </summary>
        /// <param name="finder">the finder that our results got changed of</param>
        /// <param name="_inRange">are we in range of the finder?</param>
        public override void HandleAOI(BaseAOIFinder finder, bool _inRange)
        {
            base.HandleAOI(finder, _inRange);

            if (buildingGroup == null)
            {
                buildingGroup = GetComponent <BaseBuildingGroup>();
            }

            if (buildingGroup != null)
            {
                buildingGroup.AOIGroup(_inRange, finder.aoiPosition, finder.radius);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handle the AOI.
        /// </summary>
        /// <param name="target">our target</param>
        /// <param name="finder">our finder</param>
        /// <param name="isUnityThread">is this executed from unity's thread.</param>
        private static void HandleAOI(BaseAOITarget target, BaseAOIFinder finder, bool isUnityThread)
        {
            bool inDistance = target.InZone(finder.aoiPosition, finder.radius);

            if (!target.calculateDuplicates || target.inRange != inDistance) // if we arent duplicating
            {
                if (isUnityThread)
                {
                    target.HandleAOI(finder, inDistance);
                }
                else
                {
                    ThreadManager.RunOnUnityThread(new ThreadTask <BaseAOITarget, BaseAOIFinder, bool>((BaseAOITarget _target, BaseAOIFinder _finder, bool _inDistance) =>
                    {
                        _target.HandleAOI(_finder, _inDistance);
                    }, target, finder, inDistance));
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Compute AOI for a certain finder
        /// </summary>
        /// <param name="finder">the finder you want to compute AOI for.</param>
        static void ComputeAOI(BaseAOIFinder finder)
        {
            BaseAOITarget target;

            for (int i = 0; i < targets.Count; i++)
            {
                target = targets[i];

                if (target.useMultiThreadZoneSearch)
                {
                    HandleAOI(target, finder, false);
                }
                else
                {
                    ThreadManager.RunOnUnityThread(new ThreadTask <BaseAOITarget, BaseAOIFinder>((BaseAOITarget _target, BaseAOIFinder _finder) =>
                    {
                        HandleAOI(_target, _finder, true);
                    }, target, finder));
                }
            }
        }