-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import type { AnimationObject } from 'src/storage/AnimCore'; | ||
import type { GameData, SequencerTypes } from '.'; | ||
import { devLog, ErrorMsg, getPlayerOwners, i18n, isTrueish } from 'src/utils'; | ||
Check failure on line 3 in src/presets/animation.ts
|
||
|
||
export default async function animation(seq: SequencerTypes, animation: AnimationObject, data: GameData) { | ||
const { sources } = data; | ||
const { options = {} } = animation; | ||
|
||
for (const source of sources) { | ||
if ((source.actor as ActorPF2e)?.primaryUpdater?.id === game.userId) { | ||
const ani = seq.animation() | ||
.on(source); | ||
|
||
if (isTrueish(options?.preset?.type)) { | ||
Check failure on line 14 in src/presets/animation.ts
|
||
switch (options?.preset?.type) { | ||
Check failure on line 15 in src/presets/animation.ts
|
||
case 'teleport': | ||
ani.teleportTo(options?.preset?.target); | ||
Check failure on line 17 in src/presets/animation.ts
|
||
break; | ||
case 'move': | ||
default: | ||
ani.moveTowards(options?.preset?.target); | ||
Check failure on line 21 in src/presets/animation.ts
|
||
break; | ||
} | ||
} | ||
|
||
if (isTrueish(options?.duration)) ani.duration(options.duration); | ||
if (isTrueish(options?.closestSquare)) ani.closestSquare(options.closestSquare); | ||
Check failure on line 27 in src/presets/animation.ts
|
||
if (isTrueish(options?.snapToGrid)) ani.snapToGrid(options.snapToGrid); | ||
|
||
if (isTrueish(options?.repeats)) { | ||
if (typeof options.repeats === 'object') { | ||
ani.repeats(options.repeats.count, options.repeats.delayMin, options.repeats.delayMax); | ||
} else { | ||
ani.repeats(options.repeats); | ||
} | ||
} | ||
if (isTrueish(options?.delay)) { | ||
if (typeof options.delay === 'object') { | ||
ani.delay(options.delay.min, options.delay?.max); | ||
} else { | ||
ani.delay(options.delay); | ||
} | ||
} | ||
if (isTrueish(options?.fadeIn)) { | ||
if (typeof options.fadeIn === 'object') { | ||
ani.fadeIn(options.fadeIn?.value, options.fadeIn); | ||
} else { | ||
ani.fadeIn(options.fadeIn); | ||
} | ||
} | ||
if (isTrueish(options?.fadeOut)) { | ||
if (typeof options.fadeOut === 'object') { | ||
ani.fadeOut(options.fadeOut?.value, options.fadeOut); | ||
} else { | ||
ani.fadeOut(options.fadeOut); | ||
} | ||
} | ||
} else { | ||
// Do I need to do anything here? I thought of adding some sort of socket in similar vein to crosshairs but... This doesn't seem to be needed? | ||
} | ||
} | ||
|
||
return seq; | ||
} |