fixed bugs

This commit is contained in:
Vasyl Kazakov
2026-06-17 17:06:13 +03:00
parent adf4e4b9bf
commit 930ed00c95
20 changed files with 627 additions and 415 deletions
@@ -0,0 +1,49 @@
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();
}
}