package cjw21.roboticsscenegenerator.scene;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

import cjw21.roboticsscenegenerator.scene.obstacle.Obstacle;

public class Scene implements Parcelable{

    public static final String DEFAULT_NAME = "Scene";

    public String name = Scene.DEFAULT_NAME;
    public List<Obstacle> obstaclesList;

    public Scene() {
        this.obstaclesList = new ArrayList<>();
    }

    public Scene(String name, List<Obstacle> obstaclesList) {
        this.name = name;
        this.obstaclesList = obstaclesList;
    }

    protected Scene(Parcel in) {
        this.name = in.readString();
        this.obstaclesList = new ArrayList<>();
        in.readTypedList(this.obstaclesList, Obstacle.CREATOR);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.name);
        dest.writeTypedList(this.obstaclesList);
    }

    public static final Parcelable.Creator<Scene> CREATOR = new Creator<Scene>() {
        @Override
        public Scene createFromParcel(Parcel source) {
            return new Scene(source);
        }

        @Override
        public Scene[] newArray(int size) {
            return new Scene[size];
        }
    };
}
