private bool OnCopy(ICommonSession?session, EntityCoordinates coords, EntityUid uid)
        {
            if (!CanSandbox())
            {
                return(false);
            }

            // Try copy entity.
            if (uid.IsValid() &&
                EntityManager.TryGetComponent(uid, out MetaDataComponent? comp) &&
                !comp.EntityDeleted)
            {
                if (comp.EntityPrototype == null || comp.EntityPrototype.NoSpawn || comp.EntityPrototype.Abstract)
                {
                    return(false);
                }

                if (_placementManager.Eraser)
                {
                    _placementManager.ToggleEraser();
                }

                _placementManager.BeginPlacing(new()
                {
                    EntityType      = comp.EntityPrototype.ID,
                    IsTile          = false,
                    TileType        = 0,
                    PlacementOption = comp.EntityPrototype.PlacementMode
                });
                return(true);
            }

            // Try copy tile.
            if (!_mapManager.TryFindGridAt(coords.ToMap(EntityManager), out var grid) || !grid.TryGetTileRef(coords, out var tileRef))
            {
                return(false);
            }

            if (_placementManager.Eraser)
            {
                _placementManager.ToggleEraser();
            }

            _placementManager.BeginPlacing(new()
            {
                EntityType      = null,
                IsTile          = true,
                TileType        = tileRef.Tile.TypeId,
                PlacementOption = nameof(AlignTileAny)
            });
            return(true);
        }
    private void OnStartPlacementAction(StartPlacementActionEvent args)
    {
        if (args.Handled)
        {
            return;
        }

        args.Handled = true;

        _placementMan.BeginPlacing(new()
        {
            EntityType      = args.EntityType,
            IsTile          = args.TileId != null,
            TileType        = args.TileId != null ? _tileMan[args.TileId].TileId : (ushort)0,
            PlacementOption = args.PlacementOption,
        });

        if (_placementMan.Eraser != args.Eraser)
        {
            _placementMan.ToggleEraser();
        }
    }
Exemple #3
0
 private void OnEraseButtonToggled(BaseButton.ButtonToggledEventArgs args)
 {
     placementManager.ToggleEraser();
 }
 private void EraserButtonClicked(ImageButton sender)
 {
     _placementManager.ToggleEraser();
 }