ocs

a programming paradigm combining traits of OOP and ECS

Classes

Methods


Classes

EEO

Event Emitting Object. For use in the creation of components. Event is run when the value of a specific property that an Entity gets from a Component is changed.

new ocs.EEO(obj, event);


Parameter Type Description
obj Object object for use in component
event Function event to run when properties of obj are changed. Takes (entity, key, val) as parameters

Getter

For use in the creation of components. Event is run when getting the value of a specific property and this property does not have a setter.

new ocs.Getter(arr, event);


Parameter Type Description
arr [String] keys of the getter
event Function event to run when when the property is gotten. Takes (entity, key) as parameters

Environment

environment

new ocs.Environment(name);


Parameter Type Description
name String / Number unique name of the Environment

Component

defines properties that can be added to entities

new ocs.Component(environment, name, builder);


Parameter Type Description
environment String / Number name of the environment to add the component to
name String / Number unique name of the component
builder Function a function that returns an object containing properties to add to entities. This function can take whatever parameters you would like

Entity

general purpose object

new ocs.Entity(environment, name, limit);


Parameter Type Description Default
environment String / Number name of the Environment to add the Entity to
name String / Number unique name of the Entity
limit Int (OPTIONAL) limit of key depth when adding Components 3

Tag

Tag identifiers that can be added to Entities

new ocs.Tag(name);


Parameter Type Description
name String / Number the unique name of the Tag

Singleton

creates a single instance of an object or module that can be accessed in any module

new ocs.Singleton(name);


Parameter Type Description
name String / Number the unique name of the Singleton


Methods

getEnvironment

get a specific Environment

ocs.getEnvironment(name);


Parameter Type Description
name String / Number name of the Environment

getComponent

get a specific Component

ocs.getComponent(name);


Parameter Type Description
name String / Number name of the Component

getEntity

get a specific Entity

ocs.getEntity(name);


Parameter Type Description
name String / Number name of the Entity

getTag

get a specific Tag

ocs.getTag(name);


Parameter Type Description
name String / Number name of the Tag

getSingleton

get a specific Singleton

ocs.getSingleton(name);


Parameter Type Description
name String / Number name of the Singleton

getAllWithComponents

get all entities that contain a sinlge (or multiple) component

ocs.getAllWithComponents(environment, components);


Parameter Type Description
environment String / Number Environment to search
components String / [String] component or components to check for

printAllWithComponents

get the names of all entities that contain a sinlge (or multiple) component

ocs.printAllWithComponents(environment, components);


Parameter Type Description
environment String / Number Environment to search
components String / [String] component or components to check for