Newer
Older
AlgebraicDataflowArchitectureModel / GameEngine / src / main / java / gameEngine / simulator / interfaces / SpriteReceiver.java
package gameEngine.simulator.interfaces;

import gameEngine.entites.gameComponents.Mesh;
import gameEngine.views.Sprite;
import models.algebra.Expression;
import models.algebra.Term;
import simulator.Event;
import simulator.SystemState;
import simulator.interfaces.INativeReceiver;

public class SpriteReceiver implements INativeReceiver {
	private Mesh mesh;
	
	public SpriteReceiver(Mesh mesh) {
		this.mesh = mesh;
	}

	@Override
	public void onReceiveFromModel(Event event, SystemState nextSystemState) {
		Expression message = event.getMessage();
		if (message instanceof Term) {
			Expression exp = ((Term) message).getChild(0);
			mesh.setSprite(exp.toString());
		}
	}

}