evotars 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evotars.js +26284 -0
- package/dist/evotars.umd.cjs +1147 -0
- package/dist/index.d.ts +175 -0
- package/package.json +22 -2
- package/.editorconfig +0 -13
- package/.prettierrc.json +0 -3
- package/index.html +0 -13
- package/playground/main.ts +0 -48
- package/playground/styles.css +0 -17
- package/public/evotars/agent/data.json +0 -18
- package/public/evotars/agent/sprite.json +0 -166
- package/public/evotars/agent/sprite.png +0 -0
- package/public/evotars/cat/data.json +0 -18
- package/public/evotars/cat/sprite.json +0 -231
- package/public/evotars/cat/sprite.png +0 -0
- package/public/evotars/dude/data.json +0 -18
- package/public/evotars/dude/sprite.json +0 -231
- package/public/evotars/dude/sprite.png +0 -0
- package/public/evotars/girl/data.json +0 -18
- package/public/evotars/girl/sprite.json +0 -231
- package/public/evotars/girl/sprite.png +0 -0
- package/public/evotars/nerd/data.json +0 -18
- package/public/evotars/nerd/sprite.json +0 -231
- package/public/evotars/nerd/sprite.png +0 -0
- package/public/evotars/senior/data.json +0 -18
- package/public/evotars/senior/sprite.json +0 -231
- package/public/evotars/senior/sprite.png +0 -0
- package/public/evotars/set.json +0 -10
- package/public/evotars/sith/data.json +0 -18
- package/public/evotars/sith/sprite.json +0 -166
- package/public/evotars/sith/sprite.png +0 -0
- package/public/evotars/sponge/data.json +0 -18
- package/public/evotars/sponge/sprite.json +0 -231
- package/public/evotars/sponge/sprite.png +0 -0
- package/public/fonts/Rubik.ttf +0 -0
- package/public/sounds/jump.mp3 +0 -0
- package/src/app.ts +0 -71
- package/src/config/constants.ts +0 -1
- package/src/entities/EmoteSpitter.ts +0 -102
- package/src/entities/Evotar.ts +0 -468
- package/src/entities/Message.ts +0 -164
- package/src/entities/Name.ts +0 -33
- package/src/entities/SpriteContainer.ts +0 -65
- package/src/entities/TrailEffect.ts +0 -73
- package/src/evotars.ts +0 -75
- package/src/evotarsManager.ts +0 -313
- package/src/helpers/timer.ts +0 -43
- package/src/helpers/types.ts +0 -4
- package/src/index.ts +0 -1
- package/src/services/soundService.ts +0 -30
- package/src/services/spriteService.ts +0 -167
- package/src/types/dto/action.ts +0 -79
- package/src/types/dto/chatter.ts +0 -4
- package/src/types/dto/event.ts +0 -9
- package/src/types/dto/index.ts +0 -6
- package/src/types/dto/message.ts +0 -8
- package/src/types/dto/settings.ts +0 -5
- package/src/types/dto/user.ts +0 -13
- package/src/types/index.ts +0 -1
- package/tsconfig.json +0 -23
- package/vite.config.js +0 -26
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AnimatedSprite,
|
|
3
|
-
Assets,
|
|
4
|
-
ISpritesheetData,
|
|
5
|
-
ISpritesheetFrameData,
|
|
6
|
-
SCALE_MODES,
|
|
7
|
-
Spritesheet,
|
|
8
|
-
} from 'pixi.js';
|
|
9
|
-
|
|
10
|
-
export type EvotarSpriteData = {
|
|
11
|
-
name: string;
|
|
12
|
-
collider: Collider;
|
|
13
|
-
size: SpriteSize;
|
|
14
|
-
scale: number;
|
|
15
|
-
flip: boolean;
|
|
16
|
-
colored: string[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type SpriteLoaderFn = (name: string) => Promise<
|
|
20
|
-
| {
|
|
21
|
-
sprite: SpritesheetData;
|
|
22
|
-
data: EvotarSpriteData;
|
|
23
|
-
image: string;
|
|
24
|
-
}
|
|
25
|
-
| undefined
|
|
26
|
-
>;
|
|
27
|
-
|
|
28
|
-
export type Collider = {
|
|
29
|
-
x: number;
|
|
30
|
-
y: number;
|
|
31
|
-
w: number;
|
|
32
|
-
h: number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export interface SpritesheetFrameData extends ISpritesheetFrameData {
|
|
36
|
-
duration: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface SpritesheetData extends ISpritesheetData {
|
|
40
|
-
frames: Record<string, SpritesheetFrameData>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type EvotarLayerSprites = {
|
|
44
|
-
[layer in string]: AnimatedSprite;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type EvotarAnimatedSprites = {
|
|
48
|
-
[tag in string]: EvotarLayerSprites;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export enum EvotarSpriteTags {
|
|
52
|
-
Idle = 'Idle',
|
|
53
|
-
Jump = 'Jump',
|
|
54
|
-
Fall = 'Fall',
|
|
55
|
-
Land = 'Land',
|
|
56
|
-
Run = 'Run',
|
|
57
|
-
Die = 'Die',
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type FrameTag = {
|
|
61
|
-
from: number;
|
|
62
|
-
name: string;
|
|
63
|
-
to: number;
|
|
64
|
-
direction: string;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type SpriteSize = {
|
|
68
|
-
w: number;
|
|
69
|
-
h: number;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export type SpriteData = {
|
|
73
|
-
sheet: Spritesheet<SpritesheetData>;
|
|
74
|
-
data: EvotarSpriteData;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export class SpriteService {
|
|
78
|
-
private spriteLoaderFn!: SpriteLoaderFn;
|
|
79
|
-
|
|
80
|
-
private sprites: Record<string, SpriteData> = {};
|
|
81
|
-
|
|
82
|
-
public initialize(spriteLoaderFn: SpriteLoaderFn) {
|
|
83
|
-
this.spriteLoaderFn = spriteLoaderFn;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public async getSpriteData(name: string): Promise<SpriteData | undefined> {
|
|
87
|
-
const sprite = await this.spriteLoaderFn(name);
|
|
88
|
-
|
|
89
|
-
if (!sprite) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (this.sprites[name]) {
|
|
94
|
-
return this.sprites[name];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const texture = await Assets.load(sprite.image);
|
|
98
|
-
|
|
99
|
-
const sheet = new Spritesheet({
|
|
100
|
-
texture,
|
|
101
|
-
data: sprite.sprite,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
await sheet.parse();
|
|
105
|
-
|
|
106
|
-
this.sprites[name] = {
|
|
107
|
-
sheet,
|
|
108
|
-
data: {
|
|
109
|
-
...sprite.data,
|
|
110
|
-
scale: sprite.data.scale ?? 1,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
return this.sprites[name];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public getAnimatedSprites(name: string): EvotarAnimatedSprites {
|
|
118
|
-
if (!name) {
|
|
119
|
-
throw Error('Sheet is not defined');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!this.sprites[name]) {
|
|
123
|
-
throw Error('Sprite is not loaded');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const data = this.sprites[name].data;
|
|
127
|
-
const sheet = this.sprites[name].sheet;
|
|
128
|
-
|
|
129
|
-
const sprites: EvotarAnimatedSprites = {};
|
|
130
|
-
|
|
131
|
-
for (const frameTag of sheet.data.meta.frameTags ?? []) {
|
|
132
|
-
if (!sheet.data.meta.layers) {
|
|
133
|
-
throw Error('Layers are not defined');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const layers: EvotarLayerSprites = {};
|
|
137
|
-
|
|
138
|
-
for (const layer of sheet.data.meta.layers) {
|
|
139
|
-
const textures = [];
|
|
140
|
-
|
|
141
|
-
for (let i = frameTag.from; i <= frameTag.to; i++) {
|
|
142
|
-
const framekey = i.toString();
|
|
143
|
-
|
|
144
|
-
const key = data.name + '_' + layer.name + '_' + framekey;
|
|
145
|
-
const texture = sheet.textures[key];
|
|
146
|
-
const time = sheet.data.frames[key].duration;
|
|
147
|
-
|
|
148
|
-
textures.push({ texture: texture, time: time });
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const sprite = new AnimatedSprite(textures);
|
|
152
|
-
|
|
153
|
-
sprite.texture.baseTexture.scaleMode = SCALE_MODES.NEAREST;
|
|
154
|
-
|
|
155
|
-
layers[layer.name] = sprite;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (frameTag.name) {
|
|
159
|
-
sprites[frameTag.name] = layers;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return sprites;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export const spriteService = new SpriteService();
|
package/src/types/dto/action.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { UserInfo } from './user';
|
|
2
|
-
|
|
3
|
-
export type ActionData = Record<string, string | number | undefined>;
|
|
4
|
-
|
|
5
|
-
export type ActionableData = {
|
|
6
|
-
arguments: string[];
|
|
7
|
-
action: ActionData;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type ActionEntity = {
|
|
11
|
-
id: number;
|
|
12
|
-
name: string;
|
|
13
|
-
title: string;
|
|
14
|
-
description: string;
|
|
15
|
-
data: ActionData;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type UserActionEntity = {
|
|
19
|
-
userId: string;
|
|
20
|
-
cooldown: number;
|
|
21
|
-
info: UserInfo;
|
|
22
|
-
} & ActionEntity;
|
|
23
|
-
|
|
24
|
-
export type JumpUserActionEntity = {
|
|
25
|
-
name: 'jump';
|
|
26
|
-
data: {
|
|
27
|
-
velocityX: number;
|
|
28
|
-
velocityY: number;
|
|
29
|
-
};
|
|
30
|
-
} & UserActionEntity;
|
|
31
|
-
|
|
32
|
-
export type ColorUserActionEntity = {
|
|
33
|
-
name: 'color';
|
|
34
|
-
data: {
|
|
35
|
-
color: string;
|
|
36
|
-
};
|
|
37
|
-
} & UserActionEntity;
|
|
38
|
-
|
|
39
|
-
export type GrowUserActionEntity = {
|
|
40
|
-
name: 'grow';
|
|
41
|
-
data: {
|
|
42
|
-
duration: number;
|
|
43
|
-
scale: number;
|
|
44
|
-
};
|
|
45
|
-
} & UserActionEntity;
|
|
46
|
-
|
|
47
|
-
export type DashUserActionEntity = {
|
|
48
|
-
name: 'dash';
|
|
49
|
-
data: {
|
|
50
|
-
force: number;
|
|
51
|
-
};
|
|
52
|
-
} & UserActionEntity;
|
|
53
|
-
|
|
54
|
-
export type SpriteUserActionEntity = {
|
|
55
|
-
name: 'sprite';
|
|
56
|
-
data: {
|
|
57
|
-
sprite: string;
|
|
58
|
-
};
|
|
59
|
-
} & UserActionEntity;
|
|
60
|
-
|
|
61
|
-
export const isJumpUserActionEntity = (
|
|
62
|
-
entity: ActionEntity,
|
|
63
|
-
): entity is JumpUserActionEntity => entity.name == 'jump';
|
|
64
|
-
|
|
65
|
-
export const isColorUserActionEntity = (
|
|
66
|
-
entity: ActionEntity,
|
|
67
|
-
): entity is ColorUserActionEntity => entity.name == 'color';
|
|
68
|
-
|
|
69
|
-
export const isGrowUserActionEntity = (
|
|
70
|
-
entity: ActionEntity,
|
|
71
|
-
): entity is GrowUserActionEntity => entity.name == 'grow';
|
|
72
|
-
|
|
73
|
-
export const isDashUserActionEntity = (
|
|
74
|
-
entity: ActionEntity,
|
|
75
|
-
): entity is DashUserActionEntity => entity.name == 'dash';
|
|
76
|
-
|
|
77
|
-
export const isSpriteUserActionEntity = (
|
|
78
|
-
entity: ActionEntity,
|
|
79
|
-
): entity is SpriteUserActionEntity => entity.name == 'sprite';
|
package/src/types/dto/chatter.ts
DELETED
package/src/types/dto/event.ts
DELETED
package/src/types/dto/index.ts
DELETED
package/src/types/dto/message.ts
DELETED
package/src/types/dto/user.ts
DELETED
package/src/types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dto';
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable", "ES2021.String"],
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
|
|
16
|
-
/* Linting */
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"noUnusedParameters": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true
|
|
21
|
-
},
|
|
22
|
-
"include": ["src"]
|
|
23
|
-
}
|
package/vite.config.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import { defineConfig } from 'vite';
|
|
3
|
-
import dts from 'vite-plugin-dts';
|
|
4
|
-
import pkg from './package.json' assert { type: 'json' };
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [dts()],
|
|
8
|
-
build: {
|
|
9
|
-
lib: {
|
|
10
|
-
entry: resolve(__dirname, 'src/index.ts'),
|
|
11
|
-
name: 'evotars',
|
|
12
|
-
fileName: 'evotars',
|
|
13
|
-
},
|
|
14
|
-
copyPublicDir: false,
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
external: [...Object.keys(pkg.dependencies)],
|
|
17
|
-
output: {
|
|
18
|
-
globals: {
|
|
19
|
-
'pixi.js': 'PIXI',
|
|
20
|
-
tinycolor2: 'tinycolor',
|
|
21
|
-
'@tweenjs/tween.js': 'TWEEN',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|