Skip to content

Commit

Permalink
Almost done clock keeper & overlay!
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed Jan 8, 2024
1 parent 05be23d commit b65c595
Show file tree
Hide file tree
Showing 18 changed files with 1,544 additions and 636 deletions.
247 changes: 163 additions & 84 deletions css/style.min.css

Large diffs are not rendered by default.

495 changes: 417 additions & 78 deletions module/classes/BladesClocks.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions module/classes/BladesTargetLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ class BladesTargetLink {
// #region ASYNC UPDATE & DELETE METHODS ~
async updateTarget(prop, val, isSilent = false) {
if (this.targetFlagKey) {
this.target.setFlag("eunos-blades", `${this.targetFlagKey}.${this.id}.${prop}`, val);
await this.target.setFlag("eunos-blades", `${this.targetFlagKey}.${this.id}.${prop}`, val);
}
else {
this.target.update({ [`${this.targetKey}.${this.id}.${prop}`]: val }, { render: !isSilent });
await this.target.update({ [`${this.targetKey}.${this.id}.${prop}`]: val }, { render: !isSilent });
}
}
async updateTargetData(val, isSilent = false) {
Expand Down
45 changes: 17 additions & 28 deletions module/core/gsap.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,18 @@ export const gsapEffects = {
}, {
rotateZ: config.swingAngle,
ease: "sine.inOut",
duration: 0.25 * config.duration,
repeat: 2,
yoyo: true
})
.fromTo(keyContainer, {
top: `+=${0.5 * config.yRange}`,
scale: `+=${0.5 * config.scaleRange}`
}, {
top: `-=${0.5 * config.yRange}`,
scale: `-=${0.5 * config.scaleRange}`,
ease: "sine.inOut",
duration: 0.75 * config.duration
}, 0.25 * config.duration);
// Get times where rotateZ is 0
const timesWhenRotateZIsZero = Array(4).fill(config.duration / 8)
.map((val, index) => val * (2 * (index + 1)));
// Get time when top & scale shifts are 0
const timeWhenShiftsAreZero = ((0.75 * config.duration) / 2) + (0.25 * config.duration);
// Add labels to all rotateZ === 0 times, but if shifts are also zero, name it "NEUTRAL"
timesWhenRotateZIsZero.forEach((timestamp, i) => {
tl.addLabel(`rotateZZero${i}`, timestamp);
if (timestamp === timeWhenShiftsAreZero && tl.labels.NEUTRAL === undefined) {
tl.addLabel("NEUTRAL", timestamp);
}
duration: config.duration
});
// Assign the 'NEUTRAL' label to the midpoint of the timeline, when rotateZ is zero
tl.addLabel("NEUTRAL", config.duration / 2);
// Immediately move the timeline to the "NEUTRAL" label, so the timeline begins from there
tl.seek("NEUTRAL");
return tl;
},
defaults: {
swingAngle: 1,
ease: "sine.inOut",
yRange: 10,
scaleRange: 0.1,
duration: 12
duration: 3
},
extendTimeline: true
},
Expand Down Expand Up @@ -122,7 +99,19 @@ export const gsapEffects = {
},
keyControlPanelFlip: {
effect: (target, config) => {
return U.gsap.timeline()
return U.gsap.timeline({
onComplete() {
if (target) {
const target$ = $(target);
// Get the next sibling of the target element if it has the class "clock-control"
const nextSibling$ = target$.next(".clock-control-flipper");
// Check if the nextSibling element exists
if (nextSibling$.length) {
U.gsap.effects.keyControlPanelFlip(nextSibling$[0], config);
}
}
}
})
.to(target, {
rotateX: config.angle,
duration: 0.5,
Expand Down
5 changes: 4 additions & 1 deletion module/core/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,10 @@ const makeCycler = (array, index = 0) => {
*/
function getLast(array) {
array = Object.values(array);
return array.length === 0 ? undefined : array[array.length - 1];
if (array.length === 0) {
throw new Error("Cannot get last element of an empty array.");
}
return array[array.length - 1];
}
// Const getLast = <Type>(array: Type[]): typeof array extends [] ? undefined : Type => ;
const unique = (array) => {
Expand Down
7 changes: 1 addition & 6 deletions module/documents/items/BladesClockKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class BladesClockKeeper extends BladesItem {
targetKey: "system.clocksData",
...clockKeyConfig
});
super.update({});
// super.update({});
return key;
}
async deleteClockKey(keyID) {
Expand All @@ -86,10 +86,5 @@ class BladesClockKeeper extends BladesItem {
super.prepareDerivedData();
this.system.targetScene ??= game.scenes.current?.id || null;
}
async _onUpdate(changed, options, userId) {
super._onUpdate(changed, options, userId);
// BladesActor.GetTypeWithTags(BladesActorType.pc).forEach((actor) => actor.render());
// socketlib.system.executeForEveryone("renderOverlay");
}
}
export default BladesClockKeeper;
Loading

0 comments on commit b65c595

Please sign in to comment.