Example #1
0
  public GameObject(
      int id,
      int orientation,
      int position,
      int bY,
      int cY,
      int aY,
      int dY,
      int animationId,
      boolean randomFrame) {
    this.id = id;
    this.position = position;
    this.orientation = orientation;
    anInt1603 = aY;
    centre = bY;
    anInt1605 = cY;
    anInt1606 = dY;

    if (animationId != -1) {
      animation = Animation.animations[animationId];
      currentFrameId = 0;
      lastFrameTick = Client.tick;
      if (randomFrame && animation.loopOffset != -1) {
        currentFrameId = (int) (Math.random() * animation.frameCount);
        lastFrameTick -= (int) (Math.random() * animation.duration(currentFrameId));
      }
    }

    ObjectDefinition definition = ObjectDefinition.lookup(id);
    morphVarbitsIndex = definition.morphVarbitIndex;
    morphVariableIndex = definition.morphVariableIndex;
    morphisms = definition.morphisms;
  }
Example #2
0
  @Override
  public final Model model() {
    int lastFrame = -1;
    if (animation != null) {
      int tickDelta = Client.tick - lastFrameTick;
      if (tickDelta > 100 && animation.loopOffset > 0) {
        tickDelta = 100;
      }

      while (tickDelta > animation.duration(currentFrameId)) {
        tickDelta -= animation.duration(currentFrameId);
        currentFrameId++;
        if (currentFrameId < animation.frameCount) {
          continue;
        }
        currentFrameId -= animation.loopOffset;
        if (currentFrameId >= 0 && currentFrameId < animation.frameCount) {
          continue;
        }
        animation = null;
        break;
      }

      lastFrameTick = Client.tick - tickDelta;
      if (animation != null) {
        lastFrame = animation.primaryFrames[currentFrameId];
      }
    }

    ObjectDefinition definition = morphisms != null ? morph() : ObjectDefinition.lookup(id);

    return (definition == null)
        ? null
        : definition.modelAt(
            position, orientation, anInt1603, centre, anInt1605, anInt1606, lastFrame);
  }