Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Implement new Component class and ObjectPool #168

Merged
merged 30 commits into from
Jun 17, 2020

Conversation

robertlong
Copy link
Member

@robertlong robertlong commented May 25, 2020

This PR is intended to make the component class more straightforward, predictable, and accessible to tooling.

Object pooling is now handled with .copy() and .clone() methods rather than .reset(). The Component class comes with a default implementation for the constructor, copy, and clone that is based on the component schema.

Components must now be registered, an error will be thrown if you attempt to add a component before it is registered. On component registration we validate the schema. Components must also now extend the Component class.

Schema types have a new interface. They must implement name, default, copy, and clone. Types are validated upon registration.

The createComponentClass helper has been removed. You should now use the Component class instead.

To Do:

  • Update docs
    • Remove references to createComponentClass()
    • Update createType() docs
    • Update references to Component .reset()
    • Add new Component docs
    • Add new Entity .copy() and .clone() docs
    • Add ObjectPool docs
  • Write more tests
    • Entity .copy()
    • Entity .clone()

Closes #147
Closes #118

@fernandojsg fernandojsg force-pushed the feature/component-schema-pooling branch 2 times, most recently from a498a34 to 1aed01a Compare June 5, 2020 03:27
@IfnotFr
Copy link
Contributor

IfnotFr commented Jun 16, 2020

Great work with this ! Component schema definition with upcoming proposal-class-fields. Will make some really clear/consice Components :

import { Component, Types } from "ecsy"

class MyComponent {
    static schema = {
        aNumber: { type: Types.Number },
        anArray: { type: Types.Array },
    }
}

@fernandojsg
Copy link
Member

@IfnotFr indeed! currently it's a bit uglier but it's fine so far. but when the static will arrive both the Component definition and the System's queries will be prettier for sure :)

@robertlong robertlong changed the base branch from dev to new-api June 16, 2020 22:19
@robertlong robertlong changed the base branch from new-api to dev June 16, 2020 22:20
@fernandojsg fernandojsg force-pushed the feature/component-schema-pooling branch from 4158d05 to 3095368 Compare June 17, 2020 18:02
@robertlong robertlong force-pushed the feature/component-schema-pooling branch from 3095368 to 6424e95 Compare June 17, 2020 21:31
@fernandojsg fernandojsg force-pushed the feature/component-schema-pooling branch from 6424e95 to 87268cd Compare June 17, 2020 23:02
This was referenced Jun 17, 2020
@fernandojsg
Copy link
Member

I updated the issues regarding the documentation and tests that we should update
#190
#165

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why registerComponent? Make TagComponent inherit from Component
3 participants