I love entity/component systems. And static typing can be very cool and fast. Combining the two would be amazing. Oh, and I really like C#, so why not that too. So here are my experiments and musings in adding an entity/component feature to C# as a superset, leaving the existing language as it is.
- Entities are bare identity objects, nothing else
- Concepts are interfaces
- Components implement concepts
- Concepts can require other concepts
- Components can require concepts
- Components can implicitly implement concept's data members using the keyword `implicitly`
- A component and a concept can have the same name
- `void` is an absence of an entity
- attach prepends a component to an entity
- augment makes a referential copy and prepends the component. Similar to but different from javascript prototypal inheritance
- interface -> concept
- class -> component
- struct -> value component
- Can imply other value components
- entities are value entities if and only if all components are value entities
- The components on value entities cannot be modified after initialization
concept <Name> {
requires { <concept1>, <concept2>, <concept*> }
}
component <Name> {
requires { <concept1>, <concept2>, <concept*> }
[implicitly] provides { <concept1>, <concept2>, <concept*> }
implies { <component1>, <component2>, <component*> }
{ <concept> }.<Member> = <implementation>
}
The implicit examples show it becomes very close to C# for basic setups