use of club.nsdn.nyasamarailway.network.TrainPacket in project NyaSamaRailway by NSDN.
the class NSPCT9 method applyDrag.
@Override
protected void applyDrag() {
if (this.motorState) {
TrainPacket tmpPacket = new TrainPacket(getMotorPower(), getMotorBrake(), getMotorDir());
// High speed
tmpPacket.highSpeed = true;
tmpPacket.Velocity = this.Velocity;
if (this.maxVelocity > 0) {
if (this.Velocity > this.maxVelocity && tmpMotorBrake == -1) {
tmpMotorBrake = getMotorBrake();
setMotorBrake(1);
} else if (this.Velocity > this.maxVelocity && tmpMotorBrake != -1) {
setMotorBrake(1);
} else if (this.Velocity <= this.maxVelocity && tmpMotorBrake != -1) {
setMotorBrake(tmpMotorBrake);
tmpMotorBrake = -1;
}
}
TrainController.doMotionWithAir(tmpPacket, this);
setMotorVel((float) tmpPacket.Velocity);
} else {
if (this.motionX != 0)
setMotorDir((int) Math.signum(this.motionX / Math.cos(TrainController.calcYaw(this) * Math.PI / 180.0)));
else if (this.motionZ != 0)
setMotorDir((int) Math.signum(this.motionZ / -Math.sin(TrainController.calcYaw(this) * Math.PI / 180.0)));
else
setMotorDir(0);
setMotorVel((float) Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ));
}
super.applyDrag();
}
use of club.nsdn.nyasamarailway.network.TrainPacket in project NyaSamaRailway by NSDN.
the class NSPCT4M method doEngine.
@Override
protected void doEngine() {
tmpPacket = new TrainPacket(getEnginePower(), getEngineBrake(), getEngineDir());
tmpPacket.highSpeed = isHighSpeed();
tmpPacket.Velocity = this.Velocity;
if (this.maxVelocity > 0) {
if (this.Velocity > this.maxVelocity && tmpEngineBrake == -1) {
tmpEngineBrake = getEngineBrake();
setEngineBrake(1);
} else if (this.Velocity > this.maxVelocity && tmpEngineBrake != -1) {
setEngineBrake(1);
} else if (this.Velocity <= this.maxVelocity && tmpEngineBrake != -1) {
setEngineBrake(tmpEngineBrake);
tmpEngineBrake = -1;
}
}
TrainController.doMotionWithAir(tmpPacket, this);
setEnginePrevVel(this.Velocity);
setEngineVel(tmpPacket.Velocity);
}
use of club.nsdn.nyasamarailway.network.TrainPacket in project NyaSamaRailway by NSDN.
the class LocoBase method doEngine.
protected void doEngine() {
// Do engine code
tmpPacket = new TrainPacket(getEnginePower(), getEngineBrake(), getEngineDir());
tmpPacket.highSpeed = isHighSpeed();
tmpPacket.Velocity = this.Velocity;
TrainController.doMotion(tmpPacket, this);
setEnginePrevVel(this.Velocity);
setEngineVel(tmpPacket.Velocity);
}
use of club.nsdn.nyasamarailway.network.TrainPacket in project NyaSamaRailway by NSDN.
the class NSPCT6W method applyDrag.
@Override
protected void applyDrag() {
if (this.motorState) {
TrainPacket tmpPacket = new TrainPacket(getMotorPower(), getMotorBrake(), getMotorDir());
// High speed
tmpPacket.highSpeed = true;
tmpPacket.Velocity = this.Velocity;
if (this.maxVelocity > 0) {
if (this.Velocity > this.maxVelocity && tmpMotorBrake == -1) {
tmpMotorBrake = getMotorBrake();
setMotorBrake(1);
} else if (this.Velocity > this.maxVelocity && tmpMotorBrake != -1) {
setMotorBrake(1);
} else if (this.Velocity <= this.maxVelocity && tmpMotorBrake != -1) {
setMotorBrake(tmpMotorBrake);
tmpMotorBrake = -1;
}
}
TrainController.doMotionWithAir(tmpPacket, this);
setMotorVel((float) tmpPacket.Velocity);
} else {
if (this.motionX != 0)
setMotorDir((int) Math.signum(this.motionX / Math.cos(TrainController.calcYaw(this) * Math.PI / 180.0)));
else if (this.motionZ != 0)
setMotorDir((int) Math.signum(this.motionZ / -Math.sin(TrainController.calcYaw(this) * Math.PI / 180.0)));
else
setMotorDir(0);
setMotorVel((float) Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ));
}
super.applyDrag();
}
use of club.nsdn.nyasamarailway.network.TrainPacket in project NyaSamaRailway by NSDN.
the class NSET2 method doEngine.
@Override
protected void doEngine() {
// Do engine code
tmpPacket = new TrainPacket(getEnginePower(), getEngineBrake(), getEngineDir());
tmpPacket.highSpeed = isHighSpeed();
tmpPacket.Velocity = this.Velocity;
TrainController.doMotionWithAir(tmpPacket, this);
setEnginePrevVel(this.Velocity);
setEngineVel(tmpPacket.Velocity);
}
Aggregations