Esempio n. 1
0
        public async Task Activate(Vector3 position, float range, ICellOperationCallbacks cellOperationCallback)
        {
            var activatedIndices = InnerSphereIndices(position, range);
            var entered          = new List <CellIndex>();
            var exited           = new List <CellIndex>();
            await Task.Run(() =>
            {
                foreach (var activatedIndex in activatedIndices)
                {
                    var found = false;
                    foreach (var activeIndex in activeIndices)
                    {
                        if (!activatedIndex.Equals(activeIndex))
                        {
                            continue;
                        }
                        found = true;
                        break;
                    }
                    if (!found)
                    {
                        entered.Add(activatedIndex);
                    }
                }

                foreach (var activeIndex in activeIndices)
                {
                    var found = false;
                    foreach (var activatedIndex in activatedIndices)
                    {
                        if (!activeIndex.Equals(activatedIndex))
                        {
                            continue;
                        }
                        found = true;
                        break;
                    }
                    if (!found)
                    {
                        exited.Add(activeIndex);
                    }
                }
            });

            foreach (var cellIndex in exited)
            {
                cellOperationCallback.Remove(cellIndex);
            }
            foreach (var cellIndex in entered)
            {
                cellOperationCallback.Create(cellIndex, RectFromIndex(cellIndex));
            }
            activeIndices = activatedIndices;
        }
Esempio n. 2
0
        public void Activate(Vector3 position, float range, ICellOperationCallbacks cellOperationCallback)
        {
            var activatedIndices = InnerSphereIndices(position, range);

            foreach (var activatedIndex in activatedIndices)
            {
                var found = false;
                foreach (var activeIndex in activeIndices)
                {
                    if (!activatedIndex.Equals(activeIndex))
                    {
                        continue;
                    }
                    found = true;
                    break;
                }
                if (!found)
                {
                    cellOperationCallback.Create(activatedIndex, RectFromIndex(activatedIndex));
                }
            }

            foreach (var activeIndex in activeIndices)
            {
                var found = false;
                foreach (var activatedIndex in activatedIndices)
                {
                    if (!activeIndex.Equals(activatedIndex))
                    {
                        continue;
                    }
                    found = true;
                    break;
                }
                if (!found)
                {
                    cellOperationCallback.Remove(activeIndex);
                }
            }
            activeIndices = activatedIndices;
        }