2018-02-04 15:15:03 +01:00
|
|
|
import { PlayerObject } from './model'
|
|
|
|
|
2018-02-05 02:14:43 +01:00
|
|
|
type AnimationFn = (player: PlayerObject, time: number) => void
|
|
|
|
interface IAnimation {
|
|
|
|
play(player: PlayerObject, time: number): void
|
|
|
|
}
|
2018-02-05 11:30:14 +01:00
|
|
|
export type Animation = AnimationFn | IAnimation
|
2018-02-04 15:15:03 +01:00
|
|
|
|
|
|
|
declare function invokeAnimation(
|
2018-02-04 16:23:27 +01:00
|
|
|
animation: Animation,
|
2018-02-04 15:15:03 +01:00
|
|
|
player: PlayerObject,
|
|
|
|
time: number
|
|
|
|
): void
|
|
|
|
|
2018-02-05 02:14:43 +01:00
|
|
|
declare class AnimationHandle implements IAnimation {
|
|
|
|
readonly animation: Animation
|
2018-02-04 15:15:03 +01:00
|
|
|
paused: boolean
|
|
|
|
speed: number
|
|
|
|
|
2018-02-04 16:23:27 +01:00
|
|
|
constructor(animation: Animation)
|
2018-02-04 15:15:03 +01:00
|
|
|
|
|
|
|
play(player: PlayerObject, time: number): void
|
|
|
|
|
|
|
|
reset(): void
|
|
|
|
}
|
|
|
|
|
2018-02-05 02:14:43 +01:00
|
|
|
export class CompositeAnimation implements IAnimation {
|
2018-02-05 11:45:15 +01:00
|
|
|
private handles: Set<AnimationHandle>
|
2018-02-04 15:15:03 +01:00
|
|
|
|
|
|
|
constructor()
|
|
|
|
|
2018-02-04 16:23:27 +01:00
|
|
|
add(animation: Animation): AnimationHandle
|
2018-02-04 15:15:03 +01:00
|
|
|
|
|
|
|
play(player: PlayerObject, time: number): void
|
|
|
|
}
|
|
|
|
|
2018-02-05 02:14:43 +01:00
|
|
|
export const WalkAnimation: AnimationFn
|