package gameEngine.simulator.interfaces; 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); if (xExp instanceof Term) { xExp = ((Term) xExp).reduce(); } if (yExp instanceof Term) { yExp = ((Term) yExp).reduce(); } if (zExp instanceof Term) { zExp = ((Term) zExp).reduce(); } Float x = Float.parseFloat(xExp.toString()); Float y = Float.parseFloat(yExp.toString()); Float z = Float.parseFloat(zExp.toString()); entity.transform.setScale(x, y, z); } } }