Package framework.spacial

Source Code of framework.spacial.PositionComponent$PositionChangedEvent

package framework.spacial;

import java.io.IOException;

import org.newdawn.slick.geom.Vector2f;

import framework.component.util.VectorValueComponent;
import framework.event.EventSender;
import framework.event.EventSystem;
import framework.event.util.ValueChangedEvent;
import framework.io.CustomInputStream;

public class PositionComponent extends VectorValueComponent{

  public PositionComponent(CustomInputStream in, int baseID, byte versionNum) throws IOException {
    super(in, baseID, versionNum);
  }
 
  public PositionComponent(Vector2f vector) {
    super(vector, false);
  }
 
  public PositionComponent(Vector2f vector, boolean relativeToParent) {
    super(vector, relativeToParent);
  }
 
  public PositionComponent(float x, float y) {
    super(x, y, false);
  }
 
  public PositionComponent(float x, float y, boolean relativeToParent) {
    super(x, y, relativeToParent);
  }

  @Override
  public boolean allowSameTypedSiblings() {
    return false;
  }
 
  @Override
  public void setVector(Vector2f newVector) {
    Vector2f oldVector = getVector();
    super.setVector(newVector);
    if(oldVector != null && !oldVector.equals(newVector)){
      EventSystem.getInstance().pushEvent(new PositionChangedEvent(this, oldVector, newVector));
    }
  }
 
  public static final class PositionChangedEvent extends ValueChangedEvent<Vector2f>{
    public PositionChangedEvent(EventSender sender, Vector2f from,Vector2f to) {
      super(sender, from, to);
    }
    @Override
    protected final String getEventTypeID() {
      return "PositionChanged";
    }
  }
}
TOP

Related Classes of framework.spacial.PositionComponent$PositionChangedEvent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.