package org.ntlab.radishforandroidstudio.framework.gameMain;

import org.ntlab.radishforandroidstudio.framework.model3D.Universe;

import java.util.ArrayList;

public abstract class GameBaseModelManager implements GameBaseModel {
    protected ArrayList<GameBaseModel> models = new ArrayList<>();
    protected RealTime3DFragment fragment = null;
    protected Universe universe = null;

    public GameBaseModelManager() {
    }

    public GameBaseModelManager(RealTime3DFragment fragment, Universe universe) {
        this.universe = universe;
        this.fragment = fragment;
    }


    /**
     * GameBaseModelを追加
     * instanceIDのセットなどは実行されないことを注意
     *
     * @param model 追加したいGameBaseModel
     */
    public void addModel(GameBaseModel model) {
        models.add(model);
    }

    /**
     * モデルの状態を更新する
     *
     * @author s.iwatani
     * @param interval 前回の更新からの時間差
     */
    @Override
    public void update(double interval) {
        for (GameBaseModel model: models) {
            model.update(interval);
        }
    }
}
