Ejemplo n.º 1
0
 public AIState getAIState() {
   return ai.getState();
 }
Ejemplo n.º 2
0
  public void setProximity(SpaceObject other) {
    if (other == null) {
      proximity = null;
      return;
    }
    if (!receivesProximityWarning()) {
      return;
    }
    if (proximity == other) {
      return;
    }
    if (other.getType() == ObjectType.SpaceStation) {
      if (inBay) {
        return;
      }
      float maxExtentSq = other.getMaxExtent();
      maxExtentSq *= maxExtentSq;
      if (other.getPosition().distanceSq(getPosition()) > maxExtentSq) {
        return;
      }
    }
    if (other.getType() == ObjectType.Missile) {
      if (((Missile) other).getSource() == this) {
        return;
      }
    }

    other.getPosition().sub(getPosition(), v0);
    float dotForward = v0.dot(getForwardVector());
    float dotUp = v0.dot(getUpVector());
    float dotRight = v0.dot(getRightVector());
    if (dotForward < 0 && getSpeed() < 0) {
      dotForward *= 0.25f * getMaxSpeed() / -getSpeed();
    }
    float dotSq = dotForward * dotForward + dotUp * dotUp + dotRight * dotRight;
    float collisionSq = getBoundingSphereRadius() * 3.0f + other.getBoundingSphereRadius() * 3.0f;
    collisionSq *= collisionSq;

    if (dotSq > collisionSq) {
      return;
    }
    if (ai.getState() == AIState.EVADE) {
      if (proximity != null && proximity != other) {
        getPosition().sub(proximity.getPosition(), v0);
        v0.normalize();
        float angleProx = getForwardVector().angleInDegrees(v0);
        if (angleProx >= 180) {
          angleProx = 360 - angleProx;
        }
        getPosition().sub(other.getPosition(), v0);
        v0.normalize();
        float angleOther = getForwardVector().angleInDegrees(v0);
        if (angleOther >= 180) {
          angleOther = 360 - angleOther;
        }
        if (angleProx < angleOther) {
          return;
        }
      }
    }
    proximity = other;
  }