Fix stashing

Now checks if object is stashable and clears the tile
This commit is contained in:
Marc Di Luzio 2020-06-26 19:47:01 +01:00
parent 2846ed796e
commit 00bdad6b40

View file

@ -258,9 +258,13 @@ func (w *World) RoverStash(id uuid.UUID) (byte, error) {
if tile, err := w.Atlas.GetTile(r.Pos); err != nil {
return objects.Empty, err
} else {
// TODO: Get if item grabbable and clear tile
if tile != objects.Empty {
if objects.IsStashable(tile) {
r.Inventory = append(r.Inventory, Item{Type: tile})
if err := w.Atlas.SetTile(r.Pos, objects.Empty); err != nil {
return objects.Empty, err
} else {
return tile, nil
}
}
}