dev.atedeg.ecscala.dsl
package dev.atedeg.ecscala.dsl
Type members
Classlikes
This trait provides a domain specific language (DSL) for expressing the ECScala framework operations using an english-like syntax. Here's the things you can do:
This trait provides a domain specific language (DSL) for expressing the ECScala framework operations using an english-like syntax. Here's the things you can do:
'''Create an entity in a world:'''
val world = World()
val entity1 = world hasAn entity
'''Remove entities from a world:'''
* world - entity1
* remove (entity1) from world
* remove (List(entity1, entity2, entity3)) from world
'''Create an entity in a world with a component:'''
val entity1 = world hasAn entity withComponent MyComponent()
'''Create an entity in a world with multiple components:'''
val entity1 = world hasAn entity withComponents {
MyComponent1() &: MyComponent2() &: MyComponent3()
}
'''Add components to an entity:'''
* entity1 + MyComponent()
* entity1 withComponent MyComponent()
* entity1 withComponents { MyComponent1() &: MyComponent2() }
'''Remove components from an entity:'''
* remove { MyComponent() } from entity1
* entity1 - MyComponent()
* remove { MyComponent1() &: MyComponent2() &: MyComponent3() } from entity1
'''Add a system to a world:'''
world hasA system[MyComponent &: CNil] { (_,_,_) => {}}
'''Get a view from a world:'''
val view = getView[MyComponent1 &: MyComponent2 &: CNil] from world
'''Remove all entities and their components from a world:'''
clearAll from world