Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / src / simulator / interfaces / gameEngine / EntityScaleReceiver.java
package simulator.interfaces.gameEngine;

import models.algebra.Expression;
import models.algebra.Term;
import simulator.Event;
import simulator.SystemState;
import simulator.interfaces.INativeReceiver;
import gameEngine.entites.Entity;

public class EntityScaleReceiver implements INativeReceiver {
	private Entity entity;
	
	public EntityScaleReceiver(Entity entity) {
		this.entity = entity;
	}

	@Override
	public void onReceiveFromModel(Event event, SystemState nextSystemState) {
		Expression message = event.getMessage();
		if (message instanceof Term) {
			Expression xExp = ((Term) message).getChild(0);
			Expression yExp = ((Term) message).getChild(1);
			Expression zExp = ((Term) message).getChild(2);
			Float x = Float.parseFloat(xExp.toString());
			Float y = Float.parseFloat(yExp.toString());
			Float z = Float.parseFloat(zExp.toString());
			entity.transform.setScale(x, y, z);
		}
	}

}