Skip to content

Commit

Permalink
Formalized the ClientEffectPlayCreature
Browse files Browse the repository at this point in the history
  • Loading branch information
kurokikaze committed Nov 14, 2024
1 parent aa001cf commit ab789c9
Show file tree
Hide file tree
Showing 3 changed files with 376 additions and 360 deletions.
26 changes: 15 additions & 11 deletions src/addAnimations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global window */
// @ts-nocheck
import { Observable } from 'rxjs';

import {
Expand Down Expand Up @@ -155,8 +156,9 @@ const TIMERS_BY_EVENT = {
[END_STEP_ANIMATION]: STEP_TIMEOUT,
};

const convertTimer = (type: any) => {
return TIMERS_BY_EVENT[type] || 0;
type TimersKeyType = keyof typeof TIMERS_BY_EVENT;
const convertTimer = (type: TimersKeyType | any) => {
return type in TIMERS_BY_EVENT ? TIMERS_BY_EVENT[type as TimersKeyType] : 0;
};

export default function addAnimationsNew(action$: Observable<ClientCommand>, break$: Observable<{}>, store: Store<any, Action<any>>, onlyEnemy = true) {
Expand All @@ -169,15 +171,17 @@ export default function addAnimationsNew(action$: Observable<ClientCommand>, bre
const streamActions = () => {
while (actionsStorage.length) {
const action = actionsStorage.shift();
const delayBy = convertTimer(action.type)
observer.next(action);
if (delayBy > 0) {
timeout = setTimeout(() => {
delaying = false;
streamActions();
}, delayBy);
delaying = true;
return;
if (action) {
const delayBy = convertTimer(action.type)
observer.next(action);
if (delayBy > 0) {
timeout = setTimeout(() => {
delaying = false;
streamActions();
}, delayBy);
delaying = true;
return;
}
}
}
if (finished) {
Expand Down
Loading

0 comments on commit ab789c9

Please sign in to comment.