import { Object3D, Vector3 } from "three"; import { Character } from "../Character/Character"; import { MoveC } from "../Movment/MoveC"; import { RotationC } from "../Movment/RotationC"; import { PhysicsBody } from "../../PhysicsC"; import { PlayerStateMachine } from "./PlayerStateMachine"; export class PlayerContext { stateMachine!: PlayerStateMachine; readonly character: Character; readonly movement: MoveC; readonly rotation: RotationC; readonly physics: PhysicsBody; readonly container: Object3D; isAutoAttacking = false; pendingCombatExit = false; skipStateEnterAnimation = false; onStrike: (() => void) | null = null; readonly combatTargetWorldPosition = new Vector3(); constructor(opts: { character: Character; movement: MoveC; rotation: RotationC; physics: PhysicsBody; container: Object3D; }) { this.character = opts.character; this.movement = opts.movement; this.rotation = opts.rotation; this.physics = opts.physics; this.container = opts.container; } isMoving() { return this.movement.Direction.lengthSq() > 0; } zeroVelocity() { this.physics.getPhysicsBody().velocity.set(0, 0, 0); } syncRotation() { this.rotation.syncToCurrentFacing(); } }