Skip to content

Commit

Permalink
fix: Make addTag/removeTag chainable
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Mar 30, 2024
1 parent 3f3ac09 commit 9cdea7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/engine/EntityComponentSystem/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ export class Entity<TKnownComponents extends Component = any> implements OnIniti
* Adds a tag to an entity
* @param tag
*/
public addTag(tag: string) {
public addTag(tag: string): Entity<TKnownComponents> {
this._tags.add(tag);
this.tagAdded$.notifyAll(tag);
return this;
}

/**
Expand All @@ -192,9 +193,10 @@ export class Entity<TKnownComponents extends Component = any> implements OnIniti
* Removals are deferred until the end of update
* @param tag
*/
public removeTag(tag: string) {
public removeTag(tag: string): Entity<TKnownComponents> {
this._tags.delete(tag);
this.tagRemoved$.notifyAll(tag);
return this;
}

/**
Expand Down

0 comments on commit 9cdea7c

Please sign in to comment.