Exemplo n.º 1
0
 public virtual void ClearPreview()
 {
     if (!(this.m_LastGrid == null))
     {
         BoundsInt?lastBounds = this.m_LastBounds;
         if (lastBounds.HasValue && !(this.m_LastBrushTarget == null))
         {
             GridBrushBase.Tool?lastTool = this.m_LastTool;
             if (lastTool.HasValue)
             {
                 Tilemap component = this.m_LastBrushTarget.GetComponent <Tilemap>();
                 if (component != null)
                 {
                     GridBrushBase.Tool?lastTool2 = this.m_LastTool;
                     if (lastTool2.HasValue)
                     {
                         GridBrushBase.Tool value = lastTool2.Value;
                         if (value != GridBrushBase.Tool.FloodFill)
                         {
                             if (value != GridBrushBase.Tool.Box)
                             {
                                 if (value == GridBrushBase.Tool.Paint)
                                 {
                                     foreach (Vector3Int current in this.m_LastBounds.Value.allPositionsWithin)
                                     {
                                         GridBrushEditor.ClearTilemapPreview(component, current);
                                     }
                                 }
                             }
                             else
                             {
                                 Vector3Int position  = this.m_LastBounds.Value.position;
                                 Vector3Int a         = position + this.m_LastBounds.Value.size;
                                 BoundsInt  boundsInt = new BoundsInt(position, a - position);
                                 foreach (Vector3Int current2 in boundsInt.allPositionsWithin)
                                 {
                                     GridBrushEditor.ClearTilemapPreview(component, current2);
                                 }
                             }
                         }
                         else
                         {
                             component.ClearAllEditorPreviewTiles();
                         }
                     }
                 }
                 this.m_LastBrushTarget = null;
                 this.m_LastGrid        = null;
                 this.m_LastBounds      = null;
                 this.m_LastTool        = null;
             }
         }
     }
 }
Exemplo n.º 2
0
        public override void OnPaintSceneGUI(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
        {
            BoundsInt position2 = position;
            bool      flag      = false;

            if (Event.current.type == EventType.Layout)
            {
                int hash = GridBrushEditor.GetHash(gridLayout, brushTarget, position, tool, this.brush);
                flag = (hash != this.m_LastPreviewRefreshHash);
                if (flag)
                {
                    this.m_LastPreviewRefreshHash = hash;
                }
            }
            if (tool == GridBrushBase.Tool.Move)
            {
                if (flag && executing)
                {
                    this.ClearPreview();
                    this.PaintPreview(gridLayout, brushTarget, position.min);
                }
            }
            else if (tool == GridBrushBase.Tool.Paint || tool == GridBrushBase.Tool.Erase)
            {
                if (flag)
                {
                    this.ClearPreview();
                    if (tool != GridBrushBase.Tool.Erase)
                    {
                        this.PaintPreview(gridLayout, brushTarget, position.min);
                    }
                }
                position2 = new BoundsInt(position.min - this.brush.pivot, this.brush.size);
            }
            else if (tool == GridBrushBase.Tool.Box)
            {
                if (flag)
                {
                    this.ClearPreview();
                    this.BoxFillPreview(gridLayout, brushTarget, position);
                }
            }
            else if (tool == GridBrushBase.Tool.FloodFill)
            {
                if (flag)
                {
                    this.ClearPreview();
                    this.FloodFillPreview(gridLayout, brushTarget, position.min);
                }
            }
            base.OnPaintSceneGUI(gridLayout, brushTarget, position2, tool, executing);
        }
Exemplo n.º 3
0
 public virtual void BoxFillPreview(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
 {
     if (brushTarget != null)
     {
         Tilemap component = brushTarget.GetComponent <Tilemap>();
         if (component != null)
         {
             foreach (Vector3Int current in position.allPositionsWithin)
             {
                 Vector3Int          vector3Int = current - position.min;
                 GridBrush.BrushCell brushCell  = this.brush.cells[this.brush.GetCellIndexWrapAround(vector3Int.x, vector3Int.y, vector3Int.z)];
                 if (brushCell.tile != null)
                 {
                     GridBrushEditor.SetTilemapPreviewCell(component, current, brushCell.tile, brushCell.matrix, brushCell.color);
                 }
             }
         }
     }
     this.m_LastGrid        = gridLayout;
     this.m_LastBounds      = new BoundsInt?(position);
     this.m_LastBrushTarget = brushTarget;
     this.m_LastTool        = new GridBrushBase.Tool?(GridBrushBase.Tool.Box);
 }
Exemplo n.º 4
0
        public virtual void PaintPreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
        {
            Vector3Int vector3Int = position - this.brush.pivot;
            Vector3Int a          = vector3Int + this.brush.size;
            BoundsInt  value      = new BoundsInt(vector3Int, a - vector3Int);

            if (brushTarget != null)
            {
                Tilemap component = brushTarget.GetComponent <Tilemap>();
                foreach (Vector3Int current in value.allPositionsWithin)
                {
                    Vector3Int          brushPosition = current - vector3Int;
                    GridBrush.BrushCell brushCell     = this.brush.cells[this.brush.GetCellIndex(brushPosition)];
                    if (brushCell.tile != null && component != null)
                    {
                        GridBrushEditor.SetTilemapPreviewCell(component, current, brushCell.tile, brushCell.matrix, brushCell.color);
                    }
                }
            }
            this.m_LastGrid        = gridLayout;
            this.m_LastBounds      = new BoundsInt?(value);
            this.m_LastBrushTarget = brushTarget;
            this.m_LastTool        = new GridBrushBase.Tool?(GridBrushBase.Tool.Paint);
        }