public IItem AddItem(IsoRect bounds, T content)
 {
     if (bounds.x.size > 0.0f && bounds.y.size > 0.0f)
     {
         if (_rootNode == null)
         {
             var initial_side = IsoUtils.Vec2From(
                 IsoUtils.Vec2MaxF(bounds.size));
             var initial_bounds = new IsoRect(
                 bounds.center - initial_side * 2.0f,
                 bounds.center + initial_side * 2.0f);
             _rootNode = _nodePool.Take().Init(null, initial_bounds);
         }
         Item item;
         while (!_rootNode.AddItem(bounds, content, out item, _nodePool, _itemPool))
         {
             GrowUp(
                 bounds.center.x < _rootNode.SelfBounds.center.x,
                 bounds.center.y < _rootNode.SelfBounds.center.y);
         }
         return(item);
     }
     else
     {
         return(_itemPool.Take().Init(null, bounds, content));
     }
 }
Exemple #2
0
		void SetupSectorSize() {
			_sectorsSize = 0.0f;
			var visibles_iter = _visibles.GetEnumerator();
			while ( visibles_iter.MoveNext() ) {
				_sectorsSize += IsoUtils.Vec2MaxF(visibles_iter.Current.Internal.ScreenRect.size);
			}
			var min_sector_size = IsoToScreen(IsoUtils.vec3OneX).x - IsoToScreen(Vector3.zero).x;
			_sectorsSize = Mathf.Round(Mathf.Max(min_sector_size, _sectorsSize / _visibles.Count));
		}