All files / src/missions types.ts

0% Statements 0/0
0% Branches 1/1
0% Functions 1/1
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118                                                                                                                                                                                                                                           
import * as THREE from 'three';
import RAPIER from '@dimforge/rapier3d-compat';
 
/**
 * Common lifecycle interface for all FLL Mission Elements
 */
export interface MissionElement {
  readonly id: string;
  readonly name: string;
  readonly description: string;
  readonly rootGroup: THREE.Group;
 
  /**
   * Initializes Rapier physics bodies and Three.js visual meshes at target world position
   */
  init(world: RAPIER.World, basePosition: { x: number; y: number; z: number }): void;
 
  /**
   * Steps internal physics/logic each tick
   */
  update(dt: number): void;
 
  /**
   * Synchronizes Three.js visual transforms with Rapier rigid bodies
   */
  syncVisuals(): void;
 
  /**
   * Resets the mission element to its initial un-solved state
   */
  reset(): void;
 
  /**
   * Repositions the base anchor of the mission model with optional yaw rotation (degrees)
   */
  setPosition(pos: { x: number; y: number; z: number }, yawDegrees?: number): void;
 
  /**
   * Sets the yaw rotation of the mission model in degrees
   */
  setRotation?(yawDegrees: number): void;
 
  /**
   * Returns current yaw rotation in degrees
   */
  getYawDegrees?(): number;
 
  /**
   * Whether the element is currently deployed on the field mat / workbench
   */
  isPlacedOnField?: boolean;
 
  /**
   * Original CAD source filename if imported
   */
  sourceFile?: string;
 
  /**
   * Returns current world position of base anchor
   */
  getPosition(): { x: number; y: number; z: number };
 
  /**
   * Evaluates if mission criteria are met
   */
  isSolved(): boolean;
 
  /**
   * Current mission score percentage (0 to 100)
   */
  getScore(): number;
 
  /**
   * Cleans up physics bodies and visual meshes
   */
  destroy(): void;
 
  /**
   * Returns interactive visual meshes that can be clicked/dragged directly by user
   */
  getInteractiveMeshes?(): THREE.Object3D[];
 
  /**
   * Applies user mouse drag on the mechanism's interactive component
   */
  applyUserDrag?(groundTarget: THREE.Vector3): void;
 
  /**
   * Called when user finishes/releases mouse drag on the mechanism
   */
  stopUserDrag?(): void;
 
  /**
   * Parent mission ID if decomposed from a multi-object mission model
   */
  parentMissionId?: string;
 
  /**
   * Whether the element is currently Dual-Locked (fixed) to the competition field mat
   */
  isDualLocked?: boolean;
 
  /**
   * Sets Dual-Lock fastening status (true = fixed, false = dynamic)
   */
  setDualLocked?(locked: boolean, anchorPoint?: { x: number; z: number }, targetClusterId?: string): void;
 
  /**
   * Returns current Dual Lock anchor position on the mat
   */
  getDualLockPosition?(): { x: number; z: number } | null;
 
  /**
   * Returns ID of the cluster currently anchored to the field mat
   */
  getAnchoredClusterId?(): string | null;
}