简化炮塔和武器站的自动瞄准
This commit is contained in:
parent
85b489e75c
commit
9ce6963408
2 changed files with 15 additions and 20 deletions
|
@ -333,18 +333,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void autoAimTest() {
|
|
||||||
// Entity target = EntityFindUtil.findEntity(level(), entityData.get(LAST_ATTACKER_UUID));
|
|
||||||
// if (target != null) {
|
|
||||||
// Matrix4f transform = getGunTransform(1);
|
|
||||||
// Vector4f worldPosition = transformPosition(transform, 0, -0.25f, 0);
|
|
||||||
// Vec3 shootVec = new Vec3(getGunnerVector(1).x, getGunnerVector(1).y + 0.01f, getGunnerVector(1).z);
|
|
||||||
// Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
// Vec3 targetVec = shootPos.vectorTo(target.getBoundingBox().getCenter());
|
|
||||||
// passengerWeaponAutoAimFormVector(15, 15 , -10, 45, shootVec, targetVec);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void terrainCompact(float w, float l) {
|
public void terrainCompact(float w, float l) {
|
||||||
if (onGround()) {
|
if (onGround()) {
|
||||||
|
@ -827,8 +815,9 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z));
|
return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getGunnerVector(float pPartialTicks) {
|
@Override
|
||||||
Matrix4f transform = getGunnerBarrelTransform(pPartialTicks);
|
public Vec3 getBarrelVec(float ticks) {
|
||||||
|
Matrix4f transform = getGunnerBarrelTransform(ticks);
|
||||||
Vector4f rootPosition = transformPosition(transform, 0, 0, 0);
|
Vector4f rootPosition = transformPosition(transform, 0, 0, 0);
|
||||||
Vector4f targetPosition = transformPosition(transform, 0, 0, 1);
|
Vector4f targetPosition = transformPosition(transform, 0, 0, 1);
|
||||||
return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z));
|
return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z));
|
||||||
|
|
|
@ -892,9 +892,10 @@ public abstract class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turretAutoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec, Vec3 targetVec) {
|
public void turretAutoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec) {
|
||||||
float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(targetVec) + getYRotFromVector(shootVec));
|
//shootVec是需要让炮塔以这个角度发射的向量
|
||||||
float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(targetVec) + getXRotFromVector(shootVec));
|
float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(shootVec) + getYRotFromVector(getBarrelVec(1)));
|
||||||
|
float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(shootVec) + getXRotFromVector(getBarrelVec(1)));
|
||||||
|
|
||||||
this.turretTurnSound(diffX, diffY, 0.95f);
|
this.turretTurnSound(diffX, diffY, 0.95f);
|
||||||
|
|
||||||
|
@ -911,9 +912,10 @@ public abstract class VehicleEntity extends Entity {
|
||||||
turretYRotLock = Mth.clamp(0.9f * diffY, min, max);
|
turretYRotLock = Mth.clamp(0.9f * diffY, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void passengerWeaponAutoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec, Vec3 targetVec) {
|
public void passengerWeaponAutoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec) {
|
||||||
float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(targetVec) + getYRotFromVector(shootVec));
|
//shootVec是需要让炮武器站以这个角度发射的向量
|
||||||
float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(targetVec) + getXRotFromVector(shootVec));
|
float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(shootVec) + getYRotFromVector(getGunnerVector(1)));
|
||||||
|
float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(shootVec) + getXRotFromVector(getGunnerVector(1)));
|
||||||
|
|
||||||
turretTurnSound(diffX, diffY, 0.95f);
|
turretTurnSound(diffX, diffY, 0.95f);
|
||||||
|
|
||||||
|
@ -1134,6 +1136,10 @@ public abstract class VehicleEntity extends Entity {
|
||||||
return this.calculateViewVector(this.getBarrelXRot(pPartialTicks), this.getBarrelYRot(pPartialTicks));
|
return this.calculateViewVector(this.getBarrelXRot(pPartialTicks), this.getBarrelYRot(pPartialTicks));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3 getGunnerVector(float pPartialTicks) {
|
||||||
|
return this.getViewVector(pPartialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
public float getBarrelXRot(float pPartialTicks) {
|
public float getBarrelXRot(float pPartialTicks) {
|
||||||
return Mth.lerp(pPartialTicks, turretXRotO - this.xRotO, getTurretXRot() - this.getXRot());
|
return Mth.lerp(pPartialTicks, turretXRotO - this.xRotO, getTurretXRot() - this.getXRot());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue