Files
firstProj/src/controllers/Presets/PlayerState/states/IdleState.ts
T
Vasyl Kazakov 930ed00c95 fixed bugs
2026-06-17 17:06:13 +03:00

29 lines
794 B
TypeScript

import { BaseAnimation } from "../../Enums/BaseAnimation";
import { IPlayerState } from "../IPlayerState";
import { PlayerContext } from "../PlayerContext";
import { PlayerStateType } from "../PlayerStateType";
export class IdleState implements IPlayerState {
enter(context: PlayerContext): void {
if (context.skipStateEnterAnimation) {
context.skipStateEnterAnimation = false;
return;
}
context.character.playAnimation(BaseAnimation.Idle);
}
exit(_context: PlayerContext): void {}
update(context: PlayerContext, _deltaTime: number): void {
if (context.isMoving()) {
context.stateMachine.setState(PlayerStateType.Run);
return;
}
const body = context.physics.getPhysicsBody();
body.velocity.set(0, 0, 0);
body.wakeUp();
}
}