Skip to content

Commit

Permalink
Eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
stickyfingies committed Oct 23, 2023
1 parent 9cf30fe commit 524c480
Show file tree
Hide file tree
Showing 172 changed files with 1,816 additions and 575 deletions.
5 changes: 4 additions & 1 deletion src/ecs/.eslintrc.json → .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true,
"worker": true
},
"extends": [
"airbnb-base"
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"import",
"@typescript-eslint"
],
"settings": {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
49 changes: 49 additions & 0 deletions docs/gameplay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Gameplay

> A description of what the game does
Prologue
---

- The game is black with a spinning loading indicator
- Click the play button to replace the screen with the world

Environment
---

- You are a third-person wizard character
- You are on a hilly island with beaches and a cliff
- There are trees growing sporadically
- The sky is mid-sunset, cloudy

Things
---

- The player has a sword
- Green slimes regularly fall from the sky
- Earn points by killing slimes

---

What's Next
---

#### **Lock on** to enemies and **display** possible actions
- has a visual indicator around the enemy
- adjusts the main perspective somehow (?)
- show actions AND show controls, together

#### Implementation:
1. Camera frustum -> filter -> find nearest
2. Yank `sprite.position` from `enemy.position`
3. For every action:
1. **Attack**: move towards enemy and swing sword
2. **Intimidate**: shout at enemy, buffing their stats (?)
- Create a child sprite
- Increment angle by `(2*PI):radians / (actionCount):int;`
- Crazy sin/cos/tan trigonometry shit

Things I can't work on yet
---
- **Sounds**: Need to find some, or ask John
- **Maps**: Long process, need time to work
1 change: 1 addition & 0 deletions docs/system-arch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**TODO**: Unify `SmoothCamera` + `Camera` so the engine just has a more powerful camera
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
"resolutions": {
"@grove/**/three": "0.135.0",
"three": "0.135.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"eslint": "^8.52.0",
"eslint-plugin-import": "^2.29.0"
}
}
32 changes: 23 additions & 9 deletions src/ecs/src/entity-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class EntityManager {
}
// emit 'delete' events for every component in this entity
for (const type of archetype.signature) {
const [data] = this.getComponent(entity_id, [type]) as any;
const [data] = this.get(entity_id, [type]) as any;
this.events.emit(`delete${type.name}Component`, { entity_id, name: type.name, data } as DeleteComponentEvent);
if ('destroy' in data) data.destroy();
}
Expand All @@ -141,7 +141,7 @@ export class EntityManager {
}

/** Set a component for an entity */
setComponent<T extends ComponentTypeList>(entity_id: number, types: T, data: ComponentDataFromSignature<T>) {
put<T extends ComponentTypeList>(entity_id: number, types: T, data: ComponentDataFromSignature<T>) {
const delta: SignatureDelta = { added: new Set(types), removed: new Set() }
// move entity to a different archetype matching its new signature
const old_signature = this.getEntityComponentSignature(entity_id);
Expand Down Expand Up @@ -178,7 +178,7 @@ export class EntityManager {
/** Delete a component for an entity. Returns whether the component was deleted */
deleteComponent<T extends ComponentTypeList>(entity_id: number, types: T) {
const delta: SignatureDelta = { added: new Set(), removed: new Set(types) };
const data = this.getComponent(entity_id, types) as any;
const data = this.get(entity_id, types) as any;

// calculate new signature
const old_signature = this.getEntityComponentSignature(entity_id);
Expand Down Expand Up @@ -207,7 +207,7 @@ export class EntityManager {
}

/** Get a component from an entity */
getComponent<T extends ComponentTypeList>(entity_id: number, types: T): ComponentDataFromSignature<T> {
get<T extends ComponentTypeList>(entity_id: number, types: T): ComponentDataFromSignature<T> {
const archetype = this.getArchetype(entity_id);

// Check ID
Expand Down Expand Up @@ -239,7 +239,7 @@ export class EntityManager {

// emit a `delete` event
removeTypes.forEach((type) => {
const [data] = this.getComponent(entity_id, [type]);
const [data] = this.get(entity_id, [type]);
const event: DeleteComponentEvent = { entity_id, name: type.name, data };
this.events.emit(`delete${type.name}Component`, event);
this.events.emit(`deleteComponent`, event);
Expand All @@ -253,7 +253,7 @@ export class EntityManager {

// emit a `set` event
addTypes.forEach((type) => {
const [data] = this.getComponent(entity_id, [type]);
const [data] = this.get(entity_id, [type]);
const event: SetComponentEvent = { entity_id, name: type.name, data };
this.events.emit(`set${type.name}Component`, event);
this.events.emit(`setComponent`, event);
Expand All @@ -271,25 +271,39 @@ export class EntityManager {
}

/** Check if an entity has a component */
hasComponent(entity_id: number, type: ComponentType): boolean {
has(entity_id: number, type: ComponentType): boolean {
const archetype = this.getArchetype(entity_id);
return archetype?.hasComponent(entity_id, [type]) || false;
}

hasTag(tag: symbol) {
if (!this.#tagList.has(tag)) { return false; }
const entity_id = this.#tagList.get(tag)!
const archetype = this.getArchetype(entity_id);
if (!archetype) {
return false;
}
return true;
}

/** Add a tag to an entity. Entities can later be retrieved using the same tag */
addTag(entity_id: number, tag: symbol) {
this.#tagList.set(tag, entity_id);
}

/** Get a specific entity by its tag */
getTag(tag: symbol) {
if (!this.#tagList.has(tag)) {
if (!this.hasTag(tag)) {
throw new Error(`no entity found with tag:${tag.description}`);
}

return this.#tagList.get(tag)!;
}

removeTag(tag: symbol) {
this.#tagList.delete(tag);
}

/**
* Get a list of all entity id's which match a component signature
* @example
Expand All @@ -312,7 +326,7 @@ export class EntityManager {
}
}

executeQuery<T extends ComponentTypeList>
do_with<T extends ComponentTypeList>
(query: T, callback: (c: ComponentDataFromSignature<T>, id: number) => void) {
const hash = hashSignature(new Set(query));

Expand Down
6 changes: 3 additions & 3 deletions src/ecs/src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Entity {
}

setComponent<T>(type: ComponentType<T>, data: T) {
this.manager.setComponent(this.id, [type], [data]);
this.manager.put(this.id, [type], [data]);
return this;
}

Expand All @@ -38,11 +38,11 @@ export class Entity {
}

getComponent<T>(type: ComponentType<T>): T {
return this.manager.getComponent(this.id, [type])[0];
return this.manager.get(this.id, [type])[0];
}

hasComponent(type: ComponentType): boolean {
return this.manager.hasComponent(this.id, type);
return this.manager.has(this.id, type);
}

addTag(tag: symbol) {
Expand Down
112 changes: 0 additions & 112 deletions src/editor/.eslintrc.json

This file was deleted.

Loading

0 comments on commit 524c480

Please sign in to comment.