Skip to content

Commit

Permalink
Small improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinSc committed Aug 4, 2016
1 parent 5ecc042 commit 6cfa148
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,46 @@ public class ModelTranslateOnSignalSystem {
public void moveEntity(SignalActivated event, EntityRef entityRef, ModelTranslateOnSignalComponent translateOnSignal, BaseLocationComponent baseLocation, LocationComponent location) {
long time = timeManager.getTime();
ModelTranslateOverTimeComponent translateOverTime = entityRef.getComponent(ModelTranslateOverTimeComponent.class);
if (translateOverTime == null) {
if (translateOverTime == null)
translateOverTime = entityRef.createComponent(ModelTranslateOverTimeComponent.class);
translateOverTime.setDistanceX(translateOnSignal.getDistanceX());
translateOverTime.setDistanceY(translateOnSignal.getDistanceY());
translateOverTime.setDistanceZ(translateOnSignal.getDistanceZ());
translateOverTime.setStartTime(time);
translateOverTime.setMoveTime(translateOnSignal.getMoveTime());
translateOverTime.setInterpolation(translateOnSignal.getInterpolation());
translateOverTime.setReverse(false);
} else {
translateOverTime.setDistanceX(translateOnSignal.getDistanceX());
translateOverTime.setDistanceY(translateOnSignal.getDistanceY());
translateOverTime.setDistanceZ(translateOnSignal.getDistanceZ());
translateOverTime.setStartTime(time);
translateOverTime.setMoveTime(translateOnSignal.getMoveTime());
translateOverTime.setInterpolation(translateOnSignal.getInterpolation());
translateOverTime.setReverse(false);
}

translateOverTime.setSourceX(location.getX());
translateOverTime.setSourceY(location.getY());
translateOverTime.setSourceZ(location.getZ());

translateOverTime.setDestinationX(baseLocation.getX() + translateOnSignal.getDistanceX());
translateOverTime.setDestinationY(baseLocation.getY() + translateOnSignal.getDistanceY());
translateOverTime.setDestinationZ(baseLocation.getZ() + translateOnSignal.getDistanceZ());

translateOverTime.setStartTime(time);
translateOverTime.setMoveTime(translateOnSignal.getMoveTime());

translateOverTime.setInterpolation(translateOnSignal.getInterpolation());

entityRef.saveChanges();
}

@ReceiveEvent
public void moveEntityBack(SignalDeactivated event, EntityRef entityRef, ModelTranslateOnSignalComponent translateOnSignal, BaseLocationComponent baseLocation, LocationComponent location) {
long time = timeManager.getTime();
ModelTranslateOverTimeComponent translateOverTime = entityRef.getComponent(ModelTranslateOverTimeComponent.class);
if (translateOverTime == null) {
if (translateOverTime == null)
translateOverTime = entityRef.createComponent(ModelTranslateOverTimeComponent.class);
translateOverTime.setDistanceX(translateOnSignal.getDistanceX());
translateOverTime.setDistanceY(translateOnSignal.getDistanceY());
translateOverTime.setDistanceZ(translateOnSignal.getDistanceZ());
translateOverTime.setStartTime(time);
translateOverTime.setMoveTime(translateOnSignal.getMoveTime());
translateOverTime.setInterpolation(translateOnSignal.getInterpolation());
translateOverTime.setReverse(true);
} else {
translateOverTime.setDistanceX(translateOnSignal.getDistanceX());
translateOverTime.setDistanceY(translateOnSignal.getDistanceY());
translateOverTime.setDistanceZ(translateOnSignal.getDistanceZ());
translateOverTime.setStartTime(time);
translateOverTime.setMoveTime(translateOnSignal.getMoveTime());
translateOverTime.setInterpolation(translateOnSignal.getInterpolation());
translateOverTime.setReverse(true);
}

translateOverTime.setSourceX(location.getX());
translateOverTime.setSourceY(location.getY());
translateOverTime.setSourceZ(location.getZ());

translateOverTime.setDestinationX(baseLocation.getX());
translateOverTime.setDestinationY(baseLocation.getY());
translateOverTime.setDestinationZ(baseLocation.getZ());

translateOverTime.setStartTime(time);
translateOverTime.setMoveTime(translateOnSignal.getMoveTime());

translateOverTime.setInterpolation(translateOnSignal.getInterpolation());

entityRef.saveChanges();
entityRef.saveChanges();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,36 @@
import com.gempukku.secsy.entity.Component;

public interface ModelTranslateOverTimeComponent extends Component {
float getDistanceX();
float getSourceX();

void setDistanceX(float distanceX);
void setSourceX(float sourceX);

float getDistanceY();
float getSourceY();

void setDistanceY(float distanceY);
void setSourceY(float sourceY);

float getDistanceZ();
float getSourceZ();

void setDistanceZ(float distanceZ);
void setSourceZ(float sourceZ);

long getStartTime();
float getDestinationX();

void setDestinationX(float destinationX);

float getDestinationY();

void setDestinationY(float destinationY);

float getDestinationZ();

void setDestinationZ(float destinationZ);

long getStartTime();
void setStartTime(long startTime);

long getMoveTime();

void setMoveTime(long moveTime);

String getInterpolation();

void setInterpolation(String interpolation);

boolean isReverse();

void setReverse(boolean reverse);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ public void translateModels(GameLoopUpdate event, EntityRef entityRef) {
translateOverTimeEntity.removeComponents(ModelTranslateOverTimeComponent.class);
a = 1;
}
if (translate.isReverse())
a = 1 - a;
location.setX(baseLocation.getX() + a * translate.getDistanceX());
location.setY(baseLocation.getY() + a * translate.getDistanceY());
location.setZ(baseLocation.getZ() + a * translate.getDistanceZ());
location.setX(translate.getSourceX() + a * (translate.getDestinationX() - translate.getSourceX()));
location.setY(translate.getSourceY() + a * (translate.getDestinationY() - translate.getSourceY()));
location.setZ(translate.getSourceZ() + a * (translate.getDestinationZ() - translate.getSourceZ()));
translateOverTimeEntity.saveChanges();
}

Expand Down

0 comments on commit 6cfa148

Please sign in to comment.